Refund transaction of Paypal recurring billing

岁酱吖の 提交于 2019-12-11 11:58:37

问题


I am trying to create a refund for a transaction that happened over a recurring billing agreement using AJAX but I keep getting errors like 404, 501, and 500 errors. All my other API calls to Paypal's sandbox come back successfully. I am getting the transaction ID from a get request that returns an array of transactions (/v1/payments/billing-agreements/<Agreement-Id>/transactions?start_date=yyyy-mm-dd&end_date=yyyy-mm-dd). Do any of you know if this is an issue with my API call or if Paypal doesn't allow refunds on recurring billing? Also if there is a way to just return money back to the customer using Paypal's RESTful API that would also be feedback.

Thanks in advance!


回答1:


When you do the search transactions API call, it'll return a few different fields with transaction_id. You will have ones for when the agreement is agreed to or modified. These will generally have 'I-' at the beginning. These are not refundable. But, they will also provide ones with the status "completed" that are for the actual payments. These are the ones that can be refunded.

If you are refunding the "I-" ones, you will get the INVALID RESOURCE ID error.




回答2:


You should be using the transaction id and not the agreement id. This is because the refund API Call is for a transaction not an entire billing agreement. As long as the transaction was in the last 60 days you will be able to refund it.

The below code is directly from the PayPal Developer Rest API Refund Section:

curl -v https://api.sandbox.paypal.com/v1/payments/sale/<Transaction-Id>/refund \
-H 'Content-Type:application/json'  \
-H 'Authorization: Bearer <Access-Token>' \
-d '{
  "amount":
  {
    "total": "2.34",
    "currency": "USD"
  }
}'


来源:https://stackoverflow.com/questions/32729088/refund-transaction-of-paypal-recurring-billing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!