summaryrefslogtreecommitdiff
path: root/lib/solidus_subscriptions/dispatcher/payment_failed_dispatcher.rb
blob: a56332ede75dcc28d0b49b0fb480df8dd63b0bca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module SolidusSubscriptions
  module Dispatcher
    class PaymentFailedDispatcher < Base
      def dispatch
        order.touch(:completed_at)
        order.cancel
        installment.payment_failed!(order)

        ::Spree::Event.fire(
          'solidus_subscriptions.installment_failed_payment',
          installment: installment,
          order: order,
        )
      end
    end
  end
end