Files
vmall/openspec/changes/add-aftersale-refunds/specs/order/spec.md
T

2.1 KiB

ADDED Requirements

Requirement: Order aftersale eligibility and refund summary

Order and order-item responses SHALL expose the configured after-sale deadline after confirmation of delivery, whether each line has an active aftersale, its remaining refundable integer minor-unit amount, and the order's authoritative refund_total_minor. The API SHALL allow applications for paid or shipped orders while the configured window is open, and SHALL reject new applications after the deadline. The refund summary SHALL be sourced from completed aftersales records and updated only by a guarded refund-completion transaction.

Scenario: confirmed order remains eligible during the window

  • WHEN a customer views a completed order before the configured N-day after-sale window expires
  • THEN the order detail includes an after-sale deadline and each refundable line exposes its remaining amount and application action

Scenario: expired window hides the action

  • WHEN the configured after-sale deadline has passed
  • THEN the order and item responses mark after-sale unavailable and an application returns 409

Scenario: order refund total is authoritative

  • WHEN an aftersale completes a refund
  • THEN the order response's refund_total_minor equals the sum of completed aftersale amounts and is not client-calculated

Requirement: Order item ownership and state safety

After-sale eligibility SHALL resolve the order item through the authenticated customer's order ownership (or the owning shop's own_shop scope for merchant actions), and every refund total update SHALL use a conditional status/amount guard so concurrent completions cannot refund more than the paid order amount.

Scenario: cross-customer item is hidden

  • WHEN a customer submits another customer's order item id
  • THEN the API returns 404 without disclosing order or refund data

Scenario: concurrent refunds stay within paid amount

  • WHEN concurrent aftersales would make completed refunds exceed the line or order paid amount
  • THEN the guarded update rejects the excess completion and stored refund totals remain within the paid amount