Skip to content
Last updated

Android SDK Reference

The Banxa Android SDK (BanxaPaymentSDK) is a headless Kotlin interface to Banxa Hosted Checkout for native Android apps. You initialise it once and render the StartPayment composable to run a payment. The SDK checks eligibility, creates the order, presents checkout, and reports the outcome through callback lambdas.

For the end-to-end walkthrough, see the Android SDK Integration Guide.


Requirements

RequirementVersion
Android API level24 and above
Kotlin2.0 and above, with the Compose Compiler Gradle plugin
Jetpack ComposeEnabled in your project

Installation

The SDK is distributed as an AAR. Copy it into your module's libs directory and reference it from your Gradle build file.

dependencies {
    implementation(files("libs/BanxaPayment-1.0.0.aar"))
}
AAR distribution

The Android SDK is not currently published to a Maven repository, so it does not resolve by coordinate and does not update through your dependency manager. Contact Banxa to obtain the AAR and to be notified when a new version is released.


Configuration

val config = BanxaConfig.Builder()
    .apiKey("YOUR_API_KEY")
    .partnerID("your-partner-id")
    .environment(Environment.SANDBOX)
    .build()

Banxa.initialize(config)

BanxaConfig.Builder

MethodRequiredDescription
apiKey(String)YesYour v2 API key from the merchant dashboard.
partnerID(String)YesYour partner identifier.
environment(Environment)YesEnvironment.SANDBOX or Environment.PRODUCTION.
primerTheme(PrimerTheme)NoOverrides the native payment sheet colour tokens. Relevant only when the native payment sheet is in use. See Banxa Native.

Requests use x-api-key authentication.

Environments

EnvironmentHost
Environment.SANDBOXhttps://api.banxa-sandbox.com
Environment.PRODUCTIONhttps://api.banxa.com

The effective base URL is <host>/{partnerID}/v2. Sandbox and production credentials are separate and are not interchangeable.


StartPayment

StartPayment is a composable. Render it when the customer confirms.

StartPayment(
    createOrderRequest = CreateOrderRequest(
        fiat = "EUR",
        crypto = "ETH",
        fiatAmount = "40",
        cryptoAmount = null,
        walletAddress = "0x0000000000000000000000000000000000000000",
        redirectUrl = "your-app-scheme://banxa-return",
        paymentMethodId = "debit-credit-card",
        email = "[email protected]"
    ),
    banxaDidReceiveCheckout = { result ->
        println("Paid: ${result.paymentId ?: result.rawQuery ?: "-"}")
    },
    banxaDidFail = { error ->
        println("Failed: $error")
    },
    banxaDidDismiss = {
        println("Customer dismissed checkout")
    }
)

StartPayment creates the order and presents checkout together. Render it when the customer confirms, not in advance, because Banxa checkout must be loaded within one minute of order creation.

Requires a prior Banxa.initialize(config) call.


Callbacks

All callbacks have a default no-op implementation, so supply only what you need.

CallbackFires when
banxaDidReceiveCheckoutThe customer completed payment. Receives a checkout result.
banxaDidFailAny Banxa, network, validation, or checkout failure.
banxaDidDismissThe customer closed checkout without completing.

Checkout result

FieldPopulated when
paymentIdThe native payment sheet was used.
orderIdThe native payment sheet was used.
statusThe native payment sheet was used.
rawQueryBanxa checkout was used. Contains the terminal success URL query string.

The success callback is a UI signal, not the authoritative order state. Confirm the final state from webhooks or Order Lookup before you credit a customer.


Models

CreateOrderRequest

FieldTypeRequiredDescription
paymentMethodIdStringYesBanxa payment method id, for example google-pay.
cryptoStringYesCrypto asset symbol, for example ETH.
fiatStringYesFiat currency code, for example EUR.
fiatAmountStringYesFiat amount as a string.
walletAddressStringYesDestination wallet address.
emailStringYesCustomer email address.
redirectUrlStringYesURL Banxa redirects to after checkout.
idString?NoYour order id.
blockchainString?NoExplicit blockchain network.
cryptoAmountString?NoCrypto amount when ordering by crypto value.
walletAddressTagString?NoTag or memo for chains that require it.
subPartnerIdString?NoSub-partner identifier.
metadataString?NoOpaque metadata string.
externalCustomerIdString?NoYour stable customer identifier.
externalOrderIdString?NoYour order reference.
discountCodeString?NoPromotion or discount code.
A missing memo can permanently lose funds

XRP, XLM, EOS, and ATOM require a memo or tag. Pass it as walletAddressTag. An order to one of these chains without the memo can be unrecoverable.


Configuration endpoints

Use these to populate payment method selectors and currency pickers at runtime instead of hardcoding values. Each returns a Result.

val repository = BanxaRepository(
    RetrofitClient.getApi(config.baseUrl, config.environment)
)

Payment methods

