#rakesh_code

1 messages ยท Page 1 of 1 (latest)

languid citrusBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1285901893578522676

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

wind quiver
#

Hi, let me help you with this.

simple plover
#

thanks

#

FYI im usinf "@stripe/stripe-react-native": "^0.37.2",

wind quiver
simple plover
#

but i set the compiledSdkversion to 34, all i need is to target sdk version 33. but the app crashes when i hit the "usePaymentSheet"

#

not everyone will be using the latest Android version which is 14(SDK 34)

#

i have a device with android 14, where the app doesn't even open. (sdk 34). but again it works fine in emulator

wind quiver
#

In your initial question you asked about SDK versions 33 and 32.
Is it a separate question?

simple plover
#

my question is i want the app to work with sdk version 33 and above, which is android 13 and above.

#

in sdk 33 the app crashes on the screen which has "usePaymentSheet", and in sdk 34 the app doesn't even start on touching the icon.

#

your github says "For iOS 12 support, please use @stripe/stripe-react-native@0.19.0." any version for android which support targetsdk 33?

wind quiver
simple plover
simple plover
wind quiver
#

I don't know how to help with the 34 version problem without seeing any errors.

simple plover
#

i downgraded the version of stripe to "npm i @stripe/stripe-react-native@0.20.0" and sdk to 33. now im getting an error at log Error presenting Payment Sheet: {"code": "Failed", "declineCode": null, "localizedMessage": "PaymentConfiguration was not initialized. Call PaymentConfiguration.init().", "message": "PaymentConfiguration was not initialized. Call PaymentConfiguration.init().", "stripeErrorCode": null, "type": null} im using "initPaymentSheet" to initialise

wind quiver
#

Where are you calling initialisePaymentSheet()?

simple plover
#

on button click. its happening

#

but i get error at showPaymentScreen

wind quiver
#

on button click
I can't see it in the code you shared.

simple plover
#
    
    console.log('amount', amount);
    setBtnLoading(true);
    if (Number(parseFloat(amount)) == 0 || amount == '') {
      setTitle('Error');
      setSubtitle('Please enter valid amount');
      setShowError(true);
      setBtnLoading(false);
      return;
    }
    setBalanceAfter(parseFloat(balanceBefore) + parseFloat(amount));
    initialisePaymentSheet();
  };```
wind quiver
#

Those have to be the opposite.
You should call initialisePaymentSheet() first in useEffect.
Next you call showPaymentScreen() when you submit the payment.

simple plover
#

the flow is correct otherwise how will that work in emulator. as soon as the button is clicked i call the init, followed by the others. we have await

wind quiver
#

initPaymentSheet() goes fist, then presentPaymentSheet() is called when you want to actually show the sheet.

languid citrusBOT
hearty mountain
#

Hey, taking over here. Let me know if there's any follow-up Qs I can answer!

simple plover
#

my only question is "presentPaymentSheet() is not showing up after creating a paymentIntent and passing the client_secret

hearty mountain
#

My colleague already explained why: you're calling the functions in the wrong order. It should be like this:

  1. On page load/in your effect hook, call fetchPaymentSheetParams so your server creates the intent, etc. Pass the parameters (paymentIntentClientSecret, etc) from that function to initPaymentSheet
  2. Then have a button which customers press when they want to pay that has a handler function that calls presentPaymentSheet. That then will open the sheet
#

Currently you're calling presentPaymentSheet first, hence the error

hearty mountain
simple plover
#

" showPaymentScreen();" is called only if ready is set to true. check at which point im setting it to true. after getting the response from "initPaymentSheet"

hearty mountain
#

Yes, but your showPaymentScreen function doesn't actually call initialisePaymentSheet or fetchPaymentSheetParams โ€“ where are those functions invoked?

#

All you're code is doing is trying to present a Payment Sheet that has not even been initialised. It's completely backwards

simple plover
#

the error actually says "Call PaymentConfiguration.init()."" and im calling "initPaymentSheet" are they different?

#

can i have the code for that?

hearty mountain
#

The code is at the docs link we've shared a couple of times now. I recommend you take a step back, read that guide end-to-end and implement the steps as it advises. Right now you're missing two critical parts because you call presentPaymentSheet

simple plover
#

please make a note. version 0.20.0 needs the component to be wrapped inside "<StripeProvider publishableKey="your-publishable-key-here">", where as it was not prompted in the emulator for higher versions.. i think the issue is fixed.

hearty mountain
#

Great!