Skip to content

fix(core-flows): emit payment.captured after order payment authorization - #16748

Open
Sudaisib wants to merge 1 commit into
medusajs:developfrom
Sudaisib:develop
Open

fix(core-flows): emit payment.captured after order payment authorization#16748
Sudaisib wants to merge 1 commit into
medusajs:developfrom
Sudaisib:develop

Conversation

@Sudaisib

@Sudaisib Sudaisib commented Sep 7, 2026

Copy link
Copy Markdown

Summary

The authorizePaymentSessionForOrderWorkflow can successfully authorize a payment session and create order transactions, but it did not emit the workflow-level payment.captured event when the provider returned captures. This PR emits PaymentEvents.CAPTURED when captures are present.

Why

Consumers that depend on the payment-captured workflow event were not notified for captures performed through this authorization path.

Changes

  • Import PaymentEvents and emitEventStep.
  • Emit PaymentEvents.CAPTURED with the payment ID when the authorized payment contains captures.

Testing

The change was reviewed against the existing workflow implementation and validated locally with whitespace and structural checks. The PR is intentionally limited to the missing event emission.

@Sudaisib
Sudaisib requested a review from a team as a code owner September 7, 2026 10:01
@changeset-bot

changeset-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0b56085

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@medusa-os-bot

medusa-os-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

Thanks for the contribution! A few items need to be addressed before this can move forward:

The author adds event emission for PaymentEvents.CAPTURED inside authorizePaymentSessionForOrderWorkflow when the authorized payment contains captures. The approach is sound and the payload { id: payment.id } is consistent with how capturePaymentWorkflow emits the same event. The conditional when guard (emit only when captures.length > 0) is appropriate. No security, performance, or correctness issues were found in the added code itself. However, three required items are missing before this can move forward: 1. Changeset: The changeset-bot confirms no changeset was added. Any code change under packages/ must include a changeset file. 2. Tests: The testing description only mentions manual code review and local whitespace checks. A behavior-changing fix of this kind — adding event emission on an authorization path — should have at least a unit test verifying the event is emitted when the payment has captures and is not emitted when it has none. 3. Linked issue: There is no linked issue via a closing keyword. Non-trivial behavior changes should reference a verified issue per the contribution guidelines.

  • Add a changeset for @medusajs/core-flows. Run yarn changeset from the repo root, select @medusajs/core-flows as the affected package, choose patch, and use a message like fix(core-flows): emit payment.captured after order payment authorization.
  • Add tests for the new event emission: verify that emitEventStep is called with PaymentEvents.CAPTURED and { id: payment.id } when the authorized payment has captures, and is not called when captures is empty or absent.
  • Link a verified issue via a closing keyword in the PR body (e.g. Closes #<issue>) describing the missing event emission, or explain in the PR description why no pre-existing issue applies.

Triggered by: new PR opened

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant