#rakesh_code
1 messages ยท Page 1 of 1 (latest)
๐ 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.
- rakesh_code, 21 hours ago, 24 messages
- rakesh_code, 1 day ago, 40 messages
Hi, let me help you with this.
The compiledSdkVersion must be 34, otherwise it will not work, unfortunately: https://github.com/stripe/stripe-react-native?tab=readme-ov-file#android
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
In your initial question you asked about SDK versions 33 and 32.
Is it a separate question?
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?
Where did you see it exactly?
Can you get any logs from the device?
https://github.com/stripe/stripe-react-native?tab=readme-ov-file#android
under Requirements
no logs are generated. the app gets closed
I suggest you to write to Stripe Support so my engineering team can investigate this in our own time: https://support.stripe.com/?contact=true
I don't know how to help with the 34 version problem without seeing any errors.
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
ths is my code
Where are you calling initialisePaymentSheet()?
on button click
I can't see it in the code you shared.
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();
};```
Those have to be the opposite.
You should call initialisePaymentSheet() first in useEffect.
Next you call showPaymentScreen() when you submit the payment.
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
I don't know how it works in emulator, but what I described is how it's supposed to work. You can refer to the documentation for more details: https://docs.stripe.com/payments/accept-a-payment?platform=react-native#react-native-collect-payment-details
initPaymentSheet() goes fist, then presentPaymentSheet() is called when you want to actually show the sheet.
Hey, taking over here. Let me know if there's any follow-up Qs I can answer!
my only question is "presentPaymentSheet() is not showing up after creating a paymentIntent and passing the client_secret
My colleague already explained why: you're calling the functions in the wrong order. It should be like this:
- On page load/in your effect hook, call
fetchPaymentSheetParamsso your server creates the intent, etc. Pass the parameters (paymentIntentClientSecret, etc) from that function toinitPaymentSheet - 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
Link here explains all of this step by step
" 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"
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
the error actually says "Call PaymentConfiguration.init()."" and im calling "initPaymentSheet" are they different?
can i have the code for that?
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
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.
Great!