Class: PuntoPagos::Notification
- Inherits:
-
Object
- Object
- PuntoPagos::Notification
- Defined in:
- lib/puntopagos/notification.rb
Overview
Public: Manages the notification process.
Instance Method Summary collapse
- #error ⇒ Object
-
#initialize(env = nil) ⇒ Notification
constructor
A new instance of Notification.
-
#valid?(headers, params) ⇒ Boolean
Public: Validates the message sent by PuntoPagos in the notification process.
Constructor Details
#initialize(env = nil) ⇒ Notification
Returns a new instance of Notification.
4 5 6 7 8 9 |
# File 'lib/puntopagos/notification.rb', line 4 def initialize env = nil @env = env @@config ||= PuntoPagos::Config.new(@env) @@function = "transaccion/notificacion" @verification = nil end |
Instance Method Details
#error ⇒ Object
31 32 33 |
# File 'lib/puntopagos/notification.rb', line 31 def error @verification.error end |
#valid?(headers, params) ⇒ Boolean
Public: Validates the message sent by PuntoPagos in the notification process.
headers - The headers of the request as a Hash. params - The params Hash.
Returns true or false.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/puntopagos/notification.rb', line 18 def valid? headers, params = headers = params["token"], params["trx_id"], params["monto"].to_s, = Authorization.new(@env) signature = .sign() Rails.logger.info "Generated Message: #{}" Rails.logger.info "Generated Signature #{signature}" @verification = PuntoPagos::Verification.new(@env) (signature == pp_signature(headers)) and (@verification.verify(params["token"], params["trx_id"], params["monto"].to_i.to_s + ".00")) end |