Skip to main content
POST
If you don’t want to track whether a payment is in the authorized or captured state in your own system, POST /payment/{id}/cancel_or_refund handles it for you. Therius checks the current payment state and automatically cancels the authorization (if uncaptured) or issues a full refund (if already captured). This is especially useful in order reversal workflows where the payment state may vary depending on timing — for example, a customer cancelling an order while fulfillment is in progress.

Identifying the payment

{id} is the Therius payment id returned by POST /payment/authorization and POST /payment/purchase. orderCode and paymentCode are your own reference fields and are not accepted here. An unknown or non-owned id returns 404.
This endpoint always reverses the full payment — it voids the entire authorization hold, or refunds the entire captured amount. To issue a partial refund on a captured payment, call Refund with an amount instead.

Example

Reverse a payment without knowing its state

Response when payment was captured (refund path) — 200 OK
This endpoint is ideal for order reversal flows triggered by your customer-facing cancellation UI, where the same code path handles both pre-capture and post-capture states. Use the status in the response to determine which action was taken and update your internal records accordingly.

Authorizations

Authorization
string
header
required

Your secret API key: Bearer prv_production_xxx (production) or Bearer prv_sandbox_xxx (sandbox).

Headers

Idempotency-Key
string<uuid>

A UUID you generate per operation. Required in production. Retrying with the same key returns the original response.

Path Parameters

id
string<uuid>
required

The Therius payment id returned by POST /payment/authorization or POST /payment/purchase.

Body

application/json
merchantCode
string
required

Your merchant account identifier. Validated against the Bearer key's merchant; required if the key maps to more than one merchant account.

reference
string

Optional internal reference for this operation.

Response

200 - application/json

Reverse result

Result of a capture, refund, cancel or cancel_or_refund.

id
string

The Therius payment id.

merchantCode
string
orderCode
string
paymentCode
string

Therius receipt ID.

amount
object
status
enum<string>

Outcome of the operation.

Available options:
captured,
refunded,
cancelled,
failed