Class: Plaid::PaymentInitiationPaymentGetResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/plaid/models/payment_initiation_payment_get_response.rb

Overview

PaymentInitiationPaymentGetResponse defines the response schema for ‘/payment_initation/payment/get`

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(payment_id:, amount:, status:, recipient_id:, reference:, last_status_update:, bacs:, iban:, request_id:, adjusted_reference: SKIP, schedule: SKIP, refund_details: SKIP, initiated_refunds: SKIP, emi_account_id: SKIP, additional_properties: nil) ⇒ PaymentInitiationPaymentGetResponse

Returns a new instance of PaymentInitiationPaymentGetResponse.



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 142

def initialize(payment_id:, amount:, status:, recipient_id:, reference:,
               last_status_update:, bacs:, iban:, request_id:,
               adjusted_reference: SKIP, schedule: SKIP,
               refund_details: SKIP, initiated_refunds: SKIP,
               emi_account_id: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @payment_id = payment_id
  @amount = amount
  @status = status
  @recipient_id = recipient_id
  @reference = reference
  @adjusted_reference = adjusted_reference unless adjusted_reference == SKIP
  @last_status_update = last_status_update
  @schedule = schedule unless schedule == SKIP
  @refund_details = refund_details unless refund_details == SKIP
  @bacs = bacs
  @iban = iban
  @initiated_refunds = initiated_refunds unless initiated_refunds == SKIP
  @emi_account_id =  unless  == SKIP
  @request_id = request_id
  @additional_properties = additional_properties
end

Instance Attribute Details

#adjusted_referenceString

The value of the reference sent to the bank after adjustment to pass bank validation rules.

Returns:

  • (String)


55
56
57
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 55

def adjusted_reference
  @adjusted_reference
end

#amountPaymentAmount

The amount and currency of a payment

Returns:



21
22
23
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 21

def amount
  @amount
end

#bacsSenderBacsNullable

The schedule that the payment will be executed on. If a schedule is provided, the payment is automatically set up as a standing order. If no schedule is specified, the payment will be executed only once.

Returns:



78
79
80
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 78

def bacs
  @bacs
end

#emi_account_idString

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

Returns:

  • (String)


94
95
96
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 94

def 
  @emi_account_id
end

#ibanString

The International Bank Account Number (IBAN) for the sender, if specified in the ‘/payment_initiation/payment/create` call.

Returns:

  • (String)


83
84
85
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 83

def iban
  @iban
end

#initiated_refundsArray[PaymentInitiationRefund]

Initiated refunds associated with the payment.

Returns:



87
88
89
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 87

def initiated_refunds
  @initiated_refunds
end

#last_status_updateDateTime

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

Returns:

  • (DateTime)


60
61
62
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 60

def last_status_update
  @last_status_update
end

#payment_idString

The ID of the payment. Like all Plaid identifiers, the ‘payment_id` is case sensitive.

Returns:

  • (String)


17
18
19
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 17

def payment_id
  @payment_id
end

#recipient_idString

The ID of the recipient

Returns:

  • (String)


46
47
48
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 46

def recipient_id
  @recipient_id
end

#referenceString

A reference for the payment.

Returns:

  • (String)


50
51
52
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 50

def reference
  @reference
end

#refund_detailsExternalPaymentRefundDetails

The schedule that the payment will be executed on. If a schedule is provided, the payment is automatically set up as a standing order. If no schedule is specified, the payment will be executed only once.



72
73
74
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 72

def refund_details
  @refund_details
end

#request_idString

A unique identifier for the request, which can be used for troubleshooting. This identifier, like all Plaid identifiers, is case sensitive.

Returns:

  • (String)


100
101
102
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 100

def request_id
  @request_id
end

#scheduleExternalPaymentScheduleGet

The schedule that the payment will be executed on. If a schedule is provided, the payment is automatically set up as a standing order. If no schedule is specified, the payment will be executed only once.



66
67
68
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 66

def schedule
  @schedule
end

#statusStatus3

The status of the payment. ‘PAYMENT_STATUS_INPUT_NEEDED`: This is the initial state of all payments. It indicates that the payment is waiting on user input to continue processing. A payment may re-enter this state later on if further input is needed. `PAYMENT_STATUS_PROCESSING`: The payment is currently being processed. The payment will automatically exit this state when processing is complete. `PAYMENT_STATUS_INITIATED`: The payment has been successfully initiated and is considered complete. `PAYMENT_STATUS_COMPLETED`: Indicates that the standing order has been successfully established. This state is only used for standing orders. `PAYMENT_STATUS_INSUFFICIENT_FUNDS`: The payment has failed due to insufficient funds. `PAYMENT_STATUS_FAILED`: The payment has failed to be initiated. This error is retryable once the root cause is resolved. `PAYMENT_STATUS_BLOCKED`: The payment has been blocked. This is a retryable error. `PAYMENT_STATUS_UNKNOWN`: The payment status is unknown.

Returns:



