Payout in a foreign currency
This scenario describes payout transactions initiated in a currency other than Russian rubles, for example, EUR or USD. However, the payout itself will be processed by Bank 131 and made in Russian rubles, calculated as of today's currency exchange rate. The currency exchange rates displayed are provided for information purposes only and do not constitute the real exchange rates.
You are eligible to make payouts in the following foreign currencies:
- EUR
- USD
Before making payouts in a foreign currency, please contact your manager in Bank 131.
Step 1. Start a payout
Send a request for payment session creation session/create
,
then a separate request for payout creation using this session's identifier session/start/payout
.
In the encrypted_card
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 numbers of the card, in order to show the user the payment destination.
The exact set of mandatory parameters depends on the recipient's card type.
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. if you are paying 100 EUR or USD, you need to pass
10000
)
View the parameters for payouts to Russian cards
Step 2. Wait for a confirmation that Bank 131 is ready to perform the payout
Note that autoconfirmation is not applicable for this payout scenario. You should wait for the confirmation webhook instead.
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, including the amount in Russian rubles.
You then reply with the 200 HTTP code.
Webhook example: ready_to_confirm
- cURL
- PHP
curl -X POST \
https://partner.ru \
-H 'Content-Type: application/json' \
-H 'X-PARTNER-SIGN: signature' \
-d '{
"type": "ready_to_confirm",
"session": {
"id": "ps_3230",
"status": "in_progress",
"created_at": "2018-05-27T02:03:00.000000Z",
"updated_at": "2018-05-27T02:03:00.000000Z",
"next_action": "confirm",
"payments": [
{
"id": "po_2018",
"status": "pending",
"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": 7550,
"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::READY_TO_CONFIRM) {
//do your logic here
}
Step 3. Confirm or cancel the payout
Check the payout details and confirm that you are ready to perform the payout using session/confirm
or cancel it using session/cancel
. Note that a session/confirm
request constitutes an order for Bank 131 to make the payout in Russian rubles, strictly according to the value passed within the ready_to_confirm
webhook body.
Request example: session/confirm
- cURL
- PHP
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_3230"
}'
use Bank131\SDK\Client;
use Bank131\SDK\Config;
$config = new Config(
'https://demo.bank131.ru',
'your_project_name',
file_get_contents('/path/to/your/private_key.pem')
);
$client = new Client($config);
$response = $client->session()->confirm('session_id');
Request example: session/cancel
- cURL
- PHP
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_3230"
}'
use Bank131\SDK\Client;
use Bank131\SDK\Config;
$config = new Config(
'https://demo.bank131.ru',
'your_project_name',
file_get_contents('/path/to/your/private_key.pem')
);
$client = new Client($config);
$response = $client->session()->cancel('session_id');