Skip to main content

Payout from a settlement account to a bank card

This scenario describes how to make a payout from a settlement account to a bank card. The payout consists of two transactions, first, the payment amount itself, and second, the payment commission. Details of both transactions are presented in the appropriate bank statement which can be accessible via the online bank.

You can obtain tokenized card details using the tokenization widget, and then send the payout securely.

Step 1. Generate a public token

The token is needed to work with the widget. Send a request to create a token, and use it to pass the type of widget you want to work with. You will receive the token in response.

Request example

curl -X POST \
http://demo.bank131.ru/api/v1/token \
-H 'Content-Type: application/json' \
-H 'X-PARTNER-PROJECT: your_project_name' \
-H 'X-PARTNER-SIGN: signature' \
-d '{
"tokenize_widget": {
"access": true
}
}'

Step 2. Show the details collection form to the recipient

To do this, you will need to access our JavaScript library and add the tokenization widget to the page, where the recipient will then be able to fill in the form with their card details.

The recipient then enters their card details, and you'll receive tokenized details that you can use to perform the payout.

You can initialize the widget using the token you have obtained at the previous step.

Step 3. Start the payout

Send a request for payment session creation session/multi/create/rko, then a separate request for payout creation using this session's identifier session/multi/start/payment/rko. In the EncryptedCard object, pass the tokenized bank card details obtained from the widget.

You can find information about the token or card through the token/info method. This includes receiving the last 4 digits of the card, in order to show the user the payment destination.

If you are sending money to a Russian bank card, you will need the following:

  • card number
  • recipient's name
  • amount in ruble decimal format (e.g. to pay 100 rubles, pass 10000 in the amount_details.amount field)

View the parameters for payouts to Russian cards

Request examples

Create session
curl -X POST \
https://demo.bank131.ru/api/v1/session/multi/create/rko \
-H 'Content-Type: application/json' \
-H 'X-PARTNER-PROJECT: your_project_name' \
-H 'X-PARTNER-SIGN: signature' \
-d {
"payment_details": {
"type": "internal_transfer",
"internal_transfer": {
"type": "transfer_from_bank_account",
"transfer_from_bank_account": {
"description": "Purpose of payout"
}
}
},
"payment_method": {
"type": "card",
"card": {
"type": "bank_card",
"bank_card": {
"number": "****************"
}
}
},
"participant_details": {
"sender": {
"full_name": "Sender's details"
},
"recipient": {
"full_name": "Ivan Ivanovich Ivanov"
}
},
"amount_details": {
"amount": 293400,
"currency": "RUB"
},
"customer": {
"reference": "123456789012"
}
}
Payout start
curl -X POST \
https://demo.bank131.ru/api/v1/session/multi/start/payment/rko \
-H 'Content-Type: application/json' \
-H 'X-PARTNER-PROJECT: your_project_name' \
-H 'X-PARTNER-SIGN: signature' \
-d '{
"session_id": "ps_3230",
"metadata": "good"
}'

Step 4. Wait for notification that the Bank is ready to perform the payout

Bank 131 will send you a ready_to_confirm webhook (using the webhooks address you provided to your Bank 131 manager previously). This means that the payout can be performed and the Bank is waiting for you to confirm (or cancel). The webhook body will contain all the details of the payout. You're recommended to keep the confirm_information object for confirmation purposes.

You then reply with the 200 HTTP code.

Example of a ready_to_confirm webhook

