3 posts / 0 new
Last post
samdenies6275
Decoding securitytokens response in Java

I'm writing a simple Java integration, which will basically only need to do tokenized payments.

The first step of this of course is to obtain the token for a particular card. I understand the Tokenize Credit Card POST request (/transactions/tokens) is being deprecated, so am using the GET request (/securitytokens). This request returns JSONP, regardless of whether I specify the "callback" parameter. This is somewhat frustrating, since JSONP really only has use in a Javascript context. Is there any supported way to have this request return a plain JSON object?

This response apparently also contains padding (spaces and newlines) around and inside the callback, which somewhat complicates the manual removal of the callback. I can still strip this out with a RegEx operation if necessary, but feel that manual processing of the response might make my integration sensitive to future changes to the API.


padminisampathk...
Re: Decoding securitytokens response in Java

Hi,

Retrofit is a good choice. We are on our way to rewrite the code using Retrofit.

You can refer: https://guides.codepath.com/android/Consuming-APIs-with-Retrofit

You can define a Response object with the necessary fields. Retrofit will do the remaining task for you along with the Jackson converter.

Hope, it helps.

Regards

Payeezy Team

 

 


samdenies6275
Re: Decoding securitytokens response in Java

I take it that means there is no way to have the API return an unpadded JSON response?

Switching to Retrofit might make sense for a larger project, but it doesn't makes sense to learn and integrate an entirely new library for such a small integration. I'm even so sure that Retrofit supports JSONP natively, see https://stackoverflow.com/questions/26290267/retrofit-removing-some-invalid-characters-from-response-body-before-parsing-it .