mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Initial add Stripe Auto-payment with saved card
This commit is contained in:
23
js/autopay_setup_stripe.js
Normal file
23
js/autopay_setup_stripe.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// Initialize Stripe.js
|
||||
const stripe = Stripe('pk_test_51OTpmkHRGkC845Mqz0zM2A1pjnnXwOyD5tyPzWnRwVthuizNjuBIjoYgMHBMLQBuegrUXQpIyX4yr1fNMo7QzCs500bBnFJgEr');
|
||||
|
||||
initialize();
|
||||
|
||||
// Fetch Checkout Session and retrieve the client secret
|
||||
async function initialize() {
|
||||
const fetchClientSecret = async () => {
|
||||
const response = await fetch("/portal/portal_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');
|
||||
}
|
||||
Reference in New Issue
Block a user