Class: CyberSourceMergedSpec::TransactionDetails

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

Overview

These details are only returned when the invoice event is payment.

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(transaction_id: SKIP, amount: SKIP, additional_properties: nil) ⇒ TransactionDetails

Returns a new instance of TransactionDetails.



70
71
72
73
74
75
76
77
78
# File 'lib/cyber_source_merged_spec/models/transaction_details.rb', line 70

def initialize(transaction_id: SKIP, amount: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @transaction_id = transaction_id unless transaction_id == SKIP
  @amount = amount unless amount == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountString

Grand total for the order. This value cannot be negative. You can include a decimal point (.), but no other special characters. CyberSource truncates the amount to the correct number of decimal places. Note For CTV, FDCCompass, Paymentech processors, the maximum length for this field is 12. Important Some processors have specific requirements and limitations, such as maximum amounts and maximum field lengths. 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.

Card Present

Required to include either this field or orderInformation.lineItems[].unitPrice for the order.

Required for creating a new invoice or payment link.

PIN Debit

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. 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; however, for all other processors, these fields are required.

DCC with a Third-Party Provider

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

DCC for First Data

Not used.

Returns:

  • (String)


47
48
49
# File 'lib/cyber_source_merged_spec/models/transaction_details.rb', line 47

def amount
  @amount
end

#transaction_idString

Payer auth Transaction identifier.

Returns:

  • (String)


14
15
16
# File 'lib/cyber_source_merged_spec/models/transaction_details.rb', line 14

def transaction_id
  @transaction_id
end

Class Method Details

.from_element(root) ⇒ Object



101
102
103
104
105
106
107
108
# File 'lib/cyber_source_merged_spec/models/transaction_details.rb', line 101

def self.from_element(root)
  transaction_id = XmlUtilities.from_element(root, 'transactionId', String)
  amount = XmlUtilities.from_element(root, 'amount', String)

  new(transaction_id: transaction_id,
      amount: amount,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/cyber_source_merged_spec/models/transaction_details.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  transaction_id = hash.key?('transactionId') ? hash['transactionId'] : SKIP
  amount = hash.key?('amount') ? hash['amount'] : 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.
  TransactionDetails.new(transaction_id: transaction_id,
                         amount: amount,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



50
51
52
53
54
55
# File 'lib/cyber_source_merged_spec/models/transaction_details.rb', line 50

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['transaction_id'] = 'transactionId'
  @_hash['amount'] = 'amount'
  @_hash
end

.nullablesObject

An array for nullable fields



66
67
68
# File 'lib/cyber_source_merged_spec/models/transaction_details.rb', line 66

def self.nullables
  []
end

.optionalsObject

An array for optional fields



58
59
60
61
62
63
# File 'lib/cyber_source_merged_spec/models/transaction_details.rb', line 58

def self.optionals
  %w[
    transaction_id
    amount
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



129
130
131
132
133
# File 'lib/cyber_source_merged_spec/models/transaction_details.rb', line 129

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} transaction_id: #{@transaction_id.inspect}, amount: #{@amount.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



122
123
124
125
126
# File 'lib/cyber_source_merged_spec/models/transaction_details.rb', line 122

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} transaction_id: #{@transaction_id}, amount: #{@amount},"\
  " additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



110
111
112
113
114
115
116
117
118
119
# File 'lib/cyber_source_merged_spec/models/transaction_details.rb', line 110

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

  XmlUtilities.add_as_subelement(doc, root, 'transactionId', transaction_id)
  XmlUtilities.add_as_subelement(doc, root, 'amount', amount)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end