Added stripe load method

no issue

- Load Stripe script if not already loaded on page
- Many members.js features rely on Stripe script to be loaded on the page to allow checkout/billing updates etc.
This commit is contained in:
Rish 2020-05-27 18:03:12 +05:30
parent fc75d9881d
commit 9cf8e0e435

View File

@ -11,6 +11,20 @@ function addRootDiv() {
document.body.appendChild(elem);
}
function loadStripe() {
// We don't want to load Stripe again if already loaded
if (!window.Stripe) {
// Get the first script element on the page
const ref = document.getElementsByTagName('script')[0];
// Create a new script element
const script = document.createElement('script');
// Set the script element `src`
script.src = 'https://js.stripe.com/v3/';
// Inject the script into the DOM
ref.parentNode.insertBefore(script, ref);
}
}
function handleTokenUrl() {
const url = new URL(window.location);
if (url.searchParams.get('token')) {