B4J Question PayPal API problem

hatzisn

Well-Known Member
Licensed User
Longtime User
Good evening everyone,

I am trying to implement the paypal REST API in a webapp and until now I have successfully charged a sandbox account with the amount I want. Now I wanted to check the card rejection errors and I cannot figure out completely the procedure to follow. Here is what I have done:

1) I activate in PayPal developer for the Sandbox application in "Features > Accept Payments" the "PayPal Here" checkbox to charge directly with credit card details (right or wrong ?)
2) I create a VISA credit card and I use this credit card's details with First Name = "CCREJECT-REFUSED" as described in the credit card generation page and last name something else. (the [Pay with bank account or Credit card] button appears only once in my check out process and never again - what is wrong with this?).
3) If I proceed I get the following in capture payment end point with Status 422 and the httpjob responds that "java.io.FileNotFoundException: C:\Users\hatzi\AppData\Local\Temp\8 (The system cannot find the file specified)". I do not get the desired response that has all the details of the rejection.

Can anyone point me on what am I doing wrong? Thanks in advance

B4X:
ResponseError. Reason: , Response: {"name":"UNPROCESSABLE_ENTITY","details":[{"issue":"INSTRUMENT_DECLINED","description":"The instrument presented  was either declined by the processor or bank, or it can't be used for this payment."}],"message":"The requested action could not be performed, semantically incorrect, or failed business validation.","debug_id":"4b0214b3afb13","links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-INSTRUMENT_DECLINED","rel":"information_link","method":"GET"},{"href":"https://www.sandbox.paypal.com/checkoutnow?token=65L90346A0404894J","rel":"redirect","method":"GET"}]}
 

drgottjr

Expert
Licensed User
Longtime User
there are 2 issues here. technically, they are unrelated.

error 422 is an http response error relating to the paypal api. it means you made a mistake.
"ResponseError.Reason .. " message you posted shows what your mistake was.

the file not found error refers to a temporary file created by jokhttputils2 to handle a successful http request.
it is erased when you release the http job, but if the job is not successful and you call job.release, you will
get a file not found error because there is no temporary file to release.
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
there are 2 issues here. technically, they are unrelated.

error 422 is an http response error relating to the paypal api. it means you made a mistake.
"ResponseError.Reason .. " message you posted shows what your mistake was.

the file not found error refers to a temporary file created by jokhttputils2 to handle a successful http request.
it is erased when you release the http job, but if the job is not successful and you call job.release, you will
get a file not found error because there is no temporary file to release.

The second error was corrected. Obviously now but I was not aware of this at that time I was copying the value of the trigger for rejection in Firstname but it had a tab character in the biggining so maybe the okhttp job or the PayPal API could not handle it. Totally stupid error created out of avoidance of writting myself the trigger. On the other hand the 422 status remains.
 
Upvote 0
Top