Commit f57b942
authored
fix(core-flows, payment, types): expose
Closes #14816
## What
Expose the `metadata` field on refund creation when using `refundPaymentsWorkflow`.
## Why
The `Refund` data model already has a `metadata` column (see `packages/modules/payment/src/models/refund.ts`), but the field is not present on:
- `CreateRefundDTO`
- `RefundPaymentsStepInput`
- `RefundPaymentsWorkflowInput`
So callers of `refundPaymentsWorkflow` (and the `PaymentModuleService.refundPayment` API directly) have no way to attach metadata to a refund — even though the underlying storage supports it. The reporter in #14816 hit this exact gap.
## How
1. Add `metadata?: Record<string, unknown>` to `CreateRefundDTO` in `@medusajs/types`.
2. Add the same optional field to `RefundPaymentsStepInput` and `RefundPaymentsWorkflowInput` in `@medusajs/core-flows`. The step already spreads the input into `paymentModule.refundPayment`, so no behavioral change is needed at the workflow layer once the type allows it.
3. Forward `data.metadata` to `refundService_.create(...)` inside `PaymentModuleService.refundPayment_` so the value actually lands on the refund row.
Changes are additive and the new property is optional — no behavior change for existing callers.
## Testing
- Added an integration test in `packages/modules/payment/integration-tests/__tests__/services/payment-module/index.spec.ts` that calls `refundPayment` with a `metadata` payload and asserts the refund persists those values.
- Existing refund tests continue to pass (no signature changes, field is optional).
## Changeset
Included: `.changeset/refund-payments-metadata.md` (patch bumps for `@medusajs/core-flows`, `@medusajs/payment`, `@medusajs/types`).
---
> [!NOTE]
> **Medium Risk**
> Touches refund creation in the payment module (a money-critical path), but the change is additive (optional `metadata`) and covered by an integration test.
>
> **Overview**
> Exposes optional `metadata` when creating refunds via `refundPaymentsWorkflow` by extending `RefundPaymentsStepInput`, `RefundPaymentsWorkflowInput`, and `CreateRefundDTO`.
>
> Threads the new field through `PaymentModuleService.refundPayment` into `refundService_.create(...)`, and adds an integration test asserting refund metadata is persisted. Includes a changeset bumping `@medusajs/core-flows`, `@medusajs/payment`, and `@medusajs/types`.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c100f18. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>metadata on refund creation through refundPaymentsWorkflow (#15273)1 parent b1c4aee commit f57b942
6 files changed
Lines changed: 56 additions & 0 deletions
File tree
- .changeset
- packages
- core
- core-flows/src/payment
- steps
- workflows
- types/src/payment
- modules/payment
- integration-tests/__tests__/services/payment-module
- src/services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
105 | 109 | | |
106 | 110 | | |
107 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
190 | 195 | | |
191 | 196 | | |
192 | 197 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
944 | 944 | | |
945 | 945 | | |
946 | 946 | | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
947 | 975 | | |
948 | 976 | | |
949 | 977 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
926 | 926 | | |
927 | 927 | | |
928 | 928 | | |
| 929 | + | |
929 | 930 | | |
930 | 931 | | |
931 | 932 | | |
| |||
0 commit comments