I'd appreciate any feedback on how this could be possible.
This is how I create and mount the payment element:
let element = stripeFuncs.getElements(client_secret);
element.mount('#userModalMPStripeElement');
And this is the 'getElements' function:
stripeFuncs.getElements = function(csecret) {
const foo = {};
foo.clientSecret = csecret;
const { clientSecret } = foo;
const appearance = { theme: 'flat' };
elements = stripe.elements({ appearance, clientSecret });
const paymentElementOptions = {
layout : 'tabs',
fields : {
billingDetails : {
email : 'auto',
address : { country : 'never' }
}
}
};
paymentElement =
elements.create('payment', paymentElementOptions);
return paymentElement;
};