stripe-react-native: confirmSetupIntent not working as expected
Describe the bug
Currently when I try to call confirmSetupIntent
I get the following error:
{
"stripeErrorCode": null,
"declineCode": null,
"localizedMessage": "Card details not complete",
"message": "Card details not complete",
"type": null,
"code": "Failed"
}
Card details are always complete
To Reproduce Steps to reproduce the behavior:
This is my current code for the component
<StripeProvider publishableKey="my test key">
<CardField
postalCodeEnabled={true}
placeholder={{
number: '4242 4242 4242 4242',
expiration: '10/24',
cvc: '123',
postalCode: 'C.P.',
}}
cardStyle={{
backgroundColor: '#FFFFFF',
textColor: '#000000',
borderWidth: 1,
borderColor: COLOR.gray_100,
}}
style={{
width: '100%',
height: 50,
marginVertical: SIZES.MD,
borderRadius: SIZES.MD,
...STYLE_SHADOW,
}}
onCardChange={inputCard => {
setCardDetails(inputCard);
}}
onFocus={focusedField => {
setInputField(
focusedField ? INPUT_FIELD[focusedField.toString()] : '',
);
}}
/>
<Text>{inputField}</Text>
<Button
disabled={!cardDetails?.complete}
onPress={submit}
style={{
marginTop: SIZES.MD,
borderRadius: SIZES.MD,
...STYLE_SHADOW,
}}>
Guardar
</Button>
</StripeProvider>
And this is the submit function
const submit = async () => {
setLoading(true);
try {
await createOrUpdateClient();
await updateProfile({
variables: {
input: {
card: {
last_digits: cardDetails?.last4,
expiry_date: `${cardDetails?.expiryMonth}/${cardDetails?.expiryYear}`,
},
},
},
});
const setupIntentResponse = await createSetupIntent();
const billingDetails: PaymentMethods.BillingDetails = {
email,
};
const { setupIntent, error } = await confirmSetupIntent(
setupIntentResponse.data?.stripeSetUpIntent?.client_secret as string,
{
type: 'Card',
billingDetails,
},
);
console.log('LOG: error ', JSON.stringify(error, null, 2));
console.log('LOG: setupIntent ', JSON.stringify(setupIntent, null, 2));
if (error) {
throw error;
}
Navigation.pop(componentId);
} catch (error) {}
setLoading(false);
};
client_secret
is always defined, so no issue there.
Expected behavior
The card is saved for future payments.
I debugged the issue directly on android studio and xcode, so I found that the native card manager is always null when it gets to the confirmSetupIntent
native method on both platforms. I’m attaching the evidence from xcode.
Screenshots

Desktop (please complete the following information):
- OS: MacOS big sur (M1)
Smartphone (please complete the following information):
- Device: I used the iOS simulator, the android emulator, an iPhone 11 and a moto g5 plus
- OS: iOS 14, android 11
Additional context
Please, don’t close this issue until you can help, this is becoming a huge block for our company.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 28 (3 by maintainers)
Background
We are in the process of migrating from tipsi-stripe to official react native library now due to Google Play Store not allowing anymore the version of stripe used by tipsi.
When migrating code, we have followed these steps:
CardField
component. This screen callsstripe.createToken
and returns the tokenId in a callback function.token
), or by selecting from saved cards retrieved from our API (we work withpaymentMethodId
in this case), we make a call toconfirmSetupIntent
, passing as parameters either thetoken
orpaymentMethodId
(by the time we make this call there is no UI related to stripe on screen).Note:
ConfirmSetupIntent.Param
spec doesn’t consider any card parameter except fortype
.Issues found
After calling
confirmSetupintent
, we are getting these errors:Card details not complete
when passing paymentMethodId instead of token.iOS investigation
When inspecting what happens under the hood when calling
confirmSetupIntent
on iOS, we can see thatStripeSdk.swift#confirmSetupIntent
is not handlingpaymentMethodId
parameter, so because by the time this is called there is nocardFieldView
and notoken
param is passed, errorPaymentMethodError.cardPaymentMissingParams
is resolved.Android investigation
When inspecting what happens under the hood when calling
confirmSetupIntent
on Android, we can see thatStripeSdkModule#confirmSetupIntent
is not handlingtoken
orpaymentMethodId
parameters, so because by the time this is called there is noinstance
, and this causescardParams
to be null, app is throwing an exception when trying to create card params, and trying to usecard!!
Conclusion
When using tipsi-stripe, they are under the hood calling stripe API V1 manually, and they handle passing
paymentMethodId
toPOST v1/setup_intents/:id/confirm
, but when replacing it with this library,paymentMethodId
is ignored and not passed correctly. On top of that, Android is not handling correctly passing atoken
parameter.@thorsten-stripe @arekkubaczkowski any chance you are looking into this issue? It seems a lot of people is facing the same problem, and I already give you guys steps to reproduce the error.
My company is close to launching our apps and we heavily depend on this, so this is becoming a major blocking for us.
We can get into a call and I can give you details if that helps.
We really need this to get fixed 😢
We think that this issue is related with other reported issue but we are still trying to find a solution, you can track the progress here: https://github.com/stripe/stripe-react-native/issues/391
@fdelacruzsoto can you please try https://github.com/stripe/stripe-react-native/issues/371#issuecomment-877764806
@jheslop25
When you already have a payment method ID you should create the PaymentIntent with said method and
confirm:true
and only callconfirmPayment
on the client if needed. That way you minimize the amount of API calls needed. See the docs: https://stripe.com/docs/payments/save-and-reuse?platform=react-native#react-native-create-payment-intent-off-session@prox2 I have just created a PR with the fixes we did to get our flows working.
so how to over come this issue? @idcuesta
OKAY, so finally worked for me and what i did was the following: I have changed the page extension to
type script (tsx)
instead ofjavascript(js)
i have specified the type of billingbillingDetails
same as stated in example which to be something like:and after success result or fail must re-render to call initiate stripe again or will throw an error in case for example first attempt for adding the card failed, which i think is an issue related to
stripe provider
.this may consider as temporary workaround the issue
@arekkubaczkowski the current configuration for the project is a bit complex but I can give you some steps of what I did to get to the screen with the card component.
As soon as the user hits the button the screen for some reason calls the ondestroy method that removes the reference to the card view and all the details are lost, which prompts the missing details error on the confirm setup call. The card component with all the data is still there and I can continue changing its data, so I’m 100% the screen was not destroyed.
The PR you rejected did actually fix the issue in both platforms.