如何使用 php 在 PayPal 订阅中获取付款详细信息?

时间:2021-03-08 21:28:39

标签: events paypal payment subscription

我正在使用 PayPal 和 php 设置订阅。到目前为止,我知道如果事件 PAYMENT.SALE.COMPLETED 被调用,则付款成功。要在我的 webhook 上处理付款,我需要有关付款的更多详细信息(谁付款?什么计划或订阅?)。我如何获得更多详细信息?是关于IDs吗?

这是一个测试事件的事件主体:

{
  "id": "WH-2WR32451HC0233532-67976317FL4543714",
  "create_time": "2014-10-23T17:23:52Z",
  "resource_type": "sale",
  "event_type": "PAYMENT.SALE.COMPLETED",
  "summary": "A successful sale payment was made for $ 0.48 USD",
  "resource": {
    "parent_payment": "PAY-1PA12106FU478450MKRETS4A",
    "update_time": "2014-10-23T17:23:04Z",
    "amount": {
      "total": "0.48",
      "currency": "USD"
    },
    "payment_mode": "ECHECK",
    "create_time": "2014-10-23T17:22:56Z",
    "clearing_time": "2014-10-30T07:00:00Z",
    "protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
    "protection_eligibility": "ELIGIBLE",
    "links": [
    ...
    ],
    "id": "80021663DE681814L",
    "state": "completed"
  },
  "links": [
...

1 个答案:

答案 0 :(得分:1)

一个真实的(非 webhook-test-simulator)事件应该有支付对应订阅的订阅 ID(I-#### 编号)。您应该在订阅创建时将该 ID 存储在您自己的用户个人资料中。

另一种方法是在订阅创建时传递您自己的 custom_id

您可以在沙盒模式下测试所有这些。