Class: PuntoPagos::Verification
- Inherits:
-
Object
- Object
- PuntoPagos::Verification
- Defined in:
- lib/puntopagos/verification.rb
Overview
Public: This class manage the signing of a message using the secret and api-key defined in puntopagos.yml
Instance Method Summary collapse
- #error ⇒ Object
-
#initialize(env = nil) ⇒ Verification
constructor
A new instance of Verification.
- #valid?(response) ⇒ Boolean
-
#verify(token, trx_id, amount) ⇒ Object
Public: Signs a string using the secret and api-key defined in puntopagos.yml.
Constructor Details
#initialize(env = nil) ⇒ Verification
Returns a new instance of Verification.
6 7 8 9 10 11 12 |
# File 'lib/puntopagos/verification.rb', line 6 def initialize env = nil @env = env @@config ||= PuntoPagos::Config.new(env) @@function = "transaccion/traer" @@path = "transaccion" @response = {} end |
Instance Method Details
#error ⇒ Object
37 38 39 |
# File 'lib/puntopagos/verification.rb', line 37 def error @response end |
#valid?(response) ⇒ Boolean
33 34 35 |
# File 'lib/puntopagos/verification.rb', line 33 def valid? response response["respuesta"] == "00" end |
#verify(token, trx_id, amount) ⇒ Object
Public: Signs a string using the secret and api-key defined in puntopagos.yml
string - The String to be signed Returns the signed String.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/puntopagos/verification.rb', line 18 def verify token, trx_id, amount executioner = PuntoPagos::Executioner.new(@env) = = token, trx_id, amount, = PuntoPagos::Authorization.new(@env) signature = .sign() puts "SIGNATURE: #{signature} TIMESTAMP: #{} TOKEN: #{token} TRX: #{trx_id}" puts "MESSAGE: #{}" @response = executioner.call_api(token, @@path, :get, signature, ) valid?(@response) end |