Build with the API
Refund, void, or capture
Complete an authorization, void a payment that has not been sent to the bank, or refund one that has.
After a payment exists, three calls can change it. Which one you use depends on where the payment is.
| Call | Body | When |
|---|---|---|
POST /v1/transactions/{id}/capture | payerFee is required. amount is optional, and sets how much of the authorization to capture. | The transaction is an authorization that has not been captured yet. |
POST /v1/transactions/{id}/void | Empty | The payment has not been sent to the bank yet. Once the Process event is recorded, void is no longer available. A void usually costs the merchant nothing. |
POST /v1/transactions/{id}/refund | Optional amount. Leave it out to refund the remaining balance. | The payment can no longer be voided. |
Capture also accepts platformFee, splits, shipping, tax, line items, paidCustomers, and paidInvoices. As on pay, send payerFee as 0 when the payer is not charged a fee.
Refund and capture accept an Idempotency-Key header. Void does not.
Refunds after funding
A refund or a return works differently depending on whether the merchant was already funded:
- Already funded: dhango creates a new transaction linked to the original, and a later batch debits the merchant.
- Not funded yet: dhango updates the original transaction, and no extra funding entry is created.
Transaction lifecycles shows both sequences.
To refund a split payment, refund each leg separately. On Stripe, dhango reverses that leg's transfer, then refunds the payer against the parent charge. See Split a payment.
refund
curl -s -u "$DHANGO_KEY:$DHANGO_SECRET" \ -H "Content-Type: application/json" \ -H "accountKey: $ACCOUNT_KEY" \ -H "Idempotency-Key: aa0b1c2d-3e4f-5678-90ab-cdef12345678" \ -d '{"amount":10.00}' \ https://api.dhangodemo.com/v1/transactions/txn_example/refundawait fetch("https://api.dhangodemo.com/v1/transactions/txn_example/void", { method: "POST", headers: { Authorization: "Basic " + Buffer.from(process.env.DHANGO_KEY + ":" + process.env.DHANGO_SECRET).toString("base64"), accountKey: process.env.ACCOUNT_KEY }});import os, uuid, requestsauth = (os.environ["DHANGO_KEY"], os.environ["DHANGO_SECRET"])headers = {"accountKey": os.environ["ACCOUNT_KEY"]}response = requests.post( "https://api.dhangodemo.com/v1/transactions/txn_example/refund", auth=auth, headers={**headers, "Idempotency-Key": str(uuid.uuid4())}, json={ "amount": 10.0 },)response.raise_for_status()refund = response.json()