So I'm having some trouble. Even after trying many different solutions my problem is still persistent.
The button click will fire the java script code, but not the server side code.
<asp:Button ID="btnSubmit" runat="server" CssClass="ins_sub_btn_form_map" OnClientClick="javascript: stripeSubmit(); return true;" onClick="btnSubmit_Click"
UseSubmitBehavior="false" ValidationGroup="Submit" Text="Submit" />
here's my javascript:
function stripeResponseHandler(status, response) {
if (response.error) {
// show the errors on the form
$(".payment-errors").html(response.error.message);
} else {
var form$ = $("#form1");
// 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("<input type='visible' id='stripeToken' name='stripeToken' value='" + token + "' />");
// and submit
form$.get(0).submit();
}
}
function stripeSubmit() {
Stripe.setPublishableKey($("input#txtStripePK").val());
var expDate = $("input#txtExpirationDate").val();
if (Stripe.card.validateCardNumber($("input#txtCreditCardNumber").val()) == false)
{
alert("Credit Card Number Error");
return;
}
if (Stripe.card.validateCVC($("input#txtCVVNumber").val()) == false) {
alert("CVN Number Error");
return;
}
if (Stripe.card.validateExpiry((expDate.slice(0, 2)) , ("20" + expDate.slice(2, 4))) == false) {
alert("Expiration Date Error");
return;
}
// createToken returns immediately - the supplied callback submits the form if there are no errors
Stripe.card.createToken({
number: $("input#txtCreditCardNumber").val(),
cvc: $("input#txtCVVNumber").val(),
exp_month: (expDate.slice(0, 2)),
exp_year: ("20" + expDate.slice(2, 4))
}, stripeResponseHandler);
//return true; // submit from callback
}
I've tried it without the return true in javascript, with it in javascript. Also tried it without the return true in the onClientClick, also without the "javascript:". Literally everything I can think of.
Any help is appreciated. Thanks in advance.