#.leb_

1 messages ยท Page 1 of 1 (latest)

idle eagleBOT
cosmic pivot
#

Hello

#

That's correct, if you don't want to redirect your customer to the page then you would use embedded Checkout

#

If there is something specific confusing you then I'd be happy to help

tidal grove
#

Ok, I'll try it here following this documentation link.

cosmic pivot
#

๐Ÿ‘

tidal grove
#

initEmbeddedCheckout is deprecated?

#
const stripe = Stripe('pk_test_123');

initialize();

// Fetch Checkout Session and retrieve the client secret
async function initialize() {
  const response = await fetch("/create-checkout-session", {
    method: "POST",
  });

  const { clientSecret } = await response.json();

  const checkout = await stripe.initEmbeddedCheckout({
    clientSecret,
  });

  // Mount Checkout
  checkout.mount('#checkout');
}
cosmic pivot
#

Should not be deprecated, no.

tidal grove
#

at the time of writing const create_checkout = await stripe., initEmbeddedCheckout is not being referenced

#

library Stripe in my package.json: "stripe": "^14.2.0",

cosmic pivot
#

Are you importing Stripe.JS as a script?

tidal grove
#

hmm, no. Is it really necessary to install via CDN in script? By NPM wouldn't it be the same thing?

cosmic pivot
#

You can use it as a module, yes.

lone peak
#

Hi there ๐Ÿ‘‹ jumping in as my teammate needs to step away soon.

When you said that the version you're using is 14.2.0, I think that is referring to our server-side Node library that you're including in your project:
https://github.com/stripe/stripe-node

Can you help me understand how you're currently including Stripe.js (where the initEmbeddedCheckout function is coming from) in your site?
https://stripe.com/docs/js/including

tidal grove
#
import Stripe from 'stripe';



function myFunction(id: string) {
            const stripe = new Stripe(import.meta.env.VITE_STRIPE_PUBLIC_KEY);

            try {
                const create_checkout = await stripe.initEmbeddedCheckout({
                    clientSecret: id
                });
                
                create_checkout.mount('#_reference-frame-stripe-payment');
            } catch (error) {
                console.log(error);
            }
}

Property 'initEmbeddedCheckout' does not exist on type 'Stripe'.ts(2339)

lone peak
#

Ah, it's the type script that is missing the property. Are you getting the types directly from us as part of our stripe.js module?
Version 2.1.9 of that module removed the beta requirement for embedded checkout flows, but it already supported the fields I believe:
https://github.com/stripe/stripe-js/releases/tag/v2.1.9

tidal grove
#

And is there any other method that replaces initEmbeddedCheckout to perform this checkout integration on the page itself (as if it were a modal)?

lone peak
#

No, that's the function you need to use for embedded checkout flows.