Sha256: 265227b8f84844386d5671abcff42133b20b00831c5fd0c280c19f6658cf32a9

Contents?: true

Size: 678 Bytes

Versions: 3

Compression:

Stored size: 678 Bytes

Contents

module Transactionable
  module CreditCardTransactionable
    extend ActiveSupport::Concern
    include BalancedCustomer

    included do
      has_many :credit_cards, as: :credit_cardable, dependent: :destroy, class_name: "Transactionable::CreditCard"

      def add_credit_card(balanced_uri, credit_card = {})
        self.credit_cards.destroy_all if one_card?
        credit_card = self.credit_cards.create
        remote_card = RemoteCreditCard.create(uri: balanced_uri, local_entity: credit_card)
        credit_card.reload.sync
        sync_customer
        self.reload.remote.add_card(balanced_uri)
      end

      def one_card?
        false
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
transactionable-0.3.0 lib/transactionable/credit_card_transactionable.rb
transactionable-0.2.0 lib/transactionable/credit_card_transactionable.rb
transactionable-0.1.0 lib/transactionable/credit_card_transactionable.rb