Sha256: 84639acd8da2e47ad571f958acf98e2271937e0bfeeb4d0b126c8e53e910ef6c

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

require "test_helper"

module Workarea
  module Forter
    class GatewayTest < Workarea::TestCase
      include ForterApiConfig

      def gateway
        Workarea::Forter::Gateway.new(
          secret_key: Rails.application.secrets.forter[:secret_key],
          site_id: site_id
        )
      end

      def test_get_decision
        VCR.use_cassette("forter/get_decision", match_requests_on: [:method, :uri]) do
          order = create_placed_forter_order(id: "fortertest1234", email: "approve@forter.com")

          forter_decision = Forter::Decision.find order.id
          response = forter_decision.responses.first
          assert response.decision_response.success?
        end
      end

      def test_update_order_status
         VCR.use_cassette("forter/update_status", match_requests_on: [:method, :uri]) do
          order = create_placed_forter_order(id: "statusfortertest12345", email: "approve@forter.com")

          hsh = Forter::Order.new(order).to_h

          response = gateway.create_decision(order.id, hsh)
          assert(response.success?)


          hsh = {
            orderId: order.id,
            eventTime: Time.new.to_i * 1000,
            updatedStatus: "CANCELED_BY_MERCHANT"
          }

          update_status_response = gateway.update_order_status(order.id, hsh)
          assert(update_status_response.success?)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-forter-1.2.4 test/lib/workarea/forter/gateway_test.rb
workarea-forter-1.2.3 test/lib/workarea/forter/gateway_test.rb
workarea-forter-1.2.2 test/lib/workarea/forter/gateway_test.rb