Module: Pay::Braintree

Extended by:
Env
Defined in:
lib/pay/braintree.rb,
lib/pay/braintree/error.rb,
lib/pay/braintree/charge.rb,
lib/pay/braintree/billable.rb,
lib/pay/braintree/subscription.rb,
lib/pay/braintree/payment_method.rb,
lib/pay/braintree/authorization_error.rb,
lib/pay/braintree/webhooks/subscription_expired.rb,
lib/pay/braintree/webhooks/subscription_canceled.rb,
lib/pay/braintree/webhooks/subscription_trial_ended.rb,
lib/pay/braintree/webhooks/subscription_went_active.rb,
lib/pay/braintree/webhooks/subscription_went_past_due.rb,
lib/pay/braintree/webhooks/subscription_charged_successfully.rb,
lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb

Defined Under Namespace

Modules: Webhooks Classes: AuthorizationError, Billable, Charge, Error, PaymentMethod, Subscription

Class Method Summary collapse

Class Method Details

.configure_webhooksObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/pay/braintree.rb', line 49

def self.configure_webhooks
  Pay::Webhooks.configure do |events|
    events.subscribe "braintree.subscription_canceled", Pay::Braintree::Webhooks::SubscriptionCanceled.new
    events.subscribe "braintree.subscription_charged_successfully", Pay::Braintree::Webhooks::SubscriptionChargedSuccessfully.new
    events.subscribe "braintree.subscription_charged_unsuccessfully", Pay::Braintree::Webhooks::SubscriptionChargedUnsuccessfully.new
    events.subscribe "braintree.subscription_expired", Pay::Braintree::Webhooks::SubscriptionExpired.new
    events.subscribe "braintree.subscription_trial_ended", Pay::Braintree::Webhooks::SubscriptionTrialEnded.new
    events.subscribe "braintree.subscription_went_active", Pay::Braintree::Webhooks::SubscriptionWentActive.new
    events.subscribe "braintree.subscription_went_past_due", Pay::Braintree::Webhooks::SubscriptionWentPastDue.new
  end
end

.environmentObject



45
46
47
# File 'lib/pay/braintree.rb', line 45

def self.environment
  find_value_by_name(:braintree, :environment) || "sandbox"
end

.merchant_idObject



41
42
43
# File 'lib/pay/braintree.rb', line 41

def self.merchant_id
  find_value_by_name(:braintree, :merchant_id)
end

.private_keyObject



37
38
39
# File 'lib/pay/braintree.rb', line 37

def self.private_key
  find_value_by_name(:braintree, :private_key)
end

.public_keyObject



33
34
35
# File 'lib/pay/braintree.rb', line 33

def self.public_key
  find_value_by_name(:braintree, :public_key)
end

.setupObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/pay/braintree.rb', line 22

def self.setup
  Pay.braintree_gateway = ::Braintree::Gateway.new(
    environment: environment.to_sym,
    merchant_id: merchant_id,
    public_key: public_key,
    private_key: private_key
  )

  configure_webhooks
end