Sha256: bec0209260cc8134c2e1447e6a9303bb2f473e87b6fd97bd4e9c3853c4473a40

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

module Braintree
  class TestingGateway

    def initialize(gateway)
      @gateway = gateway
      @config = gateway.config
      @config.assert_has_access_token_or_keys
      @transaction_gateway = TransactionGateway.new(gateway)
    end

    def settle(transaction_id)
      check_environment

      response = @config.http.put("#{@config.base_merchant_path}/transactions/#{transaction_id}/settle")
      @transaction_gateway._handle_transaction_response(response)
    end

    def settlement_confirm(transaction_id)
      check_environment

      response = @config.http.put("#{@config.base_merchant_path}/transactions/#{transaction_id}/settlement_confirm")
      @transaction_gateway._handle_transaction_response(response)
    end

    def settlement_decline(transaction_id)
      check_environment

      response = @config.http.put("#{@config.base_merchant_path}/transactions/#{transaction_id}/settlement_decline")
      @transaction_gateway._handle_transaction_response(response)
    end

    def settlement_pending(transaction_id)
      check_environment

      response = @config.http.put("#{@config.base_merchant_path}/transactions/#{transaction_id}/settlement_pending")
      @transaction_gateway._handle_transaction_response(response)
    end

    def check_environment
      raise TestOperationPerformedInProduction if @config.environment == :production
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
braintree-4.23.0 lib/braintree/testing_gateway.rb
braintree-4.22.0 lib/braintree/testing_gateway.rb
braintree-4.21.0 lib/braintree/testing_gateway.rb
braintree-4.20.0 lib/braintree/testing_gateway.rb
braintree-4.19.0 lib/braintree/testing_gateway.rb
braintree-4.18.0 lib/braintree/testing_gateway.rb
braintree-4.17.0 lib/braintree/testing_gateway.rb
braintree-4.16.0 lib/braintree/testing_gateway.rb