# Bepaid

## **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**.

{% hint style="info" %}
To obtain the **Store ID**, **secret key**, and **public key**, please contact **baPaid** technical support for assistance.
{% endhint %}

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

<div data-with-frame="true"><figure><img src="/files/L7LKIjWGhEytoW31Fl8d" alt=""><figcaption></figcaption></figure></div>

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

<div data-with-frame="true"><figure><img src="/files/ovK6vNMKCRR4Oa83J1Mn" alt=""><figcaption></figcaption></figure></div>

## **How to Generate a Payment Link**

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.

{% hint style="info" %}
By default, the currency is set to **Belarusian ruble**. If you need to use a different currency, set a value for the **currency** variable.
{% endhint %}

<table><thead><tr><th width="209">Function Parameters</th><th width="242">Description</th><th>More Information</th></tr></thead><tbody><tr><td><strong>currency</strong></td><td>Payment currency in ISO 4217 format</td><td>For example: <strong>USD</strong></td></tr><tr><td><strong>language</strong></td><td><strong>Payment page language</strong><br>Default: <strong>en</strong>.</td><td><p><strong>Allowed values:</strong></p><ul><li><strong>en</strong> – English</li><li><strong>es</strong> – Spanish</li><li><strong>tr</strong> – Turkish</li><li><strong>de</strong> – German</li><li><strong>it</strong> – Italian</li><li><strong>ru</strong> – Russian</li><li><strong>zh</strong> – Chinese</li><li><strong>fr</strong> – French</li><li><strong>da</strong> – Danish</li><li><strong>sv</strong> – Swedish</li><li><strong>no</strong> – Norwegian</li><li><strong>fi</strong> – Finnish</li><li><strong>pl</strong> – Polish</li><li><strong>ja</strong> – Japanese</li><li><strong>uk</strong> – Ukrainian</li><li><strong>be</strong> – Belarusian</li><li><strong>ka</strong> – Georgian</li><li><strong>ro</strong> – Romanian</li></ul></td></tr><tr><td><strong>payment_description</strong></td><td>Payment Description</td><td></td></tr><tr><td><strong>link_expired</strong> </td><td><strong>Payment Link Expiration</strong><br>Set the expiration date in the format <strong>dd.mm.yyyy</strong> (for example: <strong>25.06.2025</strong>).<br>By default, the payment must be completed within <strong>24 hours</strong>.</td><td><p>You can also use the <strong>"Assign Variables on Redirect"</strong> field to set:</p><ul><li><code>link_expired = current_date + 2</code> — the link will be valid for <strong>2 days until 00:00</strong>.</li><li>You can also specify an exact expiration date and time in the format <strong>dd.mm.yyyy hh:mm</strong> (for example: <strong>25.06.2025 12:23</strong>). By default, the payment must be completed within <strong>24 hours</strong>.</li></ul><p>Standard variables can also be used. For example, to set the link validity to <strong>30 minutes</strong>:<br>time = current_time + 30<br>link_expired = "#{current_date} #{time}"</p></td></tr><tr><td>russian_host</td><td><strong>Indicator for Store Registered on Russian bePaid Host</strong><br>Set this parameter to <strong>1</strong> if your store is registered on <strong>bepaid.tech</strong>.</td><td>If you need to switch the host to Belarus, set this parameter to <strong>""</strong> (empty value).</td></tr><tr><td><strong>test_payments</strong></td><td>This variable is used for <strong>test payments</strong>. To perform a test payment, add it with any value.</td><td></td></tr><tr><td><strong>bepaid_attempts</strong> </td><td>Specifies the <strong>number of payment attempts</strong>. By default, <strong>1 attempt</strong> is allowed.</td><td></td></tr><tr><td><strong>сustomer_data</strong></td><td>An array containing the payer’s <strong>first_name</strong>, <strong>last_name</strong>, and <strong>email</strong>. This data is required to send the receipt to the payer’s email and can be edited on the payment page.</td><td>The parameter must be passed as a <strong>JSON-formatted list of key-value pairs</strong>.<br>For example:<br>customer_data = ‘{“first_name”: “Sam”, “last_name”: “Smith”, “email”: “sam_smith@mavibot.ai” }’</td></tr><tr><td><strong>bepaid_contract</strong> (conditionally required)</td><td>Payment Purpose by Token</td><td><p><strong>Expected values:</strong></p><ul><li><strong>“recurring”</strong> – for regular payments with a set frequency</li><li><strong>“card_on_file”</strong> – for one-time or irregular payments, e.g., post-payment for a service</li></ul></td></tr></tbody></table>

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>

## **Example of Generating a Payment Link**

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.

{% hint style="warning" %}
If the **“Plans”** and **“Subscriptions”** menus do not appear in your account, please contact your manager.
{% endhint %}

**Creating a Subscription and Generating a Payment Link**

Use the **get\_bepaid\_subscription\_url** function, passing the **plan\_id** parameter, where…

<table><thead><tr><th width="233"></th><th></th></tr></thead><tbody><tr><td>plan_id</td><td><strong>plan_id</strong> is the ID of the plan in the <strong>bePaid</strong> system.</td></tr></tbody></table>

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

<table data-header-hidden><thead><tr><th width="270"></th><th></th></tr></thead><tbody><tr><td>trial</td><td>Active or canceled <strong>trial period</strong> subscription.</td></tr><tr><td>active</td><td>Active subscription with <strong>payment made on time</strong>.</td></tr><tr><td>failed</td><td>Failed subscription. <strong>bePaid</strong> was unable to process the next payment.</td></tr><tr><td>error</td><td>An error occurred while <strong>bePaid</strong> was attempting to process the payment.</td></tr><tr><td>canceled</td><td>Subscription has been <strong>canceled</strong> and is no longer active.</td></tr></tbody></table>

## **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

{% hint style="warning" %}
The **“card\_on\_file”** option is not supported by all acquirers. If you want to use it, please contact your account manager.
{% endhint %}

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

<table><thead><tr><th width="286"></th><th></th></tr></thead><tbody><tr><td>amount (required)</td><td><strong>Payment amount</strong> – expected value is an <strong>integer</strong> or <strong>decimal number</strong>, for example: 100 or 100.5.</td></tr><tr><td>currency (required)</td><td><strong>Payment currency</strong> in <strong>ISO 4217</strong> format, for example: <strong>“USD”</strong>.</td></tr><tr><td>description (required)</td><td><strong>Description of the charge</strong>, for example: <strong>“Weekly subscription payment for participation in the hobby club”</strong>.</td></tr><tr><td>contract (required)</td><td><strong>Payment purpose by token.</strong> Expected values: <strong>“recurring”</strong> or <strong>“card_on_file”</strong>.</td></tr></tbody></table>

{% hint style="warning" %}
The **contract** value must **exactly match** the value specified when creating the initial payment link!
{% endhint %}

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”**.

{% hint style="warning" %}
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**.
{% endhint %}

## **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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mavibot.ai/integrations/payment/bepaid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
