Class: PaymentCalculator::Braintree

Inherits:
Object
  • Object
show all
Defined in:
app/models/piggybak_braintree/payment_calculator/braintree.rb

Constant Summary collapse

KEYS =
['private_key', 'public_key', 'merchant_id']
KLASS =
::Braintree

Instance Method Summary collapse

Constructor Details

#initialize(payment_method) ⇒ Braintree

Returns a new instance of Braintree.



6
7
8
# File 'app/models/piggybak_braintree/payment_calculator/braintree.rb', line 6

def initialize(payment_method)
  @payment_method = payment_method
end

Instance Method Details

#client_tokenObject



17
18
19
# File 'app/models/piggybak_braintree/payment_calculator/braintree.rb', line 17

def client_token
  Braintree::ClientToken.generate
end

#configureObject



10
11
12
13
14
15
# File 'app/models/piggybak_braintree/payment_calculator/braintree.rb', line 10

def configure
  Braintree::Configuration.environment = gateway_mode
  Braintree::Configuration.merchant_id = merchant_id
  Braintree::Configuration.public_key = public_key
  Braintree::Configuration.private_key = private_key
end

#gateway_modeObject



21
22
23
# File 'app/models/piggybak_braintree/payment_calculator/braintree.rb', line 21

def gateway_mode
  Piggybak.config.activemerchant_mode
end

#merchant_idObject



33
34
35
# File 'app/models/piggybak_braintree/payment_calculator/braintree.rb', line 33

def merchant_id
  @payment_method.key_values["merchant_id".to_sym]
end

#private_keyObject



25
26
27
# File 'app/models/piggybak_braintree/payment_calculator/braintree.rb', line 25

def private_key
  @payment_method.key_values["private_key".to_sym]
end

#public_keyObject



29
30
31
# File 'app/models/piggybak_braintree/payment_calculator/braintree.rb', line 29

def public_key
  @payment_method.key_values["public_key".to_sym]
end