Skip to content

Fix phantom payment bugs in Stripe payment type#2459

Open
alecritson wants to merge 1 commit into
1.xfrom
phantom-payments-vendor-fix
Open

Fix phantom payment bugs in Stripe payment type#2459
alecritson wants to merge 1 commit into
1.xfrom
phantom-payments-vendor-fix

Conversation

@alecritson
Copy link
Copy Markdown
Collaborator

Three entangled bugs in the Stripe package allowed Stripe-side succeeded payments to leave no local trace, hiding double-charges from operators:

StripeManager::getCartIntentId referenced an undefined $cartModel variable, silently breaking the legacy cart meta payment_intent fallback (the null-coalesce always fell through).

StripePaymentType::authorize retrieved the Stripe PaymentIntent after attempting cart->createOrder(). When createOrder threw a CartException (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::scopeActive was 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 by getCartIntentId on 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.

@github-project-automation github-project-automation Bot moved this to Todo in Roadmap May 1, 2026
@alecritson alecritson requested a review from glennjacobs May 1, 2026 07:16
@alecritson alecritson marked this pull request as ready for review May 1, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant