Cashout To Bank

This API is cashout from your Sipay account to the bank. You can also cashout money to your customers bank accounts.

The API can be used for one or more withdrawals to bank data.

Request

Method URL Content Type
Post /api/cashout/tobank application/json


Type Params Data Types Condition
HEADER Authorization string Mandatory
HEADER Accept string Mandatory
HEADER Content-Type string Mandatory
KEY merchant_key string Mandatory
KEY hash_key string Mandatory
KEY cashout_type int Mandatory
KEY cashout_data array of objects Mandatory

Authorization

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

Example Value

 Bearer
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImRlMGVlZGFiZjdhZDhkODYzYTgyM
zQ4Nzk5NTFkYzFlMDZkZTUxYjU0NWRjYmU3MzRjMmQ1OGNkMWFlOWE4YjliZTkyMjdlZGVmZD
dlMDliIn0.eyJhdWQiOiIxNSIsImp0aSI6ImRlMGVlZGFiZjdhZDhkODYzYTgyMzQ4Nzk5NTFkYzFlMD
ZkZTUxYjU0NWRjYmU3MzRjMmQ1OGNkMWFlOWE4YjliZTkyMjdlZGVmZDdlMDliIiwiaWF0IjoxNTc
zNzUyNDcyLCJuYmYiOjE1NzM3NTI0NzIsImV4cCI6MTYwNTM3NDg3Miwic3ViIjoiMSIsInNjb3BlcyI6W119.m
Dtdzcv15p8SnYjZYJUJrhdskO5NohXbkcAxKWWZ72lNtrg86RZ1yxQwfQlRu6IPoa1rfG3M4jfsNeH-Sh7g6PaVf
fIoKvjdcUG7Cc2lLqhE4qMEdPgO28luCMOFf6UHn6XxeEhK3XWaboZJvrubdeb0t04a6btrdHUa-FgeV6I8bNSRl
zUjOjBcsVrd1pxKhKnsREFHCWfzYVC_ZQ4RRCi9CZsJGz7_KQ8mo0BdNmtbNKwfvYkpcdsm
VicsJYvnw7OMZ3u-TorhakndhQkUK0JPAzl_LSHqAKCju8dTG1-vZjbh9ifRB85TGwW4HimQk46RPG9Hp6kydLnuhFOkbvGpaxcs5qyZ67-
cmjDa6aeGNjZHfNa7dQ8bTokdbkxqwKrVVUUVjgkMtPXhpL9yffaHHPNBCkc-1Vz40nsmNFeaoWlk2S7fDxFTcGYv8HFFiSRyfsPpfTbXPI
RMoZUX1kC4cDMyQmjuBqtxIwEFzJexs9PkZEUze5Qcm_ZrkqeKUlL4tJidO9ZzwfCI9bpihMATHlDyM6IP7XyhgMRt3yr2WvzxuxavqSyu09
YlybYU0WpTUtDVOavL7xnuKBXhwDSoCjtCMh__tL9ZfK9lDvq6mrHQ5Z4RXLixvWMbl98_Btbnfg_SqnCNYwL14FSHyeb3lnuF8VFyERwbf-tAlI

Acceept

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

Content-Type

Content-Type determines what kind of representation is requested on the server side. Value must be “application / JSON”

merchant_key

merchant_key is unique key of the merchant provided by Sipay.

hash_key

hash_key generated by the following special algorithm;

private function generateCashOutAPIHashKey($sum_of_amount_column, $first_row_iban,
$first_row_amount, $first_row_currency, $first_row_gsm, $app_secret ){

    //remove plus(+) sign from gsm number.
    $data = $sum_of_amount_column.'|'.$first_row_iban.'|'.$first_row_amount.'|'.$first_row_currency.'|'.$first_row_gsm;

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

NOTES

FYI: Do not use ‘+’ sign for gsm_number and check Post Request Params below for better understanding.

cashout_type

cashout_type must be 1 for the cashout transaction to the bank

cashout_data

cashout_data the array of objects which follows the format of cashout to bank excel sample of merchant panel. For better understanding please check the request params.

-> Maximum size of cashout_data is 100.

-> An unique id must be send with every data.

Post Request Params

{

    "hash_key": "43c750b5dc9cec0e:10f3:d5wNZuxsD53PZkvzHv0R5lBBdVBg+5ejBiwjP16PLtYNwXqWCHFXTOgTgF8bpDUL42PSflzcxqJN97+UKCYwBA==",
    "cashout_type": 1,
    "merchant_key": "$2y$10$ooyzbg0nI4wZCihugHcLie4ZAqx67szU80zF2oA5FKn9WAY2gjtxq",
    "cashout_data": [
        [
            {
                "unique_id": 6182458,
                "name_surname": "John Doe",
                "iban": "TR150006247004881217621234",
                "amount": 5,
                "currency": "TRY",
                "id_tc_kn": "12345636268",
                "gsm_number": "901111137653",
                "description": "Test"
            }
        ],
        [
            {
                "unique_id": 8402133,
                "name_surname": "John Doe",
                "iban": "TR150006254412451274071234",
                "amount": 13,
                "currency": "TRY",
                "id_tc_kn": "12345698345",
                "gsm_number": "901111184973",
                "description": "Test"
            }
        ]
    ]
}

Response

Fail Response

{
    "statuscode": 99,
    "description": [
        "You don't have permission . Amount can't be less than 10 TRY"
    ],
    "data": [],
    "status_code": 99,
    "status_description": [
        "You don't have permission . Amount can't be less than 10 TRY"
    ]
}

Partial Response

{
    "statuscode": 100,
    "description": "Successful 1 out of 2",
    "data": [
        {
            "unique_id": 6182458,
            "response_code": 422,
            "response_message": "You don't have permission . Amount can't be less than 10 TRY"
        },
        {
            "unique_id": "8402133",
            "response_code": 100,
            "response_message": "SUCCESS",
            "merchant commission": 1.13,
            "receiver commission": 1.13
        }
    ],
    "status_code": 100,
    "status_description": "Successful 1 out of 2"
}

Successful Response

{
    "statuscode": 100,
    "description": "SUCCESS",
    "data": [
        {
            "unique_id": "4112697",
            "response_code": 100,
            "response_message": "SUCCESS",
            "merchant commission": 1.2,
            "receiver commission": 1.2
        },
        {
            "unique_id": "2604051",
            "response_code": 100,
            "response_message": "SUCCESS",
            "merchant commission": 1.2,
            "receiver commission": 1.2
        }
    ],
    "status_code": 100,
    "status_description": "SUCCESS"
}

Notes

Data values can be an array. In case of multiple unsuccessful cash outs, the unsuccessful reasons will be in it.