Sha256: a178903a989bf964213b6fa8b9a7aea10450ffd6163e662ce6625ed5ce152468

Contents?: true

Size: 987 Bytes

Versions: 1

Compression:

Stored size: 987 Bytes

Contents

require "pay/env"
require "pay/braintree/billable"
require "pay/braintree/charge"
require "pay/braintree/subscription"
require "pay/braintree/webhooks"

module Pay
  module Braintree
    include Env

    extend self

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

      Pay.charge_model.include Pay::Braintree::Charge
      Pay.subscription_model.include Pay::Braintree::Subscription
      Pay.billable_models.each { |model| model.include Pay::Braintree::Billable }
    end

    def public_key
      find_value_by_name(:braintree, :public_key)
    end

    def private_key
      find_value_by_name(:braintree, :private_key)
    end

    def merchant_id
      find_value_by_name(:braintree, :merchant_id)
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pay-2.5.0 lib/pay/braintree.rb