Implementation guides

Financing & installments

Financing lets a contact pay over time instead of all at once. Qualy supports two financing providers: PagBank for Brazilian credit-card installments (parcelamento), and Klarna for pay-later and pay-over-time options in supported regions.

Working with financing is a two-step flow:

  1. Retrieve options — find out which financing types are available for an amount or Payment Intent, and the maximum number of installments.
  2. Simulate a plan — pick a number of installments and get the exact per-installment amount, the total with interest, and the fees.

Amounts are in cents

Every monetary value in these endpoints is an integer in minor currency units (cents). 5000 means R$ 50.00. Rates such as feePercentage and interestRate are decimals — 0.0405 means 4.05%.


Gateways & methods

Each request must name the gateway and its financing method. The valid combinations are:

GatewaygatewaymethodRegionFinancing typesSimulate?
PagBankpagbankPGBNK_CCBrazil (BRL only)installments (up to 18x)Yes
KlarnaklarnaKLARNA_PYMTKlarna-supported regionspay-later, installments (4x)No

Retrieving financing options

Call POST /v1/payment-gateways/financing/options to see what is available. You can describe the amount in one of two ways:

  • Pass a paymentIntent ID — Qualy uses the Payment Intent's outstanding due amount.
  • Pass an amount and currency directly — useful before a Payment Intent exists (e.g. on a checkout page).

Klarna requires a Payment Intent

The amount + currency shortcut works only with PagBank. Klarna always needs a paymentIntent, since available categories depend on the payer's country and the settlement currency.

Request fields

FieldRequiredDescription
gatewayYespagbank or klarna.
methodYesPGBNK_CC for PagBank, KLARNA_PYMT for Klarna.
paymentIntentConditionalA Payment Intent ID. Required when amount/currency are omitted, and always required for Klarna.
amountConditionalAmount to finance, in cents. Required (with currency) when paymentIntent is omitted. PagBank only.
currencyConditionalISO 4217 currency code. Must be BRL for PagBank. Required when paymentIntent is omitted.

Example (PagBank)

try {
  const response = await fetch(
    'https://api.qualyhq.com/v1/payment-gateways/financing/options',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': 'ApiKey your-api-key-here',
        'X-TENANT-ID': 'your-tenant-id-here',
      },
      body: JSON.stringify({
        gateway: 'pagbank',
        method: 'PGBNK_CC',
        amount: 135000, // R$ 1,350.00
        currency: 'BRL',
      }),
    }
  );

  const { data } = await response.json();
  console.log(data.options);
} catch (error) {
  console.error(error);
}

The response lists the available financing types. For PagBank, nInstallments is the maximum number of installments the buyer can choose from (1 up to this value):

{
  "data": {
    "options": [
      {
        "type": "installments",
        "amount": 135000,
        "currency": "BRL",
        "nInstallments": 12
      }
    ]
  }
}

Minimum amount

PagBank only offers multiple installments above R$ 20.00 (2000 cents). Below that, the response returns a single option with nInstallments: 1.

Example (Klarna)

try {
  const response = await fetch(
    'https://api.qualyhq.com/v1/payment-gateways/financing/options',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': 'ApiKey your-api-key-here',
        'X-TENANT-ID': 'your-tenant-id-here',
      },
      body: JSON.stringify({
        gateway: 'klarna',
        method: 'KLARNA_PYMT',
        paymentIntent: '6634f56c7dbbc16e07b5025e',
      }),
    }
  );

  const { data } = await response.json();
  console.log(data.options);
} catch (error) {
  console.error(error);
}

Klarna returns one entry per available category. pay-later settles the full amount on a later date; installments splits it into four payments:

{
  "data": {
    "options": [
      { "type": "pay-later", "amount": 135000, "currency": "AUD" },
      { "type": "installments", "amount": 135000, "currency": "AUD", "nInstallments": 4 }
    ]
  }
}

Option fields

