You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
/*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
|
|
$("#add_child_row").click(function () {
|
|
$.get("parts/template_child_entry.php", {}, function (resp) {
|
|
$("#child_list").append(resp);
|
|
});
|
|
});
|
|
|
|
// Create a Stripe client.
|
|
var stripe = Stripe(stripe_pubkey);
|
|
|
|
// Create an instance of Elements.
|
|
var elements = stripe.elements();
|
|
|
|
// Create an instance of the card Element.
|
|
var card = elements.create('card');
|
|
|
|
// Add an instance of the card Element into the `card-element` <div>.
|
|
card.mount('#card-element');
|
|
|
|
card.addEventListener('change', function (event) {
|
|
if (event.error) {
|
|
$("#card-errors").removeClass("d-none");
|
|
$("#card-errors").text(event.error.message);
|
|
} else {
|
|
$("#card-errors").addClass("d-none");
|
|
$("#card-errors").text("");
|
|
}
|
|
});
|
|
|
|
$("#membershipform").on("submit", function (event) {
|
|
event.preventDefault();
|
|
|
|
stripe.createToken(card).then(function (result) {
|
|
if (result.error) {
|
|
// Inform the customer that there was an error.
|
|
$("#card-errors").removeClass("d-none");
|
|
$("#card-errors").text(event.error.message);
|
|
} else {
|
|
$("#stripe-token").val(result.token.id);
|
|
console.log(result.token);
|
|
document.getElementById('membershipform').submit();
|
|
}
|
|
});
|
|
}); |