Fix phantom payment bugs in Stripe payment type#2459
Open
alecritson wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three entangled bugs in the Stripe package allowed Stripe-side succeeded payments to leave no local trace, hiding double-charges from operators:
StripeManager::getCartIntentIdreferenced an undefined$cartModelvariable, silently breaking the legacy cart meta payment_intent fallback (the null-coalesce always fell through).StripePaymentType::authorizeretrieved the Stripe PaymentIntent after attemptingcart->createOrder(). WhencreateOrderthrew aCartException(e.g. abandoned cart with no addresses), the catch returned a failure DTO without ever syncing the PI status from Stripe, leaving lunar_stripe_payment_intents.status null for a row whose charge had already succeeded server-side. No transaction, no failed_jobs entry, no operator visibility.StripePaymentIntent::scopeActivewas correct, but because the status was never written for the orphan case above, succeeded PIs continued to look "active" in queries and were re-fetched bygetCartIntentIdon subsequent requests.Reorder authorize() so the PaymentIntent is retrieved and its status persisted to the local row before any order work is attempted. When createOrder fails on a Stripe-side succeeded PI, mark the row processed_at and dispatch a new OrphanedPaymentIntentDetected event so operators can reconcile. Non-succeeded PI failures keep their existing failure-DTO behaviour but now also leave a correct local status.
Tests cover the legacy meta lookup, both branches of the order-fail path, and the active-scope contract.