Sha256: e0846bfd970d94b8cfe6825b1c7a882f442eb556e36a0c8791a24d04733cd199

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

I"¯(function() {
  var stripeResponseHandler;

  $(function() {
    var $form;
    $form = $('#payment-form');
    $form.submit(function(event) {
      var cardType, cvc, exp, number, valid;
      number = $('input[data-stripe="number"]').val();
      valid = $.payment.validateCardNumber(number);
      if (!valid) {
        alert('Your card is not valid!');
        return false;
      }
      exp = $('input[data-stripe="exp"]').payment('cardExpiryVal');
      valid = $.payment.validateCardExpiry(exp.month, exp.year);
      if (!valid) {
        alert('Your card is not valid!');
        return false;
      }
      cvc = $('input[data-stripe="cvc"]').val();
      cardType = $.payment.cardType(number);
      valid = $.payment.validateCardCVC(cvc, cardType);
      if (!valid) {
        alert('Your card is not valid!');
        return false;
      }
      $form.find('.submit').prop('disabled', true);
      Stripe.card.createToken($form, stripeResponseHandler);
      return false;
    });
    $('input[data-stripe="number"]').payment('formatCardNumber');
    $('input[data-stripe="exp"]').payment('formatCardExpiry');
    $('input[data-stripe="cvc"]').payment('formatCardCVC');
    return $('input[data-stripe="address_zip"]').payment('restrictNumeric');
  });

  stripeResponseHandler = function(status, response) {
    var $form, token;
    $form = $('#payment-form');
    if (response.error) {
      $form.find('.payment-errors').text(response.error.message);
      return $form.find('.submit').prop('disabled', false);
    } else {
      token = response.id;
      $form.append($('<input type="hidden" name="stripe_token">').val(token));
      return $form.get(0).submit();
    }
  };

}).call(this);
:ET

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tang-0.0.1 spec/tang_app/tmp/cache/assets/sprockets/v3.0/4f/4fORX69UQPO3AjO2FqqwWFAE3EXbCSL0EQiup6qVnYY.cache