Sha256: e7c684c240ce742e06977266456d05785529b54403a95162173b5e9ba43989f0

Contents?: true

Size: 728 Bytes

Versions: 5

Compression:

Stored size: 728 Bytes

Contents

# frozen_string_literal: true

module ActiveMerchant
  module Billing
    class EncryptedNexioCard < CreditCard
      ALLOWED_CARD_BRANDS = %w[amex discover jcb mastercard visa].freeze

      attr_accessor :encrypted_number, :own_form, :one_time_token

      attr_reader :brand

      def short_year
        year % 100 if year
      end

      private

      def validate_card_brand_and_number
        errors = []

        if empty?(brand)
          errors << [:brand, 'is required'] if own_form
        elsif !ALLOWED_CARD_BRANDS.include?(brand)
          errors << [:brand, 'is invalid']
        end

        errors << [:encrypted_number, 'is required'] if empty?(encrypted_number)

        errors
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nexio_activemerchant-0.4.3 lib/active_merchant/billing/encrypted_nexio_card.rb
nexio_activemerchant-0.4.2 lib/active_merchant/billing/encrypted_nexio_card.rb
nexio_activemerchant-0.4.1 lib/active_merchant/billing/encrypted_nexio_card.rb
nexio_activemerchant-0.4.0 lib/active_merchant/billing/encrypted_nexio_card.rb
nexio_activemerchant-0.3.1 lib/active_merchant/billing/encrypted_nexio_card.rb