Transaction Refund

Method URL Content-Type
POST /api/refund Application/json


Type Params Data Type Condition
HEADER Authorization string Mandatory
HEADER Accept string Mandatory
KEY invoice_id string Mandatory
KEY amount string Mandatory
KEY app_id string Mandatory
KEY app_secret string Mandatory
KEY merchant_key string Mandatory
KEY hash_key string Mandatory
KEY refund_transaction_id string Mandatory
KEY refund_web_hook_key string Optional

Authorization

Authorization is a header key which defines verification that the connection attempt is allowed. The method should be “Bearer”.

Example Value

 Bearer
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImRlMGVlZGFiZjd
hZDhkODYzYTgyMzQ4Nzk5NTFkYzFlMDZkZTUxYjU0NWRjYmU3MzRjMmQ1O
GNkMWFlOWE4YjliZTkyMjdlZGVmZDdlMDliIn0.eyJhdWQiOiIxNSIsIm
p0aSI6ImRlMGVlZGFiZjdhZDhkODYzYTgyMzQ4Nzk5NTFkYzFlMDZkZTU
xYjU0NWRjYmU3MzRjMmQ1OGNkMWFlOWE4YjliZTkyMjdlZGVmZDdlMDliI
iwiaWF0IjoxNTczNzUyNDcyLCJuYmYiOjE1NzM3NTI0NzIsImV4cCI6MTYw
NTM3NDg3Miwic3ViIjoiMSIsInNjb3BlcyI6W119.mDtdzcv15p8SnYjZYJ
UJrhdskO5NohXbkcAxKWWZ72lNtrg86RZ1yxQwfQlRu6IPoa1rfG3M4jfsNe
H-Sh7g6PaVffIoKvjdcUG7Cc2lLqhE4qMEdPgO28luCMOFf6UHn6XxeEhK3XW
aboZJvrubdeb0t04a6btrdHUa-FgeV6I8bNSRlzUjOjBcsVrd1pxKhKnsREFHC
WfzYVC_ZQ4RRCi9CZsJGz7_KQ8mo0BdNmtbNKwfvYkpcdsmVicsJYvnw7OMZ3u-
TorhakndhQkUK0JPAzl_LSHqAKCju8dTG1-vZjbh9ifRB85TGwW4HimQk46RPG9
Hp6kydLnuhFOkbvGpaxcs5qyZ67-cmjDa6a
eGNjZHfNa7dQ8bTokdbkxqwKrVVUUVjgkMtPXhpL9yffaHHPNBCkc-1Vz40nsmNF
eaoWlk2S7fDxFTcGYv8HFFiSRyfsPpfTbXPIRMoZUX1kC4c-DMyQmjuBqtxIwEFzJexs9P
kZEUze5Qcm_ZrkqeKUlL4tJidO9ZzwfCI9bpihMATH
lDyM6IP7XyhgMRt3yr2WvzxuxavqSyu09YlybYU0WpTUtDVOavL7xnuKBXhwDSoCj
tCMh__tL9ZfK9lDvq6mrHQ5Z4RXLixvWMbl98_Btbnfg_SqnCNYwL14FSHyeb3lnuF8VFyERwbf-tAlI

Accept

Accept client determines what type of representation is desired at client side. The value should be “application/json”.

invoice_id

invoice_id is a unique order id sent by merchant.

amount

amount to be refuned.

app_id

app_id is the unique id provided by Sipay.

app_secret

app_secret is a secret key provided by Sipay.

merchant_key

merchant_key is unique key of the merchant provided by Sipay.

refund_web_hook_key

refund_web_hook_key When there is no successful response from the bank, the transaction returns to a manual refund, in this case you can use the refund webhook to get a notification.

Hash Key Generation Method

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;
}

Success Response

{
     "status_code": 100,
    "status_description": "Refund completed successfully",
    "order_no": "15925741639038",
    "invoice_id": "66955",
    "ref_no": "5454545dgdgd545545"

}

Failed Response

{
    "status_code": 49,
    "status_description": "Refund Failed",
    "order_no": "15925741639038",
    "invoice_id": "66955",
    "ref_no": ""

}

Failed Response for Awaiting Refund

{

"status_code":101,
"status_description":"Your refund request created successfully. Our team will complete the refund process.",
"order_no":"163583940749353",
"invoice_id":"J9PPJCEK0R7WEQJ-1635839059",
"ref_no":""

}