Sha256: 5eb8272356b0f6aec2662983e9f1e084e9c9d4227c6a84addda67970cfecf2fe

Contents?: true

Size: 711 Bytes

Versions: 3

Compression:

Stored size: 711 Bytes

Contents

module Workarea
  decorate Payment::Tender::CreditCard, Payment::SavedCreditCard, with: :stripe do
    decorated do
      field :stripe_token, type: String
    end

    def stripe?
      stripe_token.present?
    end

    def set_display_number
      if !stripe? && number.present?
        self.display_number = ActiveMerchant::Billing::CreditCard.mask(number)
      end
    end

    def set_issuer
      if !stripe? && number.present?
        brand = ActiveMerchant::Billing::CreditCard.brand?(number)

        if brand.present?
          self.issuer = Workarea.config.credit_card_issuers[brand].to_s
        end
      end
    end

    def issuer_accepted
      return if stripe?
      super
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-stripe-1.1.2 app/models/workarea/payment/credit_card.decorator
workarea-stripe-1.1.1 app/models/workarea/payment/credit_card.decorator
workarea-stripe-1.1.0 app/models/workarea/payment/credit_card.decorator