Refund
A refund returns funds from a previous payin back to the originating customer. You can issue a full refund or a partial refund. Funds are debited from your specified Celar wallet and sent back on-chain.
Examples use the sandbox environment. For production, replace
api.sandbox.celar.iowithapi.celar.io.
How it works
- Identify the
payment_idof the original payin to refund - Submit a
refundrequest referencing that payment and your source wallet - Celar processes the refund and returns funds to the customer's originating address
Prerequisites
- The
payment_idof the original payin: see Payment Statuses - A funded Celar wallet (
walletId) to source the refund from - A unique
Idempotency-Keyfor the request
Request
curl --request POST \
--url https://api.sandbox.celar.io/api/v1/payments/transfer \
--header 'Authorization: Bearer <your_api_key>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <unique_uuid>' \
--data '{
"operationType": "refund",
"customer_id": "cr_2ae76bc76f03437d",
"amount": 25,
"source": {
"paymentId": "transfer_272638d79c97cdb3",
"walletId": "cw_1053b738d73ad9b5",
"type": "partial"
}
}'
For a full refund, set type to full and omit amount: Celar refunds the entire original payment amount.
Response
{
"id": "transfer_39fdf5b02cda5670",
"amount": 25,
"message": "Refund completed successfully",
"tx_hash": "0x52c635aec786d97908e44db8c14409301cac8992cfd849eea333759faf997a67"
}
| Field | Required | Description |
|---|---|---|
id | Refund transfer ID | |
amount | Amount refunded | |
tx_hash | On-chain transaction hash: use to verify on a block explorer |
Field reference
| Field | Required | Description |
|---|---|---|
operationType | Yes | refund |
customer_id | Yes | The customer who made the original payment |
amount | Conditional | Refund amount: required for partial, omit for full |
source.paymentId | Yes | The payment_id of the original payin |
source.walletId | Yes | Celar wallet ID to debit the refund from |
source.type | Yes | full or partial |
Full vs partial refund
| Status | Description |
|---|---|
full | Refunds the entire original payin amount. The amount field is ignored. |
partial | Refunds only the specified amount. Must be less than the original payment amount. |
See Payment Statuses and Webhooks for more.