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.



56388
56389
56390
56391
56392
56393
56394
56395
56396
56397
56398
56399
56400
56401
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56388

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.



56386
56387
56388
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56386

def amount
  @amount
end

#capturesObject (readonly)

Returns the value of attribute captures.



56386
56387
56388
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56386

def captures
  @captures
end

#created_atObject (readonly)

Returns the value of attribute created_at.



56386
56387
56388
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56386

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



56386
56387
56388
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56386

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



56386
56387
56388
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56386

def id
  @id
end

#payment_method_summaryObject (readonly)

Returns the value of attribute payment_method_summary.



56386
56387
56388
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56386

def payment_method_summary
  @payment_method_summary
end

#refundsObject (readonly)

Returns the value of attribute refunds.



56386
56387
56388
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56386

def refunds
  @refunds
end

#reversalsObject (readonly)

Returns the value of attribute reversals.



56386
56387
56388
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56386

def reversals
  @reversals
end

#statusObject (readonly)

Returns the value of attribute status.



56386
56387
56388
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56386

def status
  @status
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



56386
56387
56388
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56386

def updated_at
  @updated_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



56407
56408
56409
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56407

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

#to_hashObject



56411
56412
56413
56414
56415
56416
56417
56418
56419
56420
56421
56422
56423
56424
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56411

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



56403
56404
56405
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56403

def to_json
  JSON.dump(to_hash)
end