Sha256: 97c7a410e4d684e0a78e2ebedc67fc5b3dae9a97295ca289d80d518b2fea0fa8

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 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 = order.fraud_decision
          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.3.2 test/lib/workarea/forter/gateway_test.rb
workarea-forter-1.3.1 test/lib/workarea/forter/gateway_test.rb
workarea-forter-1.3.0 test/lib/workarea/forter/gateway_test.rb