mirror of
https://github.com/itflow-org/itflow
synced 2026-11-22 04:17:24 +00:00
Stripe: when Stripe no longer has a client's customer, deleted there or made under other keys, forget it and the cards saved on it so the client sets up again, let new-card payments go ahead, tell agents, and remove the unused autopay_setup_stripe.js
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
// 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');
|
||||
}
|
||||
@@ -105,6 +105,12 @@
|
||||
return fetch('/client/post.php?create_stripe_checkout', {method: 'POST', credentials: 'same-origin'})
|
||||
.then(function (response) { return response.json(); })
|
||||
.then(function (data) {
|
||||
// Their Stripe customer was gone and has been forgotten - the page
|
||||
// comes back with the Add a card step that sets them up again
|
||||
if (data.reload) {
|
||||
window.location.reload();
|
||||
return new Promise(function () {});
|
||||
}
|
||||
if (!data.clientSecret) {
|
||||
throw new Error(data.error || 'No checkout');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user