Class: Spree::Conekta::PaymentNotificationHandler
- Inherits:
-
Object
- Object
- Spree::Conekta::PaymentNotificationHandler
- Includes:
- Celluloid
- Defined in:
- lib/spree/conekta/payment_notification_handler.rb
Constant Summary collapse
- ACTIONS =
Hash.new(:failure!).merge! 'charge.paid' => :capture!
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#delay ⇒ Object
readonly
Returns the value of attribute delay.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(params, delay = 60) ⇒ PaymentNotificationHandler
constructor
A new instance of PaymentNotificationHandler.
- #perform_action ⇒ Object
Constructor Details
#initialize(params, delay = 60) ⇒ PaymentNotificationHandler
12 13 14 15 16 17 |
# File 'lib/spree/conekta/payment_notification_handler.rb', line 12 def initialize(params, delay = 60) @params = params @delay = delay @action = ACTIONS[params['type']] @order = params['data']['object']['reference_id'].split('-').first end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
8 9 10 |
# File 'lib/spree/conekta/payment_notification_handler.rb', line 8 def action @action end |
#delay ⇒ Object (readonly)
Returns the value of attribute delay.
8 9 10 |
# File 'lib/spree/conekta/payment_notification_handler.rb', line 8 def delay @delay end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
8 9 10 |
# File 'lib/spree/conekta/payment_notification_handler.rb', line 8 def order @order end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/spree/conekta/payment_notification_handler.rb', line 8 def params @params end |
Instance Method Details
#perform_action ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/spree/conekta/payment_notification_handler.rb', line 19 def perform_action after(delay) do ActiveRecord::Base.connection_pool.with_connection do payment.try(action) end end end |