
Implements Stripe payment processing with support for iDEAL, Card, UPI, and CashApp. Features initialization, payment method creation, payment confirmation, and handling next actions for authentication.
This repository provides an implementation of Stripe Payment using Kotlin Multiplatform Mobile (KMM). It supports multiple payment methods, including iDEAL, Card, UPI, and CashApp.
Add Dependencies
Add the Stripe KMM dependency in your shared module's build.gradle.kts under commonMain:
kotlin {
sourceSets {
commonMain {
dependencies {
implementation("io.github.qburst.stripekmm:<version>")
}
}
}
}Add Shared Dependency
Add Swift Package
SwiftKMMStripeKit
Before making any payments, initialize the Stripe SDK with your publishable key:
val stripe = ProvideStripeSdk()
val initialiseParams = InitialiseParams(
publishableKey = "<your_publishable_key>",
appInfo = AppInfo(
name = "<your_app_name>",
version = "<your_app_version>",
partnerId = "<your_partner_id>",
url = "<your_app_url>",
)
)
// Initialize Stripe
CoroutineScope(Dispatchers.Default).launch {
stripe.initialise(initialiseParams)
}Before proceeding with payment, collect user billing details:
val billingDetails = BillingDetails(
name = "<customer_name>",
email = "<customer_email>",
phone = "<customer_phone>"
)The app provides different payment methods. The user selects one from:
var selectedMethod by remember { mutableStateOf("") }Once the user provides the necessary details, create the payment method:
CoroutineScope(Dispatchers.Default).launch {
stripe.createPaymentMethod(
params = when(selectedMethod) {
"Ideal" -> {
CreateParams.IdealParams(
paymentMethodData = CreateParams.PaymentMethodDataIdeal(
bankName = "<ideal_bank_name>",
billingDetails = billingDetails
)
)
}
"Card" -> {
CreateParams.CardParamsWithToken(
paymentMethodData = CreateParams.PaymentMethodDataWithToken(
token = "<card_token>",
billingDetails = billingDetails
)
)
}
"Upi" -> {
CreateParams.UpiParams(
paymentMethodData = CreateParams.PaymentMethodDataUpi(
vpa = "<upi_vpa>",
billingDetails = billingDetails
)
)
}
"CashApp" -> {
CreateParams.CashAppParams(
paymentMethodData = CreateParams.PaymentMethodDataCashApp(
billingDetails = billingDetails
)
)
}
else -> throw IllegalStateException("Invalid payment method selected")
},
options = CreateOptions(FutureUsage.OFF_SESSION),
onSuccess = { result ->
println("Payment Method Created: $result")
},
onError = { error ->
println("Error: $error")
}
)
}Once a payment method is created, confirm the payment:
CoroutineScope(Dispatchers.Default).launch {
stripe.confirmPayment(
paymentIntentClientSecret = "<payment_intent_client_secret>",
params = ConfirmParams.CardParamsWithToken(
paymentMethodData = ConfirmParams.PaymentMethodDataWithToken(
token = "<card_token>",
billingDetails = billingDetails
)
),
options = CreateOptions(FutureUsage.OFF_SESSION),
onSuccess = { result ->
println("Payment Confirmed: $result")
},
onError = { error ->
println("Error: $error")
}
)
}Sometimes, additional steps are required for authentication (e.g., 3D Secure). In such cases, handle next actions:
CoroutineScope(Dispatchers.Default).launch {
stripe.handleNextAction(
paymentIntentClientSecret = "<payment_intent_client_secret>",
returnURL = "<your_return_url>",
onSuccess = { result ->
println("Next Action Handled: $result")
},
onError = { error ->
println("Error: $error")
}
)
}You can customize the following parameters:
BillingDetails(name, email, phone))CreateOptions(FutureUsage.OFF_SESSION))<your_return_url>)<your_publishable_key>)<your_publishable_key>, <payment_intent_client_secret>, <your_return_url>) with your actual credentialsThis project is licensed under the MIT License.
For issues and support, open an issue on the repository or check Stripe Documentation:
This repository provides an implementation of Stripe Payment using Kotlin Multiplatform Mobile (KMM). It supports multiple payment methods, including iDEAL, Card, UPI, and CashApp.
Add Dependencies
Add the Stripe KMM dependency in your shared module's build.gradle.kts under commonMain:
kotlin {
sourceSets {
commonMain {
dependencies {
implementation("io.github.qburst.stripekmm:<version>")
}
}
}
}Add Shared Dependency
Add Swift Package
SwiftKMMStripeKit
Before making any payments, initialize the Stripe SDK with your publishable key:
val stripe = ProvideStripeSdk()
val initialiseParams = InitialiseParams(
publishableKey = "<your_publishable_key>",
appInfo = AppInfo(
name = "<your_app_name>",
version = "<your_app_version>",
partnerId = "<your_partner_id>",
url = "<your_app_url>",
)
)
// Initialize Stripe
CoroutineScope(Dispatchers.Default).launch {
stripe.initialise(initialiseParams)
}Before proceeding with payment, collect user billing details:
val billingDetails = BillingDetails(
name = "<customer_name>",
email = "<customer_email>",
phone = "<customer_phone>"
)The app provides different payment methods. The user selects one from:
var selectedMethod by remember { mutableStateOf("") }Once the user provides the necessary details, create the payment method:
CoroutineScope(Dispatchers.Default).launch {
stripe.createPaymentMethod(
params = when(selectedMethod) {
"Ideal" -> {
CreateParams.IdealParams(
paymentMethodData = CreateParams.PaymentMethodDataIdeal(
bankName = "<ideal_bank_name>",
billingDetails = billingDetails
)
)
}
"Card" -> {
CreateParams.CardParamsWithToken(
paymentMethodData = CreateParams.PaymentMethodDataWithToken(
token = "<card_token>",
billingDetails = billingDetails
)
)
}
"Upi" -> {
CreateParams.UpiParams(
paymentMethodData = CreateParams.PaymentMethodDataUpi(
vpa = "<upi_vpa>",
billingDetails = billingDetails
)
)
}
"CashApp" -> {
CreateParams.CashAppParams(
paymentMethodData = CreateParams.PaymentMethodDataCashApp(
billingDetails = billingDetails
)
)
}
else -> throw IllegalStateException("Invalid payment method selected")
},
options = CreateOptions(FutureUsage.OFF_SESSION),
onSuccess = { result ->
println("Payment Method Created: $result")
},
onError = { error ->
println("Error: $error")
}
)
}Once a payment method is created, confirm the payment:
CoroutineScope(Dispatchers.Default).launch {
stripe.confirmPayment(
paymentIntentClientSecret = "<payment_intent_client_secret>",
params = ConfirmParams.CardParamsWithToken(
paymentMethodData = ConfirmParams.PaymentMethodDataWithToken(
token = "<card_token>",
billingDetails = billingDetails
)
),
options = CreateOptions(FutureUsage.OFF_SESSION),
onSuccess = { result ->
println("Payment Confirmed: $result")
},
onError = { error ->
println("Error: $error")
}
)
}Sometimes, additional steps are required for authentication (e.g., 3D Secure). In such cases, handle next actions:
CoroutineScope(Dispatchers.Default).launch {
stripe.handleNextAction(
paymentIntentClientSecret = "<payment_intent_client_secret>",
returnURL = "<your_return_url>",
onSuccess = { result ->
println("Next Action Handled: $result")
},
onError = { error ->
println("Error: $error")
}
)
}You can customize the following parameters:
BillingDetails(name, email, phone))CreateOptions(FutureUsage.OFF_SESSION))<your_return_url>)<your_publishable_key>)<your_publishable_key>, <payment_intent_client_secret>, <your_return_url>) with your actual credentialsThis project is licensed under the MIT License.
For issues and support, open an issue on the repository or check Stripe Documentation: