← Blog

·

Pagar.me + WhatsApp Business API: order notifications and payment recovery

Updated on November 24, 2026

To integrate Pagar.me with WhatsApp, you register a webhook in the Pagar.me dashboard, receive events such as order.paid, charge.pending and order.payment_failed in your backend or in n8n, and send an approved template through the official WhatsApp Business API for each event. Payment confirmed and PIX or boleto awaiting payment become utility messages. A declined card becomes a notice with a new payment link, with no promotional tone.

Pagar.me is a Brazilian payment gateway. This guide is the Pagar.me-specific map (API v5): events, where the phone number, the PIX QR code and the boleto payment line live, how to protect your endpoint without a documented signature, and which template to send in each case. Two Brazilian payment methods show up throughout: PIX, the Central Bank’s instant payment system (paid with a “copy and paste” code or QR code), and boleto, a bank slip paid by a typed line or barcode, which can take days to clear. The timing between reminders is covered in recovering PIX, boleto and abandoned carts on WhatsApp.

What Pagar.me offers for WhatsApp

The Pagar.me documentation shows a button to send a payment link via WhatsApp when you create the link. That send is manual, from the dashboard, and the documentation does not describe a native integration with the official WhatsApp API for automatic order notifications.

If you want every status change to trigger a message from your own official number, with your templates and delivery reports, the documented path is the webhook. Pagar.me notifies your URL when something happens; your system chooses the template and calls the API. If you are new to the API, the official WhatsApp API guide explains numbers, templates and billing.

How to set up the webhook in Pagar.me

According to the API v5 documentation:

  1. In the Pagar.me dashboard (Dash), open Configurações (Settings) > Webhook.
  2. Create a webhook pointing to your endpoint URL (HTTPS).
  3. Select the events this endpoint should receive. You can have more than one endpoint, each with its own events.
  4. Set how many times Pagar.me should resend on failure.

In the API, the webhooks resource lets you get, list and resend notifications. Each record includes status (pending, sent or failed), attempts, last_attempt, response_status and response_raw. That helps you find out why a notification didn’t go out: if your server answered 500, the error is logged there.

The documentation does not create webhooks through the API: setup happens in the dashboard.

Want to try it while you read? Create a Vectalk account and send your first message through the official API. Create free account →

Pagar.me events and the template for each

The events reference lists, among others, order events (order.created, order.paid, order.payment_failed, order.canceled, order.closed, order.updated), charge events (charge.created, charge.pending, charge.paid, charge.payment_failed, charge.refunded, charge.underpaid, charge.overpaid, charge.partial_canceled) and payment link events (checkout.created, checkout.closed, checkout.canceled).

For WhatsApp, only a few matter:

EventWhatsApp useLikely category
order.paidPayment confirmation and next stepsUtility
charge.pending (PIX or boleto)Payment instructions with the PIX code or boleto lineUtility
order.payment_failedPayment not approved, with a link to try againUtility, if there is no offer
charge.underpaidNotice that the amount paid was below the totalUtility
charge.refundedRefund confirmationUtility
order.canceledCancellation confirmationUtility
checkout.canceledPayment link expired: consider sending a new linkDepends on the wording

Subscribe to order events or charge events for the same notice, not both. A paid order fires both charge.paid and order.paid; if both are wired to the same template, the customer gets two messages.

About chargebacks: Pagar.me marked charge.chargedback as deprecated, with migration to chargeback.received by September 30, 2026. A chargeback calls for action from your team, not an automated message.

Where the phone, PIX and boleto are in the payload

The webhook body has id, account, type, created_at and data. In order events, data is the order, with customer and charges.

  • Phone: in the customer resource, the mobile number is in phones.mobile_phone, with country_code, area_code and number as strings. A customer with 55, 11 and 999999999 becomes 5511999999999 on WhatsApp (55 is Brazil’s country code). The documentation’s webhook example has an empty phones, because the phone only exists if it was sent when the order or customer was created. No mobile number at checkout means no WhatsApp.
  • PIX: in charges[].last_transaction, the fields qr_code (the copy-and-paste code), qr_code_url (image) and expires_at.
  • Boleto: in charges[].last_transaction, the fields url, pdf and line (the typed payment line).

