Class: Batches::Transaction
- Defined in:
- lib/batches/models/transaction.rb
Overview
Transaction Model.
Instance Attribute Summary collapse
-
#amount ⇒ String
The amount to transfer between Payer and Merchant for a SALE or a REFUND.
-
#cashback_amount ⇒ String
The amount of the transaction that relates to cashback.
-
#currency ⇒ CurrencyBatchesTransactionsCurrency
The currency of the amount in ISO-4217(alpha-3).
-
#gratuity_amount ⇒ String
The amount of the gratuity for a transaction.
-
#id ⇒ String
A unique identifier that is used to identify and reference an instance of this resource.
-
#payment_method ⇒ PaymentMethod
Merchant defined field to reference the transaction.
-
#reference ⇒ String
Merchant defined field to reference the transaction.
-
#status ⇒ StatusBatchesTransactionsStatus
Indicates where a transaction is in its lifecycle.
-
#surcharge_amount ⇒ String
The amount that reflects the additional charge the merchant applied to the transaction for using a specific payment method.
-
#tax_amount ⇒ String
The total amount of tax charges associated with this transaction.
-
#time_created ⇒ String
Time indicating when the transaction was created in ISO-8601 format.
-
#type ⇒ TypeBatchesTransactionsType
Describes whether the transaction is a SALE, that moves funds from Payer to Merchant, or a REFUND where funds move from Merchant to Payer.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(id: SKIP, time_created: SKIP, status: SKIP, type: TypeBatchesTransactionsType::SALE, amount: SKIP, tax_amount: SKIP, currency: SKIP, gratuity_amount: SKIP, surcharge_amount: SKIP, cashback_amount: SKIP, reference: SKIP, payment_method: SKIP, additional_properties: nil) ⇒ Transaction
constructor
A new instance of Transaction.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(id: SKIP, time_created: SKIP, status: SKIP, type: TypeBatchesTransactionsType::SALE, amount: SKIP, tax_amount: SKIP, currency: SKIP, gratuity_amount: SKIP, surcharge_amount: SKIP, cashback_amount: SKIP, reference: SKIP, payment_method: SKIP, additional_properties: nil) ⇒ Transaction
Returns a new instance of Transaction.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/batches/models/transaction.rb', line 115 def initialize(id: SKIP, time_created: SKIP, status: SKIP, type: TypeBatchesTransactionsType::SALE, amount: SKIP, tax_amount: SKIP, currency: SKIP, gratuity_amount: SKIP, surcharge_amount: SKIP, cashback_amount: SKIP, reference: SKIP, payment_method: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id unless id == SKIP @time_created = time_created unless time_created == SKIP @status = status unless status == SKIP @type = type unless type == SKIP @amount = amount unless amount == SKIP @tax_amount = tax_amount unless tax_amount == SKIP @currency = currency unless currency == SKIP @gratuity_amount = gratuity_amount unless gratuity_amount == SKIP @surcharge_amount = surcharge_amount unless surcharge_amount == SKIP @cashback_amount = cashback_amount unless cashback_amount == SKIP @reference = reference unless reference == SKIP @payment_method = payment_method unless payment_method == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ String
The amount to transfer between Payer and Merchant for a SALE or a REFUND. It is always represented in the lowest denomination of the related currency. and with no decimal point.
43 44 45 |
# File 'lib/batches/models/transaction.rb', line 43 def amount @amount end |
#cashback_amount ⇒ String
The amount of the transaction that relates to cashback.
64 65 66 |
# File 'lib/batches/models/transaction.rb', line 64 def cashback_amount @cashback_amount end |
#currency ⇒ CurrencyBatchesTransactionsCurrency
The currency of the amount in ISO-4217(alpha-3).
51 52 53 |
# File 'lib/batches/models/transaction.rb', line 51 def currency @currency end |
#gratuity_amount ⇒ String
The amount of the gratuity for a transaction.
55 56 57 |
# File 'lib/batches/models/transaction.rb', line 55 def gratuity_amount @gratuity_amount end |
#id ⇒ String
A unique identifier that is used to identify and reference an instance of this resource. It is generated by Global Payments to identify the transaction and must be used to action that transaction in future.
16 17 18 |
# File 'lib/batches/models/transaction.rb', line 16 def id @id end |
#payment_method ⇒ PaymentMethod
Merchant defined field to reference the transaction.
72 73 74 |
# File 'lib/batches/models/transaction.rb', line 72 def payment_method @payment_method end |
#reference ⇒ String
Merchant defined field to reference the transaction.
68 69 70 |
# File 'lib/batches/models/transaction.rb', line 68 def reference @reference end |
#status ⇒ StatusBatchesTransactionsStatus
Indicates where a transaction is in its lifecycle.
BATCHED- A Transaction has been successfully BatchedCAPTURED- A Transaction has been successfully authorized and captured. The funding process will commence once the transaction remains in this status.
28 29 30 |
# File 'lib/batches/models/transaction.rb', line 28 def status @status end |
#surcharge_amount ⇒ String
The amount that reflects the additional charge the merchant applied to the transaction for using a specific payment method.
60 61 62 |
# File 'lib/batches/models/transaction.rb', line 60 def surcharge_amount @surcharge_amount end |
#tax_amount ⇒ String
The total amount of tax charges associated with this transaction.
47 48 49 |
# File 'lib/batches/models/transaction.rb', line 47 def tax_amount @tax_amount end |
#time_created ⇒ String
Time indicating when the transaction was created in ISO-8601 format.
20 21 22 |
# File 'lib/batches/models/transaction.rb', line 20 def time_created @time_created end |
#type ⇒ TypeBatchesTransactionsType
Describes whether the transaction is a SALE, that moves funds from Payer
to Merchant, or a REFUND where funds move from Merchant to Payer.
* SALE - indicates the movement, or the attempt to
move, funds from payer to a merchant.
* REFUND - indicates the movement, or the attempt to
move, funds from merchant to the payer.
37 38 39 |
# File 'lib/batches/models/transaction.rb', line 37 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/batches/models/transaction.rb', line 140 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP time_created = hash.key?('time_created') ? hash['time_created'] : SKIP status = hash.key?('status') ? hash['status'] : SKIP type = hash['type'] ||= TypeBatchesTransactionsType::SALE amount = hash.key?('amount') ? hash['amount'] : SKIP tax_amount = hash.key?('tax_amount') ? hash['tax_amount'] : SKIP currency = hash.key?('currency') ? hash['currency'] : SKIP gratuity_amount = hash.key?('gratuity_amount') ? hash['gratuity_amount'] : SKIP surcharge_amount = hash.key?('surcharge_amount') ? hash['surcharge_amount'] : SKIP cashback_amount = hash.key?('cashback_amount') ? hash['cashback_amount'] : SKIP reference = hash.key?('reference') ? hash['reference'] : SKIP payment_method = PaymentMethod.from_hash(hash['payment_method']) if hash['payment_method'] # 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. Transaction.new(id: id, time_created: time_created, status: status, type: type, amount: amount, tax_amount: tax_amount, currency: currency, gratuity_amount: gratuity_amount, surcharge_amount: surcharge_amount, cashback_amount: cashback_amount, reference: reference, payment_method: payment_method, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/batches/models/transaction.rb', line 75 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['time_created'] = 'time_created' @_hash['status'] = 'status' @_hash['type'] = 'type' @_hash['amount'] = 'amount' @_hash['tax_amount'] = 'tax_amount' @_hash['currency'] = 'currency' @_hash['gratuity_amount'] = 'gratuity_amount' @_hash['surcharge_amount'] = 'surcharge_amount' @_hash['cashback_amount'] = 'cashback_amount' @_hash['reference'] = 'reference' @_hash['payment_method'] = 'payment_method' @_hash end |
.nullables ⇒ Object
An array for nullable fields
111 112 113 |
# File 'lib/batches/models/transaction.rb', line 111 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/batches/models/transaction.rb', line 93 def self.optionals %w[ id time_created status type amount tax_amount currency gratuity_amount surcharge_amount cashback_amount reference payment_method ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
194 195 196 197 198 199 200 201 202 203 |
# File 'lib/batches/models/transaction.rb', line 194 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, time_created: #{@time_created.inspect}, status:"\ " #{@status.inspect}, type: #{@type.inspect}, amount: #{@amount.inspect}, tax_amount:"\ " #{@tax_amount.inspect}, currency: #{@currency.inspect}, gratuity_amount:"\ " #{@gratuity_amount.inspect}, surcharge_amount: #{@surcharge_amount.inspect},"\ " cashback_amount: #{@cashback_amount.inspect}, reference: #{@reference.inspect},"\ " payment_method: #{@payment_method.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
184 185 186 187 188 189 190 191 |
# File 'lib/batches/models/transaction.rb', line 184 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, time_created: #{@time_created}, status: #{@status}, type:"\ " #{@type}, amount: #{@amount}, tax_amount: #{@tax_amount}, currency: #{@currency},"\ " gratuity_amount: #{@gratuity_amount}, surcharge_amount: #{@surcharge_amount},"\ " cashback_amount: #{@cashback_amount}, reference: #{@reference}, payment_method:"\ " #{@payment_method}, additional_properties: #{@additional_properties}>" end |