PayPal AdaptivePayments PaymentDetail PayKey

那年仲夏 提交于 2019-12-04 06:19:55

I was at this for ages too myself. I finally figured it out. Paypal docs are hard to follow. I found the answer in the paypal adaptive pdf guide which I downloaded. It specifies to add payKey=${payKey} to the end of your return_url. I just tried it there and the paypal get request to my return url now contains the paykey.

So in rails which I'm using the return_url looks like this. Writing a php variable (I think) into the url as instructed by the guide

:return_url      => "http://***********.com/paypal-return?payKey=${payKey}"
moluv00

It seems that you're missing a step in the sequence.

The first step is to send your transaction parameters to

https://svcs.paypal.com/AdaptivePayments/Pay&yourtransactionparameters=blah
[sandbox]https://svcs.sandbox.paypal.com/AdaptivePayments/Pay&yourtransactionparameters=blah

You'll get the paykey in this response.

Once you've retrieved the paykey successfully, you'll call:

https://www.paypal.com/webscr&cmd=_ap-payment&paykey=xxxx
[sandbox]https://www.sandbox.paypal.com/webscr&cmd=_ap-payment&paykey=xxxx

In the second call, the payKey represents the rest of your transaction so you don't have to build another giant query string.

Change your code for:

//Create request payload with minimum required parameters
  $bodyparams = array ("requestEnvelope.errorLanguage" => "en_US",
                       "actionType" => "PAY",
                       "currencyCode" => "USD",
                       "cancelUrl" => "http://www.paypal.com", 
                       "returnUrl" => $return_url . '&payKey=${payKey}',  **// That's right**
                       "receiverList.receiver(0).email" => "account1@hotmail.com", //TODO
                       "receiverList.receiver(0).amount" => $price, //TODO
                       "receiverList.receiver(0).primary" => "true", //TODO
                       "receiverList.receiver(1).email" => "account2@hotmail.com", //TODO
                       "receiverList.receiver(1).amount" => $receiver_gets, //TODO
                       "receiverList.receiver(1).primary" => "false" //TODO
                       );

PHP interprets ${payKey} as variable between the double quotes. Change double quotes (") for simple quotes (')

Apparently you can embed dynamic variables in the return URL: https://www.x.com/thread/49785

Unfortunately, {$payKey} is invalid. so it must be $paykey or $pay_key. Good luck!

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