Class: Io::Flow::V0::Models::PaymentPaypal

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

Overview

Represents an online payment processed through PayPal.

Instance Attribute Summary collapse

Attributes inherited from Payment

#discriminator

Instance Method Summary collapse

Methods inherited from Payment

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ PaymentPaypal

Returns a new instance of PaymentPaypal.



51530
51531
51532
51533
51534
51535
51536
51537
51538
51539
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51530

def initialize(incoming={})
  super(:discriminator => Payment::Types::PAYMENT_PAYPAL)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :amount, :currency, :paypal], 'PaymentPaypal')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @order = (x = opts.delete(:order); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::AuthorizationOrderReference) ? x : ::Io::Flow::V0::Models::AuthorizationOrderReference.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)
  @paypal = (x = opts.delete(:paypal); x.is_a?(::Io::Flow::V0::Models::OnlineAuthorizationDetails) ? x : ::Io::Flow::V0::Models::OnlineAuthorizationDetails.from_json(x))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



51528
51529
51530
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51528

def amount
  @amount
end

#currencyObject (readonly)

Returns the value of attribute currency.



51528
51529
51530
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51528

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



51528
51529
51530
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51528

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



51528
51529
51530
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51528

def order
  @order
end

#paypalObject (readonly)

Returns the value of attribute paypal.



51528
51529
51530
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51528

def paypal
  @paypal
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



51545
51546
51547
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51545

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

#subtype_to_hashObject



51549
51550
51551
51552
51553
51554
51555
51556
51557
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51549

def subtype_to_hash
  {
    :id => id,
    :order => order.nil? ? nil : order.to_hash,
    :amount => amount.to_f.to_s,
    :currency => currency,
    :paypal => paypal.to_hash
  }
end

#to_jsonObject



51541
51542
51543
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51541

def to_json
  JSON.dump(to_hash)
end