fix(core-flows): emit payment.captured event in authorizePaymentSessionForOrderWorkflow when captures exist - #16738
Conversation
🦋 Changeset detectedLatest commit: e182a2a The changes in this PR will be included in the next version bump. This PR includes changesets to release 83 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks for the contribution! A few items need to be addressed before this can move forward: The PR aims to emit PaymentEvents.CAPTURED inside authorizePaymentSessionForOrderWorkflow when the authorized session produces captures — a valid fix for the linked issue. However, there are several issues that need to be addressed before this can move forward: 1. A dead import from Node's process module was added and is unused. 2. An unrelated change to edit-role-permissions-form.tsx is bundled into the PR without being described in the PR body. This needs to be either split into a separate PR or explicitly described. 3. The changeset for the dashboard change uses a major bump type for what appears to be a bug fix; Medusa conventions require patch for bug fixes. Because changeset bump types cascade through the monorepo, a major bump here would incorrectly trigger major version bumps for 83+ packages. 4. A semicolon was introduced in the workflow file, violating the no-semicolons code style. 5. No tests were added to verify the event is emitted under the expected condition.
Triggered by: new PR opened |
What
Emits
PaymentEvents.CAPTUREDinsideauthorizePaymentSessionForOrderWorkflowwhen the authorized payment session results in payment captures.Why
Fixes #16727. When checking payment status in the admin dashboard (or running
authorizePaymentSessionForOrderWorkflow), if the payment provider authorizes and auto-captures the payment, transactions were added to the order, butPaymentEvents.CAPTUREDwas never emitted. This prevented downstream event subscribers (notifications, accounting integrations, emails) from receiving payment capture events.How
when("emit-payment-captured-event", ...)block inauthorizePaymentSessionForOrderWorkflowthat checks!!payment?.captures?.length.emitEventStepwithPaymentEvents.CAPTUREDand{ id: payment.id }when captures are present.Testing
capturePaymentWorkflow.