Class: Docdata::Order::ExtendedStatusResponse

Inherits:
Response
  • Object
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

Constructor Details

This class inherits a constructor from Docdata::Order::Response

Instance Method Details

#approximate_totalsObject



239
240
241
# File 'lib/docdata/order/response.rb', line 239

def approximate_totals
  report[:approximate_totals]
end

#authorizationObject



204
205
206
# File 'lib/docdata/order/response.rb', line 204

def authorization
  payment[:authorization] if payment
end

#authorization_amountObject



231
232
233
# File 'lib/docdata/order/response.rb', line 231

def authorization_amount
  to_decimal(authorization[:amount]) if authorization
end

#authorization_currencyObject



235
236
237
# File 'lib/docdata/order/response.rb', line 235

def authorization_currency
  authorization[:amount].attributes['currency'] if authorization
end

#authorization_statusObject

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.


227
228
229
# File 'lib/docdata/order/response.rb', line 227

def authorization_status
  authorization[:status] if authorization
end

#cancelled?Boolean

Returns:

  • (Boolean)


300
301
302
# File 'lib/docdata/order/response.rb', line 300

def cancelled?
  authorization_status == 'CANCELED'
end

#charged_back?Boolean

Returns:

  • (Boolean)


287
288
289
# File 'lib/docdata/order/response.rb', line 287

def charged_back?
  total_registered == total_charged_back
end

#consumer_bicObject



315
316
317
318
319
320
321
322
323
324
# File 'lib/docdata/order/response.rb', line 315

def consumer_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

#consumer_ibanObject



304
305
306
307
308
309
310
311
312
313
# File 'lib/docdata/order/response.rb', line 304

def consumer_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

#consumer_nameObject



326
327
328
329
330
331
# File 'lib/docdata/order/response.rb', line 326

def consumer_name
  if payment_method == PaymentMethod::IDEAL
    payment_info = payment[:extended][:i_deal_payment_info]
    payment_info[:holder_name] if payment_info
  end
end

#dataObject



165
166
167
# File 'lib/docdata/order/response.rb', line 165

def data
  body[:extended_status_response]
end

#error?Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/docdata/order/response.rb', line 173

def error?
  data.key?(:status_errors)
end

#errorsObject



177
178
179
# File 'lib/docdata/order/response.rb', line 177

def errors
  data[:status_errors]
end

#exchanged_toObject



243
244
245
# File 'lib/docdata/order/response.rb', line 243

def exchanged_to
  report[:approximate_totals][:@exchanged_to]
end

#mandate_numberObject



333
334
335
336
337
338
# File 'lib/docdata/order/response.rb', line 333

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

Returns:

  • (Boolean)


279
280
281
# File 'lib/docdata/order/response.rb', line 279

def paid?
  (total_registered == total_captured) || (total_registered == total_acquirer_approved)
end

#paymentObject



185
186
187
188
189
190
191
192
193
194
# File 'lib/docdata/order/response.rb', line 185

def payment
  payment = report[:payment]

  # When multiple payments are found, return the payment with the newest ID.
  if payment.is_a?(Array)
    payment.max_by { |key, _value| key[:id] }
  else
    payment
  end
end

#payment_idObject



196
197
198
# File 'lib/docdata/order/response.rb', line 196

def payment_id
  payment[:id] if payment
end

#payment_methodObject



200
201
202
# File 'lib/docdata/order/response.rb', line 200

def payment_method
  payment[:payment_method] if payment
end

#refunded?Boolean

Returns:

  • (Boolean)


283
284
285
# File 'lib/docdata/order/response.rb', line 283

def refunded?
  total_registered == total_refunded
end

#reportObject



181
182
183
# File 'lib/docdata/order/response.rb', line 181

def report
  data[:status_success][:report]
end

#reversed?Boolean

Returns:

  • (Boolean)


291
292
293
# File 'lib/docdata/order/response.rb', line 291

def reversed?
  total_registered == total_reversed
end

#started?Boolean

Returns:

  • (Boolean)


295
296
297
298
# File 'lib/docdata/order/response.rb', line 295

def started?
  (authorization_status == 'NEW' || authorization_status == 'STARTED' ||
    (total_captured.zero? && total_acquirer_approved.zero?)) && authorization_status != 'CANCELED'
end

#success?Boolean

Returns:

  • (Boolean)


169
170
171
# File 'lib/docdata/order/response.rb', line 169

def success?
  data.key?(:status_success)
end

#total_acquirer_approvedObject



259
260
261
# File 'lib/docdata/order/response.rb', line 259

def total_acquirer_approved
  to_decimal(approximate_totals[:total_acquirer_approved])
end

#total_acquirer_pendingObject



255
256
257
# File 'lib/docdata/order/response.rb', line 255

def total_acquirer_pending
  to_decimal(approximate_totals[:total_acquirer_pending])
end

#total_capturedObject



263
264
265
# File 'lib/docdata/order/response.rb', line 263

def total_captured
  to_decimal(approximate_totals[:total_captured])
end

#total_charged_backObject



275
276
277
# File 'lib/docdata/order/response.rb', line 275

def total_charged_back
  to_decimal(approximate_totals[:total_chargedback])
end

#total_refundedObject



267
268
269
# File 'lib/docdata/order/response.rb', line 267

def total_refunded
  to_decimal(approximate_totals[:total_refunded])
end

#total_registeredObject



247
248
249
# File 'lib/docdata/order/response.rb', line 247

def total_registered
  to_decimal(approximate_totals[:total_registered])
end

#total_reversedObject



271
272
273
# File 'lib/docdata/order/response.rb', line 271

def total_reversed
  to_decimal(approximate_totals[:total_reversed])
end

#total_shopper_pendingObject



251
252
253
# File 'lib/docdata/order/response.rb', line 251

def total_shopper_pending
  to_decimal(approximate_totals[:total_shopper_pending])
end