> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # CalculateRefund # Package: orders # Namespace: OrderBillingService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/order-billing/calculate-refund.md ## Permission Scopes: Manage Orders: SCOPE.DC-STORES.MANAGE-ORDERS ## Introduction Calculates the total refund amount and breakdown for specified line items, shipping, and additional fees. Returns detailed calculations including: - Total refund amount with tax, discount, and subtotal breakdowns - Individual item calculations with pricing details - Validation of whether the requested refund items are available Use this method to preview refund amounts before calling Refund Payments. --- ## REST API ### Schema ``` Method: calculateRefund Description: Calculates the total refund amount and breakdown for specified line items, shipping, and additional fees. Returns detailed calculations including: - Total refund amount with tax, discount, and subtotal breakdowns - Individual item calculations with pricing details - Validation of whether the requested refund items are available Use this method to preview refund amounts before calling Refund Payments. URL: https://www.wixapis.com/ecom/v1/order-billing/calculate-refund Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: orderId, refundItems.lineItems.lineItemId, refundItems.lineItems.quantity, refundItems.additionalFees.additionalFeeId Method parameters: param name: orderId | type: orderId | description: Order GUID to calculate refund for. | required: true param name: refundItems | type: RefundItems - name: lineItems | type: array | description: Line items and their quantities to refund. - name: lineItemId | type: string | description: Line item GUID. - name: quantity | type: integer | description: Quantity of this product to refund. Cannot exceed the available refund quantity for this line item. - name: additionalFees | type: array | description: Additional fees and their amounts to refund. - name: additionalFeeId | type: string | description: Additional fee GUID to refund. - name: amount | type: Price | description: Amount of the additional fee to refund. If not specified, the full remaining refundable amount for this fee will be refunded. - name: amount | type: string | description: Amount. - name: shipping | type: ShippingRefund | description: Shipping amount to refund. - name: amount | type: Price | description: Amount of shipping charges to refund. If not specified, the full remaining refundable shipping amount will be refunded. Return type: CalculateRefundResponse - ONE-OF: - name: available | type: boolean | description: Whether the refund is available for all requested items. `true` indicates all items can be refunded as requested. - name: notAvailable | type: CalculatedRefundNotAvailableStatus | description: Refund unavailability details when some or all items cannot be refunded. Contains specific error information for each problematic item. - name: errors | type: array | description: Refund calculation errors. - ONE-OF: - name: lineItem | type: LineItemRefund | description: Line item - name: lineItemId | type: string | description: Line item GUID. - name: quantity | type: integer | description: Quantity of this product to refund. Cannot exceed the available refund quantity for this line item. - name: additionalFee | type: AdditionalFeeRefund | description: Additional fee - name: additionalFeeId | type: string | description: Additional fee GUID to refund. - name: amount | type: Price | description: Amount of the additional fee to refund. If not specified, the full remaining refundable amount for this fee will be refunded. - name: amount | type: string | description: Amount. - name: formattedAmount | type: string | description: Amount formatted with currency symbol. - name: shipping | type: ShippingRefund | description: Shipping - name: amount | type: Price | description: Amount of shipping charges to refund. If not specified, the full remaining refundable shipping amount will be refunded. - name: error | type: Details | description: Error details - ONE-OF: - name: applicationError | type: ApplicationError | description: - name: code | type: string | description: Error code. - name: description | type: string | description: Description of the error. - name: data | type: object | description: Data related to the error. - name: validationError | type: ValidationError | description: - name: fieldViolations | type: array | description: - name: field | type: string | description: - name: description | type: string | description: - name: violatedRule | type: RuleType | description: - enum: VALIDATION, OTHER, MAX, MIN, MAX_LENGTH, MIN_LENGTH, MAX_SIZE, MIN_SIZE, FORMAT, DECIMAL_LTE, DECIMAL_GTE, DECIMAL_LT, DECIMAL_GT, DECIMAL_MAX_SCALE, INVALID_ENUM_VALUE, REQUIRED_FIELD, FIELD_NOT_ALLOWED, ONE_OF_ALIGNMENT, EXACT_LENGTH, EXACT_SIZE, REQUIRED_ONE_OF_FIELD - name: ruleName | type: string | description: applicable when violated_rule=OTHER - name: data | type: object | description: - name: systemError | type: SystemError | description: - name: errorCode | type: string | description: Error code. - name: summary | type: AggregatedRefundSummary | description: Aggregated summary of all items provided for refund. This field is not returned when refund is not available for the given list of items. - name: total | type: Price | description: Total refund amount. - name: tax | type: Price | description: Tax amount for the items being refunded. - name: discount | type: Price | description: Discount amount for the items being refunded. - name: subtotal | type: Price | description: Total cost of the items being refunded (without tax and discount). - name: lineItemsSubtotal | type: Price | description: Total cost of the line items being refunded (without tax and discount). - name: additionalFeesTotal | type: Price | description: Total cost of the additional fees being refunded. - name: calculatedRefundItems | type: CalculatedRefundItems | description: Detailed refund calculations broken down by each requested item type. - name: lineItems | type: array | description: Calculated refund details for each line item. - name: item | type: LineItemRefund | description: Line item refund details. - name: summary | type: CalculatedRefundSummary | description: Calculated refund summary for this line item. - name: total | type: Price | description: Total refundable amount. - name: tax | type: Price | description: Tax amount for the items being refunded. - name: discount | type: Price | description: Discount amount for the items being refunded. - name: subtotal | type: Price | description: Total cost of the items being refunded (without tax and discount). - name: additionalFees | type: array | description: Calculated refund details for each additional fee. - name: additionalFee | type: AdditionalFeeRefund | description: Additional fee refund details. - name: summary | type: CalculatedRefundSummary | description: Calculated refund summary for this additional fee. - name: shipping | type: CalculatedShippingRefund | description: Calculated refund details for the shipping fee. - name: shipping | type: ShippingRefund | description: Shipping refund details. - name: summary | type: CalculatedRefundSummary | description: Calculated refund summary for shipping. ``` ### Examples ### Calculate Refund Calculate valid refund for 1 line item and 1 additional fee. ```curl curl -X POST \ 'https://www.wixapis.com/ecom/v1/order-billing/calculate-refund' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ -d '{ "orderId": "585daa0c-08d2-42ae-bd6b-18fe59c75836", "refundItems": { "lineItems": [ { "lineItemId": "00000000-0000-0000-0000-000000000001", "quantity": 1 } ], "additionalFees": [ { "additionalFeeId": "d3d9cafb-9e2d-4dae-8129-091df0a6c24f", "amount": { "amount": "1" } } ] } }' ``` ### Calculate Refund Calculate refund for invalid quantity of line items and shipping that's already been refunded. ```curl curl -X POST \ 'https://www.wixapis.com/ecom/v1/order-billing/calculate-refund' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ -d '{ "orderId": "585daa0c-08d2-42ae-bd6b-18fe59c75836", "refundItems": { "lineItems": [ { "lineItemId": "00000000-0000-0000-0000-000000000001", "quantity": 10000 } ], "shipping": { "amount": { "amount": "1" } } } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.orders.OrderBillingService.calculateRefund(orderId, options) Description: Calculates the total refund amount and breakdown for specified line items, shipping, and additional fees. Returns detailed calculations including: - Total refund amount with tax, discount, and subtotal breakdowns - Individual item calculations with pricing details - Validation of whether the requested refund items are available Use this method to preview refund amounts before calling Refund Payments. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: orderId, options.refundItems.lineItems.lineItemId, options.refundItems.lineItems.quantity, options.refundItems.additionalFees.additionalFeeId Method parameters: param name: options | type: CalculateRefundOptions none - name: refundItems | type: RefundItems | description: Items to include in the refund calculation with their respective quantities and amounts. Specify which line items, shipping charges, and additional fees to refund. - name: lineItems | type: array | description: Line items and their quantities to refund. - name: lineItemId | type: string | description: Line item GUID. - name: quantity | type: integer | description: Quantity of this product to refund. Cannot exceed the available refund quantity for this line item. - name: additionalFees | type: array | description: Additional fees and their amounts to refund. - name: additionalFeeId | type: string | description: Additional fee GUID to refund. - name: amount | type: Price | description: Amount of the additional fee to refund. If not specified, the full remaining refundable amount for this fee will be refunded. - name: amount | type: string | description: Amount. - name: shipping | type: ShippingRefund | description: Shipping amount to refund. - name: amount | type: Price | description: Amount of shipping charges to refund. If not specified, the full remaining refundable shipping amount will be refunded. param name: orderId | type: string | description: Order GUID to calculate refund for. | required: true Return type: PROMISE - ONE-OF: - name: available | type: boolean | description: Whether the refund is available for all requested items. `true` indicates all items can be refunded as requested. - name: notAvailable | type: CalculatedRefundNotAvailableStatus | description: Refund unavailability details when some or all items cannot be refunded. Contains specific error information for each problematic item. - name: errors | type: array | description: Refund calculation errors. - ONE-OF: - name: lineItem | type: LineItemRefund | description: Line item - name: lineItemId | type: string | description: Line item GUID. - name: quantity | type: integer | description: Quantity of this product to refund. Cannot exceed the available refund quantity for this line item. - name: additionalFee | type: AdditionalFeeRefund | description: Additional fee - name: additionalFeeId | type: string | description: Additional fee GUID to refund. - name: amount | type: Price | description: Amount of the additional fee to refund. If not specified, the full remaining refundable amount for this fee will be refunded. - name: amount | type: string | description: Amount. - name: formattedAmount | type: string | description: Amount formatted with currency symbol. - name: shipping | type: ShippingRefund | description: Shipping - name: amount | type: Price | description: Amount of shipping charges to refund. If not specified, the full remaining refundable shipping amount will be refunded. - name: error | type: Details | description: Error details - ONE-OF: - name: applicationError | type: ApplicationError | description: - name: code | type: string | description: Error code. - name: description | type: string | description: Description of the error. - name: data | type: object | description: Data related to the error. - name: validationError | type: ValidationError | description: - name: fieldViolations | type: array | description: - name: field | type: string | description: - name: description | type: string | description: - name: violatedRule | type: RuleType | description: - enum: VALIDATION, OTHER, MAX, MIN, MAX_LENGTH, MIN_LENGTH, MAX_SIZE, MIN_SIZE, FORMAT, DECIMAL_LTE, DECIMAL_GTE, DECIMAL_LT, DECIMAL_GT, DECIMAL_MAX_SCALE, INVALID_ENUM_VALUE, REQUIRED_FIELD, FIELD_NOT_ALLOWED, ONE_OF_ALIGNMENT, EXACT_LENGTH, EXACT_SIZE, REQUIRED_ONE_OF_FIELD - name: ruleName | type: string | description: applicable when violated_rule=OTHER - name: data | type: object | description: - name: systemError | type: SystemError | description: - name: errorCode | type: string | description: Error code. - name: summary | type: AggregatedRefundSummary | description: Aggregated summary of all items provided for refund. This field is not returned when refund is not available for the given list of items. - name: total | type: Price | description: Total refund amount. - name: tax | type: Price | description: Tax amount for the items being refunded. - name: discount | type: Price | description: Discount amount for the items being refunded. - name: subtotal | type: Price | description: Total cost of the items being refunded (without tax and discount). - name: lineItemsSubtotal | type: Price | description: Total cost of the line items being refunded (without tax and discount). - name: additionalFeesTotal | type: Price | description: Total cost of the additional fees being refunded. - name: calculatedRefundItems | type: CalculatedRefundItems | description: Detailed refund calculations broken down by each requested item type. - name: lineItems | type: array | description: Calculated refund details for each line item. - name: item | type: LineItemRefund | description: Line item refund details. - name: summary | type: CalculatedRefundSummary | description: Calculated refund summary for this line item. - name: total | type: Price | description: Total refundable amount. - name: tax | type: Price | description: Tax amount for the items being refunded. - name: discount | type: Price | description: Discount amount for the items being refunded. - name: subtotal | type: Price | description: Total cost of the items being refunded (without tax and discount). - name: additionalFees | type: array | description: Calculated refund details for each additional fee. - name: additionalFee | type: AdditionalFeeRefund | description: Additional fee refund details. - name: summary | type: CalculatedRefundSummary | description: Calculated refund summary for this additional fee. - name: shipping | type: CalculatedShippingRefund | description: Calculated refund details for the shipping fee. - name: shipping | type: ShippingRefund | description: Shipping refund details. - name: summary | type: CalculatedRefundSummary | description: Calculated refund summary for shipping. ``` ### Examples ### calculateRefund ```javascript import { orderBilling } from '@wix/ecom'; async function calculateRefund(orderId,options) { const response = await orderBilling.calculateRefund(orderId,options); }; ``` ### calculateRefund (with elevated permissions) ```javascript import { orderBilling } from '@wix/ecom'; import { auth } from '@wix/essentials'; async function myCalculateRefundMethod(orderId,options) { const elevatedCalculateRefund = auth.elevate(orderBilling.calculateRefund); const response = await elevatedCalculateRefund(orderId,options); } ``` ### calculateRefund (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { orderBilling } from '@wix/ecom'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { orderBilling }, // Include the auth strategy and host as relevant }); async function calculateRefund(orderId,options) { const response = await myWixClient.orderBilling.calculateRefund(orderId,options); }; ``` ---