import { hidePayButton, showPayButton, showCardError, showCardSuccess, stripe, card, processing, } from './common.js'; export function val() { let form = document.getElementById("charge_form"); if (form.checkValidity() === false) { this.event.preventDefault(); this.event.stopPropagation(); form.classList.add("was-validated"); return; } form.classList.add("was-validated"); hidePayButton(); let amountToCharge = document.getElementById("amount").value; stripe.createPaymentMethod({ type: 'card', card: card, billing_details: { email: document.getElementById("cardholder-email").value, }, }).then(stripePaymentMethodHandler); } function stripePaymentMethodHandler(result) { if (result.error) { showCardError(result.error.message); } else { // create a customer and subscribe to plan } }