Class: CyberSourceMergedSpec::MerchantInitiatedTransactionObject

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

Overview

MerchantInitiatedTransactionObject 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(reason: SKIP, previous_transaction_id: SKIP, original_authorized_amount: SKIP, agreement_id: SKIP, additional_properties: nil) ⇒ MerchantInitiatedTransactionObject

Returns a new instance of MerchantInitiatedTransactionObject.



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

def initialize(reason: SKIP, previous_transaction_id: SKIP,
               original_authorized_amount: SKIP, agreement_id: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @reason = reason unless reason == SKIP
  @previous_transaction_id = previous_transaction_id unless previous_transaction_id == SKIP
  unless original_authorized_amount == SKIP
    @original_authorized_amount =
      original_authorized_amount
  end
  @agreement_id = agreement_id unless agreement_id == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#agreement_idString

This field contains the predetermined agrement id with the merchant

Returns:

  • (String)


57
58
59
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction_object.rb', line 57

def agreement_id
  @agreement_id
end

#original_authorized_amountString

Amount of the original authorization. This field is supported only for Apple Pay, Google Pay, and Samsung Pay transactions with Discover on FDC Nashville Global and Chase Paymentech.

Returns:

  • (String)


53
54
55
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction_object.rb', line 53

def original_authorized_amount
  @original_authorized_amount
end

#previous_transaction_idString

Network transaction identifier that was returned in the payment response field processorInformation.transactionID in the reply message for either the original merchant-initiated payment in the series or the previous merchant-initiated payment in the series. If the current payment request includes a token instead of an account number, the following time limits apply for the value of this field:

  • For a resubmission, the transaction ID must be less than 14 days old.
  • For a delayed charge or reauthorization, the transaction ID must be less than 30 days old. NOTE: The value for this field does not correspond to any data in the TC 33 capture file5. This field is supported only for Visa transactions on CyberSource through VisaNet.

Returns:

  • (String)


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

def previous_transaction_id
  @previous_transaction_id
end

#reasonString

Reason for the merchant-initiated transaction or incremental authorization. Possible values:

  • 1: Resubmission
  • 2: Delayed charge
  • 3: Reauthorization for split shipment
  • 4: No show
  • 5: Account top up This field is required only for the five kinds of transactions in the preceding list. This field is supported only for merchant-initiated transactions and incremental authorizations.

CyberSource through VisaNet

The value for this field corresponds to the following data in the TC 33 capture file5:

  • Record: CP01 TCR0
  • Position: 160-163
  • Field: Message Reason Code

Returns:

  • (String)


30
31
32
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction_object.rb', line 30

def reason
  @reason
end

Class Method Details

.from_element(root) ⇒ Object



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

def self.from_element(root)
  reason = XmlUtilities.from_element(root, 'reason', String)
  previous_transaction_id = XmlUtilities.from_element(
    root, 'previousTransactionId', String
  )
  original_authorized_amount = XmlUtilities.from_element(
    root, 'originalAuthorizedAmount', String
  )
  agreement_id = XmlUtilities.from_element(root, 'agreementId', String)

  new(reason: reason,
      previous_transaction_id: previous_transaction_id,
      original_authorized_amount: original_authorized_amount,
      agreement_id: agreement_id,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction_object.rb', line 101

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  reason = hash.key?('reason') ? hash['reason'] : SKIP
  previous_transaction_id =
    hash.key?('previousTransactionId') ? hash['previousTransactionId'] : SKIP
  original_authorized_amount =
    hash.key?('originalAuthorizedAmount') ? hash['originalAuthorizedAmount'] : SKIP
  agreement_id = hash.key?('agreementId') ? hash['agreementId'] : 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.
  MerchantInitiatedTransactionObject.new(reason: reason,
                                         previous_transaction_id: previous_transaction_id,
                                         original_authorized_amount: original_authorized_amount,
                                         agreement_id: agreement_id,
                                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



60
61
62
63
64
65
66
67
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction_object.rb', line 60

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['reason'] = 'reason'
  @_hash['previous_transaction_id'] = 'previousTransactionId'
  @_hash['original_authorized_amount'] = 'originalAuthorizedAmount'
  @_hash['agreement_id'] = 'agreementId'
  @_hash
end

.nullablesObject

An array for nullable fields



80
81
82
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction_object.rb', line 80

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    reason
    previous_transaction_id
    original_authorized_amount
    agreement_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



168
169
170
171
172
173
174
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction_object.rb', line 168

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

#to_sObject

Provides a human-readable string representation of the object.



160
161
162
163
164
165
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction_object.rb', line 160

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

#to_xml_element(doc, root_name) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction_object.rb', line 144

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

  XmlUtilities.add_as_subelement(doc, root, 'reason', reason)
  XmlUtilities.add_as_subelement(doc, root, 'previousTransactionId',
                                 previous_transaction_id)
  XmlUtilities.add_as_subelement(doc, root, 'originalAuthorizedAmount',
                                 original_authorized_amount)
  XmlUtilities.add_as_subelement(doc, root, 'agreementId', agreement_id)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end