Payment Confirmation

In PreAuth payment, a transaction is created as Pre-Provision/Pre-Authorization in the system. To make this operation failed or successful, this API must be called using the following request parameters given below.

Method URL Content-Type
POST /api/confirmPayment application/json


Type Params Data Type Condition
HEADER Authorization string Mandatory
HEADER Accept string Mandatory
KEY invoice_id string Mandatory
KEY merchant_key string Mandatory
KEY status string Mandatory
KEY hash_key string Mandatory
KEY total double Optional

Authorization

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

Exampe Value

Bearer
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6Im
RlMGVlZGFiZjdhZDhkODYzYTgyMzQ4Nzk5NTFkYzFlMDZkZ
TUxYjU0NWRjYmU3MzRjMmQ1OGNkMWFlOWE4YjliZTkyMjd
lZGVmZDdlMDliIn0.eyJhdWQiOiIxNSIsImp0aSI6ImRlMGVlZGF
iZjdhZDhkODYzYTgyMzQ4Nzk5NTFkYzFlMDZkZTUxYjU0NWR
jYmU3MzRjMmQ1OGNkMWFlOWE4YjliZTkyMjdlZGVmZDdlMD
liIiwiaWF0IjoxNTczNzUyNDcyLCJuYmYiOjE1NzM3NTI0NzIsImV
4cCI6MTYwNTM3NDg3Miwic3ViIjoiMSIsInNjb3BlcyI6W119.mDtd
zcv15p8SnYjZYJUJrhdskO5NohXbkcAxKWWZ72lNtrg86RZ1yxQwf
QlRu6IPoa1rfG3M4jfsNeH

Accept

Accept 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

merchant_key

merchant_key is the unique key of the merchant provided by Sipay.

status

status can be 1 or 2 (1=approve, 2 = Cancel)

total

the value of total parameter must be less than or equal to product price of the pre auth transaction

hash_key

hash_key is a unique key that should be generated using input value. The method for generating hash_key given below

function generateConfrimPaymentHashKey($merchant_key, $invoice_id, $status, $app_secret)
{

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

   $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";
   $msg_encrypted_bundle = str_replace('/', '__', $msg_encrypted_bundle);
   return $msg_encrypted_bundle;
}

Fail Response

{
    "status_code": 105,
    "status_description": " The transaction is not Approved",
    "transaction_status": "Pending",
    "order_id": "162435924998223",
    "invoice_id": "50781624359247
}

Success Response

{
    "status_code": 100,
    "status_description": "An order has been taken place for this invoice id: 33491162435928”,
    "transaction_status": "Completed",
    "order_id": "162435932934307",
    "invoice_id": "33491162435928"

}