Sha256: e0cfe9ff54a3a357f20bd0d6e5d2f2a5bd7545911b94b692eed54d45f2639bdf

Contents?: true

Size: 795 Bytes

Versions: 3

Compression:

Stored size: 795 Bytes

Contents

module Spree
  module SolidusSixSaferpay
    class CancelAuthorizedPayment

      attr_reader :saferpay_payment

      def self.call(saferpay_payment)
        new(saferpay_payment).call
      end

      def initialize(saferpay_payment)
        @saferpay_payment = saferpay_payment
      end

      def call
        if transaction_id = saferpay_payment.transaction_id
          gateway.void(saferpay_payment.transaction_id)
        else
          ::SolidusSixSaferpay::ErrorHandler.handle(
            ::SolidusSixSaferpay::InvalidSaferpayPayment.new(
              details: "Can not cancel payment #{saferpay_payment.id} because it has no transaction ID.")
          )
        end
      end

      private

      def gateway
        ::SolidusSixSaferpay::Gateway.new
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_six_saferpay-0.5.0 app/services/spree/solidus_six_saferpay/cancel_authorized_payment.rb
solidus_six_saferpay-0.4.0 app/services/spree/solidus_six_saferpay/cancel_authorized_payment.rb
solidus_six_saferpay-0.3.0 app/services/spree/solidus_six_saferpay/cancel_authorized_payment.rb