Sha256: 103839b201e055acca7ecb344f79d98f656257adee0f4b593c6145326e5b9dfa

Contents?: true

Size: 1.18 KB

Versions: 27

Compression:

Stored size: 1.18 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(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

27 entries across 27 versions & 1 rubygems

Version Path
braintree-2.75.0 lib/braintree/merchant_gateway.rb
braintree-2.74.0 lib/braintree/merchant_gateway.rb
braintree-2.73.0 lib/braintree/merchant_gateway.rb
braintree-2.72.0 lib/braintree/merchant_gateway.rb
braintree-2.71.0 lib/braintree/merchant_gateway.rb
braintree-2.70.0 lib/braintree/merchant_gateway.rb
braintree-2.69.1 lib/braintree/merchant_gateway.rb
braintree-2.69.0 lib/braintree/merchant_gateway.rb
braintree-2.68.2 lib/braintree/merchant_gateway.rb
braintree-2.68.1 lib/braintree/merchant_gateway.rb
braintree-2.68.0 lib/braintree/merchant_gateway.rb
braintree-2.67.0 lib/braintree/merchant_gateway.rb
braintree-2.66.0 lib/braintree/merchant_gateway.rb
braintree-2.65.0 lib/braintree/merchant_gateway.rb
braintree-2.64.0 lib/braintree/merchant_gateway.rb
braintree-2.63.0 lib/braintree/merchant_gateway.rb
braintree-2.62.0 lib/braintree/merchant_gateway.rb
braintree-2.61.1 lib/braintree/merchant_gateway.rb
braintree-2.61.0 lib/braintree/merchant_gateway.rb
braintree-2.60.0 lib/braintree/merchant_gateway.rb