Connecting our form to stripe.js

This commit is contained in:
vinchent 2024-08-04 14:55:29 +02:00
parent 00b58c5b3a
commit e30dc5865e

View File

@ -56,8 +56,44 @@ Virtual Terminal
{{ define "js" }} {{ define "js" }}
<script src="https://js.stripe.com/v3/"></script> <script src="https://js.stripe.com/v3/"></script>
<script> <script>
let card;
let stripe;
stripe = Stripe(''); // TODO: Publish key to be added
function val() { function val() {
} }
(function () {
// create stripe & elements
const elements = stripe.elements();
const style = {
base: {
fontSize: '16px',
lineHeight: '24px',
}
};
// create card entry
card = elements.create('card', {
style:style,
hidePostalCode: true,
});
card.mount("#card-element");
// check for input errors
card.addEventListener('change', function(event) {
var displayError = document.getElementById("card-errors");
if (event.error) {
displayError.classList.remove('d-none');
displayError.textContent = event.error.message;
} else {
displayError.classList.add('d-none');
displayError.textContent = "";
}
});
})();
</script> </script>
{{ end }} {{ end }}