Skip to main content

Single-request payout

You can create a payout and send it with a single request, without any intermediate steps.

You should consider this option if you are sending money:

  • to a bank account;
  • or to a bank card if you have PCI DSS.

How to enable

Inform your Bank 131 manager that you want to use this option. Then all your payouts will be performed using this method.

How to send a payout

Using the session/init/payout request.

For a payout to an account:

  • in the PaymentMethod.type  parameter, pass bank_account;
  • in the bank_account.ru object, pass the bank's BIC, the account number, the recipient's full name, and the purpose of the payout.

View the parameters for payouts to accounts

For a payout to a card:

  • in thePaymentMethod.type parameter, pass card;
  • in the BankCard object, pass the recipient's bank card details.

If this is a Russian bank card, you will need the card number, the recipient's name, and the amount in in ruble decimal format (e.g. if you are paying 100 rubles, you will need to pass 10000 in the amount_details.amount field).

View the parameters for payouts to Russian cards

Payout request examples

curl -X POST \
https://demo.bank131.ru/api/v1/session/init/payout \
-H 'Content-Type: application/json' \
-H 'X-PARTNER-SIGN: sign' \
-H 'X-PARTNER-PROJECT: your_project_name' \
-d '{
"payment_method": {
"type": "bank_account",
"bank_account": {
"system_type": "ru",
"ru": {
"bik": "044525971",
"account": "40817810100000270411",
"full_name": "Ivanov Ivan Ivanovich",
"description": "Wire for agreement № 5015553111 Ivanov Ivan Ivanovich VAT exempt"
}
}
},
"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\BankAccount\BankAccountRu;

$config = new Config(
'https://demo.bank131.ru',
'your_project_name',
file_get_contents('/path/to/your/private_key.pem')
);

$client = new Client($config);

$request = RequestBuilderFactory::create()
->initPayoutSession()
->setBankAccount(
new BankAccountRu(
'044525971',
'40817810100000270411',
'Ivanov Ivan Ivanovich',
'Wire for agreement № 5015553111 Ivanov Ivan Ivanovich VAT exempt'
)
)
->setAmount(1000, 'rub')
->setMetadata('good')
->build();

$response = $client->session()->initPayout($request);

How to check the result

Wait for the payment_finished webhook or query the payout's status using the session/status method.

The result of the payout can be found in the payment.status field.

If the status is succeeded, then the payout has been successful. If the status is failed, then the payout has not been completed because of an error.

More about payout statuses

Webhook example: payout result

curl -X POST \
https://partner.ru \
-H 'Content-Type: application/json' \
-H 'X-PARTNER-SIGN: a4f1698616d6ad7b8b73a9d72d281eeb443b64dee3f38df430eeed6aa29e1dc' \
-d '{
"type": "payment_finished",
"session": {
"id": "3230",
"status": "accepted",
"created_at": "2018-05-27T02:03:00.000000Z",
"updated_at": "2018-05-27T02:03:00.000000Z",
"payments": [
{
"id": "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"
}
]
}
}'

An example of handling a webhook using SDK

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
}
Feedback