class CityPayApiClient::ChargeRequest
Attributes
The amount to authorise in the lowest unit of currency with a variable length to a maximum of 12 digits. No decimal points are to be included and no divisional characters such as 1,024. The amount should be the total amount required for the transaction. For example with GBP £1,021.95 the amount value is 102195.
A policy value which determines whether an AVS postcode policy is enforced or bypassed. Values are `0` for the default policy (default value if not supplied). Your default values are determined by your account manager on setup of the account. `1` for an enforced policy. Transactions that are enforced will be rejected if the AVS postcode numeric value does not match. `2` to bypass. Transactions that are bypassed will be allowed through even if the postcode did not match. `3` to ignore. Transactions that are ignored will bypass the result and not send postcode details for authorisation.
The Card
Security Code (CSC) (also known as CV2/CVV2) is normally found on the back of the card (American Express has it on the front). The value helps to identify posession of the card as it is not available within the chip or magnetic swipe. When forwarding the CSC, please ensure the value is a string as some values start with 0 and this will be stripped out by any integer parsing. The CSC number aids fraud prevention in Mail Order and Internet payments. Business rules are available on your account to identify whether to accept or decline transactions based on mismatched results of the CSC. The Payment Card
Industry (PCI) requires that at no stage of a transaction should the CSC be stored. This applies to all entities handling card data. It should also not be used in any hashing process. CityPay do not store the value and have no method of retrieving the value once the transaction has been processed. For this reason, duplicate checking is unable to determine the CSC in its duplication check algorithm.
A policy value which determines whether a CSC policy is enforced or bypassed. Values are `0` for the default policy (default value if not supplied). Your default values are determined by your account manager on setup of the account. `1` for an enforced policy. Transactions that are enforced will be rejected if the CSC value does not match. `2` to bypass. Transactions that are bypassed will be allowed through even if the CSC did not match. `3` to ignore. Transactions that are ignored will bypass the result and not send the CSC details for authorisation.
The processing currency for the transaction. Will default to the merchant account currency.
A policy value which determines whether a duplication policy is enforced or bypassed. A duplication check has a window of time set against your account within which it can action. If a previous transaction with matching values occurred within the window, any subsequent transaction will result in a T001 result. Values are `0` for the default policy (default value if not supplied). Your default values are determined by your account manager on setup of the account. `1` for an enforced policy. Transactions that are enforced will be checked for duplication within the duplication window. `2` to bypass. Transactions that are bypassed will not be checked for duplication within the duplication window. `3` to ignore. Transactions that are ignored will have the same affect as bypass.
The identifier of the transaction to process. The value should be a valid reference and may be used to perform post processing actions and to aid in reconciliation of transactions. The value should be a valid printable string with ASCII character ranges from 32 to 127. The identifier is recommended to be distinct for each transaction such as a [random unique identifier](en.wikipedia.org/wiki/Universally_unique_identifier) this will aid in ensuring each transaction is identifiable. When transactions are processed they are also checked for duplicate requests. Changing the identifier on a subsequent request will ensure that a transaction is considered as different.
A policy value which determines whether an AVS address policy is enforced, bypassed or ignored. Values are `0` for the default policy (default value if not supplied). Your default values are determined by your account manager on setup of the account. `1` for an enforced policy. Transactions that are enforced will be rejected if the AVS address numeric value does not match. `2` to bypass. Transactions that are bypassed will be allowed through even if the address did not match. `3` to ignore. Transactions that are ignored will bypass the result and not send address numeric details for authorisation.
Identifies the merchant account to perform processing for.
An optional reference value for the calling client such as a version number i.e.
A tokenised form of a card that belongs to a card holder's account and that has been previously registered. The token is time based and will only be active for a short duration. The value is therefore designed not to be stored remotely for future use. Tokens will start with ct and are resiliently tamper proof using HMacSHA-256. No sensitive card data is stored internally within the token. Each card will contain a different token and the value may be different on any retrieval call. The value can be presented for payment as a selection value to an end user in a web application.
Further information that can be added to the transaction will display in reporting. Can be used for flexible values such as operator id.
The type of transaction being submitted. Normally this value is not required and your account manager may request that you set this field.
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/citypay_api_client/models/charge_request.rb, line 56 def self.attribute_map { :'amount' => :'amount', :'avs_postcode_policy' => :'avs_postcode_policy', :'csc' => :'csc', :'csc_policy' => :'csc_policy', :'currency' => :'currency', :'duplicate_policy' => :'duplicate_policy', :'identifier' => :'identifier', :'match_avsa' => :'match_avsa', :'merchantid' => :'merchantid', :'sdk' => :'sdk', :'token' => :'token', :'trans_info' => :'trans_info', :'trans_type' => :'trans_type' } end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/citypay_api_client/models/charge_request.rb, line 343 def self.build_from_hash(attributes) new.build_from_hash(attributes) end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/citypay_api_client/models/charge_request.rb, line 101 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `CityPayApiClient::ChargeRequest` 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 `CityPayApiClient::ChargeRequest`. 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?(:'amount') self.amount = attributes[:'amount'] end if attributes.key?(:'avs_postcode_policy') self.avs_postcode_policy = attributes[:'avs_postcode_policy'] end if attributes.key?(:'csc') self.csc = attributes[:'csc'] end if attributes.key?(:'csc_policy') self.csc_policy = attributes[:'csc_policy'] end if attributes.key?(:'currency') self.currency = attributes[:'currency'] end if attributes.key?(:'duplicate_policy') self.duplicate_policy = attributes[:'duplicate_policy'] end if attributes.key?(:'identifier') self.identifier = attributes[:'identifier'] end if attributes.key?(:'match_avsa') self.match_avsa = attributes[:'match_avsa'] end if attributes.key?(:'merchantid') self.merchantid = attributes[:'merchantid'] end if attributes.key?(:'sdk') self.sdk = attributes[:'sdk'] else self.sdk = CityPayApiClient::FULL_VERSION end if attributes.key?(:'token') self.token = attributes[:'token'] end if attributes.key?(:'trans_info') self.trans_info = attributes[:'trans_info'] end if attributes.key?(:'trans_type') self.trans_type = attributes[:'trans_type'] end end
List of attributes with nullable: true
# File lib/citypay_api_client/models/charge_request.rb, line 94 def self.openapi_nullable Set.new([ ]) end
Attribute type mapping.
# File lib/citypay_api_client/models/charge_request.rb, line 75 def self.openapi_types { :'amount' => :'Integer', :'avs_postcode_policy' => :'String', :'csc' => :'String', :'csc_policy' => :'String', :'currency' => :'String', :'duplicate_policy' => :'String', :'identifier' => :'String', :'match_avsa' => :'String', :'merchantid' => :'Integer', :'sdk' => :'String', :'token' => :'String', :'trans_info' => :'String', :'trans_type' => :'String' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/citypay_api_client/models/charge_request.rb, line 310 def ==(o) return true if self.equal?(o) self.class == o.class && amount == o.amount && avs_postcode_policy == o.avs_postcode_policy && csc == o.csc && csc_policy == o.csc_policy && currency == o.currency && duplicate_policy == o.duplicate_policy && identifier == o.identifier && match_avsa == o.match_avsa && merchantid == o.merchantid && sdk == o.sdk && token == o.token && trans_info == o.trans_info && trans_type == o.trans_type end
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/citypay_api_client/models/charge_request.rb, line 371 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 CityPayApiClient.const_get(type).build_from_hash(value) end end
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/citypay_api_client/models/charge_request.rb, line 440 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
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/citypay_api_client/models/charge_request.rb, line 350 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.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[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end
Custom attribute writer method with validation @param [Object] csc Value to be assigned
# File lib/citypay_api_client/models/charge_request.rb, line 244 def csc=(csc) if !csc.nil? && csc.to_s.length > 4 fail ArgumentError, 'invalid value for "csc", the character length must be smaller than or equal to 4.' end if !csc.nil? && csc.to_s.length < 3 fail ArgumentError, 'invalid value for "csc", the character length must be great than or equal to 3.' end @csc = csc end
Custom attribute writer method with validation @param [Object] currency Value to be assigned
# File lib/citypay_api_client/models/charge_request.rb, line 258 def currency=(currency) if !currency.nil? && currency.to_s.length > 3 fail ArgumentError, 'invalid value for "currency", the character length must be smaller than or equal to 3.' end if !currency.nil? && currency.to_s.length < 3 fail ArgumentError, 'invalid value for "currency", the character length must be great than or equal to 3.' end @currency = currency end
@see the `==` method @param [Object] Object to be compared
# File lib/citypay_api_client/models/charge_request.rb, line 330 def eql?(o) self == o end
Calculates hash code according to all attributes. @return [Integer] Hash code
# File lib/citypay_api_client/models/charge_request.rb, line 336 def hash [amount, avs_postcode_policy, csc, csc_policy, currency, duplicate_policy, identifier, match_avsa, merchantid, sdk, token, trans_info, trans_type].hash end
Custom attribute writer method with validation @param [Object] identifier Value to be assigned
# File lib/citypay_api_client/models/charge_request.rb, line 272 def identifier=(identifier) if identifier.nil? fail ArgumentError, 'identifier cannot be nil' end if identifier.to_s.length > 50 fail ArgumentError, 'invalid value for "identifier", the character length must be smaller than or equal to 50.' end if identifier.to_s.length < 4 fail ArgumentError, 'invalid value for "identifier", the character length must be great than or equal to 4.' end @identifier = identifier end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/citypay_api_client/models/charge_request.rb, line 171 def list_invalid_properties invalid_properties = Array.new if @amount.nil? invalid_properties.push('invalid value for "amount", amount cannot be nil.') end if !@csc.nil? && @csc.to_s.length > 4 invalid_properties.push('invalid value for "csc", the character length must be smaller than or equal to 4.') end if !@csc.nil? && @csc.to_s.length < 3 invalid_properties.push('invalid value for "csc", the character length must be great than or equal to 3.') end if !@currency.nil? && @currency.to_s.length > 3 invalid_properties.push('invalid value for "currency", the character length must be smaller than or equal to 3.') end if !@currency.nil? && @currency.to_s.length < 3 invalid_properties.push('invalid value for "currency", the character length must be great than or equal to 3.') end if @identifier.nil? invalid_properties.push('invalid value for "identifier", identifier cannot be nil.') end if @identifier.to_s.length > 50 invalid_properties.push('invalid value for "identifier", the character length must be smaller than or equal to 50.') end if @identifier.to_s.length < 4 invalid_properties.push('invalid value for "identifier", the character length must be great than or equal to 4.') end if @merchantid.nil? invalid_properties.push('invalid value for "merchantid", merchantid cannot be nil.') end if @token.nil? invalid_properties.push('invalid value for "token", token cannot be nil.') end if !@trans_info.nil? && @trans_info.to_s.length > 50 invalid_properties.push('invalid value for "trans_info", the character length must be smaller than or equal to 50.') end if !@trans_type.nil? && @trans_type.to_s.length > 1 invalid_properties.push('invalid value for "trans_type", the character length must be smaller than or equal to 1.') end invalid_properties end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/citypay_api_client/models/charge_request.rb, line 422 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end
Returns the string representation of the object @return [String] String presentation of the object
# File lib/citypay_api_client/models/charge_request.rb, line 410 def to_s to_hash.to_s end
Custom attribute writer method with validation @param [Object] trans_info
Value to be assigned
# File lib/citypay_api_client/models/charge_request.rb, line 290 def trans_info=(trans_info) if !trans_info.nil? && trans_info.to_s.length > 50 fail ArgumentError, 'invalid value for "trans_info", the character length must be smaller than or equal to 50.' end @trans_info = trans_info end
Custom attribute writer method with validation @param [Object] trans_type
Value to be assigned
# File lib/citypay_api_client/models/charge_request.rb, line 300 def trans_type=(trans_type) if !trans_type.nil? && trans_type.to_s.length > 1 fail ArgumentError, 'invalid value for "trans_type", the character length must be smaller than or equal to 1.' end @trans_type = trans_type end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/citypay_api_client/models/charge_request.rb, line 226 def valid? return false if @amount.nil? return false if !@csc.nil? && @csc.to_s.length > 4 return false if !@csc.nil? && @csc.to_s.length < 3 return false if !@currency.nil? && @currency.to_s.length > 3 return false if !@currency.nil? && @currency.to_s.length < 3 return false if @identifier.nil? return false if @identifier.to_s.length > 50 return false if @identifier.to_s.length < 4 return false if @merchantid.nil? return false if @token.nil? return false if !@trans_info.nil? && @trans_info.to_s.length > 50 return false if !@trans_type.nil? && @trans_type.to_s.length > 1 true end