question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Expo][iOS] App crashes on presentPaymentSheet with React Navigation

See original GitHub issue

Hi, calling presentPaymentSheet causes my app to crash with no useful error messages. I’m getting the error, Service exited due to SIGABRT.

I am able to get the paymentOption from initPaymentSheet and am not receiving any errors with that function, so I believe I have set up the StripeProvider correctly.

I have also confirmed that I have successfully set paymentIntent, ephemeralKey, and customerId.

Here is the relevant code:

Initializing Payment

useEffect(() => {
    const initializePaymentSheet = async () => {
      console.log('initializing payment sheet');
      setState({ ...state, paymentSheetLoading: true });
      const variables = { phone, email, customerId, products, promo };
      const { paymentIntent, ephemeralKey, customer } = await fetchPaymentSheetParams(variables);

      const paymentVariables = {
        customerId: customer,
        customerEphemeralKeySecret: ephemeralKey,
        paymentIntentClientSecret: paymentIntent,
        customFlow: true,
        merchantDisplayName: 'Flyby',
        applePay: true,
        merchantCountryCode: 'US',
        googlePay: true,
        testEnv: true,
      };

      console.log(paymentVariables);

      const { paymentOption, error } = await initPaymentSheet(paymentVariables);

      if (!error) {
        console.log('no error');
        setState({
          ...state,
          paymentMethod: paymentOption,
          paymentSheetEnabled: true,
          clientSecret: paymentIntent,
          paymentSheetLoading: false,
        });
      } else {
        setState({ ...state, paymentSheetLoading: false });
        console.error(error);
      }
    };
    initializePaymentSheet();
  }, []);

Choosing payment object

const choosePaymentOption = async () => {
    if (!clientSecret) {
      return;
    }
    console.log('choosing payment option');
    console.log(clientSecret);

    let results;
    try {
      results = await presentPaymentSheet({
        confirmPayment: false,
        clientSecret: clientSecret,
      });
    } catch (e) {
      console.log(e);
    }
    const { error, paymentOption } = results;

    console.log(paymentOption);

    if (error) {
      console.log('error', error);
    } else if (paymentOption) {
      setState({
        ...state,
        paymentMethod: {
          label: paymentOption.label,
          image: paymentOption.image,
        },
      });
    } else {
      setState({ ...state, paymentMethod: null });
    }
  };

Component

<TouchableOpacity onPress={choosePaymentOption} disabled={!paymentSheetEnabled}>
     <View>
          <SectionTitle>Add Payment Method</SectionTitle>
          <FontAwesomeIcon icon={faPlus} />
     </View>
</TouchableOpacity>

I am using React Navigation. I have read that presentPaymentSheet doesn’t work in modals, and my screen is not a modal.

Any ideas or suggestions on how to debug this would be very much appreciated!!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
bbenson09commented, Sep 13, 2021

This was the issue! Thanks for your help!

0reactions
arekkubaczkowskicommented, Sep 12, 2021

So the docs says that you can’t use latest version of library within Expo. https://github.com/stripe/stripe-react-native/blob/master/CHANGELOG.md#014---2021-06-04---expo-sdk-4200

Read more comments on GitHub >

github_iconTop Results From Across the Web

presentPaymentSheet crashes the app in android #620 - GitHub
My checkout page: import React, { useState, useEffect } from "react"; ... The app crashes after calling presentPaymentSheet . To Reproduce
Read more >
React Native app crashes when using React Navigation (Expo)
I'm trying to make a simple drawer navigator, and the app simply crashes without errors in the console. These are just the example...
Read more >
App Crashing on startup | Simple Drawer Navigation ... - Reddit
import "react-native-gesture-handler"; import { StatusBar } from ... App is crashing on startup for Basic Drawer Navigation implementation.
Read more >
Crash when used with react-navigation
The YoutubePlayer causes a crash immediately on navigating to another screen, and also sometimes when navigating to the screen that contains the component....
Read more >
App Center Crashes for React Native - Microsoft Learn
App Center Crashes will automatically generate a crash log every time your app crashes. The log is first written to the device's storage...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found