Class: PaypalServerSdk::PaymentCollection

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/paypal_server_sdk/models/payment_collection.rb

Overview

The collection of payments, or transactions, for a purchase unit in an order. For example, authorized payments, captured payments, and refunds.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(authorizations: SKIP, captures: SKIP, refunds: SKIP) ⇒ PaymentCollection

Returns a new instance of PaymentCollection.



51
52
53
54
55
# File 'lib/paypal_server_sdk/models/payment_collection.rb', line 51

def initialize(authorizations: SKIP, captures: SKIP, refunds: SKIP)
  @authorizations = authorizations unless authorizations == SKIP
  @captures = captures unless captures == SKIP
  @refunds = refunds unless refunds == SKIP
end

Instance Attribute Details

#authorizationsArray[AuthorizationWithAdditionalData]

An array of authorized payments for a purchase unit. A purchase unit can have zero or more authorized payments.



16
17
18
# File 'lib/paypal_server_sdk/models/payment_collection.rb', line 16

def authorizations
  @authorizations
end

#capturesArray[Capture]

An array of captured payments for a purchase unit. A purchase unit can have zero or more captured payments.

Returns:



21
22
23
# File 'lib/paypal_server_sdk/models/payment_collection.rb', line 21

def captures
  @captures
end

#refundsArray[Refund]

An array of refunds for a purchase unit. A purchase unit can have zero or more refunds.

Returns:



26
27
28
# File 'lib/paypal_server_sdk/models/payment_collection.rb', line 26

def refunds
  @refunds
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/paypal_server_sdk/models/payment_collection.rb', line 58

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  authorizations = nil
  unless hash['authorizations'].nil?
    authorizations = []
    hash['authorizations'].each do |structure|
      authorizations << (AuthorizationWithAdditionalData.from_hash(structure) if structure)
    end
  end

  authorizations = SKIP unless hash.key?('authorizations')
  # Parameter is an array, so we need to iterate through it
  captures = nil
  unless hash['captures'].nil?
    captures = []
    hash['captures'].each do |structure|
      captures << (Capture.from_hash(structure) if structure)
    end
  end

  captures = SKIP unless hash.key?('captures')
  # Parameter is an array, so we need to iterate through it
  refunds = nil
  unless hash['refunds'].nil?
    refunds = []
    hash['refunds'].each do |structure|
      refunds << (Refund.from_hash(structure) if structure)
    end
  end

  refunds = SKIP unless hash.key?('refunds')

  # Create object from extracted values.
  PaymentCollection.new(authorizations: authorizations,
                        captures: captures,
                        refunds: refunds)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
# File 'lib/paypal_server_sdk/models/payment_collection.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['authorizations'] = 'authorizations'
  @_hash['captures'] = 'captures'
  @_hash['refunds'] = 'refunds'
  @_hash
end

.nullablesObject

An array for nullable fields



47
48
49
# File 'lib/paypal_server_sdk/models/payment_collection.rb', line 47

def self.nullables
  []
end

.optionalsObject

An array for optional fields



38
39
40
41
42
43
44
# File 'lib/paypal_server_sdk/models/payment_collection.rb', line 38

def self.optionals
  %w[
    authorizations
    captures
    refunds
  ]
end