curl -X POST \
https://partner.ru \
-H 'Content-Type: application/json' \
-H 'X-PARTNER-SIGN: signature' \
-d '{
"type": "ready_to_confirm",
"session": {
"id": "ps_14667043",
"status": "in_progress",
"created_at": "2022-09-14T09:32:19.891392Z",
"updated_at": "2022-09-14T09:32:20.494410Z",
"payments": [
{
"id": "po_7639847",
"status": "pending",
"created_at": "2022-09-14T09:32:20.100149Z",
"customer": {
"reference": "123456789012"
},
"payment_method": {
"type": "card",
"card": {
"brand": "mastercard",
"last4": "8371",
"country_iso3": "RUS"
}
},
"amount_details": {
"amount": 293400,
"currency": "RUB"
},
"amounts": {
"net": {
"amount": 293400,
"currency": "RUB"
},
"gross": {
"amount": 293400,
"currency": "RUB"
}
},
"participant_details": {
"sender": {
"full_name": "Acme"
},
"recipient": {
"full_name": "Ivan Ivanovich Ivanov"
}
}
}
],
"acquiring_payments": [
{
"id": "pm_6933973",
"status": "pending",
"created_at": "2022-09-14T09:32:20.099952Z",
"customer": {
"reference": "123456789012"
},
"payment_details": {
"type": "internal_transfer",
"internal_transfer": {
"type": "transfer_from_bank_account",
"transfer_from_bank_account": {
"description": "Payout by the agreement",
"card_mask": "553691******8371"
}
}
},
"amount_details": {
"amount": 293400,
"currency": "RUB"
},
"amounts": {
"net": {
"amount": 293400,
"currency": "RUB"
},
"gross": {
"amount": 293400,
"currency": "RUB"
}
},
"participant_details": {
"sender": {
"full_name": "Acme"
},
"recipient": {
"full_name": "Ivan Ivanovich Ivanov"
}
}
}
],
"next_action": "confirm"
},
"confirm_information": {
"transfer_details": {
"payment_method": {
"type": "card",
"card": {
"brand": "mastercard",
"last4": "8371",
"country_iso3": "RUS"
}
},
"customer": {
"account_number": "40702810700200000000",
"name": "Company name",
"bank_name": "Bank 131",
"bik": "049205131",
"correspondent_account_number": "30101810822000000000"
},
"recipient": {
"account_number": "30233810000000000000",
"name": "ООО Банк 131",
"bank_name": "ООО Банк 131",
"bik": "049205131",
"correspondent_account_number": "30101810822000000000"
},
"purpose": "Payout by the agreement",
"amount": {
"amount": 293400,
"currency": "RUB"
}
}
}
},

Step 5. Confirm or cancel the payout

Check the payout details and confirm that you are ready to perform the payout (using the confirm_request request) or cancel it using the cancel_request request.

Example of confirm_request

curl -X POST \
https://demo.bank131.ru/api/v1/session/confirm \
-H 'Content-Type: application/json' \
-H 'X-PARTNER-PROJECT: your_project_name' \
-H 'X-PARTNER-SIGN: signature' \
-d '{
"session_id": "ps_14667043",
"confirm_information": {
"transfer_details": {
"payment_method": {
"type": "card",
"card": {
"brand": "mastercard",
"last4": "8371",
"country_iso3": "RUS"
}
},
"customer": {
"account_number": "40702810700200000000",
"name": "Company name",
"bank_name": "Bank 131",
"bik": "049205131",
"correspondent_account_number": "30101810822000000000"
},
"recipient": {
"account_number": "30233810000000000000",
"name": "Bank 131",
"bank_name": "Bank 131",
"bik": "049205131",
"correspondent_account_number": "30101810822000000000"
},
"purpose": "Payout by the agreement",
"amount": {
"amount": 293400,
"currency": "RUB"
}
}
}
}'

Example of cancel_request

curl -X POST \
https://demo.bank131.ru/api/v1/session/cancel \
-H 'Content-Type: application/json' \
-H 'X-PARTNER-PROJECT: your_project_name' \
-H 'X-PARTNER-SIGN: signature' \
-d '{
"session_id": "ps_14667043",
"confirm_information": {
"transfer_details": {
"payment_method": {
"type": "card",
"card": {
"brand": "mastercard",
"last4": "8371",
"country_iso3": "RUS"
}
},
"customer": {
"account_number": "40702810700200000000",
"name": "Company name",
"bank_name": "Bank 131",
"bik": "049205131",
"correspondent_account_number": "30101810822000000000"
},
"recipient": {
"account_number": "30233810000000000000",
"name": "Bank 131",
"bank_name": "Bank 131",
"bik": "049205131",
"correspondent_account_number": "30101810822000000000"
},
"purpose": "Payout by the agreement",
"amount": {
"amount": 293400,
"currency": "RUB"
}
}
}
} '

Step 6. Wait to be notified of the results of the payout

Bank 131 will send you a payment_finished webhook. The webhook body will contain all the details of the payout. 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.

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
}