Class: SquareConnect::V1Payment

Inherits:
Object
  • Object
show all
Defined in:
lib/square_connect/models/v1_payment.rb

Overview

A payment represents a paid transaction between a Square merchant and a customer. Payment details are usually available from Connect API endpoints within a few minutes after the transaction completes. Each Payment object includes several fields that end in ‘_money`. These fields describe the various amounts of money that contribute to the payment total: <ul> <li> Monetary values are positive if they represent an increase in the amount of money the merchant receives (e.g., tax_money, tip_money). </li> <li> Monetary values are negative if they represent an decrease in the amount of money the merchant receives (e.g., discount_money, refunded_money). </li> </ul>

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ V1Payment

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/square_connect/models/v1_payment.rb', line 165

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}

  if attributes.has_key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.has_key?(:'merchant_id')
    self.merchant_id = attributes[:'merchant_id']
  end

  if attributes.has_key?(:'created_at')
    self.created_at = attributes[:'created_at']
  end

  if attributes.has_key?(:'creator_id')
    self.creator_id = attributes[:'creator_id']
  end

  if attributes.has_key?(:'device')
    self.device = attributes[:'device']
  end

  if attributes.has_key?(:'payment_url')
    self.payment_url = attributes[:'payment_url']
  end

  if attributes.has_key?(:'receipt_url')
    self.receipt_url = attributes[:'receipt_url']
  end

  if attributes.has_key?(:'inclusive_tax_money')
    self.inclusive_tax_money = attributes[:'inclusive_tax_money']
  end

  if attributes.has_key?(:'additive_tax_money')
    self.additive_tax_money = attributes[:'additive_tax_money']
  end

  if attributes.has_key?(:'tax_money')
    self.tax_money = attributes[:'tax_money']
  end

  if attributes.has_key?(:'tip_money')
    self.tip_money = attributes[:'tip_money']
  end

  if attributes.has_key?(:'discount_money')
    self.discount_money = attributes[:'discount_money']
  end

  if attributes.has_key?(:'total_collected_money')
    self.total_collected_money = attributes[:'total_collected_money']
  end

  if attributes.has_key?(:'processing_fee_money')
    self.processing_fee_money = attributes[:'processing_fee_money']
  end

  if attributes.has_key?(:'net_total_money')
    self.net_total_money = attributes[:'net_total_money']
  end

  if attributes.has_key?(:'refunded_money')
    self.refunded_money = attributes[:'refunded_money']
  end

  if attributes.has_key?(:'swedish_rounding_money')
    self.swedish_rounding_money = attributes[:'swedish_rounding_money']
  end

  if attributes.has_key?(:'gross_sales_money')
    self.gross_sales_money = attributes[:'gross_sales_money']
  end

  if attributes.has_key?(:'net_sales_money')
    self.net_sales_money = attributes[:'net_sales_money']
  end

  if attributes.has_key?(:'inclusive_tax')
    if (value = attributes[:'inclusive_tax']).is_a?(Array)
      self.inclusive_tax = value
    end
  end

  if attributes.has_key?(:'additive_tax')
    if (value = attributes[:'additive_tax']).is_a?(Array)
      self.additive_tax = value
    end
  end

  if attributes.has_key?(:'tender')
    if (value = attributes[:'tender']).is_a?(Array)
      self.tender = value
    end
  end

  if attributes.has_key?(:'refunds')
    if (value = attributes[:'refunds']).is_a?(Array)
      self.refunds = value
    end
  end

  if attributes.has_key?(:'itemizations')
    if (value = attributes[:'itemizations']).is_a?(Array)
      self.itemizations = value
    end
  end

  if attributes.has_key?(:'surcharge_money')
    self.surcharge_money = attributes[:'surcharge_money']
  end

  if attributes.has_key?(:'surcharges')
    if (value = attributes[:'surcharges']).is_a?(Array)
      self.surcharges = value
    end
  end

  if attributes.has_key?(:'is_partial')
    self.is_partial = attributes[:'is_partial']
  end

end

Instance Attribute Details

#additive_taxObject

All of the additive taxes associated with the payment.



76
77
78
# File 'lib/square_connect/models/v1_payment.rb', line 76

def additive_tax
  @additive_tax
end

#additive_tax_moneyObject

The sum of all additive taxes associated with the payment.



40
41
42
# File 'lib/square_connect/models/v1_payment.rb', line 40

def additive_tax_money
  @additive_tax_money
end

#created_atObject

The time when the payment was created, in ISO 8601 format. Reflects the time of the first payment if the object represents an incomplete partial payment, and the time of the last or complete payment otherwise.



22
23
24
# File 'lib/square_connect/models/v1_payment.rb', line 22

def created_at
  @created_at
end

#creator_idObject

The unique identifier of the Square account that took the payment.



25
26
27
# File 'lib/square_connect/models/v1_payment.rb', line 25

def creator_id
  @creator_id
end

#deviceObject

The device that took the payment.



28
29
30
# File 'lib/square_connect/models/v1_payment.rb', line 28

def device
  @device
end

#discount_moneyObject

The total of all discounts applied to the payment.



49
50
51
# File 'lib/square_connect/models/v1_payment.rb', line 49

def discount_money
  @discount_money
end

#gross_sales_moneyObject

The total of all sales, including any applicable taxes.



67
68
69
# File 'lib/square_connect/models/v1_payment.rb', line 67

def gross_sales_money
  @gross_sales_money
end

#idObject

The payment’s unique identifier.



16
17
18
# File 'lib/square_connect/models/v1_payment.rb', line 16

def id
  @id
end

#inclusive_taxObject

All of the inclusive taxes associated with the payment.



73
74
75
# File 'lib/square_connect/models/v1_payment.rb', line 73

def inclusive_tax
  @inclusive_tax
end

#inclusive_tax_moneyObject

The sum of all inclusive taxes associated with the payment.



37
38
39
# File 'lib/square_connect/models/v1_payment.rb', line 37

def inclusive_tax_money
  @inclusive_tax_money
end

#is_partialObject

Indicates whether or not the payment is only partially paid for. If true, this payment will have the tenders collected so far, but the itemizations will be empty until the payment is completed.



94
95
96
# File 'lib/square_connect/models/v1_payment.rb', line 94

def is_partial
  @is_partial
end

#itemizationsObject

The items purchased in the payment.



85
86
87
# File 'lib/square_connect/models/v1_payment.rb', line 85

def itemizations
  @itemizations
end

#merchant_idObject

The unique identifier of the merchant that took the payment.



19
20
21
# File 'lib/square_connect/models/v1_payment.rb', line 19

def merchant_id
  @merchant_id
end

#net_sales_moneyObject

The total of all sales, minus any applicable taxes.



70
71
72
# File 'lib/square_connect/models/v1_payment.rb', line 70

def net_sales_money
  @net_sales_money
end

#net_total_moneyObject

The amount to be deposited into the merchant’s bank account for the payment.



58
59
60
# File 'lib/square_connect/models/v1_payment.rb', line 58

def net_total_money
  @net_total_money
end

#payment_urlObject

The URL of the payment’s detail page in the merchant dashboard. The merchant must be signed in to the merchant dashboard to view this page.



31
32
33
# File 'lib/square_connect/models/v1_payment.rb', line 31

def payment_url
  @payment_url
end

#processing_fee_moneyObject

The total of all processing fees collected by Square for the payment.



55
56
57
# File 'lib/square_connect/models/v1_payment.rb', line 55

def processing_fee_money
  @processing_fee_money
end

#receipt_urlObject

The URL of the receipt for the payment. Note that for split tender payments, this URL corresponds to the receipt for the first tender listed in the payment’s tender field. Each Tender object has its own receipt_url field you can use to get the other receipts associated with a split tender payment.



34
35
36
# File 'lib/square_connect/models/v1_payment.rb', line 34

def receipt_url
  @receipt_url
end

#refunded_moneyObject

The total of all refunds applied to the payment.



61
62
63
# File 'lib/square_connect/models/v1_payment.rb', line 61

def refunded_money
  @refunded_money
end

#refundsObject

All of the refunds applied to the payment. Note that the value of all refunds on a payment can exceed the value of all tenders if a merchant chooses to refund money to a tender after previously accepting returned goods as part of an exchange.



82
83
84
# File 'lib/square_connect/models/v1_payment.rb', line 82

def refunds
  @refunds
end

#surcharge_moneyObject

The total of all surcharges applied to the payment.



88
89
90
# File 'lib/square_connect/models/v1_payment.rb', line 88

def surcharge_money
  @surcharge_money
end

#surchargesObject

A list of all surcharges associated with the payment.



91
92
93
# File 'lib/square_connect/models/v1_payment.rb', line 91

def surcharges
  @surcharges
end

#swedish_rounding_moneyObject

The total of all sales, including any applicable taxes, rounded to the smallest legal unit of currency (e.g., the nearest penny in USD, the nearest nickel in CAD)



64
65
66
# File 'lib/square_connect/models/v1_payment.rb', line 64

def swedish_rounding_money
  @swedish_rounding_money
end

#tax_moneyObject

The total of all taxes applied to the payment. This is always the sum of inclusive_tax_money and additive_tax_money.



43
44
45
# File 'lib/square_connect/models/v1_payment.rb', line 43

def tax_money
  @tax_money
end

#tenderObject

All of the tenders associated with the payment.



79
80
81
# File 'lib/square_connect/models/v1_payment.rb', line 79

def tender
  @tender
end

#tip_moneyObject

The total of all tips applied to the payment.



46
47
48
# File 'lib/square_connect/models/v1_payment.rb', line 46

def tip_money
  @tip_money
end

#total_collected_moneyObject

The total of all discounts applied to the payment.



52
53
54
# File 'lib/square_connect/models/v1_payment.rb', line 52

def total_collected_money
  @total_collected_money
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/square_connect/models/v1_payment.rb', line 98

def self.attribute_map
  {
    :'id' => :'id',
    :'merchant_id' => :'merchant_id',
    :'created_at' => :'created_at',
    :'creator_id' => :'creator_id',
    :'device' => :'device',
    :'payment_url' => :'payment_url',
    :'receipt_url' => :'receipt_url',
    :'inclusive_tax_money' => :'inclusive_tax_money',
    :'additive_tax_money' => :'additive_tax_money',
    :'tax_money' => :'tax_money',
    :'tip_money' => :'tip_money',
    :'discount_money' => :'discount_money',
    :'total_collected_money' => :'total_collected_money',
    :'processing_fee_money' => :'processing_fee_money',
    :'net_total_money' => :'net_total_money',
    :'refunded_money' => :'refunded_money',
    :'swedish_rounding_money' => :'swedish_rounding_money',
    :'gross_sales_money' => :'gross_sales_money',
    :'net_sales_money' => :'net_sales_money',
    :'inclusive_tax' => :'inclusive_tax',
    :'additive_tax' => :'additive_tax',
    :'tender' => :'tender',
    :'refunds' => :'refunds',
    :'itemizations' => :'itemizations',
    :'surcharge_money' => :'surcharge_money',
    :'surcharges' => :'surcharges',
    :'is_partial' => :'is_partial'
  }
end

.swagger_typesObject

Attribute type mapping.



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/square_connect/models/v1_payment.rb', line 131

def self.swagger_types
  {
    :'id' => :'String',
    :'merchant_id' => :'String',
    :'created_at' => :'String',
    :'creator_id' => :'String',
    :'device' => :'Device',
    :'payment_url' => :'String',
    :'receipt_url' => :'String',
    :'inclusive_tax_money' => :'V1Money',
    :'additive_tax_money' => :'V1Money',
    :'tax_money' => :'V1Money',
    :'tip_money' => :'V1Money',
    :'discount_money' => :'V1Money',
    :'total_collected_money' => :'V1Money',
    :'processing_fee_money' => :'V1Money',
    :'net_total_money' => :'V1Money',
    :'refunded_money' => :'V1Money',
    :'swedish_rounding_money' => :'V1Money',
    :'gross_sales_money' => :'V1Money',
    :'net_sales_money' => :'V1Money',
    :'inclusive_tax' => :'Array<V1PaymentTax>',
    :'additive_tax' => :'Array<V1PaymentTax>',
    :'tender' => :'Array<V1Tender>',
    :'refunds' => :'Array<V1Refund>',
    :'itemizations' => :'Array<V1PaymentItemization>',
    :'surcharge_money' => :'V1Money',
    :'surcharges' => :'Array<V1PaymentSurcharge>',
    :'is_partial' => :'BOOLEAN'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/square_connect/models/v1_payment.rb', line 308

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      merchant_id == o.merchant_id &&
      created_at == o.created_at &&
      creator_id == o.creator_id &&
      device == o.device &&
      payment_url == o.payment_url &&
      receipt_url == o.receipt_url &&
      inclusive_tax_money == o.inclusive_tax_money &&
      additive_tax_money == o.additive_tax_money &&
      tax_money == o.tax_money &&
      tip_money == o.tip_money &&
      discount_money == o.discount_money &&
      total_collected_money == o.total_collected_money &&
      processing_fee_money == o.processing_fee_money &&
      net_total_money == o.net_total_money &&
      refunded_money == o.refunded_money &&
      swedish_rounding_money == o.swedish_rounding_money &&
      gross_sales_money == o.gross_sales_money &&
      net_sales_money == o.net_sales_money &&
      inclusive_tax == o.inclusive_tax &&
      additive_tax == o.additive_tax &&
      tender == o.tender &&
      refunds == o.refunds &&
      itemizations == o.itemizations &&
      surcharge_money == o.surcharge_money &&
      surcharges == o.surcharges &&
      is_partial == o.is_partial
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/square_connect/models/v1_payment.rb', line 376

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = SquareConnect.const_get(type).new
    temp_model.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'lib/square_connect/models/v1_payment.rb', line 442

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map{ |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/square_connect/models/v1_payment.rb', line 355

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


342
343
344
# File 'lib/square_connect/models/v1_payment.rb', line 342

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



348
349
350
# File 'lib/square_connect/models/v1_payment.rb', line 348

def hash
  [id, merchant_id, created_at, creator_id, device, payment_url, receipt_url, inclusive_tax_money, additive_tax_money, tax_money, tip_money, discount_money, total_collected_money, processing_fee_money, net_total_money, refunded_money, swedish_rounding_money, gross_sales_money, net_sales_money, inclusive_tax, additive_tax, tender, refunds, itemizations, surcharge_money, surcharges, is_partial].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properies with the reasons



295
296
297
298
# File 'lib/square_connect/models/v1_payment.rb', line 295

def list_invalid_properties
  invalid_properties = Array.new
  return invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



422
423
424
# File 'lib/square_connect/models/v1_payment.rb', line 422

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



428
429
430
431
432
433
434
435
436
# File 'lib/square_connect/models/v1_payment.rb', line 428

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



416
417
418
# File 'lib/square_connect/models/v1_payment.rb', line 416

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



302
303
304
# File 'lib/square_connect/models/v1_payment.rb', line 302

def valid?
  return true
end