Skip to content

Quickstart

Before reading this document, ensure you have completed the Integration Guide and are familiar with the APIs for creating a checkout.

The Android SDK provided by PayKKa allows you to easily embed our Web Checkout via a WebView. By simply providing a sessionId to the SDK, you can open the checkout page within your app, accept payments, and customize payment callbacks. The latest SDK download link is available in the Android SDK Release History.

Step 1: Integrate the SDK into Your Project

After downloading the SDK, you will receive a .zip file with the following directory structure:

.
├── libs
│   └── paykka-checkout-payments-1.0-alpha-Release.aar
└── PayKKaCheckoutApp-Android
    ├── JavaCheckoutDemo
    │   ├── app
    │   ├── build.gradle
    │   ├── gradle
    │   ├── gradle.properties
    │   ├── gradlew
    │   ├── gradlew.bat
    │   └── settings.gradle
    └── KotlinCheckoutDemo
        ├── app
        ├── build.gradle.kts
        ├── gradle
        ├── gradle.properties
        ├── gradlew
        ├── gradlew.bat
        └── settings.gradle.kts

The PayKKaCheckoutApp-Android folder contains sample Android projects in Java and Kotlin, allowing developers to understand how to use the PayKKa SDK APIs through sample code.

The .aar file in the libs folder is the core PayKKa SDK. Copy the libs folder from the zip file into your Android project's app/ directory (e.g., YourAppProject/app/). Then, edit your app/build.gradle.kts or app/build.gradle file and add the following code to integrate and use the SDK:

app/build.gradle.kts
plugins {
    ...
}

android {
    ...
}

dependencies {
    ...
    // Required, for JSON serialization/deserialization
    implementation("com.alibaba:fastjson:1.2.83")
    // Required, the SDK uses WebKit features
    implementation("androidx.webkit:webkit:1.14.0")
    // Required, includes all libraries and dependencies in the libs directory
    implementation(
        fileTree(
            mapOf(
                "dir" to "libs",
                "include" to listOf("*.aar", "*.jar")
            )
        )
    )
}

Step 2: Use the SDK in Your Project

Once the SDK is integrated, you can start using the PayKKa Checkout in your app. Key code snippets are provided below showing how to customize callbacks and launch the checkout to guide users through the payment process.

import ...

class ConfirmOrderActivity : ComponentActivity() {
    val TAG = "ConfirmOrderActivity"
    private lateinit var paykkaLauncher: PayKKaActivityResultLauncher;
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // Ensure registerForActivityResult is called before Activity onCreate
        paykkaLauncher = PayKKa.registerForActivityResult(this) {paymentResult ->
            // Write your payment callback logic here
            val intent = Intent(this, PaymentCompleteActivity::class.java)
            intent.putExtra("paymentResult", paymentResult.toString())
            startActivity(intent)
            finish()
        }

        setContent {
            KotlinCheckoutDemoTheme {
                ConfirmOrderScreen {
                    goPay()
                }
            }
        }
    }

    private fun goPay() {
        // Switch PayKKa environment
        PayKKa.useEnv(PayKKaEnv.SANDBOX)
        // Tapping the "Confirm Payment" button launches the checkout (the sessionId is typically returned by your app's backend API)
        paykkaLauncher.goPay("CSXXXXXXXXXXXXXXXXXX")
    }

    override fun onActivityResult(
        requestCode: Int,
        resultCode: Int,
        data: Intent?
    ) {
        super.onActivityResult(requestCode, resultCode, data)
    }
}

Step 3: Test the Payment

You can use test cards in the PayKKa SANDBOX environment for testing. Switch to the PROD environment when building the release version of your app.

/// SANDBOX (default)
PayKKa.useEnv(PayKKaEnv.SANDBOX)
/// Switch to European production environment
PayKKa.useEnv(PayKKaEnv.PROD_EU)
/// Switch to Hong Kong production environment
PayKKa.useEnv(PayKKaEnv.PROD_HK)

Precautions

Google Pay

1. How to use test cards for payment testing?

Please refer to: Payment Method - Google Pay.

2. Google Pay unable to receive payments in PROD environment, error "OR_BIBED_11"

Google Pay uses test environments and mock data during testing, but processes real user payment card information once live. To protect user and merchant funds and privacy, Google requires:

  • A supported payment gateway (e.g., PayKKa) or
  • A PCI DSS-compliant (Payment Card Industry Data Security Standard) environment to apply for production access. This ensures you can safely handle sensitive payment information beyond development and test modes.

Therefore, you must also complete the Google Pay - Publish your integration steps.