Class: ThePlaidApi::WalletTransaction

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/wallet_transaction.rb

Overview

The transaction details

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(transaction_id:, wallet_id:, reference:, type:, amount:, counterparty:, status:, created_at:, last_status_update:, scheme: SKIP, payee_verification_status: SKIP, payment_id: SKIP, failure_reason: SKIP, error: SKIP, related_transactions: SKIP, additional_properties: nil) ⇒ WalletTransaction

Returns a new instance of WalletTransaction.



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 186

def initialize(transaction_id:, wallet_id:, reference:, type:, amount:,
               counterparty:, status:, created_at:, last_status_update:,
               scheme: SKIP, payee_verification_status: SKIP,
               payment_id: SKIP, failure_reason: SKIP, error: SKIP,
               related_transactions: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @transaction_id = transaction_id
  @wallet_id = wallet_id
  @reference = reference
  @type = type
  @scheme = scheme unless scheme == SKIP
  @amount = amount
  @counterparty = counterparty
  @status = status
  @created_at = created_at
  @last_status_update = last_status_update
  unless payee_verification_status == SKIP
    @payee_verification_status =
      payee_verification_status
  end
  @payment_id = payment_id unless payment_id == SKIP
  @failure_reason = failure_reason unless failure_reason == SKIP
  @error = error unless error == SKIP
  @related_transactions = related_transactions unless related_transactions == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountWalletTransactionAmount

The amount and currency of a transaction



62
63
64
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 62

def amount
  @amount
end

#counterpartyWalletTransactionCounterparty

An object representing the e-wallet transaction’s counterparty



66
67
68
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 66

def counterparty
  @counterparty
end

#created_atDateTime

Timestamp when the transaction was created, in [ISO 8601](wikipedia.org/wiki/ISO_8601) format.

Returns:

  • (DateTime)


89
90
91
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 89

def created_at
  @created_at
end

#errorError

Errors are identified by ‘error_code` and categorized by `error_type`. Use these in preference to HTTP status codes to identify and handle specific errors. HTTP status codes are set and provide the broadest categorization of errors: 4xx codes are for developer- or user-related errors, and 5xx codes are for Plaid-related errors, and the status will be 2xx in non-error cases. An Item with a non-`null` error object will only be part of an API response when calling `/item/get` to view Item status. Otherwise, error fields will be `null` if no error has occurred; if an error has occurred, an error code will be returned instead.

Returns:



135
136
137
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 135

def error
  @error
end

#failure_reasonWalletTransactionFailureReason

The error code of a failed transaction. Error codes include: ‘EXTERNAL_SYSTEM`: The transaction was declined by an external system. `EXPIRED`: The transaction request has expired. `CANCELLED`: The transaction request was rescinded. `INVALID`: The transaction did not meet certain criteria, such as an inactive account or no valid counterparty, etc. `UNKNOWN`: The transaction was unsuccessful, but the exact cause is unknown.



123
124
125
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 123

def failure_reason
  @failure_reason
end

#last_status_updateDateTime

The date and time of the last time the ‘status` was updated, in IS0 8601 format

Returns:

  • (DateTime)


94
95
96
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 94

def last_status_update
  @last_status_update
end

#payee_verification_statusWalletTransactionPayeeVerificationStatus

Result of payee verification check for EUR payouts. Payee verification checks whether the payee name provided matches the account holder name at the destination institution. ‘FULL_MATCH`: The payee name fully matches the account holder. `PARTIAL_MATCH`: The payee name partially matches the account holder. `NO_MATCH`: The payee name does not match the account holder. `ERROR`: An error occurred during payee verification. `CHECK_NOT_POSSIBLE`: Payee verification could not be performed. This field is only populated for applicable EUR payout transactions and will be `null` for other transaction types.



107
108
109
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 107

def payee_verification_status
  @payee_verification_status
end

#payment_idString

The payment id that this transaction is associated with, if any. This is present only for transaction types ‘PIS_PAY_IN` and `REFUND`.

Returns:

  • (String)


112
113
114
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 112

def payment_id
  @payment_id
end

#referenceString

A reference for the transaction

Returns:

  • (String)


25
26
27
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 25

def reference
  @reference
end

A list of wallet transactions that this transaction is associated with, if any.

Returns:



140
141
142
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 140

def related_transactions
  @related_transactions
end

#schemeWalletPaymentScheme

The payment scheme used to execute this transaction. This is present only for transaction types ‘PAYOUT` and `REFUND`. `FASTER_PAYMENTS`: The standard payment scheme within the UK. `SEPA_CREDIT_TRANSFER`: The standard payment to a beneficiary within the SEPA area. `SEPA_CREDIT_TRANSFER_INSTANT`: Instant payment to a beneficiary within the SEPA area.

Returns:



58
59
60
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 58

def scheme
  @scheme
end

#statusWalletTransactionStatus

The status of the transaction. ‘AUTHORISING`: The transaction is being processed for validation and compliance. `INITIATED`: The transaction has been initiated and is currently being processed. `EXECUTED`: The transaction has been successfully executed and is considered complete. This is only applicable for debit transactions. `SETTLED`: The transaction has settled and funds are available for use. This is only applicable for credit transactions. A transaction will typically settle within seconds to several days, depending on which payment rail is used. `FAILED`: The transaction failed to process successfully. This is a terminal status. `BLOCKED`: The transaction has been blocked for violating compliance rules. This is a terminal status.



84
85
86
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 84

def status
  @status
end

#transaction_idString

A unique ID identifying the transaction

Returns:

  • (String)


15
16
17
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 15

def transaction_id
  @transaction_id
end

#typeType5

The type of the transaction. The supported transaction types that are returned are: ‘BANK_TRANSFER:` a transaction which credits an e-wallet through an external bank transfer. `PAYOUT:` a transaction which debits an e-wallet by disbursing funds to a counterparty. `PIS_PAY_IN:` a payment which credits an e-wallet through Plaid’s Payment Initiation Services (PIS) APIs. For more information see the [Payment Initiation endpoints](plaid.com/docs/api/products/payment-initiation/). ‘REFUND:` a transaction which debits an e-wallet by refunding a previously initiated payment made through Plaid’s [PIS APIs](plaid.com/docs/api/products/payment-initiation/). ‘FUNDS_SWEEP`: an automated transaction which debits funds from an e-wallet to a designated client-owned account. `RETURN`: an automated transaction where a debit transaction was reversed and money moved back to originating account. `RECALL`: a transaction where the sending bank has requested the return of funds due to a fraud claim, technical error, or other issue associated with the payment.

Returns:



48
49
50
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 48

def type
  @type
end

#wallet_idString

The EMI (E-Money Institution) wallet that this payment is associated with, if any. This wallet is used as an intermediary account to enable Plaid to reconcile the settlement of funds for Payment Initiation requests.

Returns:

  • (String)


21
22
23
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 21

def wallet_id
  @wallet_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 216

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  transaction_id =
    hash.key?('transaction_id') ? hash['transaction_id'] : nil
  wallet_id = hash.key?('wallet_id') ? hash['wallet_id'] : nil
  reference = hash.key?('reference') ? hash['reference'] : nil
  type = hash.key?('type') ? hash['type'] : nil
  amount = WalletTransactionAmount.from_hash(hash['amount']) if hash['amount']
  counterparty = WalletTransactionCounterparty.from_hash(hash['counterparty']) if
    hash['counterparty']
  status = hash.key?('status') ? hash['status'] : nil
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               end
  last_status_update = if hash.key?('last_status_update')
                         (DateTimeHelper.from_rfc3339(hash['last_status_update']) if hash['last_status_update'])
                       end
  scheme = hash.key?('scheme') ? hash['scheme'] : SKIP
  payee_verification_status =
    hash.key?('payee_verification_status') ? hash['payee_verification_status'] : SKIP
  payment_id = hash.key?('payment_id') ? hash['payment_id'] : SKIP
  failure_reason =
    hash.key?('failure_reason') ? hash['failure_reason'] : SKIP
  error = Error.from_hash(hash['error']) if hash['error']
  # Parameter is an array, so we need to iterate through it
  related_transactions = nil
  unless hash['related_transactions'].nil?
    related_transactions = []
    hash['related_transactions'].each do |structure|
      related_transactions << (WalletTransactionRelation.from_hash(structure) if structure)
    end
  end

  related_transactions = SKIP unless hash.key?('related_transactions')

  # 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.
  WalletTransaction.new(transaction_id: transaction_id,
                        wallet_id: wallet_id,
                        reference: reference,
                        type: type,
                        amount: amount,
                        counterparty: counterparty,
                        status: status,
                        created_at: created_at,
                        last_status_update: last_status_update,
                        scheme: scheme,
                        payee_verification_status: payee_verification_status,
                        payment_id: payment_id,
                        failure_reason: failure_reason,
                        error: error,
                        related_transactions: related_transactions,
                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 143

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['transaction_id'] = 'transaction_id'
  @_hash['wallet_id'] = 'wallet_id'
  @_hash['reference'] = 'reference'
  @_hash['type'] = 'type'
  @_hash['scheme'] = 'scheme'
  @_hash['amount'] = 'amount'
  @_hash['counterparty'] = 'counterparty'
  @_hash['status'] = 'status'
  @_hash['created_at'] = 'created_at'
  @_hash['last_status_update'] = 'last_status_update'
  @_hash['payee_verification_status'] = 'payee_verification_status'
  @_hash['payment_id'] = 'payment_id'
  @_hash['failure_reason'] = 'failure_reason'
  @_hash['error'] = 'error'
  @_hash['related_transactions'] = 'related_transactions'
  @_hash
end

.nullablesObject

An array for nullable fields



176
177
178
179
180
181
182
183
184
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 176

def self.nullables
  %w[
    scheme
    payee_verification_status
    payment_id
    failure_reason
    error
  ]
end

.optionalsObject

An array for optional fields



164
165
166
167
168
169
170
171
172
173
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 164

def self.optionals
  %w[
    scheme
    payee_verification_status
    payment_id
    failure_reason
    error
    related_transactions
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



300
301
302
303
304
305
306
307
308
309
310
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 300

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} transaction_id: #{@transaction_id.inspect}, wallet_id:"\
  " #{@wallet_id.inspect}, reference: #{@reference.inspect}, type: #{@type.inspect}, scheme:"\
  " #{@scheme.inspect}, amount: #{@amount.inspect}, counterparty: #{@counterparty.inspect},"\
  " status: #{@status.inspect}, created_at: #{@created_at.inspect}, last_status_update:"\
  " #{@last_status_update.inspect}, payee_verification_status:"\
  " #{@payee_verification_status.inspect}, payment_id: #{@payment_id.inspect}, failure_reason:"\
  " #{@failure_reason.inspect}, error: #{@error.inspect}, related_transactions:"\
  " #{@related_transactions.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_created_atObject



279
280
281
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 279

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_last_status_updateObject



283
284
285
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 283

def to_custom_last_status_update
  DateTimeHelper.to_rfc3339(last_status_update)
end

#to_sObject

Provides a human-readable string representation of the object.



288
289
290
291
292
293
294
295
296
297
# File 'lib/the_plaid_api/models/wallet_transaction.rb', line 288

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} transaction_id: #{@transaction_id}, wallet_id: #{@wallet_id}, reference:"\
  " #{@reference}, type: #{@type}, scheme: #{@scheme}, amount: #{@amount}, counterparty:"\
  " #{@counterparty}, status: #{@status}, created_at: #{@created_at}, last_status_update:"\
  " #{@last_status_update}, payee_verification_status: #{@payee_verification_status},"\
  " payment_id: #{@payment_id}, failure_reason: #{@failure_reason}, error: #{@error},"\
  " related_transactions: #{@related_transactions}, additional_properties:"\
  " #{@additional_properties}>"
end