Pular para o conteúdo

Instant Pix (redirect)

Take an immediate Pix payment by redirecting the payer to their bank. This is the with-redirection journey — the counterpart of the JSR flows like Pay a QR Code. Instead of signing on the payer's device, you send the payer to their bank's app or site to authorize, then track the result by polling.

Method sequence

  1. participants.listMostUsed(subTenantId) (optional) — let the payer pick a bank (fallback: participants.listRegistered()). You need an organisationId and authorisationServerId for the next step.
  2. consents.create({ organisationId, authorisationServerId, redirectUri, payment }) — open the payment consent. The payment carries value, cpfCnpj, redirectUri, and the creditor (for a QR/boleto instead, send payment.qrCode). Returns CreatedPayment { id, redirectUrl }; id is the paymentRequestId.
  3. [redirect] send the payer to created.redirectUrl. They authenticate and authorize in the bank, then return to your redirectUri.
  4. payments.getRequest(created.id) — poll for the status. isRequestPaid(request) returns true once any payment has status: PAGO.

Sequence diagram

Instant Pix — create the consent, redirect the payer to their bank, then poll for the result

Code

Pick the bank (organisationId + authorisationServerId), create the consent, redirect the payer to created.redirectUrl, and poll getRequest after they return.

import { isRequestPaid } from '@linainfratech/embedded-payments';

// 1) Create the payment consent (transfer by receiver data)
const created = await client.consents.create({
organisationId,
authorisationServerId,
redirectUri: 'https://minha-loja.com.br/retorno',
payment: {
  details: 'Pedido #1234',
  value: 150.5,
  cpfCnpj: '12345678901',
  redirectUri: 'https://minha-loja.com.br/retorno',
  creditor: {
    name: 'Loja Exemplo LTDA',
    personType: 'PESSOA_JURIDICA',
    cpfCnpj: '12345678000199',
    accountNumber: '1234567',
    accountIssuer: '0001',
    accountIspb: '12345678',
    accountType: 'CACC',
  },
},
});
console.log('paymentRequestId =', created.id);

// 2) Redirect the payer to created.redirectUrl, then poll after they return
const request = await client.payments.getRequest(created.id);
console.log(isRequestPaid(request) ? 'PAGO' : 'Ainda nao pago - faca polling.');

Next steps

  • Scheduled Pix — the same flow plus a schedule for future or recurring payments.
  • Pay a QR Code — the JSR (device-signed) alternative, with no redirect.
  • Error handling — handle rejected and expired payment requests.