Class: Braintree::MerchantGateway

Inherits:
Object
  • Object
show all
Defined in:
lib/braintree/merchant_gateway.rb

Instance Method Summary collapse

Constructor Details

#initialize(gateway) ⇒ MerchantGateway

Returns a new instance of MerchantGateway.



3
4
5
6
# File 'lib/braintree/merchant_gateway.rb', line 3

def initialize(gateway)
  @gateway = gateway
  @config = gateway.config
end

Instance Method Details

#_create_merchant(params) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/braintree/merchant_gateway.rb', line 23

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

#create(params) ⇒ Object



19
20
21
# File 'lib/braintree/merchant_gateway.rb', line 19

def create(params)
  _create_merchant(params)
end

#provision_raw_apple_payObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/braintree/merchant_gateway.rb', line 8

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