{
"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
。
为了执行付款,必须向https://api.sandbox.paypal.com/v1/payments/payment/{payment_id}/execute/
发出POST请求。
问题
Paypal在URL中提供的唯一两个信息是token
和PayerID
。我如何找到相应的payment_id
?
可能的解决方案
token
是approval_url
的一部分,解析URL并存储token-> payment
关系可以解决该问题。但我正在寻找不需要解析的更好的解决方案。