Refund a succeeded payment
const url = 'https://api.pachapay.io/v1/refunds';const options = { method: 'POST', headers: { 'Idempotency-Key': 'example', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"payment_id":"example","amount":1,"destination":{"type":"bank_account","bank_code":"example","account_number":"example","account_type":"checking","holder_name":"example","holder_document":{"type":"RUT","number":"example"}},"reason":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.pachapay.io/v1/refunds \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: example' \ --data '{ "payment_id": "example", "amount": 1, "destination": { "type": "bank_account", "bank_code": "example", "account_number": "example", "account_type": "checking", "holder_name": "example", "holder_document": { "type": "RUT", "number": "example" } }, "reason": "example" }'Card payments are refunded through the provider. Other families are refunded as a payout to the
payer’s account, so destination is required for them. Our fee is not returned by default.
Requires enough available balance, otherwise 422 insufficient_balance.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Unique key per logical operation, up to 255 characters. Keys are kept for 24 hours. Same key with a different body returns 409 idempotency_conflict, and the same key while the first request is still running returns 409 idempotency_in_progress.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Minor units. Omit for a full refund.
object
object
object
E.164 format.
object
object
object
object
object
object
Must be whitelisted; a new address becomes active after 24 hours.
Responses
Section titled “Responses”Refund created.
object
Set when the refund is executed as a payout.
ISO 4217 code. Crypto assets are not accepted in this field.
Example
{ "id": "ref_0192f3c2", "object": "refund", "status": "created", "currency": "CLP"}Error. See error.code.
object
object
Stable machine-readable code that does not change within a major version. Examples are
parameter_invalid, parameter_missing, amount_out_of_range, api_key_invalid,
api_key_revoked, merchant_not_active, method_not_allowed, country_not_allowed,
resource_not_found, idempotency_conflict, idempotency_in_progress, invalid_state,
insufficient_balance, method_not_available, blocked_payer, limit_exceeded,
rate_limited, internal_error, provider_unavailable, service_unavailable.
Name of the offending parameter, if any.
Examples
Merchant not approved
{ "error": { "type": "permission_error", "code": "merchant_not_active", "message": "KYB is not approved for this merchant.", "request_id": "req_01" }}Not enough balance
{ "error": { "type": "invalid_state_error", "code": "insufficient_balance", "message": "Available balance is lower than the amount plus fee.", "param": "amount", "request_id": "req_02" }}Error. See error.code.
object
object
Stable machine-readable code that does not change within a major version. Examples are
parameter_invalid, parameter_missing, amount_out_of_range, api_key_invalid,
api_key_revoked, merchant_not_active, method_not_allowed, country_not_allowed,
resource_not_found, idempotency_conflict, idempotency_in_progress, invalid_state,
insufficient_balance, method_not_available, blocked_payer, limit_exceeded,
rate_limited, internal_error, provider_unavailable, service_unavailable.
Name of the offending parameter, if any.
Examples
Merchant not approved
{ "error": { "type": "permission_error", "code": "merchant_not_active", "message": "KYB is not approved for this merchant.", "request_id": "req_01" }}Not enough balance
{ "error": { "type": "invalid_state_error", "code": "insufficient_balance", "message": "Available balance is lower than the amount plus fee.", "param": "amount", "request_id": "req_02" }}