Create a payout
Create a payout
URL | POST https://api-merchant.alikassa.com/v1/payout |
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.
* - Required fields* - When creating a payout to an account in EUR currency - required
Name | Type | Description | Example |
amount* | string | Amount | "1000.44" |
number* | string | Account number, card | |
order_id* | string (128) | Your id must be unique | |
service* | string (100) | Service (Account, Acceptance Methods) | payment_card_rub |
notification_endpoint_id | int | Notification id | |
notification_endpoint_url | string|max:255 | Link to send a callback after the statuses are finalized | |
extra* | array | Accepts optional parameters to increase conversion |
|
extra["card_exp_year"]* | string (2) | Bank card expiration date (year) | "24" |
extra["card_exp_month"]* | string (2) | Bank card expiration date (month) | "01" |
extra["card_holder"]* | string (100) | Cardholder's Name | "CARDHOLDER NAME" |
extra["card_country"]* | string (2) Alpha-2 ISO 3166-1 | Bank card country | "UA" |
extra["card_recipient_birth_date"]* | string | Cardholder's birthday | "1999-12-15" |
customer_phone | string | Customer phone | "79001112233" |
customer_email | string|email | Customer email | "[email protected]" |
customer_code | string | Customer code | "sberbank" |
customer_first_name | string | Customer first name | "IVAN" |
customer_last_name | string | Customer last name | "IVANOV" |
Response
Name | Description |
id | Id AliKassa |
payment_status | Payment status wait — in the process of payment |
When creating, always wait, check the status of the payment via the API or wait for a notification!!
Example of a successful HTTP CODE 200 response
{
"payment_status": "wait",
"id": 100001524
}
An example of an unsuccessful HTTP CODE 400 response
{
"message": "The given data was invalid.",
"errors": {
...
}
}
Possible values of payment_status, see the documentation "Payout status".
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.
If you passed notification_endpoint_id, then you will receive a notification about the change in the payout status.
Example
Unpack the downloaded archive into the folder "path to script/cert/payout /"
function requestPayout(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 = requestPayout('v1/payout', '93d5df06-996c-48c3-9847-348d6b580b80', [
'order_id' => (string)time(),
'amount' => 500,
'number' => '79005554455',
'notification_endpoint_id' => 5,
'service' => 'qiwi_rub',
]);
var_dump($payout);