Creating a payment

Creating a payment

Request Parameters

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:

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:

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:

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