class Io::Flow::V0::Models::PaymentAuthorization

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.

Attributes

amount[R]
captures[R]
created_at[R]
currency[R]
id[R]
payment_method_summary[R]
refunds[R]
reversals[R]
status[R]
updated_at[R]

Public Class Methods

new(incoming={}) click to toggle source
# 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

Public Instance Methods

copy(incoming={}) click to toggle source
# 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_hash() click to toggle source
# 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_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 56403
def to_json
  JSON.dump(to_hash)
end