Class: Braintree::ClientTokenGateway

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gateway) ⇒ ClientTokenGateway

Returns a new instance of ClientTokenGateway.



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

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

Class Method Details

._generate_signatureObject

:nodoc:



24
25
26
27
28
29
30
# File 'lib/braintree/client_token_gateway.rb', line 24

def self._generate_signature # :nodoc:
  [
    :address_id, :customer_id, :proxy_merchant_id, :merchant_account_id,
    :version, :sepa_mandate_acceptance_location, :sepa_mandate_type,
    {:options => [:make_default, :verify_card, :fail_on_duplicate_payment_method]}
  ]
end

Instance Method Details

#generate(options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/braintree/client_token_gateway.rb', line 9

def generate(options={})
  params = nil
  if options
    Util.verify_keys(ClientTokenGateway._generate_signature, options)
    params = {:client_token => options}
  end
  result = @config.http.post("#{@config.base_merchant_path}/client_token", params)

  if result[:client_token]
    result[:client_token][:value]
  else
    raise ArgumentError, result[:api_error_response][:message]
  end
end