// This identifies your website in the createToken call below Stripe.setPublishableKey(''); //Stripe.setPublishableKey('pk_live_aq1a8qr90pTjUfPqVMqqXWOj'); var stripeResponseHandler = function(status, response) { var $form = $('form#newAccount'); if (response.error) { // Show the errors on the form $form.find('.payment-errors').text(response.error.message); alert(response.error.message); } else { // token contains id, last4, and card type var token = response.id; // Insert the token into the form so it gets submitted to the server $form.append($('').val(token)); // Serialize the form var data=$('#newAccount').serialize(); // Send form to server with POST method /* $(function() { $.ajax({ type: "POST", url: "https://my.deerdat.com/_assets/js/ajax/account/stripeCreate.php", data: data, success: function(returndata){ responseData=JSON.parse(returndata); $form.find('button').prop('disabled', false); $('.payment-errors').text(responseData['message']); alert(responseData['message']); } error: function(returndata){ responseData=JSON.parse(returndata); $form.find('button').prop('disabled', false); $('.payment-errors').text(responseData['message']); alert(responseData['message']); } }); }); */ $(function() { var formData = new FormData($('form#newAccount')[0]); $.ajax({ url: '/includes/javascripts/ajax/account/stripeCreate.php', type: 'POST', data: formData, async: false, cache: false, contentType: false, processData: false, success: function(returndata){ responseData=JSON.parse(returndata); $form.find('button').prop('disabled', false); $('.payment-errors').text(''); alert(responseData['message']); }, error: function (returndata) { // was not able to connect to server responseData=JSON.parse(returndata); $form.find('button').prop('disabled', false); //$('.payment-errors').text(responseData['message']); alert(responseData['message']); } }); }); // // Prevent page from refreshing return false; } }; // ONCLICK RESPONSE jQuery(function($) { $('#createAccount').on('click', function(e){ e.preventDefault(); e.stopImmediatePropagation(); var $form = $('form#newAccount'); // // Disable the submit button to prevent repeated clicks //$form.find('button').prop('disabled', true); $form.find('button').prop('disabled', false); // //Stripe.card.createToken({ // number: $('#card-number').val(), // cvc: $('#card-cvc').val(), // exp_month: $('#card-expiry-month').val(), // exp_year: $('#card-expiry-year').val() //}, stripeResponseHandler); // // Stripe.card.createToken($form, stripeResponseHandler); // // Prevent the form from submitting with the default action return false; }); });