Class: PuntoPagos::Notification
- Inherits:
-
Object
- Object
- PuntoPagos::Notification
- Defined in:
- lib/puntopagos/notification.rb
Overview
Public: Manages the notification process.
Instance Method Summary collapse
-
#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 |
# File 'lib/puntopagos/notification.rb', line 4 def initialize env = nil @env = env @@config ||= PuntoPagos::Config.new(@env) @@function = "transaccion/notificacion" end |
Instance Method Details
#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.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/puntopagos/notification.rb', line 17 def valid? headers, params = headers = params["token"], params["trx_id"], params["monto"].to_s, = Authorization.new(@env) signature = .sign() 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 |