#hendr1x_api

1 messages ¡ Page 1 of 1 (latest)

finite pilotBOT
#

👋 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.

runic prairie
#

Hello

#

What do you mean exactly by "no response"?

steady sedge
#

hello

#

This is the code I am working on

runic prairie
#

You are getting a 402 which is the expected response?

steady sedge
#
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

runic prairie
#

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);

steady sedge
#

No console.log output

runic prairie
#

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?

steady sedge
#

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

runic prairie
#

Are you confirming anywhere else in your code?

steady sedge
#

(no errors)

#

no. Only in js, in this page

runic prairie
#

The error indicates that res isn't being initialized...

Is there somewhere I can visit to reproduce?

steady sedge
#

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

runic prairie
#

Oh wait

steady sedge
#

Click "Pay Invoice"

runic prairie
#

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);
}
steady sedge
#

ok...so that got me the console.log

#

I don't understand...sorry

#

scope of const is constrained to the if statement?

runic prairie
#

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.

steady sedge
#

Ok. Yeah...I hate js...lol

#

Thank you for explaining. I appreciate your help very much.

#

I think I can take it from here.

runic prairie
#

Sure thing

steady sedge
#

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?

runic prairie
#

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.

steady sedge
#

Thanks again. I will research. Talk to you later...lol