Skip to content
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

Closed
alexflorisca opened this issue Nov 11, 2022 · 1 comment · Fixed by #8110
Closed

The ERROR and FAIL payment status values are not accurate #7667

alexflorisca opened this issue Nov 11, 2022 · 1 comment · Fixed by #8110
Assignees
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.

Comments

@alexflorisca
Copy link
Member

Describe the bug

While working on #7666, I discovered the payment status actually changes to ERROR and FAIL based on the response from the observers that run on the onPaymentProcessing 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 a SUCCESS or ERROR 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 to SUCCESS. 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 still SUCCESS. Once the checkout is idle, the payment status gets set to PRISTINE. There is no logic to set the payment status for FAILED, which it should be in this case.

To reproduce

  1. Comment out this line
  2. Checkout with a bad card (for example: 4000000000000002) with redux dev tools open
  3. Looks at the value of the status property in the payment store

Expected behavior

I would expect the payment status to be set to FAILED when a payment fails.

@alexflorisca alexflorisca added type: bug The issue/PR concerns a confirmed bug. block: checkout Issues related to the checkout block. focus: blocks Specific work involving or impacting how blocks behave. labels Nov 11, 2022
@alexflorisca alexflorisca self-assigned this Jan 3, 2023
@ralucaStan
Copy link
Contributor

pdFofs-EM-p2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants