Skip to content

fix(payments-next): PaidInvoiceOnFailedCartError: Paid invoice found on failed cart#20708

Open
elizabeth-ilina wants to merge 1 commit into
mainfrom
PAY-3664-paid-invoice-on-failed-cart-error
Open

fix(payments-next): PaidInvoiceOnFailedCartError: Paid invoice found on failed cart#20708
elizabeth-ilina wants to merge 1 commit into
mainfrom
PAY-3664-paid-invoice-on-failed-cart-error

Conversation

@elizabeth-ilina

@elizabeth-ilina elizabeth-ilina commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Because

  • When a customer checks out with PayPal in tab 1 and then sends a second request from tab 2 while the first cart is almost done processing, they end up charged by the first tab while the second tab's stale cart version throws and transitions the cart into FAIL for both tabs. The customer sees the error page, tries to subscribe again, and finds they are already subscribed to the product.

This pull request

  • Checks if the cart is already processing, and, if it is, prevents a second request from failing a cart that another request is actively processing, so the owning request finishes rather than both tabs erroring out.

Issue that this pull request solves

Closes #PAY-3664

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

How to review

STRs and screen recordings:
Using the current console logs and timeouts (I'll remove them before merging):

  1. Make an account, go to checkout, call this Tab 1.
  2. Open new tab (Tab 2), copy Tab 1's url (make sure cart IDs are the same).
  3. Open PayPal popups + log in to PayPal on both tabs at the same time.
  4. On Tab 1, proceed to checkout with PayPal, wait until you see the log "postPaySteps: about to finish cart, sleeping, START TAB 2"
  5. Quickly proceed to pay with PayPal in Tab 2.
  6. When both tabs fail, notice that a subscription was made.
    What happens: Tab 1 charges --> Tab 2 arrives with stale cart version --> Tab 2 puts cart in FAIL --> Tab 1's finishCart fails → both tabs see an error, but the customer is subscribed.
    Video attached:
Screen.Recording.2026-06-08.at.2.52.59.PM.mov

After the fix, instead of both tabs failing in step 6, they succeed:

Screen.Recording.2026-06-08.at.12.30.30.PM.mov
  • Key files/areas to focus on:
  • Suggested review order:
  • Risky or complex parts:

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

Any other information that is important to this pull request.

});
}

// TODO: remove these after testing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo: remove before merging.

errorReasonId,
});

// TODO: remove after testing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo: remove before merging.

…on failed cart

Because:

* When a customer checks out with PayPal in tab 1 and then sends a second request from tab 2 while the first cart is almost done processing, they end up charged by the first tab while the second tab's stale cart version throws and transitions the cart into FAIL for both tabs. The customer sees the error page, tries to subscribe again, and finds they are already subscribed to the product.

This commit:

* Checks if the cart is already processing, and, if it is, prevents a second request from failing a cart that another request is actively processing, so the owning request finishes rather than both tabs erroring out.

Closes #[PAY-3664](https://mozilla-hub.atlassian.net/browse/PAY-3664)
@elizabeth-ilina elizabeth-ilina force-pushed the PAY-3664-paid-invoice-on-failed-cart-error branch from 7aef9f0 to 85907be Compare June 8, 2026 18:21
@elizabeth-ilina elizabeth-ilina marked this pull request as ready for review June 8, 2026 18:54
@elizabeth-ilina elizabeth-ilina requested a review from a team as a code owner June 8, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant