Class: VisaAcceptanceMergedSpec::LineItem4

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/visa_acceptance_merged_spec/models/line_item4.rb

Overview

LineItem4 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(product_code: SKIP, product_name: SKIP, product_sku: SKIP, quantity: 1, unit_price: SKIP, unit_of_measure: SKIP, total_amount: SKIP, tax_amount: SKIP, tax_rate: SKIP, tax_applied_after_discount: SKIP, tax_status_indicator: SKIP, tax_type_code: SKIP, amount_includes_tax: SKIP, type_of_supply: SKIP, commodity_code: SKIP, discount_amount: SKIP, discount_applied: SKIP, discount_rate: SKIP, invoice_number: SKIP, tax_details: SKIP, additional_properties: nil) ⇒ LineItem4

Returns a new instance of LineItem4.



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
322
323
324
325
326
327
328
329
330
331
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 295

def initialize(product_code: SKIP, product_name: SKIP, product_sku: SKIP,
               quantity: 1, unit_price: SKIP, unit_of_measure: SKIP,
               total_amount: SKIP, tax_amount: SKIP, tax_rate: SKIP,
               tax_applied_after_discount: SKIP, tax_status_indicator: SKIP,
               tax_type_code: SKIP, amount_includes_tax: SKIP,
               type_of_supply: SKIP, commodity_code: SKIP,
               discount_amount: SKIP, discount_applied: SKIP,
               discount_rate: SKIP, invoice_number: SKIP, tax_details: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @product_code = product_code unless product_code == SKIP
  @product_name = product_name unless product_name == SKIP
  @product_sku = product_sku unless product_sku == SKIP
  @quantity = quantity unless quantity == SKIP
  @unit_price = unit_price unless unit_price == SKIP
  @unit_of_measure = unit_of_measure unless unit_of_measure == SKIP
  @total_amount = total_amount unless total_amount == SKIP
  @tax_amount = tax_amount unless tax_amount == SKIP
  @tax_rate = tax_rate unless tax_rate == SKIP
  unless tax_applied_after_discount == SKIP
    @tax_applied_after_discount =
      tax_applied_after_discount
  end
  @tax_status_indicator = tax_status_indicator unless tax_status_indicator == SKIP
  @tax_type_code = tax_type_code unless tax_type_code == SKIP
  @amount_includes_tax = amount_includes_tax unless amount_includes_tax == SKIP
  @type_of_supply = type_of_supply unless type_of_supply == SKIP
  @commodity_code = commodity_code unless commodity_code == SKIP
  @discount_amount = discount_amount unless discount_amount == SKIP
  @discount_applied = discount_applied unless discount_applied == SKIP
  @discount_rate = discount_rate unless discount_rate == SKIP
  @invoice_number = invoice_number unless invoice_number == SKIP
  @tax_details = tax_details unless tax_details == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amount_includes_taxTrueClass | FalseClass

Flag that indicates whether the tax amount is included in the Line Item Total. Possible values:

  • true
  • false

Returns:

  • (TrueClass | FalseClass)


188
189
190
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 188

def amount_includes_tax
  @amount_includes_tax
end

#commodity_codeString

Commodity code or International description code used to classify the item. Contact your acquirer for a list of codes.

Returns:

  • (String)


201
202
203
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 201

def commodity_code
  @commodity_code
end

#discount_amountString

Discount applied to the item.

Returns:

  • (String)


205
206
207
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 205

def discount_amount
  @discount_amount
end

#discount_appliedTrueClass | FalseClass

Flag that indicates whether the amount is discounted. If you do not provide a value but you set Discount Amount to a value greater than zero, then Visa Acceptance sets this field to true. Possible values:

  • true
  • false

Returns:

  • (TrueClass | FalseClass)


215
216
217
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 215

def discount_applied
  @discount_applied
end

#discount_rateString

Rate the item is discounted. Maximum of 2 decimal places. Example 5.25 (=5.25%)

Returns:

  • (String)


220
221
222
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 220

def discount_rate
  @discount_rate
end

#invoice_numberString

Field to support an invoice number for a transaction. You must specify the number of line items that will include an invoice number. By default, the first line item will include an invoice number field. The invoice number field can be included for up to 10 line items.

Returns:

  • (String)


228
229
230
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 228

def invoice_number
  @invoice_number
end

#product_codeString

Type of product. The value for this field is used to identify the product category (electronic, handling, physical, service, or shipping). The default value is default. If you are performing an authorization transaction (processingOptions.capture is set to false), and you set this field to a value other than default or one of the values related to shipping and/or handling, then orderInformation.lineItems[].quantity, orderInformation.lineItems[].productName, and orderInformation.lineItems[].productSku fields are required. Optional field.

Tax Calculation

Optional field for U.S., Canadian, international tax, and value added taxes. The Product Codes for the tax service are located in the Visa Acceptance Tax Codes guide. Contact Customer Support to request the guide. If you don’t send a tax service Product Code in your tax request, product-based rules or exemptions will not be applied and the transaction will default to fully taxable in the locations where you’ve indicated you need to collect tax [by way of nexus, no nexus, or seller registration number fields].

Returns:

  • (String)


34
35
36
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 34

def product_code
  @product_code
end

#product_nameString

For an authorization or capture transaction (processingOptions.capture is true or false), this field is required when orderInformation.lineItems[].productCode is not default or one of the other values that are related to shipping and/or handling.

Tax Calculation

Optional field for U.S., Canadian, international tax, and value added taxes.

Returns:

  • (String)


45
46
47
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 45

def product_name
  @product_name
end

#product_skuString

Product identifier code. Also known as the Stock Keeping Unit (SKU) code for the product. For an authorization or capture transaction (processingOptions.capture is set to true or false), this field is required when orderInformation.lineItems[].productCode is not set to default or one of the other values that are related to shipping and/or handling.

Tax Calculation

Optional field for U.S. and Canadian taxes. Not applicable to international and value added taxes. For an authorization or capture transaction (processingOptions.capture is set to true or false), this field is required when orderInformation.lineItems[].productCode is not default or one of the values related to shipping and/or handling.

Returns:

  • (String)


61
62
63
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 61

def product_sku
  @product_sku
end

#quantityInteger

Number of units for this order. Must be a non-negative integer. The default is 1. For an authorization or capture transaction (processingOptions.capture is set to true or false), this field is required when orderInformation.lineItems[].productCode is not default or one of the other values related to shipping and/or handling.

Tax Calculation

Optional field for U.S., Canadian, international tax, and value added taxes.

Returns:

  • (Integer)


73
74
75
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 73

def quantity
  @quantity
end

#tax_amountString

Total tax to apply to the product. This value cannot be negative. The tax amount and the offer amount must be in the same currency. The tax amount field is additive. The following example uses a two-exponent currency such as USD:

  1. You include each line item in your request. ..- 1st line item has amount=10.00, quantity=1, and taxAmount=0.80 ..- 2nd line item has amount=20.00, quantity=1, and taxAmount=1.60
  2. The total amount authorized will be 32.40, not 30.00 with 2.40 of tax included. Optional field.

Airlines processing

Tax portion of the order amount. This value cannot exceed 99999999999999 (fourteen 9s). Format: English characters only. Optional request field for a line item.

Tax Calculation

Optional field for U.S., Canadian, international tax, and value added taxes. Note if you send this field in your tax request, the value in the field will override the tax engine

Returns:

  • (String)


133
134
135
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 133

def tax_amount
  @tax_amount
end

#tax_applied_after_discountString

Flag to indicate how you handle discount at the line item level.

  • 0: no line level discount provided
  • 1: tax was calculated on the post-discount line item total
  • 2: tax was calculated on the pre-discount line item total Note Visa will inset 0 (zero) if an invalid value is included in this field. This field relates to the value in the lineItems.discountAmount field.

Returns:

  • (String)


151
152
153
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 151

def tax_applied_after_discount
  @tax_applied_after_discount
end

#tax_detailsArray[TaxDetails1]

Field to support an invoice number for a transaction. You must specify the number of line items that will include an invoice number. By default, the first line item will include an invoice number field. The invoice number field can be included for up to 10 line items.

Returns:



236
237
238
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 236

def tax_details
  @tax_details
end

#tax_rateString

Tax rate applied to the item. Visa: Valid range is 0.01 to 0.99 (1% to 99%, with only whole percentage values accepted; values with additional decimal places will be truncated). Mastercard: Valid range is 0.00001 to 0.99999 (0.001% to 99.999%).

Returns:

  • (String)


141
142
143
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 141

def tax_rate
  @tax_rate
end

#tax_status_indicatorString

Flag to indicate whether tax is exempted or not included.

  • 0: tax not included
  • 1: tax included
  • 2: transaction is not subject to tax

Returns:

  • (String)


158
159
160
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 158

def tax_status_indicator
  @tax_status_indicator
end

#tax_type_codeString

Type of tax being applied to the item.

FDC Nashville Global

  • alternate_tax_type_applied
  • alternate_tax_type_identifier

Worldpay VAP

  • alternate_tax_type_identifier

RBS WorldPay Atlanta

  • tax_type_applied

TSYS Acquiring Solutions

  • tax_type_applied
  • local_tax_indicator

Chase Paymentech Solutions

  • tax_type_applied

Elavon Americas

  • local_tax_indicator

FDC Compass

  • tax_type_applied

OmniPay Direct

  • local_tax_indicator

Returns:

  • (String)


180
181
182
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 180

def tax_type_code
  @tax_type_code
end

#total_amountString

Total amount for the item. Normally calculated as the unit price times quantity. When orderInformation.lineItems[].productCode is "gift_card", this is the purchase amount total for prepaid gift cards in major units. Example: 123.45 USD = 123

Returns:

  • (String)


110
111
112
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 110

def total_amount
  @total_amount
end

#type_of_supplyString

Flag to indicate whether the purchase is categorized as goods or services. Possible values:

  • 00: goods
  • 01: services

Returns:

  • (String)


195
196
197
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 195

def type_of_supply
  @type_of_supply
end

#unit_of_measureString

Unit of measure, or unit of measure code, for the item.

Returns:

  • (String)


101
102
103
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 101

def unit_of_measure
  @unit_of_measure
end

#unit_priceString

Per-item price of the product. This value for this field cannot be negative. You must include either this field or the request-level field orderInformation.amountDetails.totalAmount in your request. You can include a decimal point (.), but you cannot include any other special characters. The value is truncated to the correct number of decimal places.

DCC with a Third-Party Provider

Set this field to the converted amount that was returned by the DCC provider. You must include either the 1st line item in the order and this field, or the request-level field orderInformation.amountDetails.totalAmount in your request.

Tax Calculation

Required field for U.S., Canadian, international and value added taxes.

Zero Amount Authorizations

If your processor supports zero amount authorizations, you can set this field to 0 for the authorization to check if the card is lost or stolen.

Maximum Field Lengths

For GPN and JCN Gateway: Decimal (10) All other processors: Decimal (15)

Returns:

  • (String)


97
98
99
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 97

def unit_price
  @unit_price
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
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
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 334

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  product_code = hash.key?('productCode') ? hash['productCode'] : SKIP
  product_name = hash.key?('productName') ? hash['productName'] : SKIP
  product_sku = hash.key?('productSku') ? hash['productSku'] : SKIP
  quantity = hash['quantity'] ||= 1
  unit_price = hash.key?('unitPrice') ? hash['unitPrice'] : SKIP
  unit_of_measure =
    hash.key?('unitOfMeasure') ? hash['unitOfMeasure'] : SKIP
  total_amount = hash.key?('totalAmount') ? hash['totalAmount'] : SKIP
  tax_amount = hash.key?('taxAmount') ? hash['taxAmount'] : SKIP
  tax_rate = hash.key?('taxRate') ? hash['taxRate'] : SKIP
  tax_applied_after_discount =
    hash.key?('taxAppliedAfterDiscount') ? hash['taxAppliedAfterDiscount'] : SKIP
  tax_status_indicator =
    hash.key?('taxStatusIndicator') ? hash['taxStatusIndicator'] : SKIP
  tax_type_code = hash.key?('taxTypeCode') ? hash['taxTypeCode'] : SKIP
  amount_includes_tax =
    hash.key?('amountIncludesTax') ? hash['amountIncludesTax'] : SKIP
  type_of_supply = hash.key?('typeOfSupply') ? hash['typeOfSupply'] : SKIP
  commodity_code = hash.key?('commodityCode') ? hash['commodityCode'] : SKIP
  discount_amount =
    hash.key?('discountAmount') ? hash['discountAmount'] : SKIP
  discount_applied =
    hash.key?('discountApplied') ? hash['discountApplied'] : SKIP
  discount_rate = hash.key?('discountRate') ? hash['discountRate'] : SKIP
  invoice_number = hash.key?('invoiceNumber') ? hash['invoiceNumber'] : SKIP
  # Parameter is an array, so we need to iterate through it
  tax_details = nil
  unless hash['taxDetails'].nil?
    tax_details = []
    hash['taxDetails'].each do |structure|
      tax_details << (TaxDetails1.from_hash(structure) if structure)
    end
  end

  tax_details = SKIP unless hash.key?('taxDetails')

  # 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.
  LineItem4.new(product_code: product_code,
                product_name: product_name,
                product_sku: product_sku,
                quantity: quantity,
                unit_price: unit_price,
                unit_of_measure: unit_of_measure,
                total_amount: total_amount,
                tax_amount: tax_amount,
                tax_rate: tax_rate,
                tax_applied_after_discount: tax_applied_after_discount,
                tax_status_indicator: tax_status_indicator,
                tax_type_code: tax_type_code,
                amount_includes_tax: amount_includes_tax,
                type_of_supply: type_of_supply,
                commodity_code: commodity_code,
                discount_amount: discount_amount,
                discount_applied: discount_applied,
                discount_rate: discount_rate,
                invoice_number: invoice_number,
                tax_details: tax_details,
                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 239

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['product_code'] = 'productCode'
  @_hash['product_name'] = 'productName'
  @_hash['product_sku'] = 'productSku'
  @_hash['quantity'] = 'quantity'
  @_hash['unit_price'] = 'unitPrice'
  @_hash['unit_of_measure'] = 'unitOfMeasure'
  @_hash['total_amount'] = 'totalAmount'
  @_hash['tax_amount'] = 'taxAmount'
  @_hash['tax_rate'] = 'taxRate'
  @_hash['tax_applied_after_discount'] = 'taxAppliedAfterDiscount'
  @_hash['tax_status_indicator'] = 'taxStatusIndicator'
  @_hash['tax_type_code'] = 'taxTypeCode'
  @_hash['amount_includes_tax'] = 'amountIncludesTax'
  @_hash['type_of_supply'] = 'typeOfSupply'
  @_hash['commodity_code'] = 'commodityCode'
  @_hash['discount_amount'] = 'discountAmount'
  @_hash['discount_applied'] = 'discountApplied'
  @_hash['discount_rate'] = 'discountRate'
  @_hash['invoice_number'] = 'invoiceNumber'
  @_hash['tax_details'] = 'taxDetails'
  @_hash
end

.nullablesObject

An array for nullable fields



291
292
293
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 291

def self.nullables
  []
end

.optionalsObject

An array for optional fields



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 265

def self.optionals
  %w[
    product_code
    product_name
    product_sku
    quantity
    unit_price
    unit_of_measure
    total_amount
    tax_amount
    tax_rate
    tax_applied_after_discount
    tax_status_indicator
    tax_type_code
    amount_includes_tax
    type_of_supply
    commodity_code
    discount_amount
    discount_applied
    discount_rate
    invoice_number
    tax_details
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 421

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} product_code: #{@product_code.inspect}, product_name:"\
  " #{@product_name.inspect}, product_sku: #{@product_sku.inspect}, quantity:"\
  " #{@quantity.inspect}, unit_price: #{@unit_price.inspect}, unit_of_measure:"\
  " #{@unit_of_measure.inspect}, total_amount: #{@total_amount.inspect}, tax_amount:"\
  " #{@tax_amount.inspect}, tax_rate: #{@tax_rate.inspect}, tax_applied_after_discount:"\
  " #{@tax_applied_after_discount.inspect}, tax_status_indicator:"\
  " #{@tax_status_indicator.inspect}, tax_type_code: #{@tax_type_code.inspect},"\
  " amount_includes_tax: #{@amount_includes_tax.inspect}, type_of_supply:"\
  " #{@type_of_supply.inspect}, commodity_code: #{@commodity_code.inspect}, discount_amount:"\
  " #{@discount_amount.inspect}, discount_applied: #{@discount_applied.inspect},"\
  " discount_rate: #{@discount_rate.inspect}, invoice_number: #{@invoice_number.inspect},"\
  " tax_details: #{@tax_details.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



406
407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/visa_acceptance_merged_spec/models/line_item4.rb', line 406

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} product_code: #{@product_code}, product_name: #{@product_name},"\
  " product_sku: #{@product_sku}, quantity: #{@quantity}, unit_price: #{@unit_price},"\
  " unit_of_measure: #{@unit_of_measure}, total_amount: #{@total_amount}, tax_amount:"\
  " #{@tax_amount}, tax_rate: #{@tax_rate}, tax_applied_after_discount:"\
  " #{@tax_applied_after_discount}, tax_status_indicator: #{@tax_status_indicator},"\
  " tax_type_code: #{@tax_type_code}, amount_includes_tax: #{@amount_includes_tax},"\
  " type_of_supply: #{@type_of_supply}, commodity_code: #{@commodity_code}, discount_amount:"\
  " #{@discount_amount}, discount_applied: #{@discount_applied}, discount_rate:"\
  " #{@discount_rate}, invoice_number: #{@invoice_number}, tax_details: #{@tax_details},"\
  " additional_properties: #{@additional_properties}>"
end