PaymentSheet Crashing on Android in v.0.19.0
See original GitHub issueDescribe the bug
In v0.19.0, on Android (13 and 10), presentPaymentSheet call crashes the app without any errors. After installing Sentry I see a IllegalStateException: ViewTreeLifecycleOwner not found
On iOS everything works perfectly.
To Reproduce I’m just following this Stripe Developers video about Accept a payment:
export default function TestPaymentScreen(props) {
const [ready, setReady] = useState(false);
const {initPaymentSheet, presentPaymentSheet, loading} = usePaymentSheet();
useEffect(() => {
initializePaymentSheet();
}, []);
const initializePaymentSheet = async () => {
const {paymentIntent, ephemeralKey, customer} =
await fetchPaymentSheetParams();
const {error} = await initPaymentSheet({
customerId: customer,
customerEphemeralKeySecret: ephemeralKey,
paymentIntentClientSecret: paymentIntent,
merchantDisplayName: 'MyApp',
allowsDelayedPaymentMethods: true,
returnURL: 'stripe-example://stripe-redirect',
});
if (error) {
Alert.alert(`Error codes: ${error.code}`, error.message);
} else {
setReady(true);
}
};
const fetchPaymentSheetParams = async () => {
const response = await fetch(`http://192.168.1.67:8000/checkout`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
});
const {paymentIntent, ephemeralKey, customer} = await response.json();
return {
paymentIntent,
ephemeralKey,
customer,
};
};
async function buy() {
const {error} = await presentPaymentSheet();
if (error) {
Alert.alert(`Error code: ${error.code}`, error.message);
} else {
Alert.alert('Success', 'The payment was confirmed successfully');
setReady(false);
}
}
/* ... */
}
When openPaymentSheet()
is called pressing the button, the android app crashes without any error in the Metro server console.
The Sentry dashboard shows:
IllegalStateException
ViewTreeLifecycleOwner not found from androidx.coordinatorlayout.widget.CoordinatorLayout{5876b97 V.E...... ......I. 0,0-0,0 #7f0800cf app:id/coordinator}
Expected behavior Payment sheet opening
Smartphone
- Device: Pixel 4
- OS: Android
- Version 13
I attach the following files: android:app:build.gradle.txt android:build.gradle.txt package.json.txt
Issue Analytics
- State:
- Created a year ago
- Comments:18
Top Results From Across the Web
react native - PaymentSheet Crashing on Android in v.0.19.0
In stripe-react-native v0.19.0, on Android (13 and 10), presentPaymentSheet call crashes the app without any errors.
Read more >stripe_ios | Flutter Package - Pub.dev
Added Link support in Payment Sheet. ... Several fixes by the Stripe sdk v.0.19.0. ... Fix #416 ocassional crash on Android on the...
Read more >Stripe React Native SDK - npm
The Stripe React Native SDK allows you to build delightful payment experiences in your native Android and iOS apps using React Native.
Read more >stripe-react-native - bytemeta
PaymentSheet Crashing on Android in v. · Error in createPaymentMethod: Card details not complete (Android) · requiredShippingAddressFields postal address returns ...
Read more >Stripe-payments - Bloglovin'
PaymentSheet Crashing on Android in v.0.19.0 · active questions tagged android - Stack Overflow. ·. 3d · In stripe-react-native v0.19.0, on Android (13...
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
Awesome! Glad to hear it, hopefully that addresses it for the remainder of folks experiencing random payment sheet crashes in this issue. Thanks for posting here!
@Ace090 why do you have
implementation(project(':stripe_stripe-react-native')) { exclude module: 'appcompat' }
in yourapp/build.gradle
?If you can try to reproduce this in a blank project, that would be helpful. Otherwise, my I think this is specific to your project and could have to do with that