我按照https://github.com/paypal/PayPal-Python-SDK中列出的一些代码来构建付款。问题是在哪个阶段付款完成?我的理解是它在“授权付款”之后完成,在将用户重定向到“return_url”之前完成,因为我认为“return_url”应该做一些类似“告诉用户已经完成付款”而不是付款的事情。我不确定我的想法是否正确。下面是支付流程。
在 python 应用程序中创建付款
... skipped
"return_url": "xxx.com/payment/execute",
...
在 python 应用程序中授权付款
...
Redirect user to approval_url (paypal page)
...
用户在paypal中填写所有信息后,它将用户重定向到return_url,如下所示。
在 xxx.com/payment/execute 中执行付款
...
curl 'https://api.sandbox.paypal.com/v1/payments/payment/'+paymentId+'/execute';
...
之后我得到 JSON
{
"id": "PAYID-LT3I25Y9M527750ER784091X",
"intent": "sale",
"state": "approved",
"cart": "1L498981HN342484R",
"payer": {
"payment_method": "paypal",
"status": "UNVERIFIED",
"payer_info": {
"email": "ji@gmail.com",
"first_name": "ukf",
"last_name": "tfutf",
"payer_id": "ZD7ELNRCHVLPY",
"shipping_address": {
"recipient_name": "ukf tfutf",
"line1": "ktf",
"city": "ktfu",
"state": "",
"postal_code": "",
"country_code": "HK"
},
"country_code": "HK"
}
},
"transactions": [
{
"amount": {
"total": "5.00",
"currency": "USD",
"details": {}
},
"payee": {
"merchant_id": "4J8HJBF56QT24",
"email": "facilitator@gmail.com"
},
"description": "This is the payment transaction description.",
"item_list": {
"items": [
{
"name": "item",
"sku": "item",
"price": "5.00",
"currency": "USD",
"quantity": 1
}
],
"shipping_address": {
"recipient_name": "ukf tfutf",
"line1": "ktf",
"city": "ktfu",
"state": "",
"postal_code": "",
"country_code": "HK"
},
"shipping_options": [
null
]
},
"related_resources": [
{
"sale": {
"id": "96712163V8788712D",
"state": "completed",
"amount": {
"total": "5.00",
"currency": "USD",
"details": {
"subtotal": "5.00"
}
},
"payment_mode": "INSTANT_TRANSFER",
"protection_eligibility": "ELIGIBLE",
"protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE, UNAUTHORIZED_PAYMENT_ELIGIBLE",
"transaction_fee": {
"value": "0.47",
"currency": "USD"
},
"receipt_id": "2545046194101961",
"parent_payment": "PAYID-LT3I25Y9M527750ER784091X",
"create_time": "2019-06-04T15:29:48 Z",
"update_time": "2019-06-04T15:29:48 Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/sale/96712163V8788712D",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/sale/96712163V8788712D/refund",
"rel": "refund",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LT3I25Y9M527750ER784091X",
"rel": "parent_payment",
"method": "GET"
}
],
"soft_descriptor": "PAYPAL *TESTFACILIT"
}
}
]
}
],
"create_time": "2019-06-04T15:29:49 Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LT3I25Y9M527750ER784091X",
"rel": "self",
"method": "GET"
}
]
}