stripe-react-native: [Bug] [Android] CardField onCardChange not triggering in React Native Stripe
Describe the bug The CardField component’s onCardChange callback is not triggering when entering card details. No values are being received in the callback function, making it impossible to capture and validate card information.
To Reproduce Steps to reproduce the behavior:
- Initialize Stripe in your React Native app
- Implement CardField component with onCardChange handler
- Run the app and navigate to the credit card input screen
- Try entering card details in the field
- Check console logs - no output is shown
- Check card state - remains null
Code example:
<CardField
postalCodeEnabled={false}
placeholders={{
number: '1234 1234 1234 1234',
}}
cardStyle={{
backgroundColor: '#FFFFFF',
textColor: '#000000',
}}
style={{
height: 50,
width: '100%',
}}
onCardChange={(cardDetails) => {
console.log('Card Details:', cardDetails);
setCard(cardDetails.complete ? cardDetails : null);
}}
/>
Screenshot
Expected behavior
- onCardChange callback should fire whenever user enters or modifies card details
- Callback should receive CardFieldInput.Details object containing card information
- Console should show logged card details
- Card state should update when details are complete
Smartphone (please complete the following information):
- Device: Android
- React Native Version: 0.76.1
- @stripe/stripe-react-native Version: [^0.39.0]
Additional context
- Component renders correctly and is visible
- No error messages in console
- Other Stripe components working as expected
- Stripe initialization is successful
- Issue occurs on Android only
Possible Workarounds Needed Looking for either:
- Correct implementation of CardField with working onCardChange
- Alternative method to capture card details
- Any known workarounds for this issue
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 18 (1 by maintainers)
Commits related to this issue
- [Fix] Fixes #1812 CardField onCardChange not triggering in React Native Stripe - Updated CardChangedEvent and CardFocusEvent to conform to the Fabric protocol - Updates the dispatcher in CardFieldVie... — committed to kaushil111/stripe-react-native by deleted user 2 years ago
- [Fix] Fixes #1812 CardField onCardChange not triggering in React Native Stripe - Updated CardChangedEvent and CardFocusEvent to conform to the Fabric protocol - Updates the dispatcher in CardFieldVi... — committed to kaushil111/stripe-react-native by kaushil111 2 years ago
Hi all, thank you all for your patience. I’m sorry it’s taken us way too long to support the new architecture. We have begun our work to start migrating to the new architecture over the past couple of weeks and hope to complete it over the next 4-6 weeks. If anything changes, you can expect to see an update, but I’m optimistic we should be able to complete it by then.
This particular issue should be fixed in the latest version 0.40.0.
I apologize again for the delay. Please keep the feedback coming as well; we will do a better job at communicating with you all in GitHub issues going forward. I will close this issue for now, but please re-open if you continue to experience this issue after updating to the latest version.
Here is a patch that works with fabric enabled app on Android:
@stripe-stripe-react-native-npm-0.41.0-7a76d4dacd.patch
It also includes the patch for https://github.com/stripe/stripe-react-native/issues/1732 with slight modifications. Here is the reference: https://github.com/stripe/stripe-react-native/issues/1732#issuecomment-2594110710
Same, is anyone trying to implement payment element instead?