Class: Square::Connect::Payment

Inherits:
Node
  • Object
show all
Defined in:
lib/square/connect/payment.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#access_token, #endpoint, #identifier

Instance Method Summary collapse

Methods inherited from Node

#fetch

Constructor Details

#initialize(*args) ⇒ Payment

Returns a new instance of Payment.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/square/connect/payment.rb', line 26

def initialize(*args)
  super do |attributes|
    self.merchant = if attributes[:merchant_id]
      Merchant.new attributes[:merchant_id], access_token
    else
      Merchant.me access_token
    end
    self.creator = if attributes[:creator_id]
      Merchant.new attributes[:creator_id], access_token
    end
    self.created_at = if attributes[:created_at]
      Time.parse attributes[:created_at]
    end
    self.description = attributes[:description]
    self.device = if attributes[:device]
      Device.new attributes[:device]
    end
    [
      :inclusive_tax_money,
      :additive_tax_money,
      :tax_money,
      :tip_money,
      :discount_money,
      :total_collected_money,
      :processing_fee_money,
      :net_total_money,
      :refunded_money
    ].each do |money_key|
      if attributes[money_key]
        self.send "#{money_key}=", Money.new(attributes[money_key])
      end
    end
    [
      :inclusive_tax,
      :additive_tax
    ].each do |tax_key|
      taxes = Array(attributes[tax_key]).collect do |tax_attributes|
        Tax.new tax_attributes
      end
      self.send "#{tax_key}=", taxes
    end
    self.tender = Array(attributes[:tender]).collect do |tender_attributes|
      Tender.new tender_attributes
    end
    self.refunds = Array(attributes[:refunds]).collect do |refund_attributes|
      Refund.new refund_attributes
    end
    self.itemizations = Array(attributes[:itemizations]).collect do |itemization_attributes|
      Itemization.new itemization_attributes
    end
    self.endpoint = endpoint_for merchant.identifier, :payments, identifier
  end
end

Instance Attribute Details

#additive_taxObject

Returns the value of attribute additive_tax.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def additive_tax
  @additive_tax
end

#additive_tax_moneyObject

Returns the value of attribute additive_tax_money.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def additive_tax_money
  @additive_tax_money
end

#created_atObject

Returns the value of attribute created_at.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def created_at
  @created_at
end

#creatorObject

Returns the value of attribute creator.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def creator
  @creator
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def description
  @description
end

#deviceObject

Returns the value of attribute device.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def device
  @device
end

#discount_moneyObject

Returns the value of attribute discount_money.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def discount_money
  @discount_money
end

#inclusive_taxObject

Returns the value of attribute inclusive_tax.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def inclusive_tax
  @inclusive_tax
end

#inclusive_tax_moneyObject

Returns the value of attribute inclusive_tax_money.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def inclusive_tax_money
  @inclusive_tax_money
end

#itemizationsObject

Returns the value of attribute itemizations.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def itemizations
  @itemizations
end

#merchantObject

Returns the value of attribute merchant.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def merchant
  @merchant
end

#net_total_moneyObject

Returns the value of attribute net_total_money.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def net_total_money
  @net_total_money
end

#processing_fee_moneyObject

Returns the value of attribute processing_fee_money.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def processing_fee_money
  @processing_fee_money
end

#refunded_moneyObject

Returns the value of attribute refunded_money.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def refunded_money
  @refunded_money
end

#refundsObject

Returns the value of attribute refunds.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def refunds
  @refunds
end

#tax_moneyObject

Returns the value of attribute tax_money.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def tax_money
  @tax_money
end

#tenderObject

Returns the value of attribute tender.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def tender
  @tender
end

#tip_moneyObject

Returns the value of attribute tip_money.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def tip_money
  @tip_money
end

#total_collected_moneyObject

Returns the value of attribute total_collected_money.



4
5
6
# File 'lib/square/connect/payment.rb', line 4

def total_collected_money
  @total_collected_money
end