贝宝订阅获取交易列表

时间:2019-11-11 08:23:17

标签: php paypal-subscriptions

我正在建立在线商店。 我目前在https://api.sandbox.paypal.com

我创建了订阅,并且客户批准了该订阅。 一切正常,如文档中所述。此处

  

https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions

现在,我需要获取此订阅的实际付款,以使我的门户与Paypal付款同步。

我猜我需要List transactions for subscription,就像它在这里所说的那样:

  

https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_transactions

但是当我调用此路径时

/v1/billing/subscriptions/I-T99999999999/transactions?start_time=2014-11-11T05:09:16.000Z&end_time=2020-11-11T05:09:16.000Z

我得到空数组作为响应。即使没有交易,我也希望具有这样的结构:

{
  "transactions": [],
  "links": [
    {
      "href": "https://api.paypal.com/v1/billing/subscriptions/I-T99999999999/transactions?start_time=2014-11-11T05:09:16.000Z&end_time=2020-11-11T05:09:16.000Z",
      "rel": "self",
      "method": "GET"
    }
  ]
}

但是我得到的是没有错误的空响应。

1 个答案:

答案 0 :(得分:1)

我面临着同样的问题,但是我发现可以解决。

我可以通过调用计费协议中已弃用的方法来列出订阅交易。

v1/payments/billing-agreements/{{0}}/transactions?start_date={ "agreement_transaction_list": [{ "transaction_id": "I-WBT8MCXV1XD5", "status": "Created", "transaction_type": "Recurring Payment", "payer_name": "Test Payer", "time_stamp": "2019-11-17T01:36:59Z", "time_zone": "GMT" }, { "transaction_id": "2V3487226T084702S", "status": "Updated", "transaction_type": "Recurring Payment", "amount": { "currency": "BRL", "value": "-24.90" }, "fee_amount": { "currency": "BRL", "value": "0.00" }, "net_amount": { "currency": "BRL", "value": "-24.90" }, "payer_email": "test@email.com", "payer_name": "John Doe's Test Store", "time_stamp": "2019-11-17T01:37:01Z", "time_zone": "GMT" }] } &end_date={{2}}

链接到文档:

https://developer.paypal.com/docs/api/payments.billing-agreements/v1/#billing-agreements_transactions

您将收到类似以下的示例响应:

tag