按照 https://developer.paypal.com/webapps/developer/docs/integration/web/accept-paypal-payment/的指南,我已经成功地创建了付款,并重定向了用户以批准它. 创建的支付是一些看起来像bellow,我保存在用户的会
创建的支付是一些看起来像bellow,我保存在用户的会话进一步参考.
{ "id": "PAY-6RV70583SB702805EKEYSZ6Y", "create_time": "2013-03-01T22:34:35Z", "update_time": "2013-03-01T22:34:36Z", "state": "created", "intent": "sale", "payer": { "payment_method": "paypal" }, "transactions": [ { "amount": { "total": "7.47", "currency": "USD", "details": { "subtotal": "7.47" } }, "description": "This is the payment transaction description." } ], "links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-6RV70583SB702805EKEYSZ6Y", "rel": "self", "method": "GET" }, { "href": "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=EC-60U79048BN7719609", "rel": "approval_url", "method": "REDIRECT" }, { "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-6RV70583SB702805EKEYSZ6Y/execute", "rel": "execute", "method": "POST" } ] }
用户批准付款后,Paypal将重定向到return_url用户.例如,http://< return_url>?token = EC-60U79048BN7719609& PayerID = 7E7MGXCWTTKK2.
为了执行付款,POST请求必须发送到https://api.sandbox.paypal.com/v1/payments/payment/{payment_id}/execute/.
题
从Paypal在URL中提供的唯一两条信息是token和PayerID.如何找到相应的payment_id?
可能的解决方案
令牌是approval_url的一部分,解析URL并存储令牌 – >付款关系可以解决问题.但是我正在寻找一个不需要解析的更好的解决方案.
我认为paypal文件并不清楚.但是,您可以简单地解决您通过返回URL中的参数传递付款方式的问题.喜欢这个:
return_url =’http://www.yourdomain.com/paypal/success/?paymentID = PAY-1234567′
当PayPal重定向到您的网站时,它将返回paymentID与其他参数.
Emportuguês:
Paypal是一个不错的选择.一个解决方案,它是一个简单的例子,支付方式PayD comoparâmetrona minha URL de retorno que informo para o Paypal. Assim,quando o Paypal redirecionar para meu site de volta ele matem oparâmetrocom o PaymentID que eu tinha passado.