Getnet DocsGetnet Docs

Process a Refund

This guide shows how to reverse a previously approved transaction with initRefund.

How it works

You start a refund with initRefund. The refundData parameter decides who provides the paymentId:

  • Direct refund — your application provides a known paymentId.
  • Indirect refund — the user finds the transaction on the SDK screens.

The outcome arrives through a callback (see Transaction result). A successful warm-up (WarmUpStatus.Success) is required.

Refunds apply only to credit and debit transactions. Pix and voucher transactions cannot be refunded.

Before you begin

For a direct refund, keep your own transaction history. The SDK does not expose past transactions, and the paymentId returned in the sale’s result is the key to refund it. Store the paymentId — you do not need to store card data.

Direct refund

Provide the paymentId you persisted from the original sale:

ApoloSdk.getClient().initRefund(
    context = activity,
    refundData = Refund(paymentId = paymentIdFromYourRecord),
    onResult = { result -> /* see Transaction result */ },
)

Indirect refund

Omit refundData (or pass an empty paymentId) to let the SDK guide the search on its own screens:

ApoloSdk.getClient().initRefund(
    context = activity,
    onResult = { result -> /* see Transaction result */ },
)

Read the result

The outcome arrives in onResult. On success, the payload is an ICancelPaymentResponse. See Transaction result for the codes and the payload fields.

Next steps