问题描述
按照 https://developer.paypal.com上的指南进行操作/webapps/developer/docs/integration/web/accept-paypal-payment/,我已经成功创建了付款并重定向了用户以批准它.
By following the guide on https://developer.paypal.com/webapps/developer/docs/integration/web/accept-paypal-payment/ , I have successfully created a payment and redirect the user to approve it.
创建的付款如下所示,我将其保存在用户会话中以备将来参考.
The created payment is something look like bellow, and I save it in user's session for further reference.
{
"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"
}
]
}
用户批准付款后,贝宝会将用户重定向到return_url
.例如,http://<return_url>?token=EC-60U79048BN7719609&PayerID=7E7MGXCWTTKK2
.
After user approved the payment, Paypal will redirect the user to the return_url
. For example, http://<return_url>?token=EC-60U79048BN7719609&PayerID=7E7MGXCWTTKK2
.
为了执行付款,必须向https://api.sandbox.paypal.com/v1/payments/payment/{payment_id}/execute/
发出POST请求.
In order to execute the payment, a POST request has to made to https://api.sandbox.paypal.com/v1/payments/payment/{payment_id}/execute/
.
问题
从Paypal在URL中提供的仅有的两条信息是token
和PayerID
.如何找到相应的payment_id
?
The only two pieces of information provided from Paypal in the URL is token
and PayerID
. How can I find the corresponding payment_id
?
可能的解决方案
token
是approval_url
的一部分,解析URL并存储token -> payment
关系可以解决此问题.但是我正在寻找不需要解析的更好的解决方案.
The token
is part of the approval_url
, parse the URL and store the token -> payment
relationship can solve the problem. But I'm looking for a better solution that doesn't require parsing.
推荐答案
我认为贝宝(Paypal)文档尚不清楚.但是您可以做一些简单的事情来解决通过返回URL中的参数传递de PaymentID的问题.
I think the paypal documentation isn't clear about this. But you can do something simple to resolve your problem passing de PaymentID through a parameter in your return url.
赞:return_url =' http://www.yourdomain.com/paypal/success/? paymentID = PAY- 1234567 '
Like this:return_url = 'http://www.yourdomain.com/paypal/success/?paymentID=PAY-1234567'
当Paypal重定向到您的网站时,它将返回PaymentID以及其他参数.
When the Paypal redirect to your site, then, it will return the paymentID together with the other parameters.
Em葡萄牙语:
贝宝(Paypal)商店.一种简单易用的解决方案,可以使用PayID或其他付款方式通过PayID进行付款. Assim,quando或Paypal redirecionar para meu site of volta ele matem或parâmetrocom或PaymentID que eu tinha passado.
Não acho que isso esteja claro na documentação do Paypal. A solução que eu usei foi simples, eu passo o PaymentID como parâmetro na minha URL de retorno que informo para o Paypal. Assim, quando o Paypal redirecionar para meu site de volta ele matem o parâmetro com o PaymentID que eu tinha passado.
这篇关于Paypal REST API:用户批准付款后如何检索付款ID.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!