-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Labels
Description
Steps to reproduce
- Mock the CompleteOrderApi::complete method to pass an additional header parameter to the capture action request so that Paypal will generate an error (doc: https://developer.paypal.com/docs/business/test-and-go-live/simulation-tests/#orders) like this:
return $this->client->post(sprintf('v2/checkout/orders/%s/capture', $orderId), $token, null, [
'PayPal-Mock-Response' => '{"mock_application_codes": "INSTRUMENT_DECLINED"}'
]);
- Place an order
- In "Pay with Paypal page" use the yellow paypal button, and confirm the payment on Paypal
- You will be redirected to the homepage, but if you try to retry the payment it will fail cause it's in "PROCESSING" state but the CreatePayPalOrderAction class try to load the last payment with "NEW" state and it won't find any.
Possible solution
This does not happen with HostedFields cause there is an additional check here that cancel the payment if it is still processing after the complete call.
But i think that this solution is weak. If, for example, the user closes the page while the capture request is going on, it will never call the cancel payment. Or maybe due to another error, the cancel payment url could never be called, and the payment of the order will remain PROCESSING.
Probably, it should be responsibility of the CompletePayPalOrderAction controller to cancel the payment if it failed. What do you think?
lamasfoker and jcgdjob