medusajs/medusa

[Bug]: Stripe webhook triggers multiple (unnecessary) premature cart completion on Payment Intent creation

Open

#14,205 建立於 2025年12月3日

在 GitHub 查看
 (9 留言) (0 反應) (0 負責人)TypeScript (22,539 star) (2,090 fork)batch import
good first issuetype: bugversion: 2.0

描述

Package.json file

latest version

Node.js version

v21

Database and its version

17

Operating system name and version

Linux

Browser name

No response

What happended?

When using the Stripe Payment Element, a payment_intent is often created or updated to a processing state before the actual payment authorization is finalized. Currently, the payment webhook handler attempts to complete the cart immediately upon receiving these initial webhook events.

Since the payment is not yet fully authorized/captured, the Cart Completion workflow triggers, creates an Order (incrementing the display_id), and then fails/reverts when it realizes the payment isn't ready. (in the authorize-payment-session-step)

This leads to:

  • Reverted Workflows: Unnecessary load on the server triggering workflows that are destined to fail with a lot of unnessary large queries.

  • Order ID Gaps: The most significant side effect is that the internal display_id (Order Number) increments during the initial workflow step before the transaction reverts. This results in gaps in Order IDs (e.g., Order 1001, then 1003) which is confusing for merchants and problematic for accounting/monitoring.

Expected behavior

We should only trigger cart completion on definitive actions (like AUTHORIZED or CAPTURED) in the webhook.

Actual behavior

n/a

Link to reproduction repo

not needed

貢獻者指南

[Bug]: Stripe webhook triggers multiple (unnecessary) premature cart completion on Payment Intent creation · medusajs/medusa#14205 | Good First Issue