Method: WebpayComplete#acknowledgeTransaction

Defined in:
lib/webpaycomplete.rb

#acknowledgeTransaction(token) ⇒ Object



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/webpaycomplete.rb', line 287

def acknowledgeTransaction(token)
  acknowledgeInput ={
      "tokenInput" => token
  }

  #Preparacion firma

  req = @client.build_request(:acknowledge_complete_transaction, message: acknowledgeInput)

  #Se firma el body de la peticion

  document = sign_xml(req)

  #Se realiza el acknowledge_transaction

  begin
    puts "Iniciando acknowledge_transaction..."
    response = @client.call(:acknowledge_complete_transaction, message: acknowledgeInput) do
      xml document.to_xml(:save_with => 0)
    end

  rescue Exception, RuntimeError => e
    puts "Ocurrio un error en la llamada a Webpay: "+e.message
    response_array ={
        "error_desc" => "Ocurrio un error en la llamada a Webpay: "+e.message
    }
    return response_array
  end

  #Se revisa que respuesta no sea nula.

  if response
    puts 'Respuesta acknowledge_transaction: '+ response.to_s
  else
    puts 'Webservice Webpay responde con null'
    response_array ={
        "error_desc" => 'Webservice Webpay responde con null'
    }
    return response_array
  end

  #Verificacion de certificado respuesta

  tbk_cert = OpenSSL::X509::Certificate.new(@webpay_cert)

  if !Verifier.verify(response, tbk_cert)
    response_array ={
        "error_desc" => 'El Certificado de respuesta es Invalido'
    }
    return response_array
  else
    puts "El Certificado de respuesta es Valido."
  end

  response_array ={
      "error_desc"        => 'TRX_OK'
  }

  return response_array
end