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
participants.listMostUsed(subTenantId)(optional) — let the payer pick a bank (fallback:participants.listRegistered()). You need anorganisationIdandauthorisationServerIdfor the next step.consents.create({ organisationId, authorisationServerId, redirectUri, payment })— open the payment consent. Thepaymentcarriesvalue,cpfCnpj,redirectUri, and thecreditor(for a QR/boleto instead, sendpayment.qrCode). ReturnsCreatedPayment { id, redirectUrl };idis thepaymentRequestId.- [redirect] send the payer to
created.redirectUrl. They authenticate and authorize in the bank, then return to yourredirectUri. payments.getRequest(created.id)— poll for the status.isRequestPaid(request)returnstrueonce any payment hasstatus: PAGO.
Sequence diagram
Carregando diagrama…
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.');// 1) Create the payment consent (transfer by receiver data)
CreatedPayment created = client.consents.create(new CreateConsentRequest()
.organisationId(organisationId).authorisationServerId(authorisationServerId)
.redirectUri("https://minha-loja.com.br/retorno")
.payment(ConsentPayment.transfer(150.5, cpf,
"https://minha-loja.com.br/retorno", creditor)));
System.out.println("paymentRequestId = " + created.id());
// 2) Redirect the payer to created.redirectUrl(), then poll after they return
PaymentRequest request = client.payments.getRequest(created.id());
System.out.println(Helpers.isRequestPaid(request) ? "PAGO" : "Ainda nao pago.");// 1) Create the payment consent (transfer by receiver data)
let created = try await client.consents.create(CreateConsentRequest(
organisationId: organisationId, authorisationServerId: authorisationServerId,
payment: .transfer(value: 150.5, cpfCnpj: cpf,
redirectUri: "https://minha-loja.com.br/retorno", creditor: creditor),
redirectUri: "https://minha-loja.com.br/retorno"))
print("paymentRequestId =", created.id)
// 2) Redirect the payer to created.redirectUrl, then poll after they return
let request = try await client.payments.getRequest(created.id)
print(Helpers.isRequestPaid(request) ? "PAGO" : "Ainda nao pago.")// 1) Create the payment consent (transfer by receiver data)
var created = await client.Consents.CreateAsync(new CreateConsentRequest
{
OrganisationId = organisationId,
AuthorisationServerId = authorisationServerId,
RedirectUri = "https://minha-loja.com.br/retorno",
Payment = ConsentPayment.ForTransfer(150.5, cpf, "https://minha-loja.com.br/retorno", creditor),
});
Console.WriteLine($"paymentRequestId = {created.Id}");
// 2) Redirect the payer to created.RedirectUrl, then poll after they return
var request = await client.Payments.GetRequestAsync(created.Id);
Console.WriteLine(Helpers.IsRequestPaid(request) ? "PAGO" : "Ainda nao pago.");Next steps
- Scheduled Pix — the same flow plus a
schedulefor future or recurring payments. - Pay a QR Code — the JSR (device-signed) alternative, with no redirect.
- Error handling — handle rejected and expired payment requests.