stripe-react-native icon indicating copy to clipboard operation
stripe-react-native copied to clipboard

presentPaymentSheet not working with live publishable key

Open eleopardstudios opened this issue 4 years ago • 6 comments

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

eleopardstudios avatar Feb 09 '22 10:02 eleopardstudios

May be because it's not publishableKey={pk}, it's publishableKey='pk'.

khenriksson avatar Feb 09 '22 12:02 khenriksson

May be because it's not publishableKey={pk}, it's publishableKey='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?

snhoby avatar Feb 09 '22 13:02 snhoby

Is it working with your test key, just not your live key? You could also try using initStripe instead of the StripeProvider component

charliecruzan-stripe avatar Feb 09 '22 14:02 charliecruzan-stripe

Is it working with your test key, just not your live key? You could also try using initStripe instead of the StripeProvider component

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

eleopardstudios avatar Feb 09 '22 15:02 eleopardstudios

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

charliecruzan-stripe avatar Feb 09 '22 15:02 charliecruzan-stripe

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.

eleopardstudios avatar Feb 09 '22 15:02 eleopardstudios