Sha256: 7a97dfffcf3f78d3ebc75e6ad37076fbeb816c38b87b6da691f1291be5de1214

Contents?: true

Size: 1.72 KB

Versions: 104

Compression:

Stored size: 1.72 KB

Contents

Spree.ready(function($) {
  Spree.onPayment = function() {
    if ($("#checkout_form_payment").is("*")) {
      if ($("#existing_cards").is("*")) {
        $("#payment-method-fields").hide();
        $("#payment-methods").hide();

        $("#use_existing_card_yes").click(function() {
          $("#payment-method-fields").hide();
          $("#payment-methods").hide();
          $(".existing-cc-radio").prop("disabled", false);
        });

        $("#use_existing_card_no").click(function() {
          $("#payment-method-fields").show();
          $("#payment-methods").show();
          $(".existing-cc-radio").prop("disabled", true);
        });
      }

      $(".cardNumber").payment("formatCardNumber");
      $(".cardExpiry").payment("formatCardExpiry");
      $(".cardCode").payment("formatCardCVC");

      $(".cardNumber").change(function() {
        $(this)
          .parent()
          .siblings(".ccType")
          .val($.payment.cardType(this.value));
      });

      $(
        'input[type="radio"][name="order[payments_attributes][][payment_method_id]"]'
      ).click(function() {
        $("#payment-methods li").hide();
        if (this.checked) {
          $("#payment_method_" + this.value).show();
        }
      });

      $("#cvv_link").on("click", function(event) {
        var windowName = "cvv_info";
        var windowOptions =
          "left=20,top=20,width=500,height=500,toolbar=0,resizable=0,scrollbars=1";
        window.open($(this).attr("href"), windowName, windowOptions);
        event.preventDefault();
      });

      // Activate already checked payment method if form is re-rendered
      // i.e. if user enters invalid data
      $('input[type="radio"]:checked').click();
    }
  };
  Spree.onPayment();
});

Version data entries

104 entries across 104 versions & 2 rubygems

Version Path
solidus_frontend-4.0.0 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-4.0.0.dev app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.4.0 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.1.9 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.4.0.dev app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.3.0 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.2.5 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.2.4 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.2.3 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.1.8 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.0.8 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.2.2 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.2.1 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.3.0.alpha app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.2.0 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.2.0.alpha app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.0.7 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-2.11.17 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-3.1.7 app/assets/javascripts/spree/frontend/checkout/payment.js
solidus_frontend-2.11.16 app/assets/javascripts/spree/frontend/checkout/payment.js