# Payments via SBP

Features of the payment service through SBP in test mode:

  • To activate the test mode, you must contact Support Service (opens new window);

  • A request for a list of banks returns a list of 5 banks;

  • For a successful request with full name and obtaining payment statussuccessneed to use phone+79001234567, when using a different phone number, the transaction status will be receivedfail;

  • For a successful request without full name and obtaining payment statussuccessneed to use phone+79007654321, when using a different phone number, the transaction status will be receivedfail. When requesting a status, your full name is returned in the response.Иван Иванович Иванов;

# Getting a list of banks

[Authorization - XAuth](https://docs.mandarin.io/public/basics.html#%D0%B0%D1%83%D1%82%D0%B5%D0%BD%D1%82%D0%B8 %D1%84%D0%B8%D0%BA%D0%B0%D1%86%D0%B8%D1%8F-%D0%B7%D0%B0%D0%BF%D1%80%D0%BE%D1%81%D0%BE%D0%B2).

Parameter Type Required Description
bankName string No The name of the bank by which you want to filter, you can specify an incomplete name, the method will return all suitable options. Case is ignored when filtering

Request for a list of banks:

curl --request GET \
  --url https://secure.mandarinpay.com/api/sbp/banks/ \
--header 'x-auth: {{x_auth}}'
```**Response if the request was created successfully:**

```json
{
    "banks": [
        {
            "bankId": "100000000008",
            "bankName": "Альфа-Банк",
            "bankBic": "044525593"
        },
        {
            "bankId": "100000000005",
            "bankName": "ВТБ",
            "bankBic": "044525187"
        },
        {
            "bankId": "100000000004",
            "bankName": "Т-Банк",
            "bankBic": "044525974"
        },
        {
            "bankId": "100000000007",
            "bankName": "Райффайзен Банк",
            "bankBic": "044525700"
        },
        {
            "bankId": "100000000111",
            "bankName": "Сбербанк",
            "bankBic": "044525225"
        }
    ]
}

Request for a specific bank:

curl --request GET \
  --url https://secure.mandarinpay.com/api/sbp/banks?bankName=Сбербанк \
--header 'x-auth: {{x_auth}}'
```**Response if the request was created successfully:**

```json
{
    "banks": [
        {
            "bankId": "100000000111",
            "bankName": "Сбербанк",
            "bankBic": "044525225"
        }
    ]
}

# Creating a payment with full name

Parameter Required
customerInfo Yes
customerInfo.phone Yes
customerInfo.email Yes
customerInfo.firstName Yes
customerInfo.lastName Yes
customerInfo.middleName Yes
payment Yes
payment.action Yes
payment.orderId Yes
payment.price Yes
target Yes
target.sbp Yes
target.sbp.bankId Yes
target.sbp.bankBic Yes

Request:

curl --request POST \
  --url https://secure.mandarinpay.com/api/transactions \
--header 'Content-Type: application/json' \
--header 'x-auth: {{x_auth}}' \
--data-raw '{
    "customerInfo": {
        "phone": "+79001234567",
        "email": "test@test.com",
        "firstName": "Иванов",
        "lastName": "Иван",
        "middleName": "Иванович"
    },
    "payment": {
        "orderId": "your_unique_order_id",
        "price": "10.00",
        "action": "payout"
    },
    "target": {
        "sbp": {
            "bankId": "100000000111",
            "bankBic": "044525225"
        }
    }
}'

Response in case of successful transaction creation (200 OK):

{
	"id": "43913ddc000c4d3990fddbd3980c1725"
}

Answer if the transaction is not created (400 Bad request):

{
	"error": "Invalid request"  
}

Response in case of an attempt to create a payment with an existing valueorderId(400 Bad Request):

{
    "error": "Duplicate order id 5f2fdcf6-0b78-4dd7-be9f-212c7c058001 found for incomplete payout transaction",
    "errorCode": -2
}

# Creating a payment without full name

Payments without full name are made in two stages - creating a transaction and confirming or canceling it after checking the status and data.

Parameter Required
customerInfo Yes
customerInfo.phone Yes
customerInfo.email Yes
payment Yes
payment.action Yes
payment.orderId Yes
payment.price Yes
target Yes
target.sbp Yes
target.sbp.bankId Yes
target.sbp.bankBic Yes

Request:

curl --request POST \
  --url https://secure.mandarinpay.com/api/transactions \
--header 'Content-Type: application/json' \
--header 'x-auth: {{x_auth}}' \
--data-raw '{
    "customerInfo": {
        "phone": "+79007654321",
        "email": "test@test.com"
    },
    "payment": {
        "orderId": "your_unique_order_id",
        "price": "10.00",
        "action": "payout"
    },
    "target": {
        "sbp": {
            "bankId": "100000000111",
            "bankBic": "044525225"
        }
    }
}'

Response in case of successful transaction creation (200 OK):

{
	"id": "43913ddc000c4d3990fddbd3980c1725"
}

Answer if the transaction is not created (400 Bad request):

{
	"error": "Invalid request"  
}

Response in case of an attempt to create a payment with an existing valueorderId(400 Bad Request):

{
    "error": "Duplicate order id 5f2fdcf6-0b78-4dd7-be9f-212c7c058001 found for incomplete payout transaction",
    "errorCode": -2
}

# Checking request status without full name

Status Check Request:

After creating a payment without full name, you need to check the status if the phone number was specified as a test one from the documentation+79007654321, then the status will besuccess, if otherwise specified, then the status request will be receivedfail

curl --request GET \
  --url https://secure.mandarinpay.com/api/sbp/43913ddc000c4d3990fddbd3980c1725/status \
--header 'x-auth: {{x_auth}}'

Answer if successful:

{
    "status": "success",
    "fio": "Иван Иванович Иванов"
}

Response if unsuccessful:

{
    "status": "fail",
    "fio": null
}

# Confirmation of payment without full name

Request for confirmation of payment:

After receiving a successful status, you must confirm the payment in order for the funds to go to the recipient.

curl --request POST \
  --url https://secure.mandarinpay.com/api/sbp/43913ddc000c4d3990fddbd3980c1725/confirm \
--header 'x-auth: {{x_auth}}'

Response in case of successful confirmation of payment (200 OK)

# Cancellation of payment without full name

The payment can be canceled if a confirmation request has not yet been sentconfirm.

Request to cancel payment:

curl --request POST \
  --url https://secure.mandarinpay.com/api/sbp/43913ddc000c4d3990fddbd3980c1725/reject \
--header 'x-auth: {{x_auth}}'

Response in case of successful cancellation of payment (200 OK):

{
	"id": "43913ddc000c4d3990fddbd3980c1725"
}