Single-request payouts
You can send a payout to a bank card within a single request, without any intermediate steps. In this case, you need to comply with all the PCI DSS requirements.
To enable singe-request payouts, contact your account manager. Once this option is enabled, all your payouts will be processed this way. To disable it, contact your account manager again.
Step 1. Create a session along with a payout
Send a session/init/payout request, specifying the parameters for payouts with open data.
Request example
- cURL
- PHP
curl -X POST \
https://demo.bank131.ru/api/v1/session/init/payout \
-H 'Content-Type: application/json' \
-H 'X-PARTNER-PROJECT: your_project_name' \
-H 'X-PARTNER-SIGN: signature' \
-d '{
"payment_method": {
"type": "card",
"card": {
"type": "bank_card",
"bank_card": {
"number": "4242424242424242"
}
}
},
"participant_details": {
"recipient": {
"full_name": "Ivanov Ivan"
}
},
"amount_details": {
"amount": 10000,
"currency": "rub"
},
"metadata": "good"
}'
use Bank131\SDK\API\Request\Builder\RequestBuilderFactory;
use Bank131\SDK\Client;
use Bank131\SDK\Config;
use Bank131\SDK\DTO\Card\BankCard;
use Bank131\SDK\DTO\Participant;
$config = new Config(
'https://demo.bank131.ru',
'your_project_name',
file_get_contents('/path/to/your/private_key.pem')
);
$client = new Client($config);
$participant = new Participant();
$participant->setFullName('Ivanov Ivan');
$request = RequestBuilderFactory::create()
->initPayoutSession('3230')
->setCard(new BankCard('4242424242424242'))
->setRecipient($participant)
->setAmount(1000, 'rub')
->setMetadata('good')
->build();
$response = $client->session()->initPayout($request);
Step 2. Wait for a webhook with the payout results
Bank 131 will send you a payment_finished webhook. The result of the payout can be found in the status field of the payments/payout_list object.
If the status is succeeded, then the payout was successful. If the status is failed, then an error occurred during the payout.
More about the payout statuses >
Webhook example
- cURL
- PHP
curl -X POST \
https://partner.ru \
-H 'Content-Type: application/json' \
-H 'X-PARTNER-SIGN: signature' \
-d '{
"type": "payment_finished",
"session": {
"id": "ps_3230",
"status": "accepted",
"created_at": "2018-05-27T02:03:00.000000Z",
"updated_at": "2018-05-27T02:03:00.000000Z",
"payments": [{
"id": "po_2018",
"status": "succeeded",
"created_at": "2018-05-27T02:03:00.000000Z",
"customer": {
"reference": "user123",
"contacts": [{
"email": "user@gmail.com"
}]
},
"payment_method": {
"type": "card",
"card": {
"last4": "4242",
"brand": "visa"
}
},
"amount_details": {
"amount": 10000,
"currency": "rub"
},
"metadata": "good"
}]
}
}'
use Bank131\SDK\Client;
use Bank131\SDK\Config;
use Bank131\SDK\Services\WebHook\Hook\WebHookTypeEnum;
$config = new Config(
'https://demo.bank131.ru',
'your_project_name',
file_get_contents('/path/to/your/private_key.pem'),
file_get_contents('/path/to/bank131/public_key.pem')
);
$client = new Client($config);
$hook = $client->handleWebHook('sign from headers', 'request body');
if ($hook->getType() === WebHookTypeEnum::PAYMENT_FINISHED) {
$session = $hook->getSession();
//do your logic here
}