#rangermillze_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/1267784140376248380
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi! you are missing the await for initEmbeddedCheckout, that's why.
https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=embedded-form&client=html#mount-checkout
I already have the clientSecret I am passing to initEmbeddedCheckout
that's not related to what I said
looking at doc's the await is just calling "create-checkout-session" which returns the clientSecret doesnt it?
it's just that you're missing the await keyword, which means you call mount on the Promise object, not the actual object returned
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() {
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
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