Skip to content

feat(core-flows,types): pass cart in create payment session context#12694

Closed
shahednasser wants to merge 7 commits intodevelopfrom
feat/payment-sess-cart-context
Closed

feat(core-flows,types): pass cart in create payment session context#12694
shahednasser wants to merge 7 commits intodevelopfrom
feat/payment-sess-cart-context

Conversation

@shahednasser
Copy link
Copy Markdown
Member

Some payment providers requires details related to the cart, such as its items and totals. This PR passes the cart information in the create payment session context

@shahednasser shahednasser requested a review from a team as a code owner June 10, 2025 08:32
@vercel
Copy link
Copy Markdown

vercel bot commented Jun 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-reference Building Building Preview, Comment Apr 9, 2026 10:59am
medusa-dashboard Ready Ready Preview, Comment Apr 9, 2026 10:59am
8 Skipped Deployments
Project Deployment Actions Updated (UTC)
api-reference-v2 Ignored Ignored Preview Apr 9, 2026 10:59am
bloom-docs Ignored Ignored Preview Apr 9, 2026 10:59am
cloud-docs Ignored Ignored Preview Apr 9, 2026 10:59am
docs-ui Ignored Ignored Preview Apr 9, 2026 10:59am
docs-v2 Ignored Ignored Preview Apr 9, 2026 10:59am
medusa-docs Ignored Ignored Preview Apr 9, 2026 10:59am
resources-docs Ignored Ignored Preview Apr 9, 2026 10:59am
user-guide Ignored Ignored Preview Apr 9, 2026 10:59am

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jun 10, 2025

🦋 Changeset detected

Latest commit: 3babaaa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 77 packages
Name Type
@medusajs/core-flows Patch
@medusajs/types Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
integration-tests-http Patch
@medusajs/event-bus-redis Patch
@medusajs/draft-order Patch
@medusajs/framework Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
@medusajs/medusa-oas-cli Patch
@medusajs/admin-bundler Patch
@medusajs/dashboard Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/promotion Patch
@medusajs/rbac Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/translation Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/event-bus-local Patch
@medusajs/analytics-local Patch
@medusajs/analytics-posthog Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/caching-redis Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/oas-github-ci Patch
@medusajs/http-types-generator Patch
@medusajs/cli Patch
@medusajs/deps Patch
@medusajs/telemetry Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app Patch
medusa-dev-cli Patch
@medusajs/ui Patch

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

@shahednasser
Copy link
Copy Markdown
Member Author

/snapshot-this

@github-actions
Copy link
Copy Markdown
Contributor

🚀 A snapshot release has been made for this PR

Test the snapshots by updating your package.json with the newly published versions:

yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]

Latest commit: 1a78476

"amount",
"currency_code",
"payment_sessions.*",
"cart.id",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thought: If I am not mistaken, this workflow can also be used to create payment sessions for orders. I wonder if we should reconsider the approach here to account for this?

One idea that comes to mind would be to:

  1. Allow passing cart_id and order_id to the workflow
  2. Fetch the data based on which of these was passed
  3. Pass cart_or_order in the context passed to the provider

Not loving it, but this was the first approach that came to mind, so mainly sharing to start the discussion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think that makes sense, but maybe we can have separate cart and order properties in the context? They're both optional, so we don't guarantee they're passed anyway and that would allow us to account for other use cases in the future.

@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Aug 17, 2025
@olivermrbl olivermrbl removed the Stale label Aug 17, 2025
@shahednasser
Copy link
Copy Markdown
Member Author

@olivermrbl let me know what we should do about this one

@willbouch willbouch requested a review from olivermrbl October 6, 2025 18:59
@olivermrbl olivermrbl requested a review from a team as a code owner October 29, 2025 12:34
@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 1, 2026

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Copy link
Copy Markdown
Contributor

@NicolasGorga NicolasGorga left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Mar 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions bot closed this Mar 23, 2026
@NicolasGorga NicolasGorga reopened this Mar 23, 2026
@medusa-os-bot
Copy link
Copy Markdown

medusa-os-bot bot commented Apr 9, 2026

After an initial review, this PR looks good to us. Here's a summary:

✅ Changeset included with correct format
✅ Integration tests included
✅ Leverages the existing CartPaymentCollection link to fetch cart data from the payment collection — no new input fields needed
✅ Follows contribution guidelines and workflow patterns

Notes:

  • Payment collections are not always linked to a cart (standalone use cases). Verify that the workflow handles a missing cart gracefully, i.e. the context passes cart: undefined without erroring, and payment providers that don't need it are unaffected.
  • The PaymentCartDTO type adds 117 lines — if it includes nested line items and shipping methods, that could be a large payload for some providers. Consider whether a narrower type (e.g. totals + item count only) would be more appropriate, or document that providers should pick only what they need.

A team member will do a final review before this is merged.

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.

4 participants