palbaseDocs

Payments

Android SDK

studio.palbase:palbase-payments and studio.palbase:palbase-payments-ui bring provider-agnostic card checkout (Stripe and iyzico), 3D Secure (Custom Tabs + WebView cookie/JavascriptInterface bridge), saved cards, BIN installments, billing portal, recurring subscriptions, and closed-loop wallets with pure-Kotlin ISO/IEC 18004 QR spend tokens to Android (minSdk 26, Kotlin 2.2+).

Install

Add palbase-payments for headless checkout and palbase-payments-ui for optional drop-in PCI-DSS SAQ-A Jetpack Compose screens:

// app/build.gradle.kts
dependencies {
    implementation(platform("studio.palbase:palbase-bom:0.21.0"))
    implementation("studio.palbase:palbase")
    implementation("studio.palbase:palbase-payments")
    implementation("studio.palbase:palbase-payments-ui")
}

Forward payment return deep links in your activity's onNewIntent:

import studio.palbase.payments.payments

class CheckoutActivity : ComponentActivity() {
    override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)
        pb.payments.handleRedirectIntent(intent)
    }
}

Headless API (pb.payments)

SurfaceMethods / PropertiesWhat it does
Discoverycapabilities(currency, channel), installments(amount, currency, bin, methodId, channel)Reads active channel capabilities and Turkish BIN installment tables.
Checkoutintent(intentId, clientSecret), confirm(intentId, request, idempotencyKey), submitOtp(intentId, challengeId, otp, clientSecret, saveMethod), present(intent, activity, handlers, timeoutMs)Confirms server-created PaymentIntents, executes canonical NextAction (redirect, embed, otp), and awaits settlement over payment_intent:<ref>:<id> with zero polling.
Return linkshandleRedirectIntent(intent), handleRedirectUrl(url), parsePaymentReturnUrl(...)Delivers Custom Tab / deep-link callbacks to active present(...) flows.
Saved cardssavedMethods(), addSavedMethod(request), deleteSavedMethod(methodId)Lists, vaults (on a Stripe channel), and removes tokenized cards.
Billing profileprofile(), updateProfile(buyer)Reads and updates buyer identity and address fields required by Turkish card processors.
Wallets & QRwalletState, walletUpdates, wallets(), topUpWallet(...), createSpendToken(walletKey, maxAmount, ttlSeconds)StateFlow<WalletState> kept live over payments:<ref>:<uid>, card-to-wallet top-ups, and single-use pst_... QR spend tokens.
Subscriptionssubscriptions(limit, cursor), cancelSubscription(subscriptionId), billingPortal(returnUrl, channel)Lists/cancels recurring subscriptions and opens a self-service billing portal URL.
PluginsregisterPlugin(plugin), unregisterPlugin(id), availablePlugins(context)Optional PaymentMethodPlugin extension slot for native wallets.
import studio.palbase.payments.PaymentResult
import studio.palbase.payments.PaymentsAPI
import studio.palbase.payments.payments

suspend fun confirmAndPresent(activity: Activity, intentId: String, clientSecret: String?): PaymentResult {
    val caps = pb.payments.capabilities(currency = "TRY")
    val confirmed = pb.payments.confirm(
        intentId = intentId,
        request = PaymentsAPI.ConfirmIntentRequest(
            clientSecret = clientSecret,
            saveMethod = caps.capabilities.savedCards,
        ),
    )
    return pb.payments.present(confirmed, activity = activity)
}

Drop-in Compose components (palbase-payments-ui)

Every component in palbase-payments-ui is PCI-DSS SAQ-A compliant (raw PAN and CVV never enter your app) and styled with PaymentAppearance (LocalPaymentAppearance):

import studio.palbase.payments.PaymentResult
import studio.palbase.payments.formatMinorAmount
import studio.palbase.payments.payments
import studio.palbase.payments.ui.PaymentAppearance
import studio.palbase.payments.ui.SavedCardsView
import studio.palbase.payments.ui.SpendQRView
import studio.palbase.payments.ui.WalletTopUpSheet
import studio.palbase.payments.ui.rememberPaymentSheet

@Composable
fun PaymentsScreen(intentId: String) {
    val sheet = rememberPaymentSheet(pb, appearance = PaymentAppearance.Default)
    val walletState by pb.payments.walletState.collectAsState()
    var status by remember { mutableStateOf("") }

    Column {
        walletState.balance("try")?.let { b ->
            Text("Balance: ${formatMinorAmount(b.available, b.currency)}")
        }
        Button(onClick = {
            sheet.present(intentId) { result ->
                status = when (result) {
                    is PaymentResult.Succeeded -> "Paid ${result.intent.id}"
                    PaymentResult.Canceled -> "Canceled"
                    is PaymentResult.Failed -> result.message
                }
            }
        }) {
            Text("Pay Now")
        }
        if (status.isNotEmpty()) Text(status)
        SpendQRView(client = pb, walletKey = "try", ttlSeconds = 60L)
        SavedCardsView(client = pb)
        WalletTopUpSheet(client = pb, walletKey = "try", currency = "TRY") { result ->
            status = when (result) {
                is PaymentResult.Succeeded -> "Topped up ${result.intent.id}"
                PaymentResult.Canceled -> "Top-up canceled"
                is PaymentResult.Failed -> result.message
            }
        }
    }
}