Connecting our form to stripe.js
This commit is contained in:
parent
00b58c5b3a
commit
e30dc5865e
@ -56,8 +56,44 @@ Virtual Terminal
|
||||
{{ define "js" }}
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
<script>
|
||||
|
||||
let card;
|
||||
let stripe;
|
||||
|
||||
stripe = Stripe(''); // TODO: Publish key to be added
|
||||
|
||||
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>
|
||||
{{ end }}
|
||||
|
Loading…
Reference in New Issue
Block a user