Class: CyberSourceMergedSpec::MerchantInitiatedTransaction

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

Overview

MerchantInitiatedTransaction 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) ⇒ MerchantInitiatedTransaction

Returns a new instance of MerchantInitiatedTransaction.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction.rb', line 90

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

An API to carry the agreement ID generated for recurring and unscheduled Card on file transaction. the merchant generates this per card holder or per payment agreement and shares the generated unique ID in the subsequent transactions. This can contain foreign/arabic character set also. Cybersource forwards this value to the Saudi Payment processor.

Returns:

  • (String)


63
64
65
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction.rb', line 63

def agreement_id
  @agreement_id
end

#original_authorized_amountString

Amount of the original authorization in the series. This field is only needed for merchant-initiated transactions with Discover or Diners cards.

Returns:

  • (String)


55
56
57
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction.rb', line 55

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 the original customer-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.

Returns:

  • (String)


50
51
52
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction.rb', line 50

def previous_transaction_id
  @previous_transaction_id
end

#reasonString

Reason for the transaction. Possible values:

  • 1: Resubmission
  • 2: Delayed charge
  • 3: Reauthorization for split shipment
  • 4: No show
  • 5: Account top up or Incremental authorization
  • 6: Partial shipment
  • 7: Fixed amount recurring (subscription)
  • 8: Variable amount recurring (standing order)
  • 9: Installment
  • 10: Unscheduled Card-on-File This field should be used to identify the kind of merchant-initiated transaction. Values 7 and 8 should be used on customer-initiated transactions that are establishing the relationship for Mastercard subscriptions or standing orders.

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)


35
36
37
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction.rb', line 35

def reason
  @reason
end

Class Method Details

.from_element(root) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction.rb', line 133

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.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction.rb', line 107

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.
  MerchantInitiatedTransaction.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.



66
67
68
69
70
71
72
73
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction.rb', line 66

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



86
87
88
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction.rb', line 86

def self.nullables
  []
end

.optionalsObject

An array for optional fields



76
77
78
79
80
81
82
83
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction.rb', line 76

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.



174
175
176
177
178
179
180
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction.rb', line 174

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.



166
167
168
169
170
171
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction.rb', line 166

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



150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/cyber_source_merged_spec/models/merchant_initiated_transaction.rb', line 150

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