The PIX and boleto paths come from the orders API responses. Before you switch on the reminders, check a real payload for each payment method in the webhook history.

Security: no documented signature in v5

In the current v5 documentation, the webhook is described as a POST to your URL, with no signature header. HMAC validation through the X-Hub-Signature header appears only in the documentation for older versions (postbacks), so don’t rely on it.

Three precautions make up for the missing signature:

  • Secret in the URL. Use a hard-to-guess path, such as /webhooks/pagarme/7f3c9a..., and reject calls on any other path.
  • Confirm through the API. Before a sensitive notice, fetch the order by id from the Pagar.me API (the Get order resource) with your secret key and use the status it returns, not the one in the body you received.
  • Idempotency. The documentation doesn’t mention duplicates, but resends happen. Store the event id and discard anything already processed.

The flow: Pagar.me → your system → official API

  1. Receive the POST on the secret URL.
  2. Answer 2xx quickly, so no resend is triggered.
  3. Discard any id already processed.
  4. Map type to a template and build the phone number.
  5. Check opt-in and, for reminders, whether the charge is still pending.
  6. Send the template and store the message ID to track delivery.

Example in Node.js with Express:

import express from "express";

const app = express();
app.use(express.json());

const processed = new Set(); // in production, use a database or Redis

function phone(customer) {
  const m = customer?.phones?.mobile_phone;
  if (!m?.number) return null;
  return `${m.country_code || "55"}${m.area_code || ""}${m.number}`.replace(/\D/g, "");
}

async function send(to, name, variables) {
  await fetch("https://apis.vectalk.com.br/api/messages", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.VECTALK_TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      messaging_product: "whatsapp",
      to,
      type: "template",
      template: {
        name,
        language: { code: "pt_BR" },
        components: [{
          type: "body",
          parameters: variables.map((text) => ({ type: "text", text: String(text) })),
        }],
      },
    }),
  });
}

app.post(`/webhooks/pagarme/${process.env.PAGARME_PATH_SECRET}`, async (req, res) => {
  res.sendStatus(200);
  const { id, type, data } = req.body;
  if (processed.has(id)) return;
  processed.add(id);

  const to = phone(data?.customer);
  if (!to) return;
  const firstName = data.customer.name?.split(" ")[0] || "";
  const order = data.code || data.id;

  if (type === "order.paid") {
    await send(to, "payment_confirmed", [firstName, order]);
  }
  if (type === "order.payment_failed") {
    await send(to, "payment_not_approved", [firstName, order]);
  }
});

app.listen(3000);

The language code is pt_BR because Pagar.me customers are mostly in Brazil; if you approve the same template in English or Spanish, use en_US or es for those customers. For pending PIX and boleto, subscribe to charge.pending and read data.last_transaction (in a charge event, data is the charge itself). Opt-in checks, API confirmation and failure handling are left out on purpose. In n8n, the same design becomes a Webhook node, a Switch node on type and an HTTP Request node; the walkthrough is in n8n with the WhatsApp Business API.

Utility templates for Pagar.me

Meta defines utility as a message with no promotional intent that is specific to the user or essential to them. Order confirmations and payment reminders are among the official examples. Templates to adapt (shown in English here; Meta approves the category):

payment_confirmed

Hi {{1}}! We received payment for order {{2}}. We’ll let you know here when it ships.

pix_pending

Hi {{1}}. Your order {{2}} is waiting for PIX payment. The code is valid until {{3}}. To pay, copy the code below into your banking app: {{4}}

payment_not_approved

Hi {{1}}. Payment for order {{2}} was not approved by the card issuer. If you’d still like to complete your purchase, use the button to try another card or PIX. URL button: “Pay order”.

