Pular para o conteúdo

Pix transfer by key

Send a Pix transfer to a Pix key with an already-linked account. This is the same JSR flow as Pay a QR Code, with one difference: the consent carries the full transfer payload (amount and creditor) built from the Pix key lookup, instead of a QR Code payload.

Method sequence

  1. enrollments.listByUserJsr(cpf, { deviceId }) — gate on an AUTHORISED enrollment.
  2. pix.getDetails({ pixKey }) — resolve the Pix key into the payee's account so you can build the creditor.
  3. consents.createJsr(req) — open a JSR consent with a payment carrying details, value, cpfCnpj, redirectUri, and the creditor. Returns { id, consentId, fidoSignOptions }; id is the paymentRequestId.
  4. [device] the device produces a FIDO2 assertion from consent.fidoSignOptions.
  5. payments.processJsr(req) — submit the assertion and riskSignals to execute the transfer.

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

Sequence diagram

Pix transfer by key — resolve the key, build the creditor, consent, sign on device, execute

Code

The creditor is assembled from the pix.getDetails response, with accountPixKey set to the key you looked up.

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

// 2) Resolve the Pix key into the payee account
const details = await client.pix.getDetails({ pixKey });

// 3) Create the consent with the full transfer payload
const consent = await client.consents.createJsr({
enrollmentId: enrollment.enrollmentId,
payment: {
  details: 'Pix transfer',
  value: 300.06,
  cpfCnpj: cpf,
  redirectUri: 'https://app.example.com/payment-success',
  creditor: {
    name: details.account.name,
    personType: details.account.personType,
    cpfCnpj: details.account.cpfCnpj,
    accountNumber: details.account.accountNumber,
    accountIssuer: details.account.accountIssuer,
    accountPixKey: details.pixKey,
    accountIspb: details.account.accountIspb,
    accountType: details.account.accountType,
  },
},
fidoSignOptions: { platform: 'ANDROID' },
}, { clientIp });
// consent.id is the paymentRequestId — sign on device and call payments.processJsr,
// see Execute a JSR payment

Next steps