mirror of
https://github.com/itflow-org/itflow
synced 2026-09-13 10:15:15 +00:00
Cleanup - fix two broken script paths and drop 29 dead/duplicate files (348KB of unused FullCalendar themes)
This commit is contained in:
@@ -73,7 +73,7 @@ if (!$config_stripe_enable || !$config_stripe_publishable || !$config_stripe_sec
|
||||
|
||||
<input type="hidden" id="stripe_publishable_key" value="<?= $config_stripe_publishable ?>">
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
<script src="js/autopay_setup_stripe.js"></script>
|
||||
<script src="/js/autopay_setup_stripe.js"></script>
|
||||
<div id="checkout">
|
||||
<!-- Checkout will insert the payment form here -->
|
||||
</div>
|
||||
|
||||
@@ -29,18 +29,6 @@ echo getUserAgent();
|
||||
|
||||
<input type="tel" name="phone" id="phone">
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Minimal</label>
|
||||
<select class="form-select select2 select2-hidden-accessible" style="width: 100%;" data-select2-id="1" tabindex="-1" aria-hidden="true">
|
||||
<option selected="selected" data-select2-id="3">Alabama</option>
|
||||
<option data-select2-id="35">Alaska</option>
|
||||
<option data-select2-id="36">California</option>
|
||||
<option data-select2-id="37">Delaware</option>
|
||||
<option data-select2-id="38">Tennessee</option>
|
||||
<option data-select2-id="39">Texas</option>
|
||||
<option data-select2-id="40">Washington</option>
|
||||
</select><span class="select2 select2-container select2-container--default select2-container--below" dir="ltr" data-select2-id="2" style="width: 100%;"><span class="selection"><span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-disabled="false" aria-labelledby="select2-nbex-container"><span class="select2-selection__rendered" id="select2-nbex-container" role="textbox" aria-readonly="true" title="Alabama">Alabama</span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span></span></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>
|
||||
</div>
|
||||
|
||||
<dl>
|
||||
<dt>Requester</dt>
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
const stripe = Stripe(document.getElementById("stripe_publishable_key").value);
|
||||
|
||||
let elements;
|
||||
|
||||
initialize();
|
||||
checkStatus();
|
||||
|
||||
document
|
||||
.querySelector("#payment-form")
|
||||
.addEventListener("submit", handleSubmit);
|
||||
|
||||
let emailAddress = '';
|
||||
// Fetches a payment intent and captures the client secret
|
||||
async function initialize() {
|
||||
const { clientSecret } = await fetch("guest_ajax.php?stripe_create_pi=true", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
invoice_id: document.getElementById("invoice_id").value,
|
||||
url_key: document.getElementById("url_key").value
|
||||
}),
|
||||
}).then((r) => r.json());
|
||||
|
||||
elements = stripe.elements({ clientSecret });
|
||||
|
||||
const paymentElementOptions = {
|
||||
layout: "tabs",
|
||||
};
|
||||
|
||||
const paymentElement = elements.create("payment", paymentElementOptions);
|
||||
paymentElement.mount("#payment-element");
|
||||
|
||||
// Unhide the submit button once everything has loaded
|
||||
document.getElementById("submit").hidden = false;
|
||||
}
|
||||
|
||||
async function handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
setLoading(true);
|
||||
|
||||
const { error } = await stripe.confirmPayment({
|
||||
elements,
|
||||
confirmParams: {
|
||||
return_url: window.location.href,
|
||||
receipt_email: emailAddress,
|
||||
},
|
||||
});
|
||||
|
||||
// This point will only be reached if there is an immediate error when
|
||||
// confirming the payment. Otherwise, your customer will be redirected to
|
||||
// your `return_url`. For some payment methods like iDEAL, your customer will
|
||||
// be redirected to an intermediate site first to authorize the payment, then
|
||||
// redirected to the `return_url`.
|
||||
if (error.type === "card_error" || error.type === "validation_error") {
|
||||
showMessage(error.message);
|
||||
} else {
|
||||
showMessage("An unexpected error occurred.");
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
// Fetches the payment intent status after payment submission
|
||||
async function checkStatus() {
|
||||
const clientSecret = new URLSearchParams(window.location.search).get(
|
||||
"payment_intent_client_secret"
|
||||
);
|
||||
|
||||
if (!clientSecret) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { paymentIntent } = await stripe.retrievePaymentIntent(clientSecret);
|
||||
|
||||
switch (paymentIntent.status) {
|
||||
case "succeeded":
|
||||
showMessage("Payment succeeded!");
|
||||
break;
|
||||
case "processing":
|
||||
showMessage("Your payment is processing.");
|
||||
break;
|
||||
case "requires_payment_method":
|
||||
showMessage("Your payment was not successful, please try again.");
|
||||
break;
|
||||
default:
|
||||
showMessage("Something went wrong.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ------- UI helpers -------
|
||||
|
||||
function showMessage(messageText) {
|
||||
const messageContainer = document.querySelector("#payment-message");
|
||||
|
||||
messageContainer.classList.remove("hidden");
|
||||
messageContainer.textContent = messageText;
|
||||
|
||||
setTimeout(function () {
|
||||
messageContainer.classList.add("hidden");
|
||||
messageText.textContent = "";
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
// Show a spinner on payment submission
|
||||
function setLoading(isLoading) {
|
||||
if (isLoading) {
|
||||
// Disable the button and show a spinner
|
||||
document.querySelector("#submit").disabled = true;
|
||||
document.querySelector("#spinner").classList.remove("hidden");
|
||||
document.querySelector("#button-text").classList.add("hidden");
|
||||
} else {
|
||||
document.querySelector("#submit").disabled = false;
|
||||
document.querySelector("#spinner").classList.add("hidden");
|
||||
document.querySelector("#button-text").classList.remove("hidden");
|
||||
}
|
||||
}
|
||||
@@ -625,8 +625,16 @@ ob_start();
|
||||
</div>
|
||||
</div>
|
||||
<!-- Include scripts to fetch TOTP codes and passwords via the credential ID -->
|
||||
<script src="../js/credential_show_otp_via_id.js"></script>
|
||||
<script src="../js/credential_show_password_via_id.js"></script>
|
||||
<?php /* NOT ../js/ - this file is injected by js/ajax_modal.js, so a
|
||||
relative src resolves against the HOST page's URL (/agent/...),
|
||||
not this file's path. ../js/ therefore reached docroot, where
|
||||
credential_show_password_via_id.js does not exist at all and
|
||||
credential_show_otp_via_id.js was a stale copy posting to a
|
||||
/ajax.php that does not exist - which then redefined
|
||||
showOTPViaCredentialID and broke the reveal on the host page
|
||||
too. agent/modals/contact/contact.php has always used js/. */ ?>
|
||||
<script src="js/credential_show_otp_via_id.js"></script>
|
||||
<script src="js/credential_show_password_via_id.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($ticket_count) { ?>
|
||||
|
||||
Reference in New Issue
Block a user