使用 PayPal 获取付款详细信息的问题
Posted
技术标签:
【中文标题】使用 PayPal 获取付款详细信息的问题【英文标题】:Problem to get payment details with PayPal 【发布时间】:2020-10-16 15:56:29 【问题描述】:我使用 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,例如文档不够看懂怎么办?
【问题讨论】:
【参考方案1】:最强大的解决方案是使用服务器端前端 UI 集成 SPB:https://developer.paypal.com/demo/checkout/#/pattern/server
这将调用您服务器上的两条对应路由,一条用于“设置事务”,一条用于“捕获事务”,https://developer.paypal.com/docs/checkout/reference/server-integration/
这样,您将在交易完成时直接在您的服务器上收到包含完整详细信息的“捕获交易”响应。不需要任何异步 webhook。
【讨论】:
以上是关于使用 PayPal 获取付款详细信息的问题的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 php 在 PayPal 订阅中获取付款详细信息?