Class: Docdata::Order::ExtendedStatusResponse
- Inherits:
-
Response
- Object
- Response
- Docdata::Order::ExtendedStatusResponse
show all
- Defined in:
- lib/docdata/order/response.rb
Overview
Response to a extended status operation.
Instance Attribute Summary
Attributes inherited from Response
#options, #response
Instance Method Summary
collapse
Methods inherited from Response
#body, #error_code, #error_message, #initialize
Instance Method Details
#account_bic ⇒ Object
294
295
296
297
298
299
300
301
302
303
|
# File 'lib/docdata/order/response.rb', line 294
def account_bic
case payment_method
when PaymentMethod::IDEAL
payment_info = payment[:extended][:i_deal_payment_info]
payment_info[:shopper_bank_account][:bic] if payment_info && payment_info[:shopper_bank_account]
when PaymentMethod::SEPA_DIRECT_DEBIT
payment_info = payment[:extended][:sepa_direct_debit_payment_info]
payment_info[:bic] if payment_info
end
end
|
#account_iban ⇒ Object
283
284
285
286
287
288
289
290
291
292
|
# File 'lib/docdata/order/response.rb', line 283
def account_iban
case payment_method
when PaymentMethod::IDEAL
payment_info = payment[:extended][:i_deal_payment_info]
payment_info[:shopper_bank_account][:iban] if payment_info && payment_info[:shopper_bank_account]
when PaymentMethod::SEPA_DIRECT_DEBIT
payment_info = payment[:extended][:sepa_direct_debit_payment_info]
payment_info[:iban] if payment_info
end
end
|
#account_name ⇒ Object
305
306
307
308
309
310
|
# File 'lib/docdata/order/response.rb', line 305
def account_name
if payment_method == PaymentMethod::IDEAL
payment_info = payment[:extended][:i_deal_payment_info]
payment_info[:holder_name] if payment_info
end
end
|
#approximate_totals ⇒ Object
222
223
224
|
# File 'lib/docdata/order/response.rb', line 222
def approximate_totals
report[:approximate_totals]
end
|
#authorization ⇒ Object
195
196
197
|
# File 'lib/docdata/order/response.rb', line 195
def authorization
payment[:authorization] if payment
end
|
#authorization_status ⇒ Object
The state of the authorization. Current known values:
NEW This is a new payment without any actions performed on it yet.
RISK_CHECK_OK For this payment the risk check was okay.
RISK_CHECK_FAILED The risk check for this payment triggered.
STARTED The user has provided details and is authenticated.
START_ERROR The payment system could not start the payment due to a technical error.
AUTHENTICATED The shopper is authenticated by the acquirer.
REDIRECTED_FOR_AUTHENTICATION The shopper is redirected to the acquirer web-site for authentication.
AUTHENTICATION_FAILED The shopper is not authenticated by the acquirer.
AUTHENTICATION_ERROR Unable to do the authentication of the shopper by the acquirer.
AUTHORIZED This payment is authorized.
REDIRECTED_FOR_AUTHORIZATION The shopper is redirected to the acquirer web-site for authorization.
AUTHORIZATION_REQUESTED Requested authorization for this payment, waiting for a notification from acquirer.
AUTHORIZATION_FAILED The payment was not authorized due to a functional error.
AUTHORIZATION_ERROR Unable to do the payment authorization due to a technical error.
CANCELED The payment is canceled.
CANCEL_FAILED Payment is not canceled, due to functional error.
CANCEL_ERROR Payment is not canceled, due to technical error.
CANCEL_REQUESTED A cancel request sent to acquirer.
218
219
220
|
# File 'lib/docdata/order/response.rb', line 218
def authorization_status
authorization[:status] if authorization
end
|
#cancelled? ⇒ Boolean
279
280
281
|
# File 'lib/docdata/order/response.rb', line 279
def cancelled?
authorization_status == "CANCELED"
end
|
#charged_back? ⇒ Boolean
266
267
268
|
# File 'lib/docdata/order/response.rb', line 266
def charged_back?
total_registered == total_charged_back
end
|
#data ⇒ Object
156
157
158
|
# File 'lib/docdata/order/response.rb', line 156
def data
body[:extended_status_response]
end
|
#error? ⇒ Boolean
164
165
166
|
# File 'lib/docdata/order/response.rb', line 164
def error?
data.key?(:status_errors)
end
|
#errors ⇒ Object
168
169
170
|
# File 'lib/docdata/order/response.rb', line 168
def errors
data[:status_errors]
end
|
#mandate_number ⇒ Object
312
313
314
315
316
317
|
# File 'lib/docdata/order/response.rb', line 312
def mandate_number
if payment_method == PaymentMethod::SEPA_DIRECT_DEBIT
payment_info = payment[:extended][:sepa_direct_debit_payment_info]
payment_info[:mandate_number] if payment_info
end
end
|
#paid? ⇒ Boolean
258
259
260
|
# File 'lib/docdata/order/response.rb', line 258
def paid?
(total_registered == total_captured) || (total_registered == total_acquirer_approved)
end
|
#payment ⇒ Object
176
177
178
179
180
181
182
183
184
185
|
# File 'lib/docdata/order/response.rb', line 176
def payment
payment = report[:payment]
if payment.is_a?(Array)
payment.max_by { |key, _value| key[:id] }
else
payment
end
end
|
#payment_id ⇒ Object
187
188
189
|
# File 'lib/docdata/order/response.rb', line 187
def payment_id
payment[:id] if payment
end
|
#payment_method ⇒ Object
191
192
193
|
# File 'lib/docdata/order/response.rb', line 191
def payment_method
payment[:payment_method] if payment
end
|
#refunded? ⇒ Boolean
262
263
264
|
# File 'lib/docdata/order/response.rb', line 262
def refunded?
total_registered == total_refunded
end
|
#report ⇒ Object
172
173
174
|
# File 'lib/docdata/order/response.rb', line 172
def report
data[:status_success][:report]
end
|
#reversed? ⇒ Boolean
270
271
272
|
# File 'lib/docdata/order/response.rb', line 270
def reversed?
total_registered == total_reversed
end
|
#started? ⇒ Boolean
274
275
276
277
|
# File 'lib/docdata/order/response.rb', line 274
def started?
(authorization_status == "NEW" || authorization_status == "STARTED" ||
(total_captured.zero? && total_acquirer_approved.zero?)) && authorization_status != "CANCELED"
end
|
#success? ⇒ Boolean
160
161
162
|
# File 'lib/docdata/order/response.rb', line 160
def success?
data.key?(:status_success)
end
|
#total_acquirer_approved ⇒ Object
238
239
240
|
# File 'lib/docdata/order/response.rb', line 238
def total_acquirer_approved
to_decimal(approximate_totals[:total_acquirer_approved])
end
|
#total_acquirer_pending ⇒ Object
234
235
236
|
# File 'lib/docdata/order/response.rb', line 234
def total_acquirer_pending
to_decimal(approximate_totals[:total_acquirer_pending])
end
|
#total_captured ⇒ Object
242
243
244
|
# File 'lib/docdata/order/response.rb', line 242
def total_captured
to_decimal(approximate_totals[:total_captured])
end
|
#total_charged_back ⇒ Object
254
255
256
|
# File 'lib/docdata/order/response.rb', line 254
def total_charged_back
to_decimal(approximate_totals[:total_chargedback])
end
|
#total_refunded ⇒ Object
246
247
248
|
# File 'lib/docdata/order/response.rb', line 246
def total_refunded
to_decimal(approximate_totals[:total_refunded])
end
|
#total_registered ⇒ Object
226
227
228
|
# File 'lib/docdata/order/response.rb', line 226
def total_registered
to_decimal(approximate_totals[:total_registered])
end
|
#total_reversed ⇒ Object
250
251
252
|
# File 'lib/docdata/order/response.rb', line 250
def total_reversed
to_decimal(approximate_totals[:total_reversed])
end
|
#total_shopper_pending ⇒ Object
230
231
232
|
# File 'lib/docdata/order/response.rb', line 230
def total_shopper_pending
to_decimal(approximate_totals[:total_shopper_pending])
end
|