-
-
Notifications
You must be signed in to change notification settings - Fork 4k
feat(types,core-flows): Allow tax providers to return metadata for cart/order storage #14605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
feat(types,core-flows): Allow tax providers to return metadata for cart/order storage #14605
Conversation
🦋 Changeset detectedLatest commit: c7288d6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 74 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 |
|
@rjstanley is attempting to deploy a commit to the medusajs Team on Vercel. A member of the Team first needs to authorize it. |
…rt/order storage This change enables tax providers to return metadata alongside tax lines, which workflows automatically store on the cart or order. This is useful for tax providers that need to store calculation references (e.g., calculation_id) for later use during order completion. Changes: - Add TaxLinesResult type that providers can return instead of just tax lines array - Update ITaxProvider.getTaxLines return type to accept either array or TaxLinesResult - Update getItemTaxLinesStep to handle TaxLinesResult and pass sourceMetadata through - Update updateTaxLinesWorkflow to store sourceMetadata on cart via updateCartsStep - Update upsertTaxLinesWorkflow to store sourceMetadata on cart via updateCartsStep - Update updateOrderTaxLinesWorkflow to store sourceMetadata on order via updateOrdersStep
82b609c to
c7288d6
Compare
|
@claude review this |
Pull Request Review - #14605SummaryThis PR adds a valuable feature allowing tax providers to return metadata alongside tax lines, which is automatically stored on carts/orders. The implementation is well-designed and maintains backward compatibility. ✅ Strengths1. Clean Architecture
2. Backward Compatibility
3. Implementation Quality
|
Summary
This PR enables tax providers to return metadata alongside tax lines, which workflows automatically store on the cart or order. This addresses a common limitation where tax providers need to store calculation references (e.g.,
calculation_id) for later use during order completion (e.g., committing tax transactions).Use case: Tax providers like TaxJar, Avalara, and Numeral often perform a "calculation" during checkout that returns a
calculation_id. During order completion, thiscalculation_idis used to "commit" the transaction with the tax service. Previously, providers had to use raw SQL to store this ID on the cart since they lacked access to the Cart module from within theITaxProviderinterface.Changes
TaxLinesResulttype that providers can return instead of just a tax lines arrayITaxProvider.getTaxLinesreturn type to accept either array orTaxLinesResultgetItemTaxLinesStepto handleTaxLinesResultand passsourceMetadatathroughupdateTaxLinesWorkflowto storesourceMetadataon cart viaupdateCartsStepupsertTaxLinesWorkflowto storesourceMetadataon cart viaupdateCartsStepupdateOrderTaxLinesWorkflowto storesourceMetadataon order viaupdateOrdersStepExample usage in a tax provider
The workflow automatically merges this metadata into the cart/order's metadata field.
Backward compatibility
This change is fully backward compatible:
TaxLinesResulttype is optional and only used when providers need to store metadataTest plan
TaxLinesResultwithsourceMetadataproperly stores metadata on cartTaxLinesResultwithsourceMetadataproperly stores metadata on order