Transaction Refund / Cancel

The refund process of a payment is carried out in the form of cancellation for certain situations and as a refund for others.

Cancel: If the payment has not been completed by the end of the day and there has been no previous partial refund for this payment, this process is referred to as Cancellation.

Refund: If a partial refund has been made for the payment to be refunded, or if a refund request is received on a day different from the day the payment was made, this process is referred to as Refund.

HTTP method, Endpoint, Headers, and Request information are provided below.

Method API Endpoint Content-Type
POST /api/refund application/json

CREATE HASH KEY

function generateRefundHashKey($amount, $invoice_id, $merchant_key, $app_secret) {

    $data = $amount.'|'.$invoice_id.'|'.$merchant_key;

    $iv = substr(sha1(mt_rand()), 0, 16);
    $password = sha1($app_secret);

    $salt = substr(sha1(mt_rand()), 0, 4);
    $saltWithPassword = hash('sha256', $password . $salt);

    $encrypted = openssl_encrypt(
        "$data", 'aes-256-cbc', "$saltWithPassword", null, $iv
    );

    $msg_encrypted_bundle = "$iv:$salt:$encrypted";
    $hash_key = str_replace('/', '__', $msg_encrypted_bundle);

    return $hash_key;
}

When Status Code 100 and 101 are returned, it indicates that the Refund transaction was done successfully. You can update the Transaction Status as Refunded. In cases where the refund is not accepted by the bank, refunds are made by the PayBull Operations team.

status_code transaction_status
100 Refunded
101 Awaiting Refunded

EXAMPLE CODES

{
  "amount" : "10",
  "invoice_id" : "c9fa2586-89f5-4898-a6b6-34554fbe1c89",
  "hash_key": "1al1:47tri3g5nM4Snmc_ri3g_R1NylhHZcj0Zu3EuluVWRq9YMaHo2npFjXr7Nfe04po",
  "app_id": "c3d81ae3cc3011ef10dcefa31a458d65",
  "app_secret": "217071ea9f3f2e9b695d8f0039024e64",
  "merchant_key" :"$2y$10$w/ODdbTmfubcbUCUq/ia3OoJFMUmkM1UVNBiIQIuLfUlPmaLUT1he"
}