- Ordering
Order returns - Handling calculations
OrderCloud provides flexibility in calculating refund amounts for product returns. This guide explains key considerations and implementation approaches.
Integration event
The OrderReturn Integration Event triggers when an OrderReturn is created or updated without a specified RefundAmount. The event includes the order worksheet.
Order worksheet importance
The OrderWorksheet provides essential data for refund calculations. Store tax, shipping, and promotion data during order calculation for accurate refund processing.
Storing calculation data
Store calculation values in OrderWorksheet.OrderCalculateResponse.xp during checkout (POST v1/orders/{direction}/{orderID}/calculate). Example calculation object:
Calculation considerations
Order totals
- Track line items, shipping, promotions, and tax effects
- Handle tax-exempt items
- Apply line item and order-level promotions
- Calculate taxable subtotals
Taxes and promotions
- Handle order-level promotion distribution
- Apply line item promotions before tax calculation
- Consider tax service capabilities for promotion handling
Shipping
- Track multiple shipment costs
- Calculate shipping tax per shipment
- Handle partial shipping refunds
Return calculation types
Use OrderReturn.xp.ReturnType to route returns to appropriate calculation methods.
Standard return invoicing
Recommended approach using tax services:
- Creates return invoices
- Handles complex tax calculations
- Manages partial returns
- Ensures accurate tax distribution
Example return response:
Custom returns
Handle special cases with extended properties:
Return types:
- Shipping refunds
- Tax adjustments
- Discretionary refunds
Amount types:
- Fixed amounts
- Percentage-based refunds
Related reading
- Introducing Order Returns
- How to Calculate Tax with OrderCloud
- Promotion Integration: Calculating Custom Discounts