Anyone know of a KMM wrapper lib around the Stripe...
# multiplatform
c
Anyone know of a KMM wrapper lib around the Stripe API's? Trying to avoid writing my own lol
👀 2
c
Did not know about klibs thats cool
m
what you end up doing @chrisjenx ?
I’m not sure about that open source Stripe sdk. Particularly since it doesn’t seem to have the Stripe UI baked in.
I’m thinking of building a wrapper around the two native SDK’s myself too!
c
Yeah basically did that, for WasmJs, iOS and Android
For the WasmJs you need to make sure the js lib gets attached to the root dom, not the compose one, as stripe stupidly doesn't support shadow doms (not like basically every spa uses those.. but hey)
THen you can use LocalViewController and LocalContext for the iOS and Android libraries respectively. Using Franks SPM is hugely helpful
👍 1
m
Do you mean François?
c
yes
m
Ah not so concerned with WasmJs. I’m surprised someone hasn’t already put together a module which imports both platform dependency - with ios using spm4kmp
Anyway only need something relatively simple for my use case to begin with. So will have a go next week
c
Yeah, I only use the PaymentLauncher, which unless you're doing something odd handles pretty much adding payment methods and paying
🙌 1
m
Great!
Hey! Struggled a bit here, I thought I may be able to instantiate the Android sourceset
PaymentSheet
from within my definition, but the initialiser requires Activity For now I’ve ended up creating a
StripeCheckout
composable which owns the paymentSheet and is responsible for presenting: https://github.com/markst/stripe-kmp/blob/main/shared/src/androidMain/kotlin/com/fouroneone/stripe/StripePayments.android.kt
I thought I was going to be able to build the
PaymentSheet
simply like this:
Copy code
private class AndroidStripePayments(private val context: Context) : StripePayments {

    var paymentSheet: PaymentSheet?

    @Composable
    override fun Initialize(publishableKey: String) {
        PaymentConfiguration.init(context = context, publishableKey = publishableKey)
        paymentSheet = PaymentSheet.Builder { result -> onResult(result.toCommonResult()) }.build()
    }

    @Composable
    override fun presentWithPaymentIntent(
        clientSecret: String,
        onResult: (PaymentSheetResult) -> Unit
    ) {
        paymentSheet.presentWithPaymentIntent(
            paymentIntentClientSecret = clientSecret,
            configuration = null
        )
    }
}