#harshit-reactnative-ephemeralkey
1 messages · Page 1 of 1 (latest)
harshit-reactnative-ephemeralkey
@gentle ether 99.9% of the time the error is really because you didn't pass the right value for the secret.
It works perfectly fine on android
the same exact thing
same value for the secret
I think the first step is to cleanly log what you are passing to the iOS SDK first. It's likely something is wrong in your code still. Can you please share your exact code for that part and clean logs of what you are logging (except the API key)
the secret I'm passing is something like {customerEphemeralKeySecret: "ephkey_XXXXXXVUYL9I6Y4Ss5XXXXX"}
I will give you the exact format, android vs iOS
thanks, make sure you log if there are any invisible characters or spaces before/after. Also share exact code, exact logs, an example id (it's a secret key but sadly not sure how else to debug) and also exact version of the ReactNative SDK
Hi @covert ice, DM'ed you
please share the full info here, just redact the values so that it's easier for other people on my team to help if needed. But I'm looking at what you DM-ed me
also confirm if those are hardcoded values in the code
the values aren't hardcoded, they're coming from server
okay, can you try hardcoding them just to see what happens?
Can you also share your current real code since what you shared isn't really your code
Here is the log
// for iOS
await initPaymentSheet({
"allowsDelayedPaymentMethods": true,
"customerEphemeralKeySecret": "ephkey_XXXXXXXXUYL9I6Y4SXXXXX",
"customerId": "cus_P9XXXXXyuA12H",
"defaultBillingDetails": {
"email": "mjeXXXXX@gmail.com",
"name": "XXXXan"
},
"merchantDisplayName": "XXXXXXX",
"paymentIntentClientSecret": "pi_3ObSDLGVUYL9I6Y42yXXXX_secret_CrQc3KZgrguQkkIVFPrXXX"
})
// gives error as {"code": "Failed", "declineCode": null, "localizedMessage": "customerEphemeralKeySecret format does not match expected client secret formatting.", "message": "customerEphemeralKeySecret format does not match expected client secret formatting.", "stripeErrorCode": null, "type": null}
// for android
await initPaymentSheet({
"allowsDelayedPaymentMethods": true,
"customerEphemeralKeySecret": "ephkey_XXXXXXXXUYL9I6Y4SXXXXX",
"customerId": "cus_P9XXXXXyuA12H",
"defaultBillingDetails": {
"email": "mjeXXXXX@gmail.com",
"name": "XXXXan"
},
"merchantDisplayName": "XXXXXXX YYYYYYYY, Plano",
"paymentIntentClientSecret": "pi_3ObSGzGVUYL9I6Y4XXXX_secret_Kk6dlQJoDI0Zt5IM4XXXX"
})
// works fine
Here is my code
const stripeCustomerId = savedCardDetails?.data?.stripeCustomerId
const ephemeralKey = savedCardDetails?.data?.ephemeralKey
const orderId = placeOrderResponse?.id
const selectedMerchantsName = selectedMerchants?.name
// @ts-ignore
const userName = profile?.name;
const userEmail = profile?.email;
const { initPaymentSheet, presentPaymentSheet } = useStripe();
const options = {
merchantDisplayName: selectedMerchantsName || 'XXX Default Name',
customerId: stripeCustomerId,
customerEphemeralKeySecret: ephemeralKey,
paymentIntentClientSecret: clientSecret,
allowsDelayedPaymentMethods: true,
defaultBillingDetails: {
name: userName,
email: userEmail,
},
};
console.log('initPaymentSheet', options);
const { error } = await initPaymentSheet(options);
if (error) {
console.log(`Error initializing PaymentSheet }`, error);
console.error(error);
} else {
await openPaymentSheet()
setLoading(true);
}
Okay so first try hardcoding that customerEphemeralKeySecret and see what it does/says
Okay can you share your exact ReactNative SDK version please?
Its 0.28.0
Any chance you can try the latest version as 0.28.0 is from June 2023? Or are you using Expo?
Yeah, I'm using expo
Ack that makes things harder as Expo is drastically harder to use and debug sadly
Yeah, don't have access to native code :/
I'm looking into how we can help you debug, will take some time unfortunately
Tried upgrading the version but probably since the native SDK version is same, nothing changes!
since the native SDK version is same
not sure what that could mean, we definitely upgrade the underlying iOS and Android SDK with higher versions of our ReactNative SDKs
@gentle ether looking at what you DM-ed me, you seem to pass the EphemeralKey id instead of it's secret
I don't understand how this could even work on Android but I think that's your real bug
Oh, I will try to change that and test it
Okay I confirmed that for some reason Android basically ignores that value
I'm really sorry, it's such an obvious validation mistake on our part and so hard to figure out
@covert ice it works! I think android ignores it, yes
Yeah I'm working with our eng teams to fix this in a future version, so confusing
also someone on that team replied on that Github issue for other developers
Thank you so much for the help! 🙂