Class: CyberSourceMergedSpec::AmountDetails2

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cyber_source_merged_spec/models/amount_details2.rb

Overview

AmountDetails2 Model.

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(total_amount: SKIP, authorized_amount: SKIP, cashback_amount: SKIP, currency: SKIP, settlement_amount: SKIP, settlement_currency: SKIP, original_amount: SKIP, original_currency: SKIP, processor_transaction_fee: SKIP, exchange_rate: SKIP, foreign_currency: SKIP, foreign_amount: SKIP, discount_amount: SKIP, additional_properties: nil) ⇒ AmountDetails2

Returns a new instance of AmountDetails2.



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
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 169

def initialize(total_amount: SKIP, authorized_amount: SKIP,
               cashback_amount: SKIP, currency: SKIP,
               settlement_amount: SKIP, settlement_currency: SKIP,
               original_amount: SKIP, original_currency: SKIP,
               processor_transaction_fee: SKIP, exchange_rate: SKIP,
               foreign_currency: SKIP, foreign_amount: SKIP,
               discount_amount: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @total_amount = total_amount unless total_amount == SKIP
  @authorized_amount = authorized_amount unless authorized_amount == SKIP
  @cashback_amount = cashback_amount unless cashback_amount == SKIP
  @currency = currency unless currency == SKIP
  @settlement_amount = settlement_amount unless settlement_amount == SKIP
  @settlement_currency = settlement_currency unless settlement_currency == SKIP
  @original_amount = original_amount unless original_amount == SKIP
  @original_currency = original_currency unless original_currency == SKIP
  unless processor_transaction_fee == SKIP
    @processor_transaction_fee =
      processor_transaction_fee
  end
  @exchange_rate = exchange_rate unless exchange_rate == SKIP
  @foreign_currency = foreign_currency unless foreign_currency == SKIP
  @foreign_amount = foreign_amount unless foreign_amount == SKIP
  @discount_amount = discount_amount unless discount_amount == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#authorized_amountString

Amount that was authorized. Returned by authorization service.

PIN debit

Amount of the purchase. Returned by PIN debit purchase.

Returns:

  • (String)


26
27
28
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 26

def authorized_amount
  @authorized_amount
end

#cashback_amountString

This field contains the purchase cashback amount expressed in the acquirer transaction currency. Use this field only for clearing with your acquirer.

Returns:

  • (String)


32
33
34
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 32

def cashback_amount
  @cashback_amount
end

#currencyString

Currency used for the order. Use the three-character [ISO Standard Currency Codes.](http://apps.cybersource.com/library/documentation/sbc/quickref/cur rencies.pdf)

Used by

Authorization Required field. Authorization Reversal For an authorization reversal (reversalInformation) or a capture (processingOptions.capture is set to true), you must use the same currency that you used in your payment authorization request.

PIN Debit

Currency for the amount you requested for the PIN debit purchase. This value is returned for partial authorizations. The issuing bank can approve a partial amount if the balance on the debit card is less than the requested transaction amount. For the possible values, see the [ISO Standard Currency Codes](https://developer.cybersource.com/library/documentation/sbc/quickre f/currencies.pdf). Returned by PIN debit purchase. For PIN debit reversal requests, you must use the same currency that was used for the PIN debit purchase or PIN debit credit that you are reversing. For the possible values, see the [ISO Standard Currency Codes](https://developer.cybersource.com/library/documentation/sbc/quickre f/currencies.pdf). Required field for PIN Debit purchase and PIN Debit credit requests. Optional field for PIN Debit reversal requests.

GPX

This field is optional for reversing an authorization or credit.

DCC for First Data

Your local currency.

Tax Calculation

Required for international tax and value added tax only. Optional for U.S. and Canadian taxes. Your local currency.

Returns:

  • (String)


71
72
73
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 71

def currency
  @currency
end

#discount_amountString

If coupons/vouchers are used in the transaction, the discount amount redeemed in the settlement currency will be returned. Otherwise, no return.

Returns:

  • (String)


124
125
126
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 124

def discount_amount
  @discount_amount
end

#exchange_rateString

The rate of conversion of the currency given in the request to CNY. The conversion happens at the time when Alipay’s trade order is created

Returns:

  • (String)


110
111
112
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 110

def exchange_rate
  @exchange_rate
end

#foreign_amountString

The transaction amount in CNY.

Returns:

  • (String)


118
119
120
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 118

def foreign_amount
  @foreign_amount
end

#foreign_currencyString

Currency code for the transaction performed in cross border currency.

Returns:

  • (String)


114
115
116
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 114

def foreign_currency
  @foreign_currency
end

#original_amountString

Amount in your original local pricing currency. This value cannot be negative. You can include a decimal point (.) in this field to denote the currency exponent, but you cannot include any other special characters. If needed, CyberSource truncates the amount to the correct number of decimal places.

Returns:

  • (String)


93
94
95
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 93

def original_amount
  @original_amount
end

#original_currencyString

Your local pricing currency code. For the possible values, see the [ISO Standard Currency Codes.](http://apps.cybersource.com/library/documentation/sbc/quickref/cur rencies.pdf)

Returns:

  • (String)


100
101
102
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 100

def original_currency
  @original_currency
end

#processor_transaction_feeString

Amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code.

Returns:

  • (String)


105
106
107
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 105

def processor_transaction_fee
  @processor_transaction_fee
end

#settlement_amountString

This is a multicurrency field. It contains the transaction amount (field 4), converted to the Currency used to bill the cardholder’s account. This field is returned for OCT transactions.

Returns:

  • (String)


77
78
79
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 77

def settlement_amount
  @settlement_amount
end

#settlement_currencyString

This is a multicurrency-only field. It contains a 3-digit numeric code that identifies the currency used by the issuer to bill the cardholder's account. This field is returned for OCT transactions.

Returns:

  • (String)


84
85
86
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 84

def settlement_currency
  @settlement_currency
end

#total_amountString

Amount you requested for the payment or capture. This value is returned for partial authorizations. This field is also returned on incremental authorizations will contain the aggregated amount from the original authorizations and all the incremental authorizations.

Returns:

  • (String)


18
19
20
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 18

def total_amount
  @total_amount
end

Class Method Details

.from_element(root) ⇒ Object



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
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 250

def self.from_element(root)
  total_amount = XmlUtilities.from_element(root, 'totalAmount', String)
  authorized_amount = XmlUtilities.from_element(root, 'authorizedAmount',
                                                String)
  cashback_amount = XmlUtilities.from_element(root, 'cashbackAmount',
                                              String)
  currency = XmlUtilities.from_element(root, 'currency', String)
  settlement_amount = XmlUtilities.from_element(root, 'settlementAmount',
                                                String)
  settlement_currency = XmlUtilities.from_element(root,
                                                  'settlementCurrency',
                                                  String)
  original_amount = XmlUtilities.from_element(root, 'originalAmount',
                                              String)
  original_currency = XmlUtilities.from_element(root, 'originalCurrency',
                                                String)
  processor_transaction_fee = XmlUtilities.from_element(
    root, 'processorTransactionFee', String
  )
  exchange_rate = XmlUtilities.from_element(root, 'exchangeRate', String)
  foreign_currency = XmlUtilities.from_element(root, 'foreignCurrency',
                                               String)
  foreign_amount = XmlUtilities.from_element(root, 'foreignAmount', String)
  discount_amount = XmlUtilities.from_element(root, 'discountAmount',
                                              String)

  new(total_amount: total_amount,
      authorized_amount: authorized_amount,
      cashback_amount: cashback_amount,
      currency: currency,
      settlement_amount: settlement_amount,
      settlement_currency: settlement_currency,
      original_amount: original_amount,
      original_currency: original_currency,
      processor_transaction_fee: processor_transaction_fee,
      exchange_rate: exchange_rate,
      foreign_currency: foreign_currency,
      foreign_amount: foreign_amount,
      discount_amount: discount_amount,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 199

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  total_amount = hash.key?('totalAmount') ? hash['totalAmount'] : SKIP
  authorized_amount =
    hash.key?('authorizedAmount') ? hash['authorizedAmount'] : SKIP
  cashback_amount =
    hash.key?('cashbackAmount') ? hash['cashbackAmount'] : SKIP
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  settlement_amount =
    hash.key?('settlementAmount') ? hash['settlementAmount'] : SKIP
  settlement_currency =
    hash.key?('settlementCurrency') ? hash['settlementCurrency'] : SKIP
  original_amount =
    hash.key?('originalAmount') ? hash['originalAmount'] : SKIP
  original_currency =
    hash.key?('originalCurrency') ? hash['originalCurrency'] : SKIP
  processor_transaction_fee =
    hash.key?('processorTransactionFee') ? hash['processorTransactionFee'] : SKIP
  exchange_rate = hash.key?('exchangeRate') ? hash['exchangeRate'] : SKIP
  foreign_currency =
    hash.key?('foreignCurrency') ? hash['foreignCurrency'] : SKIP
  foreign_amount = hash.key?('foreignAmount') ? hash['foreignAmount'] : SKIP
  discount_amount =
    hash.key?('discountAmount') ? hash['discountAmount'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  AmountDetails2.new(total_amount: total_amount,
                     authorized_amount: authorized_amount,
                     cashback_amount: cashback_amount,
                     currency: currency,
                     settlement_amount: settlement_amount,
                     settlement_currency: settlement_currency,
                     original_amount: original_amount,
                     original_currency: original_currency,
                     processor_transaction_fee: processor_transaction_fee,
                     exchange_rate: exchange_rate,
                     foreign_currency: foreign_currency,
                     foreign_amount: foreign_amount,
                     discount_amount: discount_amount,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 127

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_amount'] = 'totalAmount'
  @_hash['authorized_amount'] = 'authorizedAmount'
  @_hash['cashback_amount'] = 'cashbackAmount'
  @_hash['currency'] = 'currency'
  @_hash['settlement_amount'] = 'settlementAmount'
  @_hash['settlement_currency'] = 'settlementCurrency'
  @_hash['original_amount'] = 'originalAmount'
  @_hash['original_currency'] = 'originalCurrency'
  @_hash['processor_transaction_fee'] = 'processorTransactionFee'
  @_hash['exchange_rate'] = 'exchangeRate'
  @_hash['foreign_currency'] = 'foreignCurrency'
  @_hash['foreign_amount'] = 'foreignAmount'
  @_hash['discount_amount'] = 'discountAmount'
  @_hash
end

.nullablesObject

An array for nullable fields



165
166
167
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 165

def self.nullables
  []
end

.optionalsObject

An array for optional fields



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 146

def self.optionals
  %w[
    total_amount
    authorized_amount
    cashback_amount
    currency
    settlement_amount
    settlement_currency
    original_amount
    original_currency
    processor_transaction_fee
    exchange_rate
    foreign_currency
    foreign_amount
    discount_amount
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 336

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amount: #{@total_amount.inspect}, authorized_amount:"\
  " #{@authorized_amount.inspect}, cashback_amount: #{@cashback_amount.inspect}, currency:"\
  " #{@currency.inspect}, settlement_amount: #{@settlement_amount.inspect},"\
  " settlement_currency: #{@settlement_currency.inspect}, original_amount:"\
  " #{@original_amount.inspect}, original_currency: #{@original_currency.inspect},"\
  " processor_transaction_fee: #{@processor_transaction_fee.inspect}, exchange_rate:"\
  " #{@exchange_rate.inspect}, foreign_currency: #{@foreign_currency.inspect}, foreign_amount:"\
  " #{@foreign_amount.inspect}, discount_amount: #{@discount_amount.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



324
325
326
327
328
329
330
331
332
333
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 324

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amount: #{@total_amount}, authorized_amount: #{@authorized_amount},"\
  " cashback_amount: #{@cashback_amount}, currency: #{@currency}, settlement_amount:"\
  " #{@settlement_amount}, settlement_currency: #{@settlement_currency}, original_amount:"\
  " #{@original_amount}, original_currency: #{@original_currency}, processor_transaction_fee:"\
  " #{@processor_transaction_fee}, exchange_rate: #{@exchange_rate}, foreign_currency:"\
  " #{@foreign_currency}, foreign_amount: #{@foreign_amount}, discount_amount:"\
  " #{@discount_amount}, additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/cyber_source_merged_spec/models/amount_details2.rb', line 292

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'totalAmount', total_amount)
  XmlUtilities.add_as_subelement(doc, root, 'authorizedAmount',
                                 authorized_amount)
  XmlUtilities.add_as_subelement(doc, root, 'cashbackAmount',
                                 cashback_amount)
  XmlUtilities.add_as_subelement(doc, root, 'currency', currency)
  XmlUtilities.add_as_subelement(doc, root, 'settlementAmount',
                                 settlement_amount)
  XmlUtilities.add_as_subelement(doc, root, 'settlementCurrency',
                                 settlement_currency)
  XmlUtilities.add_as_subelement(doc, root, 'originalAmount',
                                 original_amount)
  XmlUtilities.add_as_subelement(doc, root, 'originalCurrency',
                                 original_currency)
  XmlUtilities.add_as_subelement(doc, root, 'processorTransactionFee',
                                 processor_transaction_fee)
  XmlUtilities.add_as_subelement(doc, root, 'exchangeRate', exchange_rate)
  XmlUtilities.add_as_subelement(doc, root, 'foreignCurrency',
                                 foreign_currency)
  XmlUtilities.add_as_subelement(doc, root, 'foreignAmount', foreign_amount)
  XmlUtilities.add_as_subelement(doc, root, 'discountAmount',
                                 discount_amount)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end