Sha256: a14c0377ea5595da15fc36a1888676d1390d77c8d255e186da89085526f55589

Contents?: true

Size: 1.19 KB

Versions: 35

Compression:

Stored size: 1.19 KB

Contents

module Braintree
  class MerchantGateway
    def initialize(gateway)
      @gateway = gateway
      @config = gateway.config
    end

    def provision_raw_apple_pay
      response = @config.http.put("#{@config.base_merchant_path}/provision_raw_apple_pay")
      if response[:apple_pay]
        SuccessfulResult.new(response[:apple_pay])
      elsif response[:api_error_response]
        ErrorResult.new(@gateway, response[:api_error_response])
      else
        raise UnexpectedError, "expected :apple_pay or :api_error_response"
      end
    end

    def create(params)
      _create_merchant(params)
    end

    def _create_merchant(params)
      response = @config.http.post("/merchants/create_via_api", :merchant => params)

      if response.has_key?(:response) && response[:response][:merchant]
        Braintree::SuccessfulResult.new(
          :merchant => Merchant._new(@gateway, response[:response][:merchant]),
          :credentials => OAuthCredentials._new(response[:response][:credentials])
        )
      elsif response[:api_error_response]
        ErrorResult.new(@gateway, response[:api_error_response])
      else
        raise "expected :merchant or :api_error_response"
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
braintree-3.3.0 lib/braintree/merchant_gateway.rb
braintree-3.2.0 lib/braintree/merchant_gateway.rb
braintree-3.1.0 lib/braintree/merchant_gateway.rb
braintree-3.0.1 lib/braintree/merchant_gateway.rb
braintree-2.104.1 lib/braintree/merchant_gateway.rb
braintree-2.104.0 lib/braintree/merchant_gateway.rb
braintree-2.103.0 lib/braintree/merchant_gateway.rb
braintree-2.102.0 lib/braintree/merchant_gateway.rb
braintree-2.101.0 lib/braintree/merchant_gateway.rb
braintree-2.100.0 lib/braintree/merchant_gateway.rb
braintree-2.99.0 lib/braintree/merchant_gateway.rb
braintree-2.98.0 lib/braintree/merchant_gateway.rb
braintree-2.97.0 lib/braintree/merchant_gateway.rb
braintree-2.96.0 lib/braintree/merchant_gateway.rb
braintree-2.95.0 lib/braintree/merchant_gateway.rb
braintree-2.94.0 lib/braintree/merchant_gateway.rb
braintree-2.93.0 lib/braintree/merchant_gateway.rb
braintree-2.92.0 lib/braintree/merchant_gateway.rb
braintree-2.91.0 lib/braintree/merchant_gateway.rb
braintree-2.90.0 lib/braintree/merchant_gateway.rb