Class: PaypalServerSdk::PaymentAuthorization

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

Overview

The authorized payment transaction.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(status: SKIP, status_details: SKIP, id: SKIP, amount: SKIP, invoice_id: SKIP, custom_id: SKIP, network_transaction_reference: SKIP, seller_protection: SKIP, expiration_time: SKIP, links: SKIP, create_time: SKIP, update_time: SKIP, supplementary_data: SKIP, payee: SKIP) ⇒ PaymentAuthorization

Returns a new instance of PaymentAuthorization.



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 133

def initialize(status: SKIP, status_details: SKIP, id: SKIP, amount: SKIP,
               invoice_id: SKIP, custom_id: SKIP,
               network_transaction_reference: SKIP, seller_protection: SKIP,
               expiration_time: SKIP, links: SKIP, create_time: SKIP,
               update_time: SKIP, supplementary_data: SKIP, payee: SKIP)
  @status = status unless status == SKIP
  @status_details = status_details unless status_details == SKIP
  @id = id unless id == SKIP
  @amount = amount unless amount == SKIP
  @invoice_id = invoice_id unless invoice_id == SKIP
  @custom_id = custom_id unless custom_id == SKIP
  unless network_transaction_reference == SKIP
    @network_transaction_reference =
      network_transaction_reference
  end
  @seller_protection = seller_protection unless seller_protection == SKIP
  @expiration_time = expiration_time unless expiration_time == SKIP
  @links = links unless links == SKIP
  @create_time = create_time unless create_time == SKIP
  @update_time = update_time unless update_time == SKIP
  @supplementary_data = supplementary_data unless supplementary_data == SKIP
  @payee = payee unless payee == SKIP
end

Instance Attribute Details

#amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



27
28
29
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 27

def amount
  @amount
end

#create_timeString

