Sha256: 070b9a2f722618f590311f7ed9cfb9b5015d1627fdf32c05b0af7156328f5fae

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module SolidusBolt
  module Transactions
    class VoidService < SolidusBolt::Transactions::BaseService
      attr_reader :transaction_reference, :transaction_id

      def initialize(payment_method:, transaction_reference: nil, transaction_id: nil)
        @transaction_reference = transaction_reference
        @transaction_id = transaction_id
        super
      end

      def call
        void
      end

      private

      def void
        options = build_options
        handle_result(
          HTTParty.post(
            "#{api_base_url}/#{api_version}/merchant/transactions/void",
            options
          )
        )
      end

      def build_options
        {
          body: {
            transaction_reference: transaction_reference,
            transaction_id: transaction_id,
          }.to_json,
          headers: {
            'X-Nonce' => generate_nonce,
            'Content-Type' => 'application/json'
          }.merge(authentication_header)
        }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
solidus_bolt-0.7.2 app/services/solidus_bolt/transactions/void_service.rb
solidus_bolt-0.7.1 app/services/solidus_bolt/transactions/void_service.rb
solidus_bolt-0.7.0 app/services/solidus_bolt/transactions/void_service.rb
solidus_bolt-0.6.0 app/services/solidus_bolt/transactions/void_service.rb
solidus_bolt-0.5.0 app/services/solidus_bolt/transactions/void_service.rb
solidus_bolt-0.4.0 app/services/solidus_bolt/transactions/void_service.rb
solidus_bolt-0.3.0 app/services/solidus_bolt/transactions/void_service.rb
solidus_bolt-0.2.0 app/services/solidus_bolt/transactions/void_service.rb
solidus_bolt-0.1.0 app/services/solidus_bolt/transactions/void_service.rb
solidus_bolt-0.0.1 app/services/solidus_bolt/transactions/void_service.rb