问题
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¤cyCode=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