Class: Adyen::API::PaymentService::BilletResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/adyen/api/payment_service.rb

Constant Summary collapse

RECEIVED =
"Received"

Instance Attribute Summary

Attributes inherited from Response

#http_response

Instance Method Summary collapse

Methods inherited from Response

#body, #fault_message, #http_failure?, #initialize, response_attrs, #server_error?, #xml_querier

Constructor Details

This class inherits a constructor from Adyen::API::Response

Instance Method Details

#invalid_request?Boolean

Returns:

  • (Boolean)


264
265
266
# File 'lib/adyen/api/payment_service.rb', line 264

def invalid_request?
  !fault_message.nil?
end

#paramsObject



240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/adyen/api/payment_service.rb', line 240

def params
  @params ||= xml_querier.xpath('//payment:authoriseResponse/payment:paymentResult') do |result|
    result_code = result.text('./payment:resultCode')
    attributes = Hash.new('')

    if result_code == RECEIVED
      attributes = result.children[0].children.map do |child|
        { child.children[0].text => child.children[1].text }
      end
      attributes = attributes.reduce({}, :merge)
    end

    {
      :psp_reference   => result.text('./payment:pspReference'),
      :result_code     => result_code,
      :billet_url      => attributes['boletobancario.url'],
      :barcode         => attributes['boletobancario.barCodeReference'],
      :due_date        => convert_to_date(attributes['boletobancario.dueDate']),
      :expiration_date => convert_to_date(attributes['boletobancario.expirationDate']),
      :refusal_reason => (invalid_request? ? fault_message : result.text('./payment:refusalReason'))
    }
  end
end

#success?Boolean

Returns:

  • (Boolean)


236
237
238
# File 'lib/adyen/api/payment_service.rb', line 236

def success?
  super && params[:result_code] == RECEIVED
end