#rangermillze_code

1 messages ¡ Page 1 of 1 (latest)

last vigilBOT
#

👋 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/1267784140376248380

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

slow current
inland gull
#

I already have the clientSecret I am passing to initEmbeddedCheckout

slow current
#

that's not related to what I said

inland gull
#

looking at doc's the await is just calling "create-checkout-session" which returns the clientSecret doesnt it?

slow current
#

it's just that you're missing the await keyword, which means you call mount on the Promise object, not the actual object returned

inland gull
#

hmm, so i am forced to use the async function?

#

which i really dont want to do

#

i think i understand what you are saying. i'll try async function initialize() {

slow current
#

why don't you want it?

#

and yes it's required because initEmbeddedCheckout is an async action that involves things like making some API requests to set up the library/session etc

inland gull
#

the reason i dont want it is because I am also using braintreepayments dropin ui and trying to utilize code for both gateways.

#

i'm going to test the async init.

#

OMG thank you so much!!

#

I basically just did:

#

initialize(response.clientSecret);

            // Fetch Checkout Session and retrieve the client secret
            async function initialize(clientSecret) {
              // Initialize Checkout
              const checkout = await stripe.initEmbeddedCheckout({
                  clientSecret: clientSecret,
                  onComplete: () => alert('Success'),
              });

              // Mount Checkout
              checkout.mount("#st-dropin");
            }
#

this has mounted the payment div perfectly. I have been at this for a whole day scratching my head so thank you so much @slow current