Server IP : 192.185.129.71 / Your IP : 3.144.3.100 Web Server : Apache System : Linux bh-ht-3.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : svymadmin ( 4072) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home4/svymadmin/public_html/vivekaexcel.edu.in/school/assets/payment/js/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
var stripe = Stripe(stripe_key); var elements = stripe.elements(); var card = elements.create("card", { iconStyle: "solid", style: { base: { iconColor: "#8898AA", color: "white", lineHeight: "36px", fontWeight: 300, fontFamily: '"Helvetica Neue", Helvetica, sans-serif', fontSize: "19px", "::placeholder": { color: "#8898AA" } }, invalid: { iconColor: "#e85746", color: "#e85746" } }, classes: { focus: "is-focused", empty: "is-empty" } }); card.mount("#card-element"); var inputs = document.querySelectorAll("input.field"); Array.prototype.forEach.call(inputs, function(input) { input.addEventListener("focus", function() { input.classList.add("is-focused"); }); input.addEventListener("blur", function() { input.classList.remove("is-focused"); }); input.addEventListener("keyup", function() { if (input.value.length === 0) { input.classList.add("is-empty"); } else { input.classList.remove("is-empty"); } }); }); var form = document.querySelector("form"); function setOutcome(result) { var successElement = document.querySelector(".success"); var errorElement = document.querySelector(".error"); successElement.classList.remove("visible"); errorElement.classList.remove("visible"); if (result.token) { // Use the token to create a charge or a customer // https://stripe.com/docs/charges //successElement.querySelector(".token").textContent = result.token.id; form.querySelector("input[name=stripeToken]").value = result.token.id; form.submit(); //successElement.classList.add("visible"); } else if (result.error) { errorElement.textContent = result.error.message; errorElement.classList.add("visible"); } } card.on("change", function(event) { setOutcome(event); }); document.querySelector("form").addEventListener("submit", function(e) { e.preventDefault(); var extraDetails = { //name: form.querySelector("input[name=cardholder-name]").value }; stripe.createToken(card, extraDetails).then(setOutcome); });