Sha256: 97970b548e78c12fe69af66d460df9ba8848111469955cf9467a809a7a73ba8b

Contents?: true

Size: 1.96 KB

Versions: 33

Compression:

Stored size: 1.96 KB

Contents

#= require spree/frontend/coupon_manager
Spree.ready ($) ->
  Spree.onPayment = () ->
    if ($ '#checkout_form_payment').is('*')

      if ($ '#existing_cards').is('*')
        ($ '#payment-method-fields').hide()
        ($ '#payment-methods').hide()

        ($ '#use_existing_card_yes').click ->
          ($ '#payment-method-fields').hide()
          ($ '#payment-methods').hide()
          ($ '.existing-cc-radio').prop("disabled", false)

        ($ '#use_existing_card_no').click ->
          ($ '#payment-method-fields').show()
          ($ '#payment-methods').show()
          ($ '.existing-cc-radio').prop("disabled", true)


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

      $(".cardNumber").change ->
        $(this).parent().siblings(".ccType").val($.payment.cardType(@value))

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

      ($ document).on('click', '#cvv_link', (event) ->
        windowName = 'cvv_info'
        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()

      $('#checkout_form_payment').submit (event) ->
        input =
          couponCodeField: $('#order_coupon_code')
          couponStatus: $('#coupon_status')
        if input.couponCodeField.val().trim().length > 0
          if new CouponManager(input).applyCoupon()
            @submit()
            return true
          else
            Spree.enableSave()
            event.preventDefault()
            return false

  Spree.onPayment()

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
spree_frontend-3.4.6 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.2.9 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.3.6 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.2.8 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.4.5 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.3.5 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.4.4 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.4.3 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.3.4 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.2.7 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.4.2 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.3.3 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.2.6 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.4.1 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.4.0 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.4.0.rc2 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.4.0.rc1 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.3.2 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.2.5 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee
spree_frontend-3.3.1 app/assets/javascripts/spree/frontend/checkout/payment.js.coffee