This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
The ERROR and FAIL payment status values are not accurate #7667
Labels
block: checkout
Issues related to the checkout block.
focus: blocks
Specific work involving or impacting how blocks behave.
type: bug
The issue/PR concerns a confirmed bug.
Describe the bug
While working on #7666, I discovered the payment status actually changes to
ERROR
andFAIL
based on the response from the observers that run on theonPaymentProcessing
event, rather than when a payment has actually errored or failed.A bit of background...
During the checkout flow, we emit an event called
PAYMENT_PROCESSING
, which a third party payment plugin can listen to and perform some actions. This is executed after the checkout has been validated and there are not errors. A payment plugin can use this event to, for example, create a payment intent. Stripe does this. It creates a reference object to indicate a payment intent, and returns aSUCCESS
orERROR
based on the outcome of this. This isn't the actual payment though. This is made later, through a fetch call to the store api (payment is done server side). We set the payment status based on this response from the event handler. Which doesn't reflect the status of the actual payment, and is misleading. For example, the payment intent can be successful (which it is even for bad cards), so we set the payment status toSUCCESS
. We then call the store api and make the actual payment, this comes back declined with an error. The user will see the error, but the payment status is stillSUCCESS
. Once the checkout is idle, the payment status gets set toPRISTINE
. There is no logic to set the payment status forFAILED
, which it should be in this case.To reproduce
4000000000000002
) with redux dev tools openstatus
property in the payment storeExpected behavior
I would expect the payment status to be set to
FAILED
when a payment fails.The text was updated successfully, but these errors were encountered: