Abdus Samad
Abdus Samad

Reputation: 353

Paypal Adaptive API return URL mapping with token

I have been trying to solve the following issue from using Paypal Adaptive API. I have integrated Paypal Adaptive chained payment API with my website. When the user clicks on the "pay with paypal" button, it takes to paypal website for payment. My issues starts from here

Now, i want to be able to table the various payment information when into my database when the user has successfully paid, and i dont have the proper means to do it in development before putting in production

I am double surprised that a billion dollar company like paypal can deliver such a useless code to developers to integrate

I look at this answer as well, Adaptive Payments Paypal : return url without data? . The guy from paypal says

When the user returns the returnUrl endpoint, you make a call for the PaymentDetails API and check the status and proceed.

Well the question is to call PaymentDetails, i need paytoken. How can i get paytoken from the returnurl? As it is now, the return URL does not have any query parameters.

Upvotes: 0

Views: 1740

Answers (1)

Praveen
Praveen

Reputation: 2029

In your returnUrl just append payKey=${payKey}

For example if your returnUrl is example.com/return.html?myparameter=value - it would become example.com/return.html?myparameter=value&payKey=${payKey}
PayPal will replace ${payKey} with the actual PayKey. Since it's a url you would need to url encode the value of the returnUrl - so the above url becomes example.com%2Freturn.html%3Fmyparameter%3Dvalue%26payKey%3D%24%7BpayKey%7D

Here is a sample curl command

curl -s --insecure -H "X-Paypal-Security-Userid: XXX" -H "X-Paypal-Security-Password: XXX" -H "X-Paypal-Security-Signature: XXX" -H "X-Paypal-Request-Data-Format: NV" -H "X-Paypal-Response-Data-Format: NV" -H "X-Paypal-Application-Id: APP-80W284485P519543T" https://svcs.sandbox.paypal.com/AdaptivePayments/Pay -d "requestEnvelope.errorLanguage=en_US&clientDetails.ipAddress=127.0.0.1&clientDetails.deviceId=mydevice&clientDetails.applicationId=PreApprovalNvpDemo&cancelUrl=http%3A%2F%2Flocalhost%2Fcancel.html&currencyCode=USD&actionType=PAY&receiverList.receiver(0)[email protected]&&receiverList.receiver(0).amount=100.00&feesPayer=EACHRECEIVER&memo=SimplePay&returnUrl=http%3A%2F%2Flocalhost%2Freturn.html%3FpayKey%3D%24%7BpayKey%7D"

Upvotes: 7

Related Questions