【问题标题】:Get details (parent payment) of a refund获取退款的详细信息(父母付款)
【发布时间】:2015-04-24 22:54:38
【问题描述】:

如何获得 PayPal 通知我的退款父母付款?

我从 PayPal 收到了这个通知(webhook):

{
  "create_time": "2015-02-20T10:56:36Z",
  "event_type": "PAYMENT.SALE.REFUNDED",
  "id": "WH-XXX-XXX",
  "links": [
    {
      "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-XXX-XXX",
      "method": "GET",
      "rel": "self"
    },
    {
      "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-XXX-XXX/resend",
      "method": "POST",
      "rel": "resend"
    }
  ],
  "resource": {
    "amount": {
      "currency": "EUR",
      "details": {
        "subtotal": "-XX.XX",
        "tax": "XX.XX"
      },
      "total": "-XX.XX"
    },
    "create_time": "2015-02-20T10:55:10Z",
    "id": "XXX",
    "links": [
      {
        "href": "https://10.73.133.169:17881/v1/payments/refund/XXX",
        "method": "GET",
        "rel": "self"
      }
    ],
    "state": "completed"
  },
  "resource_type": "sale",
  "summary": "A EUR XX.XX EUR sale payment was refunded"
}

如果我获取资源 -> id 并使用 PayPal PHP-SDK 执行以下请求,我会得到一个退款对象,但没有“parent_payment”字段(此处记录:https://developer.paypal.com/docs/api/#look-up-a-refund

PayPal\Api\Refund::get($id, $api);

每个其他的电话都像..

PayPal\Api\Sale::get($id, $api);

PayPal\Api\Transaction::get($id, $api);

PayPal\Api\Payment::get($id, $api);

失败!

我的通知或我使用的方法有什么问题?

更新:这是我对 Refund::get() 查找的回复:

{
  "id": "XXX",
  "create_time": "2015-02-20T10:55:10Z",
  "state": "completed",
  "amount": {
    "total": "-XX.XX",
    "currency": "EUR",
    "details": {
      "subtotal": "-XX.XX",
      "tax": "XX.XX"
    }
  },
  "links": [
    {
      "href": "https://api.paypal.com/v1/payments/refund/XXX",
      "rel": "self",
      "method": "GET"
    }
  ]
}

【问题讨论】:

  • 你是怎么解决这个问题的?

标签: php paypal paypal-rest-sdk


【解决方案1】:

通常,当您执行lookup on Refund 时,您会收到一个响应,其中包括parent_payment,它应该具有可用于检索支付对象的 PaymentID。

这是响应的样子:

退款:get()

{
"id": "3KJ86032KA0123648",
"create_time": "2015-02-23T22:25:31Z",
"update_time": "2015-02-23T22:25:31Z",
"state": "completed",
"amount": {
    "total": "-0.01",
    "currency": "USD"
},
"sale_id": "4JE73984NP0170710",
"parent_payment": "PAY-0J694581CG996145EKTV2RWA",
"links": [
    {
        "href": "https://api.sandbox.paypal.com/v1/payments/refund/3KJ86032KA0123648",
        "rel": "self",
        "method": "GET"
    },
    {
        "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-0J694581CG996145EKTV2RWA",
        "rel": "parent_payment",
        "method": "GET"
    },
    {
        "href": "https://api.sandbox.paypal.com/v1/payments/sale/4JE73984NP0170710",
        "rel": "sale",
        "method": "GET"
    }
]

}

付款:get();

{
    "id": "PAY-1XX00578GL815852KKTV2RGI",
    "create_time": "2015-02-23T22:24:25Z",
    "update_time": "2015-02-23T22:24:28Z",
    "state": "approved",
    "intent": "sale",
    "payer": {
        "payment_method": "credit_card",
        "funding_instruments": [
            {
                "credit_card": {
                    "type": "visa",
                    "number": "xxxxxxxxxxxx2259",
                    "expire_month": "11",
                    "expire_year": "2019",
                    "first_name": "Joe",
                    "last_name": "Shopper"
                }
            }
        ]
    },
    "transactions": [
        {
            "amount": {
                "total": "20.00",
                "currency": "USD",
                "details": {
                    "subtotal": "17.50",
                    "tax": "1.30",
                    "shipping": "1.20"
                }
            },
            "description": "Payment description",
            "invoice_number": "54eba89962365",
            "item_list": {
                "items": [
                    {
                        "name": "Ground Coffee 40 oz",
                        "price": "7.50",
                        "currency": "USD",
                        "quantity": "1",
                        "description": "Ground Coffee 40 oz",
                        "tax": "0.30"
                    },
                    {
                        "name": "Granola bars",
                        "price": "2.00",
                        "currency": "USD",
                        "quantity": "5",
                        "description": "Granola Bars with Peanuts",
                        "tax": "0.20"
                    }
                ]
            },
            "related_resources": [
                {
                    "sale": {
                        "id": "40F92773GL716624V",
                        "create_time": "2015-02-23T22:24:25Z",
                        "update_time": "2015-02-23T22:24:28Z",
                        "amount": {
                            "total": "20.00",
                            "currency": "USD"
                        },
                        "state": "partially_refunded",
                        "parent_payment": "PAY-1XX00578GL815852KKTV2RGI",
                        "links": [
                            {
                                "href": "https://api.sandbox.paypal.com/v1/payments/sale/40F92773GL716624V",
                                "rel": "self",
                                "method": "GET"
                            },
                            {
                                "href": "https://api.sandbox.paypal.com/v1/payments/sale/40F92773GL716624V/refund",
                                "rel": "refund",
                                "method": "POST"
                            },
                            {
                                "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-1XX00578GL815852KKTV2RGI",
                                "rel": "parent_payment",
                                "method": "GET"
                            }
                        ]
                    }
                },
                {
                    "refund": {
                        "id": "50V96618DN7676452",
                        "create_time": "2015-02-23T22:24:28Z",
                        "update_time": "2015-02-23T22:24:28Z",
                        "state": "completed",
                        "amount": {
                            "total": "-0.01",
                            "currency": "USD"
                        },
                        "sale_id": "40F92773GL716624V",
                        "parent_payment": "PAY-1XX00578GL815852KKTV2RGI",
                        "links": [
                            {
                                "href": "https://api.sandbox.paypal.com/v1/payments/refund/50V96618DN7676452",
                                "rel": "self",
                                "method": "GET"
                            },
                            {
                                "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-1XX00578GL815852KKTV2RGI",
                                "rel": "parent_payment",
                                "method": "GET"
                            },
                            {
                                "href": "https://api.sandbox.paypal.com/v1/payments/sale/40F92773GL716624V",
                                "rel": "sale",
                                "method": "GET"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "links": [
        {
            "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-1XX00578GL815852KKTV2RGI",
            "rel": "self",
            "method": "GET"
        }
    ]
}

【讨论】:

  • 抱歉,Jay,但如果我对通过 webhook 获得的资源 ID 进行退款查找,我没有得到“parent_payment”。是否可以通过私信向您发送退款 id/webhook id,以便您确认?
  • 我用退款查询的回复更新了我的问题!
猜你喜欢
  • 2018-04-05
  • 2020-10-16
  • 2018-08-30
  • 2023-04-06
  • 1970-01-01
  • 2019-04-22
  • 2019-02-28
  • 2021-12-31
  • 2011-12-01
相关资源
最近更新 更多