#noroup_api
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/1387120128004460675
📝 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.
- noroup_api, 14 hours ago, 22 messages
- noroup_webhooks, 21 hours ago, 17 messages
- noroup_webhooks, 22 hours ago, 4 messages
const { error, paymentIntent } = await confirmPayment(clientSecret, {
paymentMethodType: 'Card',
paymentMethodData: {
billingDetails: {
email: user.email,
},
},
});
I have generated the client Secret on the backend and returned it to the client
hello! any chance you have the PaymentIntent ID handy and can share that?
can you share more of your code? are you using the payment sheet or mobile payment element?
Hi, sure. I am actually providing the cardfield, the user inputs their card details in
const { confirmPayment } = useStripe();
// Close keyboard if card details complete
useEffect(()=> {
if(cardDetails?.complete){
Keyboard.dismiss();
}
}, [cardDetails])
const checkoutFunction = async () => {
setLoading(true)
// Ensure card details are correct / complete
if (!cardDetails?.complete) {
Alert.alert('Invalid Card', 'Please enter complete card details.');
setLoading(false);
return;
}
// Deduct stock, create payment intent
const purchaseResp = await purchaseAPI(cart)
if(purchaseResp?.statusCode == 200){
const clientSecret = JSON.parse(purchaseResp.body).clientSecret
// Check selected card details, select appropriate payment method
const { error, paymentIntent } = await confirmPayment(clientSecret, {
paymentMethodType: 'Card',
paymentMethodData: {
billingDetails: {
email: user.email,
},
},
});
if (error) {
console.log('Error confirming payment', error);
Alert.alert('Payment Failed', error.message);
} else {
console.log('PaymentIntent', paymentIntent);
Alert.alert('Payment Successful', 'Your payment was completed.');
closeSheet();
}
}
setLoading(false)
}
<CardField
postalCodeEnabled={false}
placeholder={{
number: '4242 4242 4242 4242',
expiration: 'MM/YY',
cvc: 'CVC'
}}
cardStyle={styles.card}
style={styles.cardField}
onCardChange={setCardDetails}
/>
ahh gotcha, i am less familiar with the card element as it's a legacy feature... 1 sec
Ooo okay take your time please
is this a new implementation? is there a reason you're going with the card element?
It just seemed like the most straightforward way
Looking back, I should have probably ran through the current documentation
But I am hoping that this would be a last resort as I already have all the checkout page set up
hmmm some googling on that error message suggests it might be a networking problem, possibly a timeout
do you know how long it's taking between when you call confirm and the error throws?
That's what yesterday's support said it wasn't helpful 😭
i don't see any confirm call hitting our server so it's definitely not reaching us...
60 seconds
whoa yep that definitely sounds like a timeout then hahaha
Ah, do you think the endpoint is down? Or confirmpayment is deprecated somehow on react native?
where is your machine running? are you on a VPN or anything weird? are you able to try running the frontend on a different network?
This is just a regular iPhone on my wifi
this probably isn't related but i also noticed you're testing using your live mode key, you should be using a test mode key or sandbox key
this article goes into some details on those:
https://docs.stripe.com/keys
oh yes, I am just testing to see how the payments will actually go through
yeah, you should use test mode for those. we have test mode cards specifically for that purpose
https://docs.stripe.com/testing
it's actually against our terms of service to test in live mode, so i would strongly recommend using a sandbox or test mode key
Okay, thank you. I will switch over to test mode right away!
have you tried running through this using a simulator instead of directly on an iphone?
Ah, you mean the iOS simulator on MacOS?
i would try
- switching to a test mode / sandbox key and
- if possible use an iOS simulator
let me try the iOS simulator, I will switch over to the test mode I just want to get my code working correctly
are you using your live credit card info when you test using the live mode key?
yes I am
mmk... go ahead and give the simulator a go and let me know what happens
everything is pointing to networking problems so far
Interesting, let me do that now
Also, all I did besides this was wrap my entire app with the <StripeProvider> so maybe there is an extra IOS step I am missing?
we also have this script you can use to test if your device is having any issues reaching stripe. obviously you can't run it on your device but you can give it a go from wherever you run / will run the simulator as a sanity check
https://github.com/stripe/stripe-reachability
oooo
Getting a different error now
Error confirming payment {"code": "Failed", "declineCode": null, "localizedMessage": "There was an unexpected error -- try again in a few seconds", "message": "You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See https://stripe.com/docs/api#authentication for details, or we can help at https://support.stripe.com/.", "stripeErrorCode": "", "type": "invalid_request_error"}
that's promising! that's an actual stripe generated error
excellent yes
but in confirmPayment is there even a field to provide an API key?
it's probably the publishable key
yeah that's what i was thinking
is it possible that the public key doesn't match the key used to generate the PaymentIntent?
let me check
if this doesnt work, I think I am just going to scrap this and use the payment sheet 😭
haha fair
fwiw it will be easier to get support from us on it (since more of us are fully trained up on our current best practices than legacy features) and you're also locking yourself into a system that won't be updated by going with the card element
Oh boy
Looks like I havent even wrapped the application with the StripeProvider 🤦♂️
hahaha that would do it
One sec, let me do that now. I am guessing it's alright to do that with just the Checkout page
i think so? i know it's possible with the payment sheet
hell yeah
and I see it charged in my bank!
now time to move back to the test mode key 😛
anything else you need help with at the moment?
Yes, all I have to do is just switch the publishable keys to the test environment I am assuming
Nope, thank you so much. I LOVE you.
yep! you also need to make sure you use the test mode secret key - if those are mismatched you'll get an error saying the payment intent doesn't exist
hehe awww
You are right. Also I dont want to keep racking up charges on my credit card
hahaha
Thank you so much. I love you ❤️ time to switch over to test and set up the listening endpoints
yep happy to help! good luck out there
and again i would be doing a bad job if i didn't strongly suggest you move to the mobile payment element / payment sheet as soon as you're able. obviously what you have now will work but using the current technology will make your life better in the long run
Got it, I think I’ll do this as the UI will be less cluttered using the native sheet. And it’ll be far easier to incorporate Apple Pay
yep exactly, the built in support for other payment methods is a huge reason to use it
My app has generated $3 already!
You are right. I’ll get right on it
This is with my own card btw hehe
i figured 😛
BTW, are you familiar with incorporating stripe tax? Can I pick ur brain on it?
We can close this ticket and I can open a new one when the time comes, it’s not a priority
i know a bit about it, you're welcome to ask or come back later
Gotcha, I’ll come back later. Thank you so much for your help you made my day truly ❤️