问题
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