Skip to main content

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.io with api.celar.io.

How it works

  1. Identify the payment_id of the original payin to refund
  2. Submit a refund request referencing that payment and your source wallet
  3. Celar processes the refund and returns funds to the customer's originating address

Prerequisites

  • The payment_id of the original payin: see Payment Statuses
  • A funded Celar wallet (walletId) to source the refund from
  • A unique Idempotency-Key for 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"
}
FieldRequiredDescription
idRefund transfer ID
amountAmount refunded
tx_hashOn-chain transaction hash: use to verify on a block explorer

Field reference

FieldRequiredDescription
operationTypeYesrefund
customer_idYesThe customer who made the original payment
amountConditionalRefund amount: required for partial, omit for full
source.paymentIdYesThe payment_id of the original payin
source.walletIdYesCelar wallet ID to debit the refund from
source.typeYesfull or partial

Full vs partial refund

StatusDescription
fullRefunds the entire original payin amount. The amount field is ignored.
partialRefunds only the specified amount. Must be less than the original payment amount.

See Payment Statuses and Webhooks for more.