Skip to content

fix(mollie-payments): wrap addPayment in transaction#33

Merged
michaelbromley merged 3 commits into
vendurehq:mainfrom
casperiv0:fix/mollie-add-payment-transaction
May 11, 2026
Merged

fix(mollie-payments): wrap addPayment in transaction#33
michaelbromley merged 3 commits into
vendurehq:mainfrom
casperiv0:fix/mollie-add-payment-transaction

Conversation

@casperiv0
Copy link
Copy Markdown
Contributor

@casperiv0 casperiv0 commented May 6, 2026

This PR includes:

With the recent release of Vendure, it requires the transitionOrderToState and addPaymentToOrder fns to be wrapped in a Transaction.
That wasn't handled inside the addPayment helper function in the Mollie service.

cc @martijnvdbrug would be nice to have your input on this too, please 🙏

Related Vendure Core PR: vendurehq/vendure#4689


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

Comment thread packages/mollie-plugin/src/mollie.service.ts Outdated
Copy link
Copy Markdown
Contributor

@martijnvdbrug martijnvdbrug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor optional change requested, but approved if you choose to ignore it :-)

Good catch. I have yet to test it out though...

@casperiv0
Copy link
Copy Markdown
Contributor Author

Thanks Martijn! Tested in my Vendure project w/ our test suite and are passing now after this change. Before they were failing, mentioning that the fn wasn't wrapped in a transaction

@casperiv0 casperiv0 requested a review from martijnvdbrug May 7, 2026 07:45
Copy link
Copy Markdown

@grolmus grolmus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed locally + ran build & lint, both green.

The wrap pattern is correct and matches the canonical Vendure idiom mirroring core #4689. withTransaction correctly joins an existing tx on _ctx (webhook path via @Transaction() on MollieController) and opens a new one when _ctx has none (free-order path in createPaymentIntent where a fresh admin RequestContext is built). Applying the wrap at addPayment rather than higher up in handleMolliePaymentStatus is the right call — it also protects the free-order path and any future direct callers.

A few non-blocking suggestions for a follow-up:

  1. Param naming: _ctx is a touch confusing — the leading underscore conventionally signals an unused parameter, but here it's passed to withTransaction. Something like outerCtx would read better. Minor.

  2. Comment clarity at the top of addPayment: the current note mentions the free-order admin ctx specifically, but addPayment is a public method and any future caller without an outer tx would hit the same issue. Could be reworded to lead with the general invariant — "transitionToState and addPaymentToOrder must run in a single tx so save/hooks/save commit or roll back together; withTransaction joins an existing tx on the passed ctx, or opens a new one (e.g. for the fresh admin ctx in createPaymentIntent free-order branch)."

  3. E2E regression: core #4689 added order-process-rollback.e2e-spec.ts as a regression guard. A sibling spec in packages/mollie-plugin/e2e/ that registers a throwing hook and asserts no half-transitioned state after addPayment failure would protect against future refactors. Worth tracking as a follow-up issue.

LGTM, approving.

@michaelbromley michaelbromley merged commit 31294f1 into vendurehq:main May 11, 2026
5 checks passed
@vendure-ci-automation-bot vendure-ci-automation-bot Bot locked and limited conversation to collaborators May 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants