Pular para o conteúdo

Pay a QR Code

Pay a boleto or Pix QR Code with an already-linked account. The payer approves the payment on their device with the passkey registered during account linking — no redirection.

Method sequence

  1. enrollments.listByUserJsr(cpf, { deviceId }) — gate: confirm the payer has an AUTHORISED enrollment and pick it.
  2. pix.getDetails({ qrCode }) — decode the QR Code to show the payee, amount, and account before charging.
  3. consents.createJsr(req) — open a JSR consent with the qrCode. Returns { id, consentId, fidoSignOptions }. id is the paymentRequestId you pass in step 5.
  4. [device] the device calls navigator.credentials.get() with consent.fidoSignOptions and produces a FIDO2 assertion.
  5. payments.processJsr(req) — submit the assertion plus riskSignals to execute the payment. Check the result with the isPaid helper.

Steps 4–5 are identical across every JSR flow — see Execute a JSR payment for the full code.

Sequence diagram

Pay a QR Code — gate on the enrollment, decode, consent, sign on device, execute

Code

Steps 1–3: gate on the enrollment, decode the QR Code, and open the consent. consents.createJsr requires the clientIp (the X-Client-IP header).

// 1) Gate: an AUTHORISED enrollment is required
const user = await client.enrollments.listByUserJsr(cpf, { deviceId: riskSignals.deviceId });
const enrollment = user.enrollments[0];

// 2) Decode the QR Code (display)
const details = await client.pix.getDetails({ qrCode });

// 3) Create the consent
const consent = await client.consents.createJsr({
enrollmentId: enrollment.enrollmentId,
payment: { qrCode, redirectUri: 'https://app.example.com/payment-success' },
fidoSignOptions: { platform: 'ANDROID' },
}, { clientIp });
// consent.id is the paymentRequestId — sign on device and call payments.processJsr,
// see Execute a JSR payment

Next steps