Class: OpenapiClient::Payment

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_client/models/payment.rb

Overview

Payment information for the transaction.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Payment

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



104
105
106
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/openapi_client/models/payment.rb', line 104

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Payment` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Payment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'payment_type')
    self.payment_type = attributes[:'payment_type']
  end

  if attributes.key?(:'method')
    self.method = attributes[:'method']
  end

  if attributes.key?(:'pin_present')
    self.pin_present = attributes[:'pin_present']
  end

  if attributes.key?(:'entry_method')
    self.entry_method = attributes[:'entry_method']
  end

  if attributes.key?(:'issuer_response')
    self.issuer_response = attributes[:'issuer_response']
  end

  if attributes.key?(:'issuer_approved_amount')
    self.issuer_approved_amount = attributes[:'issuer_approved_amount']
  end

  if attributes.key?(:'issuer_card_balance')
    self.issuer_card_balance = attributes[:'issuer_card_balance']
  end

  if attributes.key?(:'verification_avs')
    self.verification_avs = attributes[:'verification_avs']
  end

  if attributes.key?(:'verification3ds')
    self.verification3ds = attributes[:'verification3ds']
  end

  if attributes.key?(:'verification_cvv')
    self.verification_cvv = attributes[:'verification_cvv']
  end

  if attributes.key?(:'user_defined')
    self.user_defined = attributes[:'user_defined']
  end
end

Instance Attribute Details

#entry_methodObject

The method in which the card information entered the system.



27
28
29
# File 'lib/openapi_client/models/payment.rb', line 27

def entry_method
  @entry_method
end

#issuer_approved_amountObject

The actual approved amount. This field should be filled in when the message has already passed through the issuer (e.g. post-authorization). For transaction/authorization this amount refers to the amount that was locked on the card-holders account.



32
33
34
# File 'lib/openapi_client/models/payment.rb', line 32

def issuer_approved_amount
  @issuer_approved_amount
end

#issuer_card_balanceObject

The payment methods account balance if available. This field should be filled in when the message has already passed through the issuer (e.g. post-authorization).



35
36
37
# File 'lib/openapi_client/models/payment.rb', line 35

def issuer_card_balance
  @issuer_card_balance
end

#issuer_responseObject

Returns the value of attribute issuer_response.



29
30
31
# File 'lib/openapi_client/models/payment.rb', line 29

def issuer_response
  @issuer_response
end

#methodObject

Returns the value of attribute method.



21
22
23
# File 'lib/openapi_client/models/payment.rb', line 21

def method
  @method
end

#payment_typeObject

Defines the type of the payment.



19
20
21
# File 'lib/openapi_client/models/payment.rb', line 19

def payment_type
  @payment_type
end

#pin_presentObject

Indicates if the cards Personal Identification Number was supplied.



24
25
26
# File 'lib/openapi_client/models/payment.rb', line 24

def pin_present
  @pin_present
end

#user_definedObject

A JSON object that carries any additional information that might be helpful for fraud detection.



44
45
46
# File 'lib/openapi_client/models/payment.rb', line 44

def user_defined
  @user_defined
end

#verification3dsObject

Returns the value of attribute verification3ds.



39
40
41
# File 'lib/openapi_client/models/payment.rb', line 39

def verification3ds
  @verification3ds
end

#verification_avsObject

Returns the value of attribute verification_avs.



37
38
39
# File 'lib/openapi_client/models/payment.rb', line 37

def verification_avs
  @verification_avs
end

#verification_cvvObject

Returns the value of attribute verification_cvv.



41
42
43
# File 'lib/openapi_client/models/payment.rb', line 41

def verification_cvv
  @verification_cvv
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/openapi_client/models/payment.rb', line 69

def self.attribute_map
  {
    :'payment_type' => :'paymentType',
    :'method' => :'method',
    :'pin_present' => :'pinPresent',
    :'entry_method' => :'entryMethod',
    :'issuer_response' => :'issuerResponse',
    :'issuer_approved_amount' => :'issuerApprovedAmount',
    :'issuer_card_balance' => :'issuerCardBalance',
    :'verification_avs' => :'verificationAvs',
    :'verification3ds' => :'verification3ds',
    :'verification_cvv' => :'verificationCvv',
    :'user_defined' => :'userDefined'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



252
253
254
# File 'lib/openapi_client/models/payment.rb', line 252

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_typesObject

Attribute type mapping.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/openapi_client/models/payment.rb', line 86

def self.openapi_types
  {
    :'payment_type' => :'String',
    :'method' => :'Method',
    :'pin_present' => :'Boolean',
    :'entry_method' => :'String',
    :'issuer_response' => :'IssuerResponse',
    :'issuer_approved_amount' => :'String',
    :'issuer_card_balance' => :'String',
    :'verification_avs' => :'VerificationAvs',
    :'verification3ds' => :'Verification3ds',
    :'verification_cvv' => :'VerificationCvv',
    :'user_defined' => :'Object'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/openapi_client/models/payment.rb', line 221

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      payment_type == o.payment_type &&
      method == o.method &&
      pin_present == o.pin_present &&
      entry_method == o.entry_method &&
      issuer_response == o.issuer_response &&
      issuer_approved_amount == o.issuer_approved_amount &&
      issuer_card_balance == o.issuer_card_balance &&
      verification_avs == o.verification_avs &&
      verification3ds == o.verification3ds &&
      verification_cvv == o.verification_cvv &&
      user_defined == o.user_defined
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
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
# File 'lib/openapi_client/models/payment.rb', line 280

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    klass = OpenapiClient.const_get(type)
    if klass.respond_to?(:openapi_discriminator_name)
      klass = OpenapiClient.const_get(value[klass.attribute_map[klass.openapi_discriminator_name]])
    end
 
    klass.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/openapi_client/models/payment.rb', line 354

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes, attribute_map = self.class.attribute_map, openapi_types = self.class.openapi_types) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/openapi_client/models/payment.rb', line 259

def build_from_hash(attributes, attribute_map = self.class.attribute_map, openapi_types = self.class.openapi_types)
  return nil unless attributes.is_a?(Hash)
  openapi_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


239
240
241
# File 'lib/openapi_client/models/payment.rb', line 239

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



245
246
247
# File 'lib/openapi_client/models/payment.rb', line 245

def hash
  [payment_type, method, pin_present, entry_method, issuer_response, issuer_approved_amount, issuer_card_balance, verification_avs, verification3ds, verification_cvv, user_defined].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/openapi_client/models/payment.rb', line 164

def list_invalid_properties
  invalid_properties = Array.new
  if @payment_type.nil?
    invalid_properties.push('invalid value for "payment_type", payment_type cannot be nil.')
  end

  if @method.nil?
    invalid_properties.push('invalid value for "method", method cannot be nil.')
  end

  if @pin_present.nil?
    invalid_properties.push('invalid value for "pin_present", pin_present cannot be nil.')
  end

  if @entry_method.nil?
    invalid_properties.push('invalid value for "entry_method", entry_method cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



330
331
332
# File 'lib/openapi_client/models/payment.rb', line 330

def to_body
  to_hash
end

#to_hash(attribute_map = self.class.attribute_map, openapi_nullable = Set.new([])) ⇒ Hash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/openapi_client/models/payment.rb', line 336

def to_hash(attribute_map = self.class.attribute_map, openapi_nullable = Set.new([]))
  hash = {}
  attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end
    
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



324
325
326
# File 'lib/openapi_client/models/payment.rb', line 324

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



187
188
189
190
191
192
193
194
195
196
197
# File 'lib/openapi_client/models/payment.rb', line 187

def valid?
  return false if @payment_type.nil?
  payment_type_validator = EnumAttributeValidator.new('String', ["payment/card", "payment/wallet"])
  return false unless payment_type_validator.valid?(@payment_type)
  return false if @method.nil?
  return false if @pin_present.nil?
  return false if @entry_method.nil?
  entry_method_validator = EnumAttributeValidator.new('String', ["manual", "stripe", "ocr", "emv", "nfc", "remote", "pin_present"])
  return false unless entry_method_validator.valid?(@entry_method)
  true
end