A coupon, “last units left” or a discount to close now turns the template into marketing. The criteria are in how Meta categorizes templates.

Recovery: what Pagar.me covers and what it doesn’t

The documentation has no abandoned-cart event. What it does have is the charge that didn’t complete: PIX or boleto generated and unpaid, card declined, and payment link expired (checkout.canceled). Pagar.me itself suggests using payment links to recover lost sales, for example after a declined card.

A lean sequence:

  1. Right away: payment instructions (charge.pending).
  2. Before it expires: one reminder with the same code, if order.paid hasn’t arrived.
  3. Card declined: one notice with a link to try again.

Stop everything as soon as payment arrives. An abandoned cart in the store (before any charge exists) comes from the e-commerce platform, not from Pagar.me, and it is marketing. For PIX, see also PIX payments on WhatsApp through the API and, if you sell through links, selling on WhatsApp with a payment link.

Opt-in and LGPD

Meta requires that people agree to receive messages from your business, with the business name made clear, and that collection complies with applicable law. At checkout, make it clear that order notices will arrive on WhatsApp and ask for separate consent for offers, storing the date, source and accepted text. Brazil’s data protection law, the LGPD (Law 13,709/2018), requires a legal basis for each use of the phone number and an easy way to stop receiving messages; see LGPD and WhatsApp. This content is informational and does not replace advice from a lawyer.

How much each notice costs

Meta charges per delivered template. For recipients in Brazil, since October 1, 2026: utility costs R$ 0.0350 and marketing R$ 0.3217 (Brazilian reais). Utility is charged even inside the customer service window, and the free tier of 1,000 service messages per month per number does not cover utility. A thousand payment confirmations sent on WhatsApp cost about R$ 35 at Meta’s rates. The WhatsApp API pricing calculator helps you estimate the whole sequence.

How to do it with Vectalk

Vectalk is a proxy for Meta’s official Cloud API. You create templates in the dashboard, with the Template Library, or through the API, and send with POST https://apis.vectalk.com.br/api/messages using the same body as Meta and a Bearer token. Delivery statuses arrive at the webhooks you register with POST https://apis.vectalk.com.br/api/webhooks. Each delivered message is deducted from your prepaid balance, with no card on file at Meta, and coexistence keeps the number working in the WhatsApp Business app.

Vectalk has no native inbox, AI or bulk messaging: the Pagar.me webhook logic lives in your backend, in n8n or in Make. See the documentation or create your account at apps.vectalk.com.br/register. Using another gateway? See Mercado Pago + WhatsApp; running your own store, see Yampi + WhatsApp.

Frequently asked questions

Does Pagar.me send WhatsApp messages on its own?

The documentation only shows a button to send a payment link via WhatsApp, manually. For automatic notices from your official number, connect the webhooks to the API.

Which event should I use to confirm a payment?

order.paid (or charge.paid, if you work with charges). Pick one of the two to avoid duplicate messages.

How do I validate that the webhook came from Pagar.me?

v5 does not document a signature. Use a secret URL and, before sensitive notices, confirm the order status by querying the API with your secret key.

Where is the PIX code in the webhook?

In the charge’s last_transaction.qr_code, with the image in qr_code_url and the expiry in expires_at.

Is a declined-card message marketing?

If it only reports the problem and offers the link to pay, it tends to be utility. With a discount or offer urgency, it becomes marketing. Meta decides at approval.


Official sources consulted on November 24, 2026: Pagar.me: webhooks, Pagar.me: webhooks overview, Pagar.me: webhook events, Pagar.me: webhook example, Pagar.me: create customer, Pagar.me: PIX, Pagar.me: boleto, Pagar.me: creating a payment link, Pagar.me: using payment links to boost sales, Meta: template categorization, Meta: opt-in, Meta: pricing, Vectalk: send template, Vectalk: webhooks.

Put your business on the official WhatsApp

Create your account, connect your number to the official API (you can keep the app with coexistence) and start serving customers and sending messages.