presentPaymentSheet not working with live publishable key
I am using this library in one of my react native app for iOS to receive payments using credit cards only.
The library work fine for test keys but as soon as I start using publishable live key, It starts giving me error:
Error code: Failed No valid API key provided. Set STPAPIClient.shared().publishableKey to your publishable key,
I double checked the publishable key from my stripe account and it is the correct live key.
Here is the code
<StripeProvider
publishableKey={
'pk_live_XXXXXXXXXX'
}>
<App />
</StripeProvider>
Because in the above code as soon as I change the publishable key from live key to test key, everything starts working as expected. Is there any setting that I am missing in case of Live in iOS apps?
Please help
May be because it's not publishableKey={pk}, it's publishableKey='pk'.
May be because it's not
publishableKey={pk}, it'spublishableKey='pk'.
I tried but no luck
<StripeProvider publishableKey="pk_live_XXXXX">
<App />
</StripeProvider>
I followed the document from here https://stripe.com/docs/payments/accept-a-payment?platform=react-native&ui=payment-sheet
Is there anything that is not mentioned here related to live environment?
Is it working with your test key, just not your live key? You could also try using initStripe instead of the StripeProvider component
Is it working with your test key, just not your live key? You could also try using
initStripeinstead of theStripeProvidercomponent
Yes, if I use publishable test key on phone and private key on server, everything works fine.
However as soon as I switch both the keys to live, it stops working.
the initPaymentSheet works fine with following input:
const {error} = await initPaymentSheet({
customerId: customer,
customerEphemeralKeySecret: ephemeralKey,
paymentIntentClientSecret: paymentIntent,
});
But as soon as I call presentPaymentSheet() It throws this error
Error code: Failed No valid API key provided. Set STPAPIClient.shared().publishableKey to your publishable key,
I tried initStripe as well but no luck
Do I have to pass merchantIdentifier as well? but I am not using apple pay
merchantIdentifier is only necessary for Apple pay. If everything works correctly, and the only thing you change is the actual text values of the publishable keys, then I would double-check that key if I were you. You may also want to confirm that the value you're getting from your server is the value you're expecting it to be
It is resolved, yes @charliecruzan-stripe you are absolutely correct, due to copy paste one of the character was coming in different format somehow, due to which it was failing, it was looking correct but was getting read incorrectly. Now its working fine. Apologies for wasting everyone's time. Thanks again.