【问题标题】:Problem to get payment details with PayPal使用 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,例如文档不够看懂怎么办?

【问题讨论】:

    标签: php api paypal transactions payment


    【解决方案1】:

    最强大的解决方案是使用服务器端前端 UI 集成 SPB:https://developer.paypal.com/demo/checkout/#/pattern/server

    这将调用您服务器上的两条对应路由,一条用于“设置事务”,一条用于“捕获事务”,https://developer.paypal.com/docs/checkout/reference/server-integration/

    这样,您将在交易完成时直接在您的服务器上收到包含完整详细信息的“捕获交易”响应。不需要任何异步 webhook。

    【讨论】:

      猜你喜欢
      • 2018-04-05
      • 2023-04-06
      • 2018-08-30
      • 2014-02-23
      • 2015-04-24
      • 2021-06-06
      • 2014-12-08
      • 2011-12-01
      • 2021-09-08
      相关资源
      最近更新 更多