EdfaPay Logo

Direct Sale (Headless)

Bypass the bundled UI and drive the sale yourself with EdfaPgSdk.sale(SaleRequest). You supply the order, customer, billing address, invoice, card, and a computed hash; the SDK returns the raw gateway response.

Overview

Headless mode is for apps that already have their own checkout. You capture the card, build a SaleRequest, and call sale(...). Direct (headless) API calls work from any layer — including pure ViewModels — because there is no bundled UI to host.

You become PCI-relevant

Going headless means your app captures raw card data, so you take on PCI scope (SAQ-A-EP). Never log raw PANs. If you'd rather stay out of scope, use the bundled Card Checkout instead.

Calling sale()

sale(...) is a suspend function on Kotlin, async on Swift, and returns a Future on Flutter. Pass the full SaleRequest — order, amount, currency, auth / recurringInit flags, customer, billing address, invoice, result URLs, the computed hash, and the card.

Loading...

Response Shape

The response mirrors EdfaPay's gateway response — a JsonObject (Kotlin/Swift) or Map<String, dynamic> (Flutter). Read result / status to branch, and errorCode / errorMessage on failure. See Error Handling for the full pattern.

FieldExampleMeaning
resultSUCCESSTop-level outcome — branch on this first.
statusAPPROVEDGateway transaction status.
ida1b2c3d4-…-ef01The gateway transaction UUID.
orderIdORDER-1234Your merchant order id, echoed back.
rrn123456789012Retrieval Reference Number.
errorCode / errorMessagenull / nullPopulated when the call fails.

Idempotency

sale is not idempotent. Always pre-generate your orderId, and before retrying a timed-out sale call getTransactionByOrderId(orderId) to see whether the gateway already booked the charge.