stripe / stripe-react-native

React Native library for Stripe.
https://stripe.dev/stripe-react-native
MIT License
1.27k stars 265 forks source link

[Android] : presentPaymentSheet() is not opening stripe payment sheet in android #267

Closed hpvnarola closed 3 years ago

hpvnarola commented 3 years ago

Describe the bug presentPaymentSheet() is not opening the stripe payment sheet in android when passing direct charge payment intent client secret. it's working fine in iOS.

server-side

// Direct charge
const payment_intent = await payment.getPaymentIntent(
    {
        payment_method_types: ['card'],
        amount: parseFloat(amount) * 100,
        currency: 'usd',
        application_fee_amount: tools.calculateApplicationFee(amount),
    }, 
    {
        stripeAccount: user.stripe_connect_id,
    }
);
console.log(payment_intent.client_secret, '------');
return res.status(200).send({
    status: 200,
    message: 'Checkout data fetched successfully.',
    data: {
        paymentIntent: payment_intent.client_secret,
        customer: customer_id,
    }
});

client-side(react-native -> android)

console.log(data);
const { error, paymentOption } = await initPaymentSheet({
    customerId: data.customer,
    paymentIntentClientSecret: data.paymentIntent,
});

const { error, paymentOption } = await presentPaymentSheet({
    clientSecret: data.paymentIntent,
});

Expected behavior The payment sheet should open in android as well like in IOS.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

thorsten-stripe commented 3 years ago

Are you setting stripeAccountId to be the same value as user.stripe_connect_id in your StripeProvider component? https://stripe.dev/stripe-react-native/api-reference/interfaces/stripeproviderprops.html#stripeaccountid

hpvnarola commented 3 years ago

Yes, I'm doing the same, I wrapped the children components inside StripeProvider, below you can see the code for the StripeProvider setup. Below also have attached the video for what happens when invoking stripe payment in android. It's a live project and we are facing a problem with android please help us with this.

Video link: https://drive.google.com/file/d/1NCW12oiso_InVKEEZ3VU3h3uGJpxK1il/view?usp=sharing

<StripeProvider
    publishableKey={Tools.getStripeKeys().PUBLISHABLE_KEY}
    stripeAccountId={params?.churchDetail?.stripe_connect_id}>
    <View style={styles.container}>
        <KeyboardAwareScrollView
            style={styles.wrapper}
            bounces={false}
            keyboardShouldPersistTaps={'handled'}
            keyboardOpeningTime={Number.MAX_SAFE_INTEGER}
            showsVerticalScrollIndicator={false}>
            <View style={styles.card}>
                <Input
                    placeholder={t('add_donation_plan.amount')}
                    style={[styles.subjectInput, { marginBottom: 0 }]}
                    placeholderColor={Colors.GRAY}
                    value={amount}
                    onChangeText={(text) => {
                        setAmount(text);
                        setAmountError('');
                    }}
                    keyboardType={'numeric'}
                    errorMsg={amountError}
                />
            </View>
            <Button
                label={t(
                    'church_details_profile.donate',
                ).toUpperCase()}
                style={styles.button}
                onPress={onPressDonate}
                isLoading={isLoadingSetupCheckout}
            />
        </KeyboardAwareScrollView>
    </View>
</StripeProvider>
thorsten-stripe commented 3 years ago

@hpvnarola thank you for reporting this, and sorry for the inconvenience! I've just merged the fix into master and am hoping to release it within v0.1.3 by end of week. If you need it earlier, you can clone down master branch and build the library locally: https://github.com/stripe/stripe-react-native/blob/master/CONTRIBUTING.md#install-library-as-local-repository

RajeshRRathod commented 3 years ago

I used master branch "@stripe/stripe-react-native": "https://github.com/RajeshRRathod/stripe-react-native#master", in package.json but still payment sheet dialog open just one second & its close automatic in android i found error message : {"code":"Failed","message":""} pls give me any suggestion for this issue, its urgent

hpvnarola commented 3 years ago

Hi @thorsten-stripe
Thanks for resolving the issue and provide quick support

We are waiting for the latest release with fixes

NuHunter commented 2 years ago

I ran into the same problem when I used flutter -> presentPaymentSheet() is not opening stripe payment sheet in android

RONAKDHOLARIYA commented 2 years ago

<StripeProvider merchantIdentifier="merchant.identifier" publishableKey="publishableKey">

Adding merchantIdentifier in my app work fine in adnroid

Mihai-github commented 2 years ago

Hi, I've run into the same problem after the paymentSheet appeared for the first time if we close it and try to make it occur for the second time we have no error but it won't appear and we have no idea how to debug this issue at least...

Maybe someone has any idea?

arslanafzal077 commented 2 years ago

payment sheet dialog open with loading for just one second & its close automatic in ios simulator..and after that i'm unable to use my app .i have to run again from xcode to use the app

mannu2saini commented 1 year ago

I have same issue presentPaymentSheet is not appearing on android device.In the previous version merchantDisplayName was not there .So update
 stripe-react-native version 0.23.1 and pass merchantDisplayName in initPaymentSheet after that it works for me.

  const {error}  = initPaymentSheet({
      merchantDisplayName:appConstant.userName,
      customerId: this.state.customerId,
      customerEphemeralKeySecret: this.state.ephemeralKey,
      paymentIntentClientSecret: this.state.clientSecretkey,
    })
saad9624-tribalScale commented 1 year ago

Just add merchantDisplayName under initPaymentSheet , it will open the modal in android.

ankitk-nimblechapps commented 1 year ago

Screenshot_2023-02-06-13-29-59-94_a40c374f801420dce36ea483382aa15e while calling initpaymentSheet method app crashed with these error in android, please help me with these issue.