Sha256: bbea3d57e61f4aab314e9ba1e6615d79656b9c84305954d4d2d32c88f9b43098

Contents?: true

Size: 1.2 KB

Versions: 25

Compression:

Stored size: 1.2 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

25 entries across 25 versions & 1 rubygems

Version Path
braintree-4.23.0 lib/braintree/merchant_gateway.rb
braintree-4.22.0 lib/braintree/merchant_gateway.rb
braintree-4.21.0 lib/braintree/merchant_gateway.rb
braintree-4.20.0 lib/braintree/merchant_gateway.rb
braintree-4.19.0 lib/braintree/merchant_gateway.rb
braintree-4.18.0 lib/braintree/merchant_gateway.rb
braintree-4.17.0 lib/braintree/merchant_gateway.rb
braintree-4.16.0 lib/braintree/merchant_gateway.rb
braintree-4.15.0 lib/braintree/merchant_gateway.rb
braintree-4.14.0 lib/braintree/merchant_gateway.rb
braintree-4.13.0 lib/braintree/merchant_gateway.rb
braintree-4.12.0 lib/braintree/merchant_gateway.rb
braintree-4.11.0 lib/braintree/merchant_gateway.rb
braintree-4.10.0 lib/braintree/merchant_gateway.rb
braintree-4.9.0 lib/braintree/merchant_gateway.rb
braintree-4.8.0 lib/braintree/merchant_gateway.rb
braintree-4.7.0 lib/braintree/merchant_gateway.rb
braintree-4.6.0 lib/braintree/merchant_gateway.rb
braintree-4.5.0 lib/braintree/merchant_gateway.rb
braintree-4.4.0 lib/braintree/merchant_gateway.rb