Skip to content

Commit

Permalink
Hooks has been deprecated in favor of subscribing to order_recalculate
Browse files Browse the repository at this point in the history
Please see PR #[3553](solidusio/solidus#3553) for more information concerning this change.
  • Loading branch information
cpfergus1 committed Jun 24, 2021
1 parent 9282580 commit 6c631d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ module Spree
module OrderDecorator
KLARNA_SESSION_LIFETIME = 48.hours

def self.prepended(base)
base.class_eval do
register_update_hook(:update_klarna_shipments)
register_update_hook(:update_klarna_customer)
end
end

def update_klarna_session(session_id: nil, client_token: nil)
update!(
klarna_session_id: session_id,
Expand Down
20 changes: 20 additions & 0 deletions app/subscribers/solidus_klarna_payments/klarna_subscriber.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module SolidusKlarnaPayments
module KlarnaSubscriber
include ::Spree::Event::Subscriber

event_action :update_klarna_shipments, event_name: :order_recalulated
event_action :update_klarna_customer, event_name: :order_recalulated

def update_klarna_shipments
order = event.payload[:order]
order.update_klarna_shipments
end

def update_klarna_customer
order = event.payload[:order]
order.update_klarna_customer
end
end
end

0 comments on commit 6c631d3

Please sign in to comment.