Class: CyberSourceMergedSpec::LineItem17
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- CyberSourceMergedSpec::LineItem17
- Defined in:
- lib/cyber_source_merged_spec/models/line_item17.rb
Overview
Line item from the order.
Instance Attribute Summary collapse
-
#discount_amount ⇒ String
Discount applied to the item.
-
#discount_percent ⇒ String
Rate the item is discounted.
-
#product_name ⇒ String
For an authorization or capture transaction (
processingOptions.captureistrueorfalse), this field is required whenorderInformation.lineItems[].productCodeis notdefaultor one of the other values that are related to shipping and/or handling. -
#product_sku ⇒ String
Product identifier code.
-
#quantity ⇒ Integer
Number of units for this order.
-
#tax_amount ⇒ String
Total tax to apply to the product.
-
#tax_rate ⇒ String
Valid range: 1% to 99%, with only whole percentage values accepted; values with additional decimal places will be truncated For processor-specific details, see the alternate_tax_amount, vat_rate, vat_tax_rate, local_tax, national_tax, vat_tax_amount or other_tax#_rate field descriptions in the Level II and Level III Processing Using the SCMP API Guide.
-
#total_amount ⇒ String
Total amount for the item.
-
#unit_price ⇒ String
Per-item price of the product.
Class Method Summary collapse
- .from_element(root) ⇒ Object
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(product_sku: SKIP, product_name: SKIP, quantity: 1, unit_price: SKIP, discount_amount: SKIP, discount_percent: SKIP, tax_amount: SKIP, tax_rate: SKIP, total_amount: SKIP, additional_properties: nil) ⇒ LineItem17
constructor
A new instance of LineItem17.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
- #to_xml_element(doc, root_name) ⇒ Object
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_sku: SKIP, product_name: SKIP, quantity: 1, unit_price: SKIP, discount_amount: SKIP, discount_percent: SKIP, tax_amount: SKIP, tax_rate: SKIP, total_amount: SKIP, additional_properties: nil) ⇒ LineItem17
Returns a new instance of LineItem17.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 161 def initialize(product_sku: SKIP, product_name: SKIP, quantity: 1, unit_price: SKIP, discount_amount: SKIP, discount_percent: SKIP, tax_amount: SKIP, tax_rate: SKIP, total_amount: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @product_sku = product_sku unless product_sku == SKIP @product_name = product_name unless product_name == SKIP @quantity = quantity unless quantity == SKIP @unit_price = unit_price unless unit_price == SKIP @discount_amount = discount_amount unless discount_amount == SKIP @discount_percent = discount_percent unless discount_percent == SKIP @tax_amount = tax_amount unless tax_amount == SKIP @tax_rate = tax_rate unless tax_rate == SKIP @total_amount = total_amount unless total_amount == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#discount_amount ⇒ String
Discount applied to the item.
77 78 79 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 77 def discount_amount @discount_amount end |
#discount_percent ⇒ String
Rate the item is discounted. Maximum of 2 decimal places. Example 5.25 (=5.25%)
82 83 84 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 82 def discount_percent @discount_percent end |
#product_name ⇒ String
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.
37 38 39 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 37 def product_name @product_name end |
#product_sku ⇒ String
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.
26 27 28 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 26 def product_sku @product_sku end |
#quantity ⇒ Integer
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.
49 50 51 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 49 def quantity @quantity end |
#tax_amount ⇒ String
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:
- 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
- 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
105 106 107 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 105 def tax_amount @tax_amount end |
#tax_rate ⇒ String
Valid range: 1% to 99%, with only whole percentage values accepted; values with additional decimal places will be truncated For processor-specific details, see the alternate_tax_amount, vat_rate, vat_tax_rate, local_tax, national_tax, vat_tax_amount or other_tax#_rate field descriptions in the Level II and Level III Processing Using the SCMP API Guide.
115 116 117 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 115 def tax_rate @tax_rate end |
#total_amount ⇒ String
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
124 125 126 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 124 def total_amount @total_amount end |
#unit_price ⇒ String
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)
73 74 75 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 73 def unit_price @unit_price end |
Class Method Details
.from_element(root) ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 217 def self.from_element(root) product_sku = XmlUtilities.from_element(root, 'productSku', String) product_name = XmlUtilities.from_element(root, 'productName', String) quantity = XmlUtilities.from_element(root, 'quantity', Integer) unit_price = XmlUtilities.from_element(root, 'unitPrice', String) discount_amount = XmlUtilities.from_element(root, 'discountAmount', String) discount_percent = XmlUtilities.from_element(root, 'discountPercent', String) tax_amount = XmlUtilities.from_element(root, 'taxAmount', String) tax_rate = XmlUtilities.from_element(root, 'taxRate', String) total_amount = XmlUtilities.from_element(root, 'totalAmount', String) new(product_sku: product_sku, product_name: product_name, quantity: quantity, unit_price: unit_price, discount_amount: discount_amount, discount_percent: discount_percent, tax_amount: tax_amount, tax_rate: tax_rate, total_amount: total_amount, additional_properties: additional_properties) end |
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 181 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. product_sku = hash.key?('productSku') ? hash['productSku'] : SKIP product_name = hash.key?('productName') ? hash['productName'] : SKIP quantity = hash['quantity'] ||= 1 unit_price = hash.key?('unitPrice') ? hash['unitPrice'] : SKIP discount_amount = hash.key?('discountAmount') ? hash['discountAmount'] : SKIP discount_percent = hash.key?('discountPercent') ? hash['discountPercent'] : SKIP tax_amount = hash.key?('taxAmount') ? hash['taxAmount'] : SKIP tax_rate = hash.key?('taxRate') ? hash['taxRate'] : SKIP total_amount = hash.key?('totalAmount') ? hash['totalAmount'] : 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. LineItem17.new(product_sku: product_sku, product_name: product_name, quantity: quantity, unit_price: unit_price, discount_amount: discount_amount, discount_percent: discount_percent, tax_amount: tax_amount, tax_rate: tax_rate, total_amount: total_amount, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 127 def self.names @_hash = {} if @_hash.nil? @_hash['product_sku'] = 'productSku' @_hash['product_name'] = 'productName' @_hash['quantity'] = 'quantity' @_hash['unit_price'] = 'unitPrice' @_hash['discount_amount'] = 'discountAmount' @_hash['discount_percent'] = 'discountPercent' @_hash['tax_amount'] = 'taxAmount' @_hash['tax_rate'] = 'taxRate' @_hash['total_amount'] = 'totalAmount' @_hash end |
.nullables ⇒ Object
An array for nullable fields
157 158 159 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 157 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 142 def self.optionals %w[ product_sku product_name quantity unit_price discount_amount discount_percent tax_amount tax_rate total_amount ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
273 274 275 276 277 278 279 280 281 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 273 def inspect class_name = self.class.name.split('::').last "<#{class_name} product_sku: #{@product_sku.inspect}, product_name:"\ " #{@product_name.inspect}, quantity: #{@quantity.inspect}, unit_price:"\ " #{@unit_price.inspect}, discount_amount: #{@discount_amount.inspect}, discount_percent:"\ " #{@discount_percent.inspect}, tax_amount: #{@tax_amount.inspect}, tax_rate:"\ " #{@tax_rate.inspect}, total_amount: #{@total_amount.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
263 264 265 266 267 268 269 270 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 263 def to_s class_name = self.class.name.split('::').last "<#{class_name} product_sku: #{@product_sku}, product_name: #{@product_name}, quantity:"\ " #{@quantity}, unit_price: #{@unit_price}, discount_amount: #{@discount_amount},"\ " discount_percent: #{@discount_percent}, tax_amount: #{@tax_amount}, tax_rate:"\ " #{@tax_rate}, total_amount: #{@total_amount}, additional_properties:"\ " #{@additional_properties}>" end |
#to_xml_element(doc, root_name) ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/cyber_source_merged_spec/models/line_item17.rb', line 242 def to_xml_element(doc, root_name) root = doc.create_element(root_name) XmlUtilities.add_as_subelement(doc, root, 'productSku', product_sku) XmlUtilities.add_as_subelement(doc, root, 'productName', product_name) XmlUtilities.add_as_subelement(doc, root, 'quantity', quantity) XmlUtilities.add_as_subelement(doc, root, 'unitPrice', unit_price) XmlUtilities.add_as_subelement(doc, root, 'discountAmount', discount_amount) XmlUtilities.add_as_subelement(doc, root, 'discountPercent', discount_percent) XmlUtilities.add_as_subelement(doc, root, 'taxAmount', tax_amount) XmlUtilities.add_as_subelement(doc, root, 'taxRate', tax_rate) XmlUtilities.add_as_subelement(doc, root, 'totalAmount', total_amount) XmlUtilities.add_as_subelement(doc, root, 'additional_properties', additional_properties) root end |