pay-lago 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/main.yml +27 -0
  3. data/.gitignore +28 -0
  4. data/.rspec +3 -0
  5. data/.standard.yml +3 -0
  6. data/CHANGELOG.md +2 -0
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/Gemfile +25 -0
  9. data/Gemfile.lock +292 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +85 -0
  12. data/Rakefile +32 -0
  13. data/app/controllers/pay/webhooks/lago_controller.rb +41 -0
  14. data/app/models/concerns/pay/lago/pay_customer_extensions.rb +15 -0
  15. data/app/models/concerns/pay/lago/pay_extensions.rb +15 -0
  16. data/bin/console +15 -0
  17. data/bin/rails +16 -0
  18. data/bin/setup +8 -0
  19. data/config/routes.rb +5 -0
  20. data/docs/1_customers.md +18 -0
  21. data/docs/2_charges.md +72 -0
  22. data/docs/3_subscriptions.md +67 -0
  23. data/docs/4_webhooks.md +66 -0
  24. data/lib/pay/lago/attributes.rb +24 -0
  25. data/lib/pay/lago/billable.rb +148 -0
  26. data/lib/pay/lago/charge.rb +82 -0
  27. data/lib/pay/lago/engine.rb +27 -0
  28. data/lib/pay/lago/error.rb +9 -0
  29. data/lib/pay/lago/payment_method.rb +37 -0
  30. data/lib/pay/lago/subscription.rb +134 -0
  31. data/lib/pay/lago/version.rb +7 -0
  32. data/lib/pay/lago/webhook_extensions.rb +10 -0
  33. data/lib/pay/lago/webhooks/customer_payment_provider_created.rb +18 -0
  34. data/lib/pay/lago/webhooks/invoice_created.rb +15 -0
  35. data/lib/pay/lago/webhooks/invoice_drafted.rb +11 -0
  36. data/lib/pay/lago/webhooks/invoice_one_off_created.rb +15 -0
  37. data/lib/pay/lago/webhooks/invoice_payment_status_updated.rb +14 -0
  38. data/lib/pay/lago/webhooks/subscription_started.rb +12 -0
  39. data/lib/pay/lago/webhooks/subscription_terminated.rb +12 -0
  40. data/lib/pay/lago.rb +91 -0
  41. data/pay-lago.gemspec +27 -0
  42. data/sig/pay/lago.rbs +6 -0
  43. data/test/controllers/pay/webhooks/lago_controller_test.rb +37 -0
  44. data/test/dummy/.browserslistrc +1 -0
  45. data/test/dummy/Rakefile +6 -0
  46. data/test/dummy/app/assets/config/manifest.js +4 -0
  47. data/test/dummy/app/assets/images/.keep +0 -0
  48. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  49. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  50. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  51. data/test/dummy/app/controllers/application_controller.rb +4 -0
  52. data/test/dummy/app/controllers/concerns/.keep +0 -0
  53. data/test/dummy/app/controllers/main_controller.rb +4 -0
  54. data/test/dummy/app/controllers/payment_methods_controller.rb +5 -0
  55. data/test/dummy/app/helpers/application_helper.rb +2 -0
  56. data/test/dummy/app/helpers/current_helper.rb +9 -0
  57. data/test/dummy/app/javascript/application.js +9 -0
  58. data/test/dummy/app/javascript/controllers/application.js +10 -0
  59. data/test/dummy/app/javascript/controllers/index.js +11 -0
  60. data/test/dummy/app/jobs/application_job.rb +2 -0
  61. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  62. data/test/dummy/app/models/account.rb +3 -0
  63. data/test/dummy/app/models/application_record.rb +3 -0
  64. data/test/dummy/app/models/concerns/.keep +0 -0
  65. data/test/dummy/app/models/team.rb +10 -0
  66. data/test/dummy/app/models/user.rb +3 -0
  67. data/test/dummy/app/views/layouts/application.html.erb +36 -0
  68. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  69. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  70. data/test/dummy/app/webhooks/charge_succeeded.rb +5 -0
  71. data/test/dummy/bin/importmap +4 -0
  72. data/test/dummy/bin/rails +4 -0
  73. data/test/dummy/bin/rake +4 -0
  74. data/test/dummy/bin/setup +33 -0
  75. data/test/dummy/bin/webpack +18 -0
  76. data/test/dummy/bin/webpack-dev-server +18 -0
  77. data/test/dummy/config/application.rb +25 -0
  78. data/test/dummy/config/boot.rb +6 -0
  79. data/test/dummy/config/cable.yml +9 -0
  80. data/test/dummy/config/database.yml +3 -0
  81. data/test/dummy/config/environment.rb +5 -0
  82. data/test/dummy/config/environments/development.rb +70 -0
  83. data/test/dummy/config/environments/production.rb +86 -0
  84. data/test/dummy/config/environments/test.rb +60 -0
  85. data/test/dummy/config/importmap.rb +8 -0
  86. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  87. data/test/dummy/config/initializers/assets.rb +11 -0
  88. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  89. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  90. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  91. data/test/dummy/config/initializers/inflections.rb +16 -0
  92. data/test/dummy/config/initializers/mime_types.rb +4 -0
  93. data/test/dummy/config/initializers/pay.rb +11 -0
  94. data/test/dummy/config/initializers/session_store.rb +3 -0
  95. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  96. data/test/dummy/config/locales/en.yml +23 -0
  97. data/test/dummy/config/puma.rb +47 -0
  98. data/test/dummy/config/routes.rb +4 -0
  99. data/test/dummy/config/secrets.yml +22 -0
  100. data/test/dummy/config/spring.rb +6 -0
  101. data/test/dummy/config/storage.yml +34 -0
  102. data/test/dummy/config.ru +6 -0
  103. data/test/dummy/db/migrate/20170205000000_create_users.rb +22 -0
  104. data/test/dummy/db/schema.rb +125 -0
  105. data/test/dummy/lib/assets/.keep +0 -0
  106. data/test/dummy/log/.keep +0 -0
  107. data/test/dummy/public/404.html +67 -0
  108. data/test/dummy/public/422.html +67 -0
  109. data/test/dummy/public/500.html +66 -0
  110. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  111. data/test/dummy/public/apple-touch-icon.png +0 -0
  112. data/test/dummy/public/favicon.ico +0 -0
  113. data/test/dummy/vendor/javascript/.keep +0 -0
  114. data/test/fixtures/accounts.yml +2 -0
  115. data/test/fixtures/pay/customers.yml +7 -0
  116. data/test/fixtures/teams.yml +4 -0
  117. data/test/fixtures/users.yml +11 -0
  118. data/test/pay/lago/billable_test.rb +42 -0
  119. data/test/pay/lago/charge_test.rb +23 -0
  120. data/test/pay/lago/subscription_test.rb +48 -0
  121. data/test/support/fixtures/lago/invoice.one_off_created.json +120 -0
  122. data/test/support/vcr.rb +28 -0
  123. data/test/test_helper.rb +66 -0
  124. data/test/vcr_cassettes/test_add_payment_method_to_lago.yml +56 -0
  125. data/test/vcr_cassettes/test_can_get_lago_processor_customer.yml +56 -0
  126. data/test/vcr_cassettes/test_can_make_a_lago_processor_charge.yml +163 -0
  127. data/test/vcr_cassettes/test_generates_lago_processor_id.yml +107 -0
  128. data/test/vcr_cassettes/test_lago_cannot_change_quantity.yml +108 -0
  129. data/test/vcr_cassettes/test_lago_processor_cancel.yml +212 -0
  130. data/test/vcr_cassettes/test_lago_processor_charge.yml +325 -0
  131. data/test/vcr_cassettes/test_lago_processor_on_grace_period__is_always_false.yml +108 -0
  132. data/test/vcr_cassettes/test_lago_processor_pause_raises_an_error.yml +108 -0
  133. data/test/vcr_cassettes/test_lago_processor_paused__is_always_false.yml +108 -0
  134. data/test/vcr_cassettes/test_lago_processor_refund_with_premium.yml +378 -0
  135. data/test/vcr_cassettes/test_lago_processor_refund_without_premium.yml +375 -0
  136. data/test/vcr_cassettes/test_lago_processor_resume_raises_an_error.yml +108 -0
  137. data/test/vcr_cassettes/test_lago_processor_subscribe.yml +108 -0
  138. data/test/vcr_cassettes/test_lago_processor_subscription.yml +160 -0
  139. data/test/vcr_cassettes/test_lago_processor_swap.yml +212 -0
  140. metadata +212 -0
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path('..', __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to setup or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at anytime and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # puts "\n== Copying sample files =="
21
+ # unless File.exist?('config/database.yml')
22
+ # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
23
+ # end
24
+
25
+ puts "\n== Preparing database =="
26
+ system! 'bin/rails db:prepare'
27
+
28
+ puts "\n== Removing old logs and tempfiles =="
29
+ system! 'bin/rails log:clear tmp:clear'
30
+
31
+ puts "\n== Restarting application server =="
32
+ system! 'bin/rails restart'
33
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "bundler/setup"
11
+
12
+ require "webpacker"
13
+ require "webpacker/webpack_runner"
14
+
15
+ APP_ROOT = File.expand_path("..", __dir__)
16
+ Dir.chdir(APP_ROOT) do
17
+ Webpacker::WebpackRunner.run(ARGV)
18
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "bundler/setup"
11
+
12
+ require "webpacker"
13
+ require "webpacker/dev_server_runner"
14
+
15
+ APP_ROOT = File.expand_path("..", __dir__)
16
+ Dir.chdir(APP_ROOT) do
17
+ Webpacker::DevServerRunner.run(ARGV)
18
+ end
@@ -0,0 +1,25 @@
1
+ require_relative "boot"
2
+
3
+ require "rails/all"
4
+
5
+ require "pay"
6
+ require "pay/lago"
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module Dummy
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ config.active_job.queue_adapter = :test
16
+ config.action_mailer.default_url_options = {host: "localhost", port: 3000}
17
+
18
+ # Remove warnings
19
+ config.active_record.legacy_connection_handling = false if Rails.gem_version >= Gem::Version.new("6.1") && Rails.gem_version < Gem::Version.new("7.1.0.alpha")
20
+
21
+ # Set the ActionMailer preview path to the gem test directory
22
+ config.action_mailer.show_previews = true
23
+ config.action_mailer.preview_path = Rails.root.join("../../test/mailers/previews")
24
+ end
25
+ end
@@ -0,0 +1,6 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3
+ ENV["RAILS_ENV"] ||= "test"
4
+
5
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
6
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -0,0 +1,9 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: async
6
+
7
+ production:
8
+ adapter: redis
9
+ url: redis://localhost:6379/1
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/test.sqlite3
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative "application"
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,70 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # In the development environment your application's code is reloaded any time
7
+ # it changes. This slows down response time but is perfect for development
8
+ # since you don't have to restart the web server when you make code changes.
9
+ config.cache_classes = false
10
+
11
+ # Do not eager load code on boot.
12
+ config.eager_load = false
13
+
14
+ # Show full error reports.
15
+ config.consider_all_requests_local = true
16
+
17
+ # Enable server timing
18
+ config.server_timing = true
19
+
20
+ # Enable/disable caching. By default caching is disabled.
21
+ # Run rails dev:cache to toggle caching.
22
+ if Rails.root.join("tmp/caching-dev.txt").exist?
23
+ config.action_controller.perform_caching = true
24
+ config.action_controller.enable_fragment_cache_logging = true
25
+
26
+ config.cache_store = :memory_store
27
+ config.public_file_server.headers = {
28
+ "Cache-Control" => "public, max-age=#{2.days.to_i}"
29
+ }
30
+ else
31
+ config.action_controller.perform_caching = false
32
+
33
+ config.cache_store = :null_store
34
+ end
35
+
36
+ # Store uploaded files on the local file system (see config/storage.yml for options).
37
+ config.active_storage.service = :local
38
+
39
+ # Don't care if the mailer can't send.
40
+ config.action_mailer.raise_delivery_errors = false
41
+
42
+ config.action_mailer.perform_caching = false
43
+
44
+ # Print deprecation notices to the Rails logger.
45
+ config.active_support.deprecation = :log
46
+
47
+ # Raise exceptions for disallowed deprecations.
48
+ config.active_support.disallowed_deprecation = :raise
49
+
50
+ # Tell Active Support which deprecation messages to disallow.
51
+ config.active_support.disallowed_deprecation_warnings = []
52
+
53
+ # Raise an error on page load if there are pending migrations.
54
+ config.active_record.migration_error = :page_load
55
+
56
+ # Highlight code that triggered database queries in logs.
57
+ config.active_record.verbose_query_logs = true
58
+
59
+ # Suppress logger output for asset requests.
60
+ config.assets.quiet = true
61
+
62
+ # Raises error for missing translations.
63
+ # config.i18n.raise_on_missing_translations = true
64
+
65
+ # Annotate rendered view with file names.
66
+ # config.action_view.annotate_rendered_view_with_filenames = true
67
+
68
+ # Uncomment if you wish to allow Action Cable access from any origin.
69
+ # config.action_cable.disable_request_forgery_protection = true
70
+ end
@@ -0,0 +1,86 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Disable serving static files from the `/public` folder by default since
18
+ # Apache or NGINX already handles this.
19
+ config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
20
+
21
+ # Compress JavaScripts and CSS.
22
+ config.assets.js_compressor = :uglifier
23
+ # config.assets.css_compressor = :sass
24
+
25
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
26
+ config.assets.compile = false
27
+
28
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
29
+
30
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
31
+ # config.action_controller.asset_host = 'http://assets.example.com'
32
+
33
+ # Specifies the header that your server uses for sending files.
34
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
35
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
36
+
37
+ # Mount Action Cable outside main process or domain
38
+ # config.action_cable.mount_path = nil
39
+ # config.action_cable.url = 'wss://example.com/cable'
40
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
41
+
42
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43
+ # config.force_ssl = true
44
+
45
+ # Use the lowest log level to ensure availability of diagnostic information
46
+ # when problems arise.
47
+ config.log_level = :debug
48
+
49
+ # Prepend all log lines with the following tags.
50
+ config.log_tags = [:request_id]
51
+
52
+ # Use a different cache store in production.
53
+ # config.cache_store = :mem_cache_store
54
+
55
+ # Use a real queuing backend for Active Job (and separate queues per environment)
56
+ # config.active_job.queue_adapter = :resque
57
+ # config.active_job.queue_name_prefix = "dummy_#{Rails.env}"
58
+ config.action_mailer.perform_caching = false
59
+
60
+ # Ignore bad email addresses and do not raise email delivery errors.
61
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
62
+ # config.action_mailer.raise_delivery_errors = false
63
+
64
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
65
+ # the I18n.default_locale when a translation cannot be found).
66
+ config.i18n.fallbacks = true
67
+
68
+ # Send deprecation notices to registered listeners.
69
+ config.active_support.deprecation = :notify
70
+
71
+ # Use default logging formatter so that PID and timestamp are not suppressed.
72
+ config.log_formatter = ::Logger::Formatter.new
73
+
74
+ # Use a different logger for distributed setups.
75
+ # require 'syslog/logger'
76
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
77
+
78
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
79
+ logger = ActiveSupport::Logger.new(STDOUT)
80
+ logger.formatter = config.log_formatter
81
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
82
+ end
83
+
84
+ # Do not dump schema after migrations.
85
+ config.active_record.dump_schema_after_migration = false
86
+ end
@@ -0,0 +1,60 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+
8
+ Rails.application.configure do
9
+ # Settings specified here will take precedence over those in config/application.rb.
10
+
11
+ # Turn false under Spring and add config.action_view.cache_template_loading = true.
12
+ config.cache_classes = true
13
+
14
+ # Eager loading loads your whole application. When running a single test locally,
15
+ # this probably isn't necessary. It's a good idea to do in a continuous integration
16
+ # system, or in some way before deploying your code.
17
+ config.eager_load = ENV["CI"].present?
18
+
19
+ # Configure public file server for tests with Cache-Control for performance.
20
+ config.public_file_server.enabled = true
21
+ config.public_file_server.headers = {
22
+ "Cache-Control" => "public, max-age=#{1.hour.to_i}"
23
+ }
24
+
25
+ # Show full error reports and disable caching.
26
+ config.consider_all_requests_local = true
27
+ config.action_controller.perform_caching = false
28
+ config.cache_store = :null_store
29
+
30
+ # Raise exceptions instead of rendering exception templates.
31
+ config.action_dispatch.show_exceptions = false
32
+
33
+ # Disable request forgery protection in test environment.
34
+ config.action_controller.allow_forgery_protection = false
35
+
36
+ # Store uploaded files on the local file system in a temporary directory.
37
+ config.active_storage.service = :test
38
+
39
+ config.action_mailer.perform_caching = false
40
+
41
+ # Tell Action Mailer not to deliver emails to the real world.
42
+ # The :test delivery method accumulates sent emails in the
43
+ # ActionMailer::Base.deliveries array.
44
+ config.action_mailer.delivery_method = :test
45
+
46
+ # Print deprecation notices to the stderr.
47
+ config.active_support.deprecation = :stderr
48
+
49
+ # Raise exceptions for disallowed deprecations.
50
+ config.active_support.disallowed_deprecation = :raise
51
+
52
+ # Tell Active Support which deprecation messages to disallow.
53
+ config.active_support.disallowed_deprecation_warnings = []
54
+
55
+ # Raises error for missing translations.
56
+ # config.i18n.raise_on_missing_translations = true
57
+
58
+ # Annotate rendered view with file names.
59
+ # config.action_view.annotate_rendered_view_with_filenames = true
60
+ end
@@ -0,0 +1,8 @@
1
+ # Pin npm packages by running ./bin/importmap
2
+
3
+ pin "application", preload: true
4
+ pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
5
+ pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
6
+ pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
7
+ pin_all_from "app/javascript/controllers", under: "controllers"
8
+ pin "@rails/ujs", to: "https://ga.jspm.io/npm:@rails/ujs@7.0.3-1/lib/assets/compiled/rails-ujs.js"
@@ -0,0 +1,6 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # ApplicationController.renderer.defaults.merge!(
4
+ # http_host: 'example.org',
5
+ # https: false
6
+ # )
@@ -0,0 +1,11 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Version of your assets, change this if you want to expire all your assets.
4
+ Rails.application.config.assets.version = "1.0" if Rails.application.config.respond_to? :assets
5
+
6
+ # Add additional assets to the asset load path
7
+ # Rails.application.config.assets.paths << Emoji.images_path
8
+
9
+ # Precompile additional assets.
10
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11
+ # Rails.application.config.assets.precompile += %w( search.js )
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Specify a serializer for the signed and encrypted cookie jars.
4
+ # Valid options are :json, :marshal, and :hybrid.
5
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,11 @@
1
+ Pay.setup do |config|
2
+ # For use in the receipt/refund/renewal mailers
3
+ config.business_name = "Test Business"
4
+ config.business_address = "1600 Pennsylvania Avenue NW\nWashington, DC 20500"
5
+ config.application_name = "My App"
6
+ config.support_email = "support@example.org"
7
+ end
8
+
9
+ ActiveSupport.on_load(:pay) do
10
+ Pay::Webhooks.delegator.subscribe "stripe.charge.succeeded", ChargeSucceeded.new
11
+ end
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: "_dummy_session"
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,47 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum, this matches the default thread size of Active Record.
6
+ #
7
+ threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
8
+ threads threads_count, threads_count
9
+
10
+ # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
11
+ #
12
+ port ENV.fetch("PORT") { 3000 }
13
+
14
+ # Specifies the `environment` that Puma will run in.
15
+ #
16
+ environment ENV.fetch("RAILS_ENV") { "development" }
17
+
18
+ # Specifies the number of `workers` to boot in clustered mode.
19
+ # Workers are forked webserver processes. If using threads and workers together
20
+ # the concurrency of the application would be max `threads` * `workers`.
21
+ # Workers do not work on JRuby or Windows (both of which do not support
22
+ # processes).
23
+ #
24
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25
+
26
+ # Use the `preload_app!` method when specifying a `workers` number.
27
+ # This directive tells Puma to first boot the application and load code
28
+ # before forking the application. This takes advantage of Copy On Write
29
+ # process behavior so workers use less memory. If you use this option
30
+ # you need to make sure to reconnect any threads in the `on_worker_boot`
31
+ # block.
32
+ #
33
+ # preload_app!
34
+
35
+ # The code in the `on_worker_boot` will be called if you are using
36
+ # clustered mode by specifying a number of `workers`. After each worker
37
+ # process is booted this block will be run, if you are using `preload_app!`
38
+ # option you will want to use this block to reconnect to any threads
39
+ # or connections that may have been created at application boot, Ruby
40
+ # cannot share connections between processes.
41
+ #
42
+ # on_worker_boot do
43
+ # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
44
+ # end
45
+
46
+ # Allow puma to be restarted by `rails restart` command.
47
+ plugin :tmp_restart
@@ -0,0 +1,4 @@
1
+ # frozen_string_literals: true
2
+
3
+ Rails.application.routes.draw do
4
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rails secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 1ca8a0578a7f730e9b976b2d4caaaf4a739bb5e391de413127bf748c9ffe8abc9784eaae87eb7fbf88543bc3ee67c74576e1763f75b6a6c6bc2071f834782652
15
+
16
+ test:
17
+ secret_key_base: ae102b18ad3fcf12beea3626f5dc743633e494919238f2153fcd5720e7625b62006350d5e11cafb0f3383417d9823eb2c8e2133cdddbd7f4b032e0412105d299
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,6 @@
1
+ %w[
2
+ .ruby-version
3
+ .rbenv-vars
4
+ tmp/restart.txt
5
+ tmp/caching-dev.txt
6
+ ].each { |path| Spring.watch(path) }
@@ -0,0 +1,34 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
8
+
9
+ # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
+ # amazon:
11
+ # service: S3
12
+ # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
+ # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
+ # region: us-east-1
15
+ # bucket: your_own_bucket-<%= Rails.env %>
16
+
17
+ # Remember not to checkin your GCS keyfile to a repository
18
+ # google:
19
+ # service: GCS
20
+ # project: your_project
21
+ # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
+ # bucket: your_own_bucket-<%= Rails.env %>
23
+
24
+ # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
+ # microsoft:
26
+ # service: AzureStorage
27
+ # storage_account_name: your_account_name
28
+ # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
+ # container: your_container_name-<%= Rails.env %>
30
+
31
+ # mirror:
32
+ # service: Mirror
33
+ # primary: local
34
+ # mirrors: [ amazon, google, microsoft ]
@@ -0,0 +1,6 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require_relative "config/environment"
4
+
5
+ run Rails.application
6
+ Rails.application.load_server
@@ -0,0 +1,22 @@
1
+ class CreateUsers < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :email
5
+ t.string :first_name
6
+ t.string :last_name
7
+ t.text :extra_billing_info
8
+ end
9
+
10
+ create_table :teams do |t|
11
+ t.string :email
12
+ t.string :name
13
+ t.references :owner, polymorphic: true
14
+ end
15
+
16
+ create_table :accounts do |t|
17
+ t.string :email
18
+ t.string :merchant_processor
19
+ t.string :pay_data
20
+ end
21
+ end
22
+ end