[ad_1]
Hi @scalax,
It depends on the specific error response from PayPal, but the integration restarts the payment process up to two times in some cases. The buyer is then redirected to the PayPal website before they would be redirected back to the checkout page with an error message.
The behavior can be tested with this filter, for example:
add_filter('ppcp_request_args', function ($args, $url){
if (strpos($url,'capture') !== false) {
$args['headers']['PayPal-Mock-Response'] = '{"mock_application_codes": "INSTRUMENT_DECLINED"}';
}
return $args;
}, 10, 2);As long as this filter is active, any (sandbox) payment would be declined.
When the payment has been declined three times (the initial one and the two restarted ones), the buyer sees an error message.
But the specific behavior depends on the kind of error that is received from PayPal.
Kind regards,
Niklas
Thread Starter
scalax
(@scalax)
Thank you Niklas for your answer.
You’ve addressed me in the right direction. To give more information for future user please let me ask two more questions related to the first one
First: where, in Paypal documentation, we can read about the restart of the payment process?
Second: i have tested the behaviour not with your snippet but by trying to pay two times with the sandbox credit card plus the insufficient funds rejection trigger; after Paypal sent me back to my shop’s checkout page i got the following error notice:
“Failed to process the payment. Please try again or contact the shop admin. [UNPROCESSABLE_ENTITY] The requested action could not be performed, semantically incorrect, or failed business validation. https://developer.paypal.com/docs/api/orders/v2/#error-TRANSACTION_REFUSED”
Did i get this error because i’m on sandbox? Will i get a “insufficient funds” notification on live?
Thank you.
Hi @scalax,
First: where, in Paypal documentation, we can read about the restart of the payment process?
The restart of the payment process is not coming from PayPal, but is actively handled like this in the plugin.
Certain API responses from PayPal are caught and handled with a more user-friendly error message and potentially a restart of the payment process.
Second: i have tested the behaviour not with your snippet but by trying to pay two times with the sandbox credit card plus the insufficient funds rejection trigger; after Paypal sent me back to my shop’s checkout page i got the following error notice:
There is a wide range of potential errors PayPal could return, and the TRANSACTION_REFUSED error response is currently not handled by the integration. This means the error you saw on the Checkout page is coming directly from the PayPal API and is the one the buyer would see in live mode as well.
This is not quite user-friendly, and there are a handful of PayPal API responses to be handled and improved with a future update. For now, I estimate that about ¾ of the most frequently occurring errors are handled with user-friendly errors, and we hope the rest will follow suit in one of the next updates.
Kind regards,
Niklas
