Paypal Adaptive API return URL mapping with token

喜你入骨 提交于 2021-02-20 04:23:45

问题


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

  • Paypal return to my returnURL, but how do i tie the original request for payment after the return. The returnURL is a HTTP GET with no query parameters from paypal.
  • If i want to use IPN, this wont allow me to test in local windows webserver, because it does not support localhost or 127.0.0.1. I even tried getting my public facing IP and trying to put port forwarding in my router, does not budge an inch

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.


回答1:


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=pd_1265515509_biz@yahoo.com&&receiverList.receiver(0).amount=100.00&feesPayer=EACHRECEIVER&memo=SimplePay&returnUrl=http%3A%2F%2Flocalhost%2Freturn.html%3FpayKey%3D%24%7BpayKey%7D"


来源:https://stackoverflow.com/questions/17377373/paypal-adaptive-api-return-url-mapping-with-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!