Sha256: 3c16c4744c489ee52d9f6068bead0d656e683c94ec9569fd36356cfa1d131596

Contents?: true

Size: 1.03 KB

Versions: 62

Compression:

Stored size: 1.03 KB

Contents

module Workarea
  module Storefront
    module CreditCardsHelper
      def credit_card_issuer_icon(issuer)
        icon_path = if card_icon_available?(issuer.optionize)
                      "workarea/storefront/payment_icons/#{issuer.systemize}.svg"
                    else
                      'workarea/storefront/default_card.svg'
                    end

        inline_svg(icon_path, class: "payment-icon payment-icon--#{issuer.downcase.dasherize}", title: issuer.humanize)
      end

      def card_icon_name(issuer)
        issuer.parameterize.underscore
      end

      def all_payment_icons
        icons = credit_card_issuers.reduce('') do |memo, issuer|
          memo + credit_card_issuer_icon(issuer.optionize)
        end

        icons.html_safe
      end

      private

      def credit_card_issuers
        Workarea.config.credit_card_issuers.values
      end

      def card_icon_available?(issuer)
        return false if issuer == 'test_card'
        credit_card_issuers.any? { |s| s.optionize == issuer }
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-storefront-3.5.15 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.4.36 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.5.14 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.4.35 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.5.13 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.4.34 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.5.12 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.4.33 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.5.11 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.5.10 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.4.32 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.5.9 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.4.31 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.5.8 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.4.30 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.5.7 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.4.29 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.5.6 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.4.28 app/helpers/workarea/storefront/credit_cards_helper.rb
workarea-storefront-3.5.5 app/helpers/workarea/storefront/credit_cards_helper.rb