#.leb_
1 messages ยท Page 1 of 1 (latest)
Hello
That's correct, if you don't want to redirect your customer to the page then you would use embedded Checkout
There is a guide here for how to integrate: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=embedded-checkout
If there is something specific confusing you then I'd be happy to help
Ok, I'll try it here following this documentation link.
๐
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');
}
Should not be deprecated, no.
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",
Are you importing Stripe.JS as a script?
hmm, no. Is it really necessary to install via CDN in script? By NPM wouldn't it be the same thing?
You can use it as a module, yes.
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
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)
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
And is there any other method that replaces initEmbeddedCheckout to perform this checkout integration on the page itself (as if it were a modal)?
No, that's the function you need to use for embedded checkout flows.