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
}

Best Practises

DO:

  • Create a new session for each payment attempt.
  • Initialize PayablSDK only when user starts payment.
  • Clean up payablSDK after receiving a result.

DON'T:

  • Reuse sessions across multiple payments.
  • Initialize SDK at app startup.
  • Share sessions between users.

Testing

Sandbox Configuration

Use sandbox while developing:

val configuration = PBLConfiguration(
    sessionId = "sandbox_session_id",
    ephemeralKey = "sandbox_ephemeral_key",
    userId = "test_user_123",
    environment = PBLEnvironment.SANDBOX
)

Test Scenarios (Pay by Card)

Here are the comprehensive test scenarios for Pay by Card using the provided test card numbers. Use Sandbox environment (PBLEnvironment.SANDBOX) for all tests.

Test Card Details

  • Expiry Date: Any future date (MM/YY later than current date, e.g., 12/27)
  • CVV/CVC: Any 3 digits (e.g., 123)

Success Scenarios

Card NetworkCard NumberExpected ResultNotes
Mastercard5232050000010003PBLPaymentResult.CompletedSuccessful authorization
VISA4149011500000147PBLPaymentResult.CompletedSuccessful authorization

Decline Scenarios

Card NetworkCard NumberExpected ResultError CodeError Meaning
VISA4024007119078466PBLPaymentResult.Failed.Error51Insufficient funds
VISA4532904789286871PBLPaymentResult.Failed.Error41Lost card / Do Not Honor