The date and time, in [Internet date and time format](tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional. Note: The regular expression provides guidance but does not reject all invalid dates.

Returns:

  • (String)


69
70
71
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 69

def create_time
  @create_time
end

#custom_idString

The API caller-provided external ID. Used to reconcile API caller-initiated transactions with PayPal transactions. Appears in transaction and settlement reports.

Returns:

  • (String)


39
40
41
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 39

def custom_id
  @custom_id
end

#expiration_timeString

The date and time, in [Internet date and time format](tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional. Note: The regular expression provides guidance but does not reject all invalid dates.

Returns:

  • (String)


57
58
59
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 57

def expiration_time
  @expiration_time
end

#idString

The PayPal-generated ID for the authorized payment.

Returns:

  • (String)


22
23
24
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 22

def id
  @id
end

#invoice_idString

The API caller-provided external invoice number for this order. Appears in both the payer’s transaction history and the emails that the payer receives.

Returns:

  • (String)


33
34
35
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 33

def invoice_id
  @invoice_id
end

An array of related [HATEOAS links](/docs/api/reference/api-responses/#hateoas-links).

Returns:



62
63
64
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 62

def links
  @links
end

#network_transaction_referenceNetworkTransactionReference

Reference values used by the card network to identify a transaction.



43
44
45
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 43

def network_transaction_reference
  @network_transaction_reference
end

#payeePayeeBase

The details for the merchant who receives the funds and fulfills the order. The merchant is also known as the payee.

Returns:



85
86
87
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 85

def payee
  @payee
end

#seller_protectionSellerProtection

The level of protection offered as defined by [PayPal Seller Protection for Merchants](www.paypal.com/us/webapps/mpp/security/seller-protectio n).

Returns:



50
51
52
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 50

def seller_protection
  @seller_protection
end

#statusAuthorizationStatus

The status for the authorized payment.

Returns:



14
15
16
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 14

def status
  @status
end

#status_detailsAuthorizationStatusDetails

The details of the authorized payment status.



18
19
20
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 18

def status_details
  @status_details
end

#supplementary_dataPaymentSupplementaryData

The supplementary data.



80
81
82
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 80

def supplementary_data
  @supplementary_data
end

#update_timeString

The date and time, in [Internet date and time format](tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional. Note: The regular expression provides guidance but does not reject all invalid dates.

Returns:

  • (String)


76
77
78
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 76

def update_time
  @update_time
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



158
159
160
161
162
163
164
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
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 158

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  status = hash.key?('status') ? hash['status'] : SKIP
  status_details = AuthorizationStatusDetails.from_hash(hash['status_details']) if
    hash['status_details']
  id = hash.key?('id') ? hash['id'] : SKIP
  amount = Money.from_hash(hash['amount']) if hash['amount']
  invoice_id = hash.key?('invoice_id') ? hash['invoice_id'] : SKIP
  custom_id = hash.key?('custom_id') ? hash['custom_id'] : SKIP
  if hash['network_transaction_reference']
    network_transaction_reference = NetworkTransactionReference.from_hash(hash['network_transaction_reference'])
  end
  seller_protection = SellerProtection.from_hash(hash['seller_protection']) if
    hash['seller_protection']
  expiration_time =
    hash.key?('expiration_time') ? hash['expiration_time'] : SKIP
  # Parameter is an array, so we need to iterate through it
  links = nil
  unless hash['links'].nil?
    links = []
    hash['links'].each do |structure|
      links << (LinkDescription.from_hash(structure) if structure)
    end
  end

  links = SKIP unless hash.key?('links')
  create_time = hash.key?('create_time') ? hash['create_time'] : SKIP
  update_time = hash.key?('update_time') ? hash['update_time'] : SKIP
  supplementary_data = PaymentSupplementaryData.from_hash(hash['supplementary_data']) if
    hash['supplementary_data']
  payee = PayeeBase.from_hash(hash['payee']) if hash['payee']

  # Create object from extracted values.
  PaymentAuthorization.new(status: status,
                           status_details: status_details,
                           id: id,
                           amount: amount,
                           invoice_id: invoice_id,
                           custom_id: custom_id,
                           network_transaction_reference: network_transaction_reference,
                           seller_protection: seller_protection,
                           expiration_time: expiration_time,
                           links: links,
                           create_time: create_time,
                           update_time: update_time,
                           supplementary_data: supplementary_data,
                           payee: payee)
end

.namesObject

A mapping from model property names to API property names.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 88

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['status'] = 'status'
  @_hash['status_details'] = 'status_details'
  @_hash['id'] = 'id'
  @_hash['amount'] = 'amount'
  @_hash['invoice_id'] = 'invoice_id'
  @_hash['custom_id'] = 'custom_id'
  @_hash['network_transaction_reference'] =
    'network_transaction_reference'
  @_hash['seller_protection'] = 'seller_protection'
  @_hash['expiration_time'] = 'expiration_time'
  @_hash['links'] = 'links'
  @_hash['create_time'] = 'create_time'
  @_hash['update_time'] = 'update_time'
  @_hash['supplementary_data'] = 'supplementary_data'
  @_hash['payee'] = 'payee'
  @_hash
end

.nullablesObject

An array for nullable fields



129
130
131
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 129

def self.nullables
  []
end

.optionalsObject

An array for optional fields



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 109

def self.optionals
  %w[
    status
    status_details
    id
    amount
    invoice_id
    custom_id
    network_transaction_reference
    seller_protection
    expiration_time
    links
    create_time
    update_time
    supplementary_data
    payee
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



221
222
223
224
225
226
227
228
229
230
231
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 221

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} status: #{@status.inspect}, status_details: #{@status_details.inspect}, id:"\
  " #{@id.inspect}, amount: #{@amount.inspect}, invoice_id: #{@invoice_id.inspect}, custom_id:"\
  " #{@custom_id.inspect}, network_transaction_reference:"\
  " #{@network_transaction_reference.inspect}, seller_protection:"\
  " #{@seller_protection.inspect}, expiration_time: #{@expiration_time.inspect}, links:"\
  " #{@links.inspect}, create_time: #{@create_time.inspect}, update_time:"\
  " #{@update_time.inspect}, supplementary_data: #{@supplementary_data.inspect}, payee:"\
  " #{@payee.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



210
211
212
213
214
215
216
217
218
# File 'lib/paypal_server_sdk/models/payment_authorization.rb', line 210

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} status: #{@status}, status_details: #{@status_details}, id: #{@id}, amount:"\
  " #{@amount}, invoice_id: #{@invoice_id}, custom_id: #{@custom_id},"\
  " network_transaction_reference: #{@network_transaction_reference}, seller_protection:"\
  " #{@seller_protection}, expiration_time: #{@expiration_time}, links: #{@links},"\
  " create_time: #{@create_time}, update_time: #{@update_time}, supplementary_data:"\
  " #{@supplementary_data}, payee: #{@payee}>"
end