Getnet DocsGetnet Docs

Process a Sale

This guide shows how to start a sale with the SDK White Label. You can let the SDK collect the amount and the payment method, or fix them from your application.

How it works

You start a sale with initSale. The saleSetup parameter decides who provides the amount and the payment method. The SDK presents the screens, runs the transaction, and returns the outcome through a callback (see Transaction result).

The call returns immediately; the result arrives later in onPaymentResult. A successful warm-up (WarmUpStatus.Success) is required.

Before you begin

Optionally, check which methods are enabled for the terminal. Both functions are suspend, so call them from a coroutine:

lifecycleScope.launch {
    val apolo = ApoloSdk.getClient()
    val available = apolo.getAvailablePaymentTypes()          // Set<IMethod>
    val pixEnabled = apolo.isPaymentTypeAvailable(IBrSaleMethod.Pix)
}

Guided sale (the SDK collects the data)

Use Default to let the user choose both the amount and the method on the SDK screens. Use Amount to fix the amount and let the user choose the method:

val apolo = ApoloSdk.getClient()

// the user informs the amount and the method
apolo.initSale(context = activity, onPaymentResult = { result -> /* ... */ })

// the application fixes the amount; the user chooses the method
apolo.initSale(
    context = activity,
    saleSetup = Amount(amountInCents = 1990L), // R$ 19.90
    onPaymentResult = { result -> /* ... */ },
)

Amounts are always in cents and must be greater than zero. Amount(19) means R$ 0.19, not R$ 19.00.

Direct sale (the application fixes the amount and the method)

Fix both the amount and the method with a BrSaleSetup variant.

Credit

Credit supports a single payment and installments:

// single payment
apolo.initSale(
    context = activity,
    saleSetup = BrSaleSetup.Credit(amountInCents = 15000L), // R$ 150.00
    onPaymentResult = { result -> /* ... */ },
)

// installments
apolo.initSale(
    context = activity,
    saleSetup = BrSaleSetup.Credit(
        amountInCents = 15000L,
        installmentPlan = CreditInstallmentPlan(
            installments = 3,
            installmentType = CreditInstallmentType.MERCHANT_NO_INTEREST,
        ),
    ),
    onPaymentResult = { result -> /* ... */ },
)

For installments, installments must be greater than 1. installmentType selects who finances the plan:

  • MERCHANT_NO_INTEREST — the merchant absorbs the cost; the cardholder pays no interest.
  • ISSUER_WITH_INTEREST — the issuer finances; the cardholder pays interest.

Debit, Voucher, and Pix

Each variant takes only the amount in cents:

apolo.initSale(context = activity, saleSetup = BrSaleSetup.Debit(amountInCents = 8990L))   // R$ 89.90
apolo.initSale(context = activity, saleSetup = BrSaleSetup.Voucher(amountInCents = 3500L)) // R$ 35.00
apolo.initSale(context = activity, saleSetup = BrSaleSetup.Pix(amountInCents = 12000L))    // R$ 120.00

For Pix, the SDK generates and displays the QR Code and monitors the payment before returning the result.

Read the result

The outcome arrives in onPaymentResult. Treat result.result == "00" as an approval and any other value as a non-approval. See Transaction result for the codes and the payload.

Next steps