How to Connect

To connect the bePaid payment system, you will need a Store ID, secret key, and public key. Once you receive these credentials, proceed to the settings in Salebot.

To obtain the Store ID, secret key, and public key, please contact baPaid technical support for assistance.

In MaviBot, open the "Payment system" section and select bePaid. Then enter the credentials you received.

Please note that the last field is a switch that selects the API hosting depending on the country of use: Belarus or Russia.

To generate a payment link, you need to set a value for the payment_sum variable (for example: 150 or 100.55 — use a dot as the decimal separator).

Once the payment_sum variable is set, the bepaid_pay_url variable will automatically appear. You can display this variable on the screen as a link or place it on a button with the text "Pay".

The payment link will look like this:
https://checkout.bepaid.by/widget/hpp.html?token=a05eabd3f9368725efbc175614c7d469da08f198cc51916b07fb75e53f9a3e1a

Before setting the payment_sum variable, you can also define the following optional variables to customize the payment.

By default, the currency is set to Belarusian ruble. If you need to use a different currency, set a value for the currency variable.

After the payment is completed, the bepaid_callback_data variable will be added for the customer. It contains the payment system’s response for the completed transaction. You can extract the required data from this dictionary using the get method.

How to Test Payments

To perform a test payment, before setting the payment_sum variable, set the test_payments variable with any value.
Remember to remove it when running the bot in live mode!

Test cards:

  • 4200000000000000 — success
  • 4005550000000019 — failed

If something doesn’t work, compare your data with the official documentation: https://docs.bepaid.by/ru/test-integration#test-card-number

Let’s create a payment link for 100 Belarusian rubles (default currency).

Note: first, set the additional variables for configuration, then set payment_sum. Variables can also be set earlier in the workflow, not necessarily in the same block — this is just an example.

Finally, display the bepaid_pay_url variable in the desired location; it contains the generated payment link.

Subscription Management

The payment system integration allows you to create subscriptions for your customers.

Before using this functionality in Salebot, create a subscription plan in your bePaid account.

If the “Plans” and “Subscriptions” menus do not appear in your account, please contact your manager.

Creating a Subscription and Generating a Payment Link

Use the get_bepaid_subscription_url function, passing the plan_id parameter, where…

As a result, the function will create a subscription and return a payment link.

Send the link to the customer and wait for the payment to be completed.

Once the payment is successful, the subscription will be activated. The deal will receive the bepaid_subscription_id and bepaid_subscription_status variables, and a callback will be sent to the bot (see the “How to Handle the Result” section).

Retrieving Subscription Information

To get the current subscription details for a customer, call the get_bepaid_subscription_info function and pass the subscription_id parameter (the value can be taken from the bepaid_subscription_id variable).

Cancelling a Subscription

To cancel a subscription, use the cancel_bepaid_subscription function.

This function accepts a single parameter: subscription_id (the value can be taken from the bepaid_subscription_id variable).

Upon successful cancellation, the bepaid_subscription_status variable will be set to “canceled”, and a callback will be sent to the bot (see the “How to Handle the Result” section).

Subscription Statuses

Recurring Payments

You can also set up a subscription system without creating a plan in your bePaid account.

For this, you will need the customer’s card token.

To obtain the card token, the customer must make an initial payment using a link generated via payment_sum.

Before setting the payment_sum value, set the bepaid_contract variable to specify the purpose of future payments by token:

  • “recurring” – for regular payments with a set frequency
  • “card_on_file” – for one-time or irregular payments, e.g., post-payment for a service

The “card_on_file” option is not supported by all acquirers. If you want to use it, please contact your account manager.

After a successful payment, the bepaid_client_card_token variable will be added to the deal, storing the customer’s card token. This token allows you to charge the customer’s card without their involvement.

Next, set up your funnel and specify a date or condition for automatic charging, then call the make_bepaid_token_payment function, passing the required parameters.

Parameter order:
amount → currency → description → contract

Parameter Descriptions

The contract value must exactly match the value specified when creating the initial payment link!

If the payment is successful, the function will return the message “Successful charge via bePaid token”, you will receive a callback for the successful payment, and the deal variable bepaid_token_payment_completed will be set to “True”.

If the payment fails, the function will return a message indicating the reason for the failed payment, a callback with the suffix _fail” will be sent to the bot, and the deal variable bepaid_token_payment_completed will be set to “False”.

The bank may require the customer to complete the payment. In this case, the function will return a link prompting the customer to go through 3-D Secure authentication.

How to Handle the Result

In response to customer actions, the bot will receive callbacks consisting of the first 20 characters of the secret key and a suffix, which depends on the type and outcome of the operation.

In the system, the callback appears as a message from the user, but the user does not see it.

For Payments

For payments not related to subscriptions, you will receive one of the following messages:

  • keyNumber_success – for a successful payment
  • keyNumber_fail – for a failed payment

You can also track the status of the last payment using the variables:

  • bepaid_payment_completed – for payments involving the customer
  • bepaid_token_payment_completed – for card token-based automatic payments

For Subscriptions

After a subscription is successfully activated, either on the first or a recurring payment, the bot will receive the message keyNumber_success.

If the subscription is canceled, you will receive keyNumber_canceled.

In the case of a failed subscription payment, the message keyNumber_fail will be sent.