Checking payout status
Checking payout status
URL | POST https://api-merchant.alikassa.com/v1/payout/status |
HEADER | |
Content-Type | application/json |
Account | Your account uuid, you can find in Accounts https://merchant.alikassa.com/cabinet/resources/project-accounts |
Sign | Request signature |
Link https://merchant.alikassa.com/cabinet/form/setting-api-certs generate "API certificate for payouts", save the archive, unpack
- password.txt
- private.pem
- public.pem
We keep only public.pem for signature verification.
Wrap all POST data in json (in the same order) and sign
$data = json_encode($data);
$privateKey = openssl_pkey_get_private(
file_get_contents('private.pem'),
file_get_contents('password.txt')
);
if ($privateKey===false) {
throw new \Exception('Error cert.');
}
openssl_sign($data, $sign, $privateKey);
$sign = base64_encode($sign);
Pass the received $sign in the Sign header. You can find a sample code at the end of the document.
Name | Type | Description |
order_id | string (128) | Your id specified during creation |
id | string (128) | AliKassa payment id |
You must pass order_id or id.
Response
Name | Description |
order_id | Your id specified during creation |
id | AliKassa payment id |
payment_status | Payment status wait — in the process of payment paid — successfully paid (final status) cancel — canceled (final status) fail — error (final status) |
card_mask | Card mask when paying by card |
amount | Amount |
payment_amount | Payment amount |
is_partial_payment | Is the payment partial? |
account_payment_amount | Amount credited to the account |
commission_amount | Commission |
service_code | Service |
RRN | RRN |
account_old_balance | Balance before making a request |
account_new_balance | Balance after request processing |
Example of a successful HTTP CODE 200 response:
{
"payment_status": "paid",
"id": 100000536,
"order_id": "6422494",
"amount": "300.00",
"payment_amount": "300.00",
"is_partial_payment": false,
"account_payment_amount": "290",
"commission_amount": "10",
"service_code": "payment_card_rub",
"rrn": "11111111111",
"account_old_balance": "1290",
"account_new_balance": "1000"
}
If you received another status code (not 200) - do not cancel such payments on your side.
Check the status of payouts with support in the chat.
Example
Unpack the downloaded archive into the folder "path to script/cert/payout /"
function requestPayment(string $method, string $account, array $data)
{
$data = json_encode($data);
$privateKey = openssl_pkey_get_private(
file_get_contents(__DIR__ . '/cert/payout/private.pem'),
file_get_contents(__DIR__ . '/cert/payout/password.txt')
);
if ($privateKey===false) {
throw new \Exception('Error cert.');
}
openssl_sign($data, $sign, $privateKey);
$sign = base64_encode($sign);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api-merchant.alikassa.com/' . $method);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Account: ' . $account,
'Sign: ' . $sign,
]);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_USERAGENT, 'AliKassa2.0 API');
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$response = curl_exec($ch);
return json_decode($response, true);
}
$payout = requestPayment('v1/payout/status', '93d5df06-996c-48c3-9847-348d6b580b80', [
'id' => '100000536',
]);
var_dump($payout);