Class: Io::Flow::V0::Models::PaymentAuthorization

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

All charges to a customer begin with an authorization, which represents the payment provider’s approval for the transaction. When it is authorized, an authorization hold has been placed on the customer’s account - this often appears as a pending charge. This authorization hold will expire unless captured or reversed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ PaymentAuthorization

Returns a new instance of PaymentAuthorization.



52153
52154
52155
52156
52157
52158
52159
52160
52161
52162
52163
52164
52165
52166
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52153

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :payment_method_summary, :captures, :refunds, :reversals, :created_at, :updated_at, :status, :amount, :currency], 'PaymentAuthorization')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @payment_method_summary = (x = opts.delete(:payment_method_summary); x.is_a?(::Io::Flow::V0::Models::PaymentMethodSummary) ? x : ::Io::Flow::V0::Models::PaymentMethodSummary.from_json(x))
  @captures = HttpClient::Preconditions.assert_class('captures', opts.delete(:captures), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PaymentCapture) ? x : ::Io::Flow::V0::Models::PaymentCapture.new(x)) }
  @refunds = HttpClient::Preconditions.assert_class('refunds', opts.delete(:refunds), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PaymentRefund) ? x : ::Io::Flow::V0::Models::PaymentRefund.new(x)) }
  @reversals = HttpClient::Preconditions.assert_class('reversals', opts.delete(:reversals), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PaymentReversal) ? x : ::Io::Flow::V0::Models::PaymentReversal.new(x)) }
  @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime)
  @updated_at = HttpClient::Preconditions.assert_class('updated_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:updated_at)), DateTime)
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::PaymentAuthorizationStatus) ? x : ::Io::Flow::V0::Models::PaymentAuthorizationStatus.new(x))
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



52151
52152
52153
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52151

def amount
  @amount
end

#capturesObject (readonly)

Returns the value of attribute captures.



52151
52152
52153
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52151

def captures
  @captures
end

#created_atObject (readonly)

Returns the value of attribute created_at.



52151
52152
52153
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52151

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



52151
52152
52153
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52151

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



52151
52152
52153
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52151

def id
  @id
end

#payment_method_summaryObject (readonly)

Returns the value of attribute payment_method_summary.



52151
52152
52153
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52151

def payment_method_summary
  @payment_method_summary
end

#refundsObject (readonly)

Returns the value of attribute refunds.



52151
52152
52153
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52151

def refunds
  @refunds
end

#reversalsObject (readonly)

Returns the value of attribute reversals.



52151
52152
52153
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52151

def reversals
  @reversals
end

#statusObject (readonly)

Returns the value of attribute status.



52151
52152
52153
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52151

def status
  @status
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



52151
52152
52153
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52151

def updated_at
  @updated_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



52172
52173
52174
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52172

def copy(incoming={})
  PaymentAuthorization.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



52176
52177
52178
52179
52180
52181
52182
52183
52184
52185
52186
52187
52188
52189
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52176

def to_hash
  {
    :id => id,
    :payment_method_summary => payment_method_summary.to_hash,
    :captures => captures.map { |o| o.to_hash },
    :refunds => refunds.map { |o| o.to_hash },
    :reversals => reversals.map { |o| o.to_hash },
    :created_at => created_at,
    :updated_at => updated_at,
    :status => status.to_hash,
    :amount => amount.to_f.to_s,
    :currency => currency
  }
end

#to_jsonObject



52168
52169
52170
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52168

def to_json
  JSON.dump(to_hash)
end