Sites WayDevelopers
API reference

Refunds

Give money back, fully or in part.

Refund a payment

POST /v1/payments/{id}/refunds

Full or partial, several times up to the captured amount. The answer may be PENDING or PROCESSING: the final result comes as a webhook (refund.succeeded / refund.failed).

Permission: refunds:write

curl -X POST https://api.sw-staging.dev/v1/payments/pay_01M6XF0H2MAC63MEKQAT4K3AXF/refunds \
  -H "Authorization: Bearer sw_test_…" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"amount":1000}'

Parameters

FieldTypeRequiredDescription
idstring (path)yesThe payment id (pay_…)
Idempotency-Keystring (header)yesA unique key per operation (1-255 visible ASCII characters). Retrying with the same key and body answers the first result.. at most 255 characters

Request body

FieldTypeRequiredDescription
amountintegeryesIn the minor unit; at most what is left to refund. > 0
metadataobjectnoYour own key-value data, returned as sent (at most 8 KB as JSON)
reasonstringnoat most 500 characters

200 — The same refund, replayed

FieldTypeDescription
amountintegerAmount in the minor unit of the currency (e.g. halalas: 1050 = 10.50 SAR)
created_atstring (date-time)
currencystringISO 4217 currency code, upper case. pattern ^[A-Z]{3}$
failure_codestring or null
failure_messagestring or null
idstring
metadataobjectYour own key-value data, returned as sent (at most 8 KB as JSON)
objectrefund
payment_idstringpattern ^pay_[0-9A-HJKMNP-TV-Z]{26}$
reasonstring or null
statusPENDING, PROCESSING, SUCCEEDED, FAILED, CANCELED

201 — The refund

FieldTypeDescription
amountintegerAmount in the minor unit of the currency (e.g. halalas: 1050 = 10.50 SAR)
created_atstring (date-time)
currencystringISO 4217 currency code, upper case. pattern ^[A-Z]{3}$
failure_codestring or null
failure_messagestring or null
idstring
metadataobjectYour own key-value data, returned as sent (at most 8 KB as JSON)
objectrefund
payment_idstringpattern ^pay_[0-9A-HJKMNP-TV-Z]{26}$
reasonstring or null
statusPENDING, PROCESSING, SUCCEEDED, FAILED, CANCELED

Errors answer with the error object.

A payment's refunds

GET /v1/payments/{id}/refunds

Permission: refunds:read

curl -X GET https://api.sw-staging.dev/v1/payments/pay_01M6XF0H2MAC63MEKQAT4K3AXF/refunds \
  -H "Authorization: Bearer sw_test_…"

Parameters

FieldTypeRequiredDescription
idstring (path)yesThe payment id (pay_…)

200 — The refunds

None.

Errors answer with the error object.

Retrieve a refund

GET /v1/refunds/{id}

Permission: refunds:read

curl -X GET https://api.sw-staging.dev/v1/refunds/pay_01M6XF0H2MAC63MEKQAT4K3AXF \
  -H "Authorization: Bearer sw_test_…"

Parameters

FieldTypeRequiredDescription
idstring (path)yesThe refund id

200 — The refund

FieldTypeDescription
amountintegerAmount in the minor unit of the currency (e.g. halalas: 1050 = 10.50 SAR)
created_atstring (date-time)
currencystringISO 4217 currency code, upper case. pattern ^[A-Z]{3}$
failure_codestring or null
failure_messagestring or null
idstring
metadataobjectYour own key-value data, returned as sent (at most 8 KB as JSON)
objectrefund
payment_idstringpattern ^pay_[0-9A-HJKMNP-TV-Z]{26}$
reasonstring or null
statusPENDING, PROCESSING, SUCCEEDED, FAILED, CANCELED

Errors answer with the error object.

Void an authorized payment

POST /v1/payments/{id}/void

Releases an authorization that was not captured.

Permission: payments:write

curl -X POST https://api.sw-staging.dev/v1/payments/pay_01M6XF0H2MAC63MEKQAT4K3AXF/void \
  -H "Authorization: Bearer sw_test_…" \
  -H "Idempotency-Key: $(uuidgen)"

Parameters

FieldTypeRequiredDescription
idstring (path)yesThe payment id (pay_…)
Idempotency-Keystring (header)yesA unique key per operation (1-255 visible ASCII characters). Retrying with the same key and body answers the first result.. at most 255 characters

Request body (optional)

FieldTypeRequiredDescription
reasonstringnoat most 500 characters

200 — The same void, replayed

FieldTypeDescription
created_atstring (date-time)
failure_codestring or null
failure_messagestring or null
idstring
metadataobjectYour own key-value data, returned as sent (at most 8 KB as JSON)
objectvoid
payment_idstringpattern ^pay_[0-9A-HJKMNP-TV-Z]{26}$
reasonstring or null
statusPENDING, PROCESSING, SUCCEEDED, FAILED

201 — The void

FieldTypeDescription
created_atstring (date-time)
failure_codestring or null
failure_messagestring or null
idstring
metadataobjectYour own key-value data, returned as sent (at most 8 KB as JSON)
objectvoid
payment_idstringpattern ^pay_[0-9A-HJKMNP-TV-Z]{26}$
reasonstring or null
statusPENDING, PROCESSING, SUCCEEDED, FAILED

Errors answer with the error object.

On this page