Class: Braintree::ApplePayGateway

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

Instance Method Summary collapse

Constructor Details

#initialize(gateway) ⇒ ApplePayGateway

Returns a new instance of ApplePayGateway.



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

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

Instance Method Details

#register_domain(domain) ⇒ Object



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

def register_domain(domain)
  response = @config.http.post("#{@config.base_merchant_path}/processing/apple_pay/validate_domains", :url => domain)

  if response.has_key?(:response) && response[:response][:success]
    Braintree::SuccessfulResult.new
  elsif response[:api_error_response]
    ErrorResult.new(@gateway, response[:api_error_response])
  else
    raise "expected :response or :api_error_response"
  end
end

#registered_domainsObject



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

def registered_domains
  response = @config.http.get("#{@config.base_merchant_path}/processing/apple_pay/registered_domains")

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

#unregister_domain(domain) ⇒ Object



20
21
22
23
# File 'lib/braintree/apple_pay_gateway.rb', line 20

def unregister_domain(domain)
  @config.http.delete("#{@config.base_merchant_path}/processing/apple_pay/unregister_domain", :url => CGI.escape(domain))
  SuccessfulResult.new
end