Creating a payment

Creating a payment

Request Parameters

FieldTypeRequiredDescription

gatewayId

integer

yes

Gateway ID

amount

string

yes

Payment amount

commissionInclude

boolean

no

Include the commission in the amount or add it on top of the payment amount

fields

Map<string, string>

yes

List of fields for the payment method

webhookUrl

string

no

URL for sending payment notifications

lifetime

integer

no

Payment lifetime in seconds

Additional comments:

  • gatewayId is the gateway ID. To find it out, you need to get a list of payment methods

  • amount — The amount of the payment. Please note that for some payment methods (for example p2p), the payment amount may change, since the user may send an amount less or more than the specified amount, in which case the amount in the payment will be updated

  • commissionInclude — By default, the commission is included in the payment amount. When the commission is enabled (the value is true), the user will need to pay the amount specified in the amount field. If the value is false, the commission percentage specified by the payment method will be added to the specified amount

  • lifetime — The lifetime of the payment in seconds. Please note that some payment methods cannot have a lifetime specified, this field will not affect their lifetime.

Some payment methods (e.g. sbp, p2p) require payment confirmation by the user. For payments created using such payment methods, the method will be available Payment confirmation

Response Description

Example of the response body

{
    "id": "133",
    "gatewayId": "12",
    "status": "PENDING",
    "extra": {
      "accountNumber": "2222222222222222",
      "accountName": "Иванов Иван Иванович",
      "bankName": "bank"
    },
    "paymentCurrency": "RUB",
    "paymentAmount": "4990",
    "destinationCurrency": "USDT",
    "destinationAmount": "string",
    "createdAt": "2023-09-26T13:29:34.172Z"
}

Description of fields:

FieldTypeDescription

id

integer

Payment ID

gatewayId

integer

Payment Gateway ID

status

enum

Payment status (list of available status below)

extra

object

Payment details

paymentCurrency

string

Expected currency to be paid

paymentAmount

string

Amount to be paid

destinationCurrency

string

Expected currency of payment crediting in the personal account

destinationAmount

string

Expected deposit amount

createdAt

string

Payment creation date

Please note that the body has the currency/amount to be paid and the currency/amount to be credited. Some gateways can immediately convert the amount received into cryptocurrency

Possible statuses:

StatusDescription

PENDING

Payment pending payment or confirmation

REJECTED

Payment rejected. To clarify the details, you need to contact support

CONFIRMED

Payment confirmed by the user

CANCELLED

The payment was rejected by the user or merchant

PROCESSED

Payment successful

ERROR

Error during processing. To clarify the details, you need to contact support

Description of the Extra field

The extra field contains the information necessary for making the payment

For payment methods like p2p, sbp, it will have the following value:

{
      "accountNumber": "2222222222222222",
      "accountName": "Иванов Иван Иванович",
      "bankName": "bank"
}

Description of fields:

aaaaaa

accountNumber

string

Details for sending funds

accountName

string

Name of the recipient to check the correctness of entering the details

bankName

string

Name of the recipient's bank for sending correctness

Fields formation

When receiving a list of payment methods, they may have a fields field. To create a payment, you will need to fill it out

Example of field extension

Payment Method Request Response:

{
  "success": "true",
  "response": [
    {
      "gatewayId": "12",
      "currency": "RUB",
      "alias": "Transfer by card number RUB",
      "type": "p2p",
      "commission": "7.5",
      "minAmount": "1000",
      "fields": [
        {
          "type": "select",
          "name": "bank",
          "alias": "Select a bank",
          "values": [
            {
              "value": "1",
              "name": "Bank 1"
            },
            {
              "value": "2",
              "name": "Bank 2"
            },
            {
              "value": "3",
              "name": "Bank 3"
            }
          ],
          "required": true,
          "regexp": "^\d$"
        },
        {
          "type": "input",
          "name": "email",
          "alias": "Email",
          "values": [],
          "required": true,
          "regexp": "^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"
        },
        {
          "type": "input",
          "name": "comment",
          "alias": "Comment",
          "values": [],
          "required": false,
          "regexp": ""
        }
      ]
    }
  ]
}

There are 3 fields in the payment method, 2 of them are required to be filled in Next, you will need to create a field fields with the type Map<string, string> The value must satisfy the regular expression if it is specified in the regexp field

It must contain the bank ID from the list of available values (the values field). The selected value must be put in fields by the key specified in the name field, for the bank it is "name": "bank"

Now the fields field should look like this

{
  "bank": 1
}

The second field Email is filled in a similar way, only this field has the type input, so there is no need to take values from values, it must be filled in so that it corresponds to a regular expression

Now the fields field should look like this

{
  "bank": 1,
  "email": "email@example.com"
}

The field with the comment has the flag "required": false, so it can not be filled in. Let's skip it

The final body of the creation request will look something like this

{
  "gatewayId": "12",
  "amount": "4990",
  "commissionInclude": true,
  "fields": {
    "bank": 1,
    "email": "email@example.com"
  },
  "webhookUrl": "https://domain.site/webhook",
  "lifetime": 0
}

Webhook

When the payment status changes, notifications about the status change will be sent to the specified URL The body of the webhook will be identical to the body of the payment creation/receipt response

{
    "id": "133",
    "gatewayId": "12",
    "status": "PENDING",
    "extra": {
      "accountNumber": "2222222222222222",
      "accountName": "Иванов Иван Иванович",
      "bankName": "bank"
    },
    "paymentCurrency": "RUB",
    "paymentAmount": "4990",
    "destinationCurrency": "USDT",
    "destinationAmount": "string",
    "createdAt": "2023-09-26T13:29:34.172Z"
}

Last updated