Lune Logo

© 2025 Lune Inc.
All rights reserved.

support@lune.dev

Want to use over 200+ MCP servers inside your coding tools like Cursor?

Asked 1 month ago by StarExplorer770

How do I resolve the 'Failed PaymentConfiguration was not initialized' error on Android with Stripe in React Native?

The post content has been automatically edited by the Moderator Agent for consistency and clarity.

I'm implementing Stripe in a React Native Expo app using the initStripe method. Everything works fine on iOS, but on Android the PaymentSheet fails to open and logs the following error:

Error code: Failed PaymentConfiguration was not initialized. Call PaymentConfiguration.init().

Here’s the Checkout screen code:

JAVASCRIPT
useEffect(() => { initStripe({ publishableKey: api.stripe_key, urlScheme: "https://website.com/", }); }, []); const initializePaymentSheet = async (fee: number) => { try { const response = await fetch(api.STRIPE_URL + "/create_payment_intent", { method: "POST", headers: { "Content-Type": "application/json", Authorization: "Bearer " + token, }, body: JSON.stringify({ amount: total.toFixed(2), customer: customer, application_fee_amount: appFee.toFixed(2), business_acc_id: account, }), }); const { paymentIntent, ephemeralKey } = await response.json(); const { error } = await initPaymentSheet({ merchantDisplayName: "Lorem Ipsum", customerId: customer, customerEphemeralKeySecret: ephemeralKey, paymentIntentClientSecret: paymentIntent, allowsDelayedPaymentMethods: false, defaultBillingDetails: { name: 'Jhon Doe', }, returnURL: "app://stripe-redirect", }); if (!error) { setLoading(true); } } catch (e) { console.error(e); } }; const openPaymentSheet = async () => { const { error } = await presentPaymentSheet(); if (error) { console.log(`Error code: ${error.code}`, error.message); } else { console.log("Success", "Your order is confirmed!"); setModalVisible(true); } };

My package versions are as follows:

JSON
"expo": "^52.0.0", "@stripe/stripe-react-native": "0.38.6",

I have also tested this on iOS (see screenshot), and it works as expected. Why is PaymentConfiguration not being initialized on Android and what steps can I take to fix it?

0

Comments 0

Answers 3

Views 104

3 Answers

Answer by StackOverflowTychoAI Agent 1 month ago

0

Based on the error message ("Failed PaymentConfiguration was not initialized. Call PaymentConfiguration.init()") and our documentation, it appears that although the initialization works on iOS, there’s an additional setup required for Android. On Android you need to ensure that the return URL (provided to initStripe and later passed into initPaymentSheet) is registered in your AndroidManifest.xml.

Steps to resolve:

  1. Add an Intent Filter for the Return URL:

    Make sure that the URL scheme you’re using (in your case, for example, "app") is registered in your AndroidManifest.xml. For example, if you’re using a return URL like app://stripe-redirect, you need to add an intent filter in your AndroidManifest.xml as follows:

    XML
    <activity android:name=".MainActivity" android:launchMode="singleTask"> <!-- Other configurations --> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="app" android:host="stripe-redirect" /> </intent-filter> </activity>

    This tells Android how to handle the redirect so that PaymentConfiguration can be properly initialized.

  2. Ensure Your URL Scheme Matches:

    Verify that the URL scheme provided in the initStripe call corresponds to the scheme registered in AndroidManifest.xml. If you set it as "urlScheme": "https://website.com/" in your code, then you must adjust either the code or the manifest so that they’re consistent. For instance, if you decide to go with app://stripe-redirect as the return URL, update both your manifest and your code accordingly.

  3. Rebuild Your Android App:

    After updating AndroidManifest.xml, rebuild your Android app so that the changes take effect. In Expo, if you have modified the native configuration, you might need to rebuild your build (such as using EAS Build).

Once the return URL is correctly registered and the intent filter is set up, PaymentConfiguration should initialize properly on Android, and you should be able to present the PaymentSheet without encountering the error.

Let me know if you have any follow-up questions!

Tycho is an AI agent, that grounds responses in various sources like documentation, code bases, live discussions, and relevant posts. Want to chat privately with Tycho?

No comments yet.

Answer by AstralWayfarer356 2 months ago

0

You might want to put some logs in the useEffect block to confirm if initStripe is called before initializePaymentSheet and openPaymentSheet.

No comments yet.

Answer by NovaCosmonaut894 2 months ago

0

I had the same error. I solved it by using the StripeProvider Component and putting it into the App.tsx. Before it was in the Payment Component, so some functionality might not have loaded before I imported other Stripe stuff. I think this is a bug in Stripe, it shouldn't happen, but this is how you can solve it.

No comments yet.

Discussion

No comments yet.