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/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, Subscription

Class Method Summary collapse

Class Method Details

.configure_webhooksObject



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

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



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

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

.merchant_idObject



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

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

.private_keyObject



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

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

.public_keyObject



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

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

.setupObject



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

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