[ios] `presentPaymentSheet` will crash the app once is being called.
See original GitHub issueDescribe the bug
Have been following this tutorial and even though most of the things went pretty well, the app would crash when I am calling the presentPaymentSheet with the clientSecret returned from my backend. There isn’t any log I could find that would help me debug the issue.
Here is my component, I hope pasting the code helps a little bit more. I am using firebase functions as my backend.
import React, {useState, useEffect} from 'react';
import {StyleSheet, Alert} from 'react-native';
import {Text, useTheme} from 'react-native-paper';
import {
useStripe,
} from '@stripe/stripe-react-native';
import {useProfile} from './ProfileProvider';
import {SafeAreaView} from 'react-native-safe-area-context';
import {FormButton} from '../../components/FormButton';
export default function CardDetailsScreen({navigation}) {
const {styles} = useStyles();
const {
profile: {stripeId},
} = useProfile();
const {initPaymentSheet, presentPaymentSheet} = useStripe();
const [paymentSheetEnabled, setPaymentSheetEnabled] = useState(false);
const [clientSecret, setClientSecret] = useState();
const [loading, setLoading] = useState(false);
useEffect(() => {
const initialisePaymentSheet = async () => {
const fetchPaymentSheetParams = async () => {
try {
const response = await fetch(
'https://MY_BACKEND_ENDPOINT.cloudfunctions.net/completePaymentWithStripe',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
amount: 55 * 100,
customerStripeId: stripeId,
}),
},
);
const {paymentIntent, ephemeralKey} = await response.json();
setClientSecret(paymentIntent);
return {paymentIntent, ephemeralKey};
} catch (e) {
console.log(e);
debugger;
}
};
const {paymentIntent, ephemeralKey} = await fetchPaymentSheetParams();
const {error} = await initPaymentSheet({
customerId: stripeId,
customerEphemeralKeySecret: ephemeralKey,
paymentIntentClientSecret: paymentIntent,
});
if (!error) {
setPaymentSheetEnabled(true);
}
};
stripeId && initialisePaymentSheet();
}, [initPaymentSheet, stripeId]);
const openPaymentSheet = async () => {
if (!clientSecret) {
return;
}
setLoading(true);
try {
debugger;
const {error} = await presentPaymentSheet({clientSecret});
if (error) {
Alert.alert(`Error code: ${error.code}`, error.message);
} else {
Alert.alert('Success', 'Your order is confirmed!');
}
} catch (e) {
debugger;
}
};
return (
<SafeAreaView style={styles.container}>
<Text>Hello</Text>
<FormButton
title="Show Payment Sheet"
modeValue="contained"
onPress={openPaymentSheet}
loading={loading}
disabled={!paymentSheetEnabled}
/>
</SafeAreaView>
);
}
Expected behavior
Expected would be to open the sheet like the example

Desktop (please complete the following information):
- OS: iOS
- Version 1.15.7
Smartphone (please complete the following information):
- Device: iPhone 12
- OS: 14.4
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
react native - PaymentSheet Crashing on Android in v.0.19.0
I found the cause of the crash in my app: I had added implementation(project(':stripe_stripe-react-native')) { exclude module: 'appcompat' } ...
Read more >[Solved]-Flutter stripe native payment crash-Flutter
Bro try removing any other stripe library. I had the same problem, but had both stripe_native stripe_payment. So be deleting stripe_native my error...
Read more >5+ Ways to Fix Apps Crashing on iPhone - YouTube
iPhone apps keep crashing is a common issue with iPhone users; if you're looking for a permanent solution, you're in the right place...
Read more >Set up future payments | Stripe Documentation
When your customer taps the Set up button, call presentPaymentSheet() to open the sheet. After the customer completes setting up their payment method...
Read more >React Native App crashing on ios 15.4.1 - Apple Developer
We will post it in React native community. Please see attached log for further details of the [crash.] Please let us know if...
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
Hey sorry for the super late response @thorsten-stripe but havent had much time lately. I am still facing the same situation. Can you please see if I am missing something or if we can reopen the issue?
PS: you can see my code on the react-native side in the issue description, in case you need it
https://user-images.githubusercontent.com/4181674/121083041-37a31080-c7df-11eb-9a15-ea56e230cb0a.mp4
So I solved it! In my case I was using wix react-native-navigation. And the app crashed when calling the function presentPaymentSheet on a modal. I had to setRoot from the modal to go to the checkout process. That closes all modals which solved the issue.