Sha256: 155deabb663fd3f58c08db54f90ebcf526c4b5690daa545a76b02336c93c5407

Contents?: true

Size: 728 Bytes

Versions: 6

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

6 entries across 6 versions & 1 rubygems

Version Path
nexio_activemerchant-0.3.0 lib/active_merchant/billing/encrypted_nexio_card.rb
nexio_activemerchant-0.2.8 lib/active_merchant/billing/encrypted_nexio_card.rb
nexio_activemerchant-0.2.7 lib/active_merchant/billing/encrypted_nexio_card.rb
nexio_activemerchant-0.2.6 lib/active_merchant/billing/encrypted_nexio_card.rb
nexio_activemerchant-0.2.5 lib/active_merchant/billing/encrypted_nexio_card.rb
nexio_activemerchant-0.2.4 lib/active_merchant/billing/encrypted_nexio_card.rb