我使用PayPal智能按钮,在用户付款后需要获取付款明细。
例如,我需要获取以下详细信息:
{
"id": "5O190127TN364715T",
"status": "COMPLETED",
"payer": {
"name": {
"given_name": "John",
"surname": "Doe"
},
"email_address": "customer@example.com",
"payer_id": "QYR5Z8XDVJNXQ"
},
"purchase_units": [
{
"reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
"shipping": {
"address": {
"address_line_1": "2211 N First Street",
"address_line_2": "Building 17",
"admin_area_2": "San Jose",
"admin_area_1": "CA",
"postal_code": "95131",
"country_code": "US"
}
},
"payments": {
"authorizations": [
{
"id": "0AW2184448108334S",
"status": "CREATED",
"amount": {
"currency_code": "USD",
"value": "100.00"
},
"seller_protection": {
"status": "ELIGIBLE",
"dispute_categories": [
"ITEM_NOT_RECEIVED",
"UNAUTHORIZED_TRANSACTION"
]
},
"expiration_time": "2018-05-01T21:20:49Z",
"create_time": "2018-04-01T21:20:49Z",
"update_time": "2018-04-01T21:20:49Z",
"links": [
{
"href": "https://api.paypal.com/v2/payments/authorizations/0AW2184448108334S",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.paypal.com/v2/payments/authorizations/0AW2184448108334S/capture",
"rel": "capture",
"method": "POST"
},
{
"href": "https://api.paypal.com/v2/payments/authorizations/0AW2184448108334S/void",
"rel": "void",
"method": "POST"
},
{
"href": "https://api.paypal.com/v2/payments/authorizations/0AW2184448108334S/reauthorize",
"rel": "reauthorize",
"method": "POST"
}
]
}
]
}
}
],
"links": [
{
"href": "https://api.paypal.com/v2/checkout/orders/5O190127TN364715T",
"rel": "self",
"method": "GET"
}
]
}
我试图在文件中使用Webhook:
$json = file_get_contents('php://input');
$data = json_decode($json);
并获得一些信息,其中没有金额,客户帐户等信息。有人可以告诉我,如何在不安装api的情况下使用一个php脚本来执行此操作,或者告诉我如何在服务器上部署api。文档不足以了解它怎么做?
答案 0 :(得分:0)
最可靠的解决方案是使用服务器端前端UI:https://developer.paypal.com/demo/checkout/#/pattern/server
集成SPB。这将在您的服务器上调用两条相应的路由,一条用于“设置交易”,一条用于“捕获交易”,https://developer.paypal.com/docs/checkout/reference/server-integration/
通过这种方式,在进行交易的那一刻,您将直接在服务器上收到“捕获交易”响应以及完整的详细信息。不需要任何异步webhooks。