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
- to a bank card
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
Use the session/init/payout
request.
- To an account
- To a card
- In the
type
parameter of thepayment_method
object, passbank_account
. - In the
ru
object, pass the bank's BIC, the account number, the recipient's full name, and the purpose of the payout.
- In the
type
parameter of thepayment_method
object, passcard
. - In the
bank_card
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 ruble decimal format (e.g. to pay 100 rubles, pass 10000
in the amount_details.amount
field).
Request example: payout to an account
- cURL
- PHP
curl -X POST \
https://demo.bank131.ru/api/v1/session/init/payout \
-H 'Content-Type: application/json' \
-H 'X-PARTNER-SIGN: signature' \
-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 a 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.
Webhook example: payout result
- 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
}