Sha256: 746b01e97c60e5906c2dc4704a491525885f046e446cde8fa798cb890b0725dc

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

module Workarea
  class Payment
    class StoreFlowCreditCard
      include FlowPaymentOperation

      def initialize(credit_card, options = {})
        @credit_card = credit_card
        @options = options
      end

      def perform!
        return true if @credit_card.token.present?

        response = handle_active_merchant_errors do
          gateway.store(@credit_card.to_active_merchant)
        end

        # gateway will return a string if successful and an
        # active merchant error if it fails
        if response.is_a? String
          @credit_card.token = response
          true
        else
          false
        end
      end

      def save!
        perform!
        @credit_card.save
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-flow_io-1.2.1 app/models/workarea/payment/store_flow_credit_card.rb