42
43
44
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 42

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
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
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 168

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  payment_id = hash.key?('payment_id') ? hash['payment_id'] : nil
  amount = PaymentAmount.from_hash(hash['amount']) if hash['amount']
  status = hash.key?('status') ? hash['status'] : nil
  recipient_id = hash.key?('recipient_id') ? hash['recipient_id'] : nil
  reference = hash.key?('reference') ? hash['reference'] : nil
  last_status_update = if hash.key?('last_status_update')
                         (DateTimeHelper.from_rfc3339(hash['last_status_update']) if hash['last_status_update'])
                       end
  bacs = SenderBacsNullable.from_hash(hash['bacs']) if hash['bacs']
  iban = hash.key?('iban') ? hash['iban'] : nil
  request_id = hash.key?('request_id') ? hash['request_id'] : nil
  adjusted_reference =
    hash.key?('adjusted_reference') ? hash['adjusted_reference'] : SKIP
  schedule = ExternalPaymentScheduleGet.from_hash(hash['schedule']) if hash['schedule']
  refund_details = ExternalPaymentRefundDetails.from_hash(hash['refund_details']) if
    hash['refund_details']
  # Parameter is an array, so we need to iterate through it
  initiated_refunds = nil
  unless hash['initiated_refunds'].nil?
    initiated_refunds = []
    hash['initiated_refunds'].each do |structure|
      initiated_refunds << (PaymentInitiationRefund.from_hash(structure) if structure)
    end
  end

  initiated_refunds = SKIP unless hash.key?('initiated_refunds')
   =
    hash.key?('emi_account_id') ? hash['emi_account_id'] : 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.
  PaymentInitiationPaymentGetResponse.new(payment_id: payment_id,
                                          amount: amount,
                                          status: status,
                                          recipient_id: recipient_id,
                                          reference: reference,
                                          last_status_update: last_status_update,
                                          bacs: bacs,
                                          iban: iban,
                                          request_id: request_id,
                                          adjusted_reference: adjusted_reference,
                                          schedule: schedule,
                                          refund_details: refund_details,
                                          initiated_refunds: initiated_refunds,
                                          emi_account_id: ,
                                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 103

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['payment_id'] = 'payment_id'
  @_hash['amount'] = 'amount'
  @_hash['status'] = 'status'
  @_hash['recipient_id'] = 'recipient_id'
  @_hash['reference'] = 'reference'
  @_hash['adjusted_reference'] = 'adjusted_reference'
  @_hash['last_status_update'] = 'last_status_update'
  @_hash['schedule'] = 'schedule'
  @_hash['refund_details'] = 'refund_details'
  @_hash['bacs'] = 'bacs'
  @_hash['iban'] = 'iban'
  @_hash['initiated_refunds'] = 'initiated_refunds'
  @_hash['emi_account_id'] = 'emi_account_id'
  @_hash['request_id'] = 'request_id'
  @_hash
end

.nullablesObject

An array for nullable fields



134
135
136
137
138
139
140
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 134

def self.nullables
  %w[
    adjusted_reference
    iban
    emi_account_id
  ]
end

.optionalsObject

An array for optional fields



123
124
125
126
127
128
129
130
131
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 123

def self.optionals
  %w[
    adjusted_reference
    schedule
    refund_details
    initiated_refunds
    emi_account_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



242
243
244
245
246
247
248
249
250
251
252
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 242

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} payment_id: #{@payment_id.inspect}, amount: #{@amount.inspect}, status:"\
  " #{@status.inspect}, recipient_id: #{@recipient_id.inspect}, reference:"\
  " #{@reference.inspect}, adjusted_reference: #{@adjusted_reference.inspect},"\
  " last_status_update: #{@last_status_update.inspect}, schedule: #{@schedule.inspect},"\
  " refund_details: #{@refund_details.inspect}, bacs: #{@bacs.inspect}, iban:"\
  " #{@iban.inspect}, initiated_refunds: #{@initiated_refunds.inspect}, emi_account_id:"\
  " #{@emi_account_id.inspect}, request_id: #{@request_id.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_last_status_updateObject



226
227
228
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 226

def to_custom_last_status_update
  DateTimeHelper.to_rfc3339(last_status_update)
end

#to_sObject

Provides a human-readable string representation of the object.



231
232
233
234
235
236
237
238
239
# File 'lib/plaid/models/payment_initiation_payment_get_response.rb', line 231

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} payment_id: #{@payment_id}, amount: #{@amount}, status: #{@status},"\
  " recipient_id: #{@recipient_id}, reference: #{@reference}, adjusted_reference:"\
  " #{@adjusted_reference}, last_status_update: #{@last_status_update}, schedule:"\
  " #{@schedule}, refund_details: #{@refund_details}, bacs: #{@bacs}, iban: #{@iban},"\
  " initiated_refunds: #{@initiated_refunds}, emi_account_id: #{@emi_account_id}, request_id:"\
  " #{@request_id}, additional_properties: #{@additional_properties}>"
end