GET /{partnerID}/v2/payment-methods/{orderType}. Optionally filter with fiat.

val result = repository.getPaymentMethods(
    partner = config.partner,
    apiKey = config.apiKey,
    orderType = "buy",
    fiat = "USD" // optional
)

result.onSuccess { methods ->
    methods.forEach { method ->
        println("${method.id}: ${method.name} to ${method.supportedFiats}")
    }
}
PaymentMethod fieldTypeNotes
idStringPayment method id, for example apple-pay.
nameStringDisplay name.
descriptionString?Human-readable description.
supportedFiatsList<String>Fiat codes available for this method.

Countries

GET /{partnerID}/v2/countries. The list is the same for buy and sell.

val result = repository.getCountries(
    partner = config.partner,
    apiKey = config.apiKey
)
TypeFields
Countryid, description, states: List<CountryState>
CountryStateid, description

states is empty when the country has no state breakdown.

Fiats

GET /{partnerID}/v2/fiats/{orderType}. Includes payment method minimum and maximum limits.

val result = repository.getFiats(
    partner = config.partner,
    apiKey = config.apiKey,
    orderType = "buy"
)
TypeFields
Fiatid, description, symbol?, supportedPaymentMethods: List<FiatPaymentMethod>
FiatPaymentMethodid, name, minimum?, maximum?

Cryptocurrencies

GET /{partnerID}/v2/crypto/{orderType}.

val result = repository.getCrypto(
    partner = config.partner,
    apiKey = config.apiKey,
    orderType = "buy"
)
TypeFields
Cryptoid, description, blockchains: List<Blockchain>
Blockchainid, description, isDefaultBlockchain, address?, network?, minimum?, unsupportedCountries: Map<String, List<String>>

In unsupportedCountries, the key is a country code and the value is the restricted state codes. An empty list means the whole country is restricted.

Quotes

GET /{partnerID}/v2/quotes/{orderType}. Do not cache: call immediately before showing a price.

val result = repository.getQuote(
    partner = config.partner,
    apiKey = config.apiKey,
    orderType = "buy",
    request = QuoteRequest(
        fiat = "AUD",
        crypto = "ETH",
        blockchain = "ETH",
        paymentMethodId = "debit-credit-card",
        fiatAmount = "200"
    )
)
QuoteRequest fieldTypeRequiredNotes
fiatStringYesFiat currency code.
cryptoStringYesCrypto asset symbol.
blockchainStringYesBlockchain network.
paymentMethodIdStringYesPayment method id.
fiatAmountString?ConditionalProvide this or cryptoAmount.
cryptoAmountString?ConditionalProvide this or fiatAmount.
externalCustomerIdString?NoYour customer identifier, for more accurate pricing.
ipAddressString?NoCustomer IP for regional pricing.
discountCodeString?NoPromotion or discount code.
Quote fieldTypeNotes
paymentMethodIdStringPayment method the quote applies to.
cryptoAmountStringCrypto the customer receives.
fiatAmountStringFiat the customer spends.
processingFeeString?Banxa processing fee in fiat.
networkFeeString?Blockchain network fee in fiat.
discountQuoteDiscount?Present when a discount code was applied.

Error handling

Failures are surfaced through banxaDidFail. Banxa-originated failures are APIError, covering invalid URL, non-2xx server response, unauthorised (401), decoding failure, no network connectivity, missing credentials, uninitialised SDK, checkout failure, and unknown.

Show user-facing messages only from validated error fields. Do not expose raw error strings that may include internal detail. See Error Codes.


Not available in the SDK

CapabilityReasonAlternative
Order lookup by id or customerNot exposedOrder Lookup via the API
Full order list across all customersNot exposedGET /{partnerRef}/v2/orders via API integration
KYC data sharing (Sumsub token share)Requires HMAC authentication, which the SDK does not useKYC Sharing
Off-ramp (sell) ordersThe SDK covers buy orders onlyCreate Sell Order

Payment methods and supported fiats

Availability varies by partner, region, and order type. Treat getPaymentMethods as the source of truth. The table below is a static reference.

Payment method idSupported fiats
debit-credit-cardAED, ARS, AUD, BRL, CAD, CHF, CZK, DKK, EUR, GBP, HKD, IDR, INR, JPY, KRW, MXN, MYR, NGN, NOK, NZD, PHP, PLN, QAR, RUB, SAR, SEK, SGD, THB, TRY, TWD, USD, VND, ZAR
google-payAUD, EUR, USD
apple-payAUD, EUR, GBP, USD
payid-bank-transferAUD
pixBRL
zar-bank-transferZAR
pseCOP
khipuCLP
interac-bank-transferCAD
klarna-paynowEUR
ideal-bank-transferAUD, EUR
sepa-bank-transferEUR
gbp-bank-transferGBP
speiMXN

For the full list, see Supported Payment Methods.


Next steps