mirror of https://github.com/itflow-org/itflow
24 lines
643 B
JavaScript
24 lines
643 B
JavaScript
// Initialize Stripe.js
|
|
const stripe = Stripe(document.getElementById("stripe_publishable_key").value);
|
|
|
|
initialize();
|
|
|
|
// Fetch Checkout Session and retrieve the client secret
|
|
async function initialize() {
|
|
const fetchClientSecret = async () => {
|
|
const response = await fetch("/client/post.php?create_stripe_checkout", {
|
|
method: "POST",
|
|
});
|
|
const { clientSecret } = await response.json();
|
|
return clientSecret;
|
|
};
|
|
|
|
// Initialize Checkout
|
|
const checkout = await stripe.initEmbeddedCheckout({
|
|
fetchClientSecret,
|
|
});
|
|
|
|
// Mount Checkout
|
|
checkout.mount('#checkout');
|
|
}
|