Android SDK
Drop-in
Launch the pre-built Plexy checkout UI in your Android app
Drop-in
Drop-in is the fastest way to integrate Plexy: a single launcher renders the full checkout UI as an Activity and returns a result for you to handle.
Quick Start (Compose)
import money.plexy.checkout.dropin.compose.PlexyCheckout
@Composable
fun CheckoutScreen(sessionId: String, sessionData: String) {
val checkoutLauncher = rememberPlexyCheckoutLauncher(
callback = { result ->
when (result) {
is PlexyCheckoutResult.Finished -> { /* handle */ }
is PlexyCheckoutResult.Error -> { /* handle */ }
is PlexyCheckoutResult.Cancelled -> { /* handle */ }
}
}
)
Button(onClick = {
checkoutLauncher.start(
checkoutSession = CheckoutSession(
id = sessionId,
sessionData = sessionData
),
configuration = checkoutConfiguration()
)
}) {
Text("Pay 100 KZT")
}
}Quick Start (Views)
class CheckoutActivity : AppCompatActivity() {
private lateinit var checkoutLauncher: PlexyCheckoutLauncher
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
checkoutLauncher = PlexyCheckoutLauncher(this) { result ->
handleResult(result)
}
findViewById<Button>(R.id.payButton).setOnClickListener {
startCheckout()
}
}
private fun startCheckout() {
checkoutLauncher.start(
checkoutSession = CheckoutSession(id, sessionData),
configuration = checkoutConfiguration()
)
}
}Configuration
val configuration = CheckoutConfiguration(
environment = Environment.TEST,
clientKey = BuildConfig.PLEXY_CLIENT_KEY,
shopperLocale = Locale("en", "KZ"),
amount = Amount(value = 10000, currency = "KZT"),
) {
card {
setHolderNameRequired(true)
setShowStorePaymentField(true)
}
googlePay {
setMerchantAccount("YOUR_MERCHANT_ACCOUNT")
}
}Google Pay
Add the dependency:
implementation 'money.plexy.checkout:google-pay:1.0.0'Then enable in configuration:
val googlePayConfig = GooglePayConfiguration.Builder(
locale = Locale("en", "KZ"),
environment = Environment.TEST,
clientKey = BuildConfig.PLEXY_CLIENT_KEY
)
.setMerchantAccount("YOUR_MERCHANT_ACCOUNT")
.setAmount(Amount(value = 10000, currency = "KZT"))
.build()Error Handling
private fun handleResult(result: PlexyCheckoutResult) {
when (result) {
is PlexyCheckoutResult.Finished -> {
Toast.makeText(this, "Success: ${result.resultCode}", LENGTH_SHORT).show()
}
is PlexyCheckoutResult.Error -> {
Log.e("Plexy", "Error: ${result.errorMessage}", result.exception)
}
is PlexyCheckoutResult.Cancelled -> {
// User cancelled
}
}
}