Refund a payment
Refunds all or part of a card or ACH payment to the original payment method.
Parameters
Send as application/x-www-form-urlencoded.
typestringrequiredSelects the operation. Always
payment_refundfor this endpoint.tokenstringrequiredYour API token from Log in. See Authentication.
Your reference for the account (its accountid).
ExampleACC-10045Amount to refund. Less than the original amount for a partial refund.
Example150Gateway transaction ID.
Examplech_3Q8x2eDCDial order ID.
Example77412Your DCDial company ID.
Example101Y to also refund the convenience fee.
One ofYN
curl https://api.dcdial.com/api/ \ -d type=payment_refund \ -d token="$DCDIAL_TOKEN" \ -d account_id=ACC-10045 \ -d amount=150 \ -d transaction_id=ch_3Q8x2e \ -d order_id=77412 \ -d company_id=101<?php$ch = curl_init('https://api.dcdial.com/api/');curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => http_build_query([ 'type' => 'payment_refund', 'token' => getenv('DCDIAL_TOKEN'), 'account_id' => 'ACC-10045', 'amount' => 150, 'transaction_id' => 'ch_3Q8x2e', 'order_id' => '77412', 'company_id' => 101, ]),]);$result = json_decode(curl_exec($ch), true);curl_close($ch);
if (($result['response']['success'] ?? 0) != 1) { throw new RuntimeException($result['response']['error'] ?? 'Request failed');}const res = await fetch('https://api.dcdial.com/api/', { method: 'POST', body: new URLSearchParams({ type: "payment_refund", token: process.env.DCDIAL_TOKEN, account_id: "ACC-10045", amount: "150", transaction_id: "ch_3Q8x2e", order_id: "77412", company_id: "101", }),});const { response } = await res.json();if (response.success != 1) throw new Error(response.error);import osimport requests
r = requests.post( "https://api.dcdial.com/api/", data={ "type": "payment_refund", "token": os.environ["DCDIAL_TOKEN"], "account_id": "ACC-10045", "amount": 150, "transaction_id": "ch_3Q8x2e", "order_id": "77412", "company_id": 101, }, timeout=30,)response = r.json()["response"]if str(response.get("success")) != "1": raise RuntimeError(response.get("error")){ "response": { "success": "1", "order_id": "77412", "error": "" }}Try it