#hendr1x_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/1329466369724387339
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
You are getting a 402 which is the expected response?
confirm: async function(secret, type, returnURL, errorURL){
if (type && parseInt(type) === 2){
const {error} = await xesm.payment.cache.stripe.confirmPayment({
clientSecret: secret,
confirmParams: {
return_url: returnURL,
},
});
} else {
const {error} = await xesm.payment.cache.stripe.confirmSetup({
clientSecret: secret,
confirmParams: {
return_url: returnURL,
},
});
}
if (error) {
// This point will only be reached if there is an immediate error when
// confirming the payment. Show error to your customer.
xesm.payment.error(error.message);
xesm.redirect(errorURL);
} else {
// Your customer will be redirected to your `return_url`. For some payment
// methods like iDEAL, your customer will be redirected to an intermediate
// site first to authorize the payment, then redirected to the `return_url`.
}
},
This is adapted from one of your tutorials
I am not getting {error}
I am not getting a redirect
There is no problem getting a 402...I assume this how things are suppose to work
Can you just log out a general variable instead of {error} and see what the response is?
like ```const res = await confirmPayment...`
console.log("res: ", res);
That looks like a bug in your code where it isn't recognizing error somewhere.
Can you remove all instances of error and log how I said above?
yes. one moment
I will provide code again as well
Same exact situation
if (type && parseInt(type) === 2){
const res = await xesm.payment.cache.stripe.confirmPayment({
clientSecret: secret,
confirmParams: {
return_url: returnURL,
},
});
} else {
const res = await xesm.payment.cache.stripe.confirmSetup({
clientSecret: secret,
confirmParams: {
return_url: returnURL,
},
});
}
console.log("res: ", res);
line 88 is the console.log()
no use of res anywhere else in my code
normal credit card processing works perfet
Are you confirming anywhere else in your code?
The error indicates that res isn't being initialized...
Is there somewhere I can visit to reproduce?
Are you willing to login into an account on a dev site?
actually I have a public version
one second
This is a dev site. So no concerns for anything you do
Oh wait
Click "Pay Invoice"
You are logging outside of your conditional block
So yeah
You need to move that log within the if block
It is out of scope right now
You need to do:
f (type && parseInt(type) === 2){
const res = await xesm.payment.cache.stripe.confirmPayment({
clientSecret: secret,
confirmParams: {
return_url: returnURL,
},
});
console.log("res: ", res);
}
ok...so that got me the console.log
I don't understand...sorry
scope of const is constrained to the if statement?
Yes since that is where it is initialized and that is "lower down" in the blocks. I'd recommend doing some reading on scope if you aren't familiar.
Ok. Yeah...I hate js...lol
Thank you for explaining. I appreciate your help very much.
I think I can take it from here.
Sure thing
Sorry..can I ask one thing
what does the {} do around a variable?
I know this super basic
can you just give me a keyword to research?
It is called destructuring
Basically it means what is returned is an object that matches your variable name. It's a "shorthand" initialization of the variable.
Thanks again. I will research. Talk to you later...lol