To use PagBank as a payment provider in Mavibot, you need to obtain an access token from your PagBank account and enter it in the payment settings.

Getting a Token

Production environment: sign in to your PagBank account from a computer, go to Vendas → Integrações (Sales → Integrations), and click Gerar token (Generate token).

Test environment (sandbox): sign in to the PagBank Developer Portal, open the Tokens tab, and copy your sandbox token.

The token is displayed only once. Store it somewhere secure: if you lose it, you will need to generate a new one, and the old token will stop working.

You do not need to configure a payment notification URL in your PagBank account — Mavibot provides it automatically when creating each payment.

Setup

In the payment system settings, select PagBank and enter:

  • Token — the API access token from your PagBank account.
  • Test mode — enable this if you entered a sandbox token. In test mode, requests are sent to sandbox.api.pagseguro.com, and no real money is charged.

Setup is complete.

Calculator function:

get_pagbank_payment_url(amount, description, product_name, customer_email, customer_phone, full_name, identity_number)

Parameters

Parameter Description
amount Payment amount. Required. Minimum: 1 BRL; maximum: 9,999,999 BRL. Enter the amount as 100.55, not 10055.
description Payment description. Optional, up to 255 characters. The customer will see it on the payment page.
product_name Product name, up to 100 characters. Optional; description is used by default.
customer_email Customer's email address. Optional; pre-filled on the payment page.
customer_phone Customer's phone number. Optional; pre-filled on the payment page. PagBank only accepts Brazilian mobile numbers: country code 55, a two-digit area code, and a nine-digit number starting with 9 (for example, +55 11 99999-8888).
full_name Customer's first and last name. Optional; pre-filled on the payment page.
identity_number Customer's CPF (11 digits) or CNPJ (14 digits). Optional; pre-filled on the payment page.

The function returns a payment URL.

PagBank accepts customer details only as a complete set: name, email, phone number, and CPF/CNPJ must all be provided. If any of these four fields is missing, or the phone number is not a valid Brazilian mobile number, Mavibot will not send any of the customer details to PagBank. The customer will simply fill them in on the payment page. This does not affect the payment itself.

To send a button with a payment link, select the payment button type and choose PagBank as the payment system. Enter the product name and payment amount. If needed, specify variables containing the customer's name, email address, and phone number.

Callbacks After Payment

After the customer follows the link and completes the payment, a successful payment callback will be sent to the dialog:

A1B2C3D4E5_success 100.55

Here, A1B2C3D4E5 is the first 10 characters of your token, and 100.55 is the payment amount.

If the payment fails, the following callback will be sent:

A1B2C3D4E5_fail 100.55

A failure callback is sent only when the payment link can no longer be used: the bank has permanently declined or canceled the payment, or the payment link has expired. No callback is sent while the payment is under review, awaiting boleto payment, or authorized but still on hold on the card, since the payment link remains active. An expired payment link has no associated payment, so the callback will not include an amount.

To handle a successful or failed payment, follow these steps:

  1. Create a block with a trigger (a gray Trigger block or a green Start block — use the green block if you want to continue building the funnel after the payment).
  2. In the Trigger field, enter the callback without the payment amount:
A1B2C3D4E5_success

Use this option if you want the block to react to every successful payment.

Set the matching type to Keyword Match.

Alternatively, enter the full callback:

A1B2C3D4E5_success 100.55

Use this option if you want the block to react only to a payment for a specific amount.

Set the matching type to Exact Match.

Customer Variables After a Successful Payment

Variable Value
pagbank_callback_data Payment information received from the payment system
pagbank_payment_completed "True" — the payment has been processed successfully
pagbank_order_id PagBank order ID (ORDE_…)
pagbank_charge_id PagBank charge ID (CHAR_…)
pagbank_payment_method Payment method: CREDIT_CARD, DEBIT_CARD, PIX, or BOLETO