Sha256: 77bcdb24155e7e495c506d63d341fdba618688dc42f136deb65f8176e2355bc5

Contents?: true

Size: 796 Bytes

Versions: 5

Compression:

Stored size: 796 Bytes

Contents

module Braintree
  class MerchantGateway
    def initialize(gateway)
      @gateway = gateway
      @config = gateway.config
    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

5 entries across 5 versions & 1 rubygems

Version Path
braintree-2.49.0 lib/braintree/merchant_gateway.rb
braintree-2.48.1 lib/braintree/merchant_gateway.rb
braintree-2.48.0 lib/braintree/merchant_gateway.rb
braintree-2.47.0 lib/braintree/merchant_gateway.rb
braintree-2.46.0 lib/braintree/merchant_gateway.rb