Hosted Checkout Page

The Hosted Checkout Page provides a unified payment UI with three options:

  1. Google Pay
  2. Instant Bank Transfer
  3. Pay by Card

Flow: user taps Pay → Hosted Checkout Page opens → user selects a payment method → result is returned via PBLPaymentResult.

Integration

  1. Fetch session configuration
private suspend fun fetchSessionConfiguration(): PBLConfiguration {
    val response = apiClient.initPayment()
    return PBLConfiguration(
        sessionId = response.sessionId,
        ephemeralKey = response.ephemeralKey,
        userId = "user_id_from_app",
        environment = PBLEnvironment.SANDBOX
    )
}
  1. Launch the Hosted Payment Page
private var payablSDK: PayablSDK? = null

private fun placeOrderWithSessionInit() {
    lifecycleScope.launch {
        val configuration = fetchSessionConfiguration()
        payablSDK = PayablSDK.init(configuration)
        payablSDK?.start(supportFragmentManager) { result ->
            handlePaymentResult(result)
        }
    }
}
  1. Handle results
private fun handlePaymentResult(result: PBLPaymentResult) {
    when (result) {
        is PBLPaymentResult.Completed -> {
            // Payment successful
        }
        is PBLPaymentResult.Canceled -> {
            // User cancelled
        }
        is PBLPaymentResult.Failed -> {
            // Payment failed
        }
    }
    payablSDK = null
}