Shopify Refund Order Line Items and Shipping Fee
Advanced refund action that refunds specific line items together with a proportional share of the shipping fee. Includes safety checks, duplicate protection and a soft-launch mode for testing.
What it does
- Fetches the order by its internal Shopify order ID.
- Records the refund attempt in a Shopify metaobject for audit and rate-limiting.
- Runs safety checks (refund frequency limits and duplicate detection via metafields).
- Calculates the shipping portion to refund proportionally based on item quantity or weight.
- Calls the Shopify Calculate and Create Refund endpoints with full line-item detail.
- Marks the order with a
digitalgenius.is_refundedmetafield after success.
Notes
- Uses the internal Shopify order ID, not the visible order number.
- Three refund modes:
full(all items + all shipping),percentage of items quantity(selected items + shipping by quantity ratio), orpercentage of items weight(selected items + shipping by weight ratio). - Safety limits block the action if too many refunds are detected (20/hour, 60/12h, 100/24h).
- Soft Launch mode calculates the refund without executing it, useful for testing flows.
- Items are not restocked by this action.
- Requires the
$app:order_refundmetaobject definition to exist in the Shopify store.
Inputs
| Name | Type | Description |
|---|---|---|
| Shopify Subdomain | Credentials | Store subdomain |
| Shopify Token | Credentials (sensitive) | Admin API access token |
| Order ID | String | Internal Shopify order ID (numeric) |
| Type of Refund | String | full, percentage of items quantity, or percentage of items weight |
| List of Line Items | List | IDs of line items to refund (required for partial refunds) |
| Soft Launch | Boolean | When true, only calculates without executing the refund |
| Reason for Refund | String | Stored as the refund note |
Outputs
| Name | Type | Description |
|---|---|---|
| Success | Boolean | Whether the refund was processed (or calculated in soft-launch mode) |
| Amount | String | Formatted refund amount (e.g. $12.50 USD) |
| Refund Details | Object | Full Shopify refund response object |