FieldDescription
typeinstallments (pay in parts) or pay-later (pay the full amount later).
amountThe amount being financed, in cents.
currencyThe settlement currency the contact pays in.
nInstallmentsFor PagBank, the maximum number of installments available. For Klarna installments, the fixed count (4). Absent for pay-later.

Simulating a plan

Once you know the maximum number of installments, call POST /v1/payment-gateways/financing/simulate with a specific nInstallments to get the exact cost breakdown.

PagBank only

Simulation is supported for PagBank (PGBNK_CC) only. Klarna calculates and presents its own plans at checkout, so there is no simulate step for Klarna.

Each simulation is persisted and returns an _id. Keep this ID — it is the reference to the chosen plan and appears on the resulting transaction's financing details.

Request fields

Same as the options endpoint, plus a required nInstallments:

FieldRequiredDescription
gatewayYesMust be pagbank.
methodYesMust be PGBNK_CC.
nInstallmentsYesThe number of installments to simulate (minimum 1). Must be within the maximum returned by the options endpoint.
paymentIntentConditionalA Payment Intent ID. Required when amount/currency are omitted.
amountConditionalAmount to finance, in cents. Required (with currency) when paymentIntent is omitted.
currencyConditionalMust be BRL. Required when paymentIntent is omitted.

Example

try {
  const response = await fetch(
    'https://api.qualyhq.com/v1/payment-gateways/financing/simulate',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': 'ApiKey your-api-key-here',
        'X-TENANT-ID': 'your-tenant-id-here',
      },
      body: JSON.stringify({
        gateway: 'pagbank',
        method: 'PGBNK_CC',
        amount: 135000, // R$ 1,350.00
        currency: 'BRL',
        nInstallments: 12,
      }),
    }
  );

  const { data } = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}

Response

{
  "data": {
    "_id": "6634f8a17dbbc16e07b50312",
    "total": 153090,
    "currency": "BRL",
    "method": "PGBNK_CC",
    "nInstallments": 12,
    "installmentAmount": 12758,
    "feePercentage": 0.1340,
    "interestRate": 0.1182
  }
}
FieldDescription
_idThe persisted simulation ID. Reference this plan when collecting the payment; it also appears on the transaction's financing details.
totalTotal amount the contact pays across all installments, in cents (original amount + interest + fees).
installmentAmountThe amount of each individual installment, in cents. total ÷ nInstallments, with each installment rounded up to the cent.
nInstallmentsThe number of installments simulated.
feePercentageThe effective uplift over the original amount: (total − amount) / amount. This is the number to show the buyer as the real cost of financing.
interestRateThe raw provider rate used to build the plan. Usually lower than feePercentage (see below).
currencyThe currency of the plan (BRL).
paymentIntentEchoed back when the simulation was created from a Payment Intent.
operationFeeAn optional fixed operation fee, in cents, when applicable.

feePercentage vs. interestRate

interestRate is the raw, fee-on-total rate PagBank applies internally (total = (amount + flat fee) / (1 − rate)). feePercentage is the effective increase the buyer actually pays versus the original amount — it is higher because it also includes a flat per-transaction fee and per-installment cent rounding. Show feePercentage to the buyer as the true cost of paying in installments.


Partial amounts

When financing against a Payment Intent, you can finance less than the full due by also passing an amount (in cents). Qualy clamps it to the outstanding amount so the contact is never overcharged. Omit amount to finance the full balance.


Cross-currency financing

A Payment Intent can be denominated in one currency (say AUD) while the contact pays in another. PagBank financing always settles in BRL, so when you finance an AUD Payment Intent:

  • The Payment Intent's settlement currency must resolve to BRL.
  • A locked FX quote must exist on the Payment Intent — Qualy converts the due to BRL at that rate before building the plan.

If the settlement currency is not BRL, or no FX quote is available, the request is rejected. See Collecting payments for how settlement currency is determined.


Next steps

After simulating a plan, collect the payment using the chosen financing method. See Collecting payments for the sign flow, and Setting up webhooks to be notified when each installment is captured.

Previous
Creating subscriptions