[Expo][iOS] App crashes on presentPaymentSheet with React Navigation
See original GitHub issueHi, 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:
- Created 2 years ago
- Comments:7
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This was the issue! Thanks for your help!
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