Cardstream exposes three distinct actions that can return money to a cardholder. Which one applies depends on whether the original sale has settled.
Cancel CANCEL
Voids a sale that has been authorised but not yet settled. Whole-transaction only — no partial cancel. Not reversible. Some acquirers won't immediately release the held funds; in that case the authorisation expires naturally (up to 30 days). Requires the original sale's xref. (For partial pre-settlement refunds you'd use a partial CAPTURE instead.)
Refund Sale REFUND_SALE
Refunds a sale that has already settled. Linked to the original sale via xref. Partial refunds are allowed, and you can issue multiple partials up to the original received amount. Typical window is up to a year, set by the card scheme.
Independent Refund REFUND
Issues a refund that is not linked to any particular sale's tracking. No amount cap. Useful when there's no original sale to reference, or when the refund doesn't correspond to a single sale at all. (We still pass an xref here so the gateway can look up which card to refund — the original sale's balance is left untouched either way.)
Common UX pattern: a single Refund button that picks the action automatically. Try CANCEL first; if the gateway rejects because the sale has already settled, fall back to REFUND_SALE. Reserve REFUND for the case where there's no original sale to point at.