Sha256: e3270cfe26c5dd2ae8e3fed7ad0d98fb4adc927f69c7cbdf08cc273abc91cf66

Contents?: true

Size: 971 Bytes

Versions: 1

Compression:

Stored size: 971 Bytes

Contents

# frozen_string_literal: true

# rubocop:disable Lint/HandleExceptions
begin
  require "braintree"
rescue LoadError
end

begin
  require "stripe"
rescue LoadError
end

begin
  require "paddle_pay"
rescue LoadError
end
# rubocop:enable Lint/HandleExceptions

module Pay
  class Engine < ::Rails::Engine
    engine_name "pay"

    initializer "pay.processors" do |app|
      # Include processor backends
      require "pay/stripe" if defined? ::Stripe
      require "pay/braintree" if defined? ::Braintree
      require "pay/paddle" if defined? ::PaddlePay

      if Pay.automount_routes
        app.routes.append do
          mount Pay::Engine, at: Pay.routes_path, as: "pay"
        end
      end
    end

    config.to_prepare do
      Pay::Stripe.setup if defined? ::Stripe
      Pay::Braintree.setup if defined? ::Braintree
      Pay::Paddle.setup if defined? ::PaddlePay

      Pay.charge_model.include Pay::Receipts if defined? ::Receipts::Receipt
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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