In order to gracefully handle a refund request on a transaction that has already been refunded, I should have the possibility to check the exact error code returned by PayPal REST API in case of a POST https://api.sandbox.paypal.com/v1/payments/capture/{captureid}/refund request.
similarly to the classic API I thought (but I was wrong) that in this case an error 10009 could be returned (https://developer.paypal.com/docs/classic/api/errorcodes/).
Actually when I try to request a refund for a payment that has already been captured i got a 400 HTTP status and the JSON body below:
{
"name": "TRANSACTION_REFUSED",
"message": "The request was refused.This transaction has already been fully refunded",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#TRANSACTION_REFUSED",
"debug_id": "e3f52374ef2e7"
}
I was wondering if there's a way to to look for this specific error other than inspecting the "message" value included in the JSON response.
Thanks, Andrea