boring_generators 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/boring_generators/version.rb +1 -1
- data/lib/generators/boring/active_storage/aws/install/install_generator.rb +10 -8
- data/lib/generators/boring/active_storage/azure/install/install_generator.rb +9 -7
- data/lib/generators/boring/active_storage/google/install/install_generator.rb +9 -7
- data/lib/generators/boring/audit/install/install_generator.rb +12 -9
- data/lib/generators/boring/bullet/install/install_generator.rb +4 -8
- data/lib/generators/boring/devise/install/install_generator.rb +1 -7
- data/lib/generators/boring/font_awesome/ruby_gem/install/install_generator.rb +3 -8
- data/lib/generators/boring/graphql/install/install_generator.rb +3 -7
- data/lib/generators/boring/oauth/facebook/install/install_generator.rb +1 -7
- data/lib/generators/boring/oauth/github/install/install_generator.rb +1 -7
- data/lib/generators/boring/payments/stripe/install/install_generator.rb +10 -11
- data/lib/generators/boring/payments/stripe/install/templates/README +15 -8
- data/lib/generators/boring/payments/stripe/install/templates/controllers/stripe/checkouts_controller.rb +63 -0
- data/lib/generators/boring/payments/stripe/install/templates/stripe.rb +1 -6
- data/lib/generators/boring/payments/stripe/install/templates/views/stripe/checkouts/create.js.erb +13 -0
- data/lib/generators/boring/payments/stripe/install/templates/views/stripe/checkouts/show.html.erb +8 -0
- data/lib/generators/boring/pry/install/install_generator.rb +4 -9
- data/lib/generators/boring/pundit/install/install_generator.rb +1 -7
- data/lib/generators/boring/rubocop/install/install_generator.rb +3 -1
- data/lib/generators/boring/simple_form/install/install_generator.rb +4 -8
- data/lib/generators/boring/twilio/install/install_generator.rb +3 -7
- metadata +5 -6
- data/lib/generators/boring/payments/stripe/install/templates/controllers/charges_controller.rb +0 -38
- data/lib/generators/boring/payments/stripe/install/templates/views/charges.html.erb +0 -7
- data/lib/generators/boring/payments/stripe/install/templates/views/create.html.erb +0 -1
- data/lib/generators/boring/payments/stripe/install/templates/views/new.html.erb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0270bea161b8e7aa0cce68a2f79bd8456865f7f0ee00c3fef81b0ecddbfba1e1
|
4
|
+
data.tar.gz: 19e58c07ef090636ca05c1e7c620e750994c72e052ae3dc51e6b1887783582cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dd9d49410e16f73b13116f490fca9407313bf845f21ce45e403b5e4ced43e7647e0ed52b020f175cae2571ad6b6a5ff16b2ade2d271a338905837c93b58317a
|
7
|
+
data.tar.gz: '092146185b12c44adad625d7c67a19253759a4d7b7a8a520ec4b541bf066f49aa98dba50787dc46ad535ad2318c79e31fb6e2fc60d7e14733872948f738ee83a'
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
|
+
|
5
|
+
## 0.10.0 (May 26th, 2021)
|
6
|
+
* Updates Stripe payment generator. ([@abhaynikam][])
|
7
|
+
* Fixes many generators which install ruby gems to not hardcode gem version. ([@abhaynikam][])
|
8
|
+
|
9
|
+
## 0.9.0 (April 14th, 2021)
|
4
10
|
* Adds Ahoy generator. ([@abhaynikam][])
|
5
11
|
* Adds Stripe payment generator. ([@abhaynikam][])
|
6
12
|
|
@@ -15,14 +15,16 @@ module Boring
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def add_aws_to_the_application
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
Bundler.with_unbundled_env do
|
19
|
+
say "Adding AWS gem", :green
|
20
|
+
aws_gem_content = <<~RUBY
|
21
|
+
\n
|
22
|
+
# for AWS Service
|
23
|
+
gem "aws-sdk-s3", require: false
|
24
|
+
RUBY
|
25
|
+
append_to_file "Gemfile", aws_gem_content
|
26
|
+
run "bundle install"
|
27
|
+
end
|
26
28
|
end
|
27
29
|
|
28
30
|
def add_configuration_to_production
|
@@ -16,13 +16,15 @@ module Boring
|
|
16
16
|
|
17
17
|
def add_azure_to_the_application
|
18
18
|
say "Adding mircosoft azure gem", :green
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
Bundler.with_unbundled_env do
|
20
|
+
azure_gem_content = <<~RUBY
|
21
|
+
\n
|
22
|
+
# for Azure Service
|
23
|
+
gem "azure-storage-blob", require: false
|
24
|
+
RUBY
|
25
|
+
append_to_file "Gemfile", azure_gem_content
|
26
|
+
run "bundle install"
|
27
|
+
end
|
26
28
|
end
|
27
29
|
|
28
30
|
def add_configuration_to_production
|
@@ -16,13 +16,15 @@ module Boring
|
|
16
16
|
|
17
17
|
def add_google_cloud_storage_to_the_application
|
18
18
|
say "Adding google cloud storage gem", :green
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
Bundler.with_unbundled_env do
|
20
|
+
google_cloud_storage_gem_content = <<~RUBY
|
21
|
+
\n
|
22
|
+
# for Google Cloud Storage Service
|
23
|
+
gem "google-cloud-storage", require: false
|
24
|
+
RUBY
|
25
|
+
append_to_file "Gemfile", google_cloud_storage_gem_content
|
26
|
+
run "bundle install"
|
27
|
+
end
|
26
28
|
end
|
27
29
|
|
28
30
|
def add_configuration_to_production
|
@@ -7,15 +7,18 @@ module Boring
|
|
7
7
|
|
8
8
|
def add_bullet_gem
|
9
9
|
say "Adding audit gems", :green
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
|
11
|
+
Bundler.with_unbundled_env do
|
12
|
+
audit_gems_content = <<~RUBY
|
13
|
+
\n
|
14
|
+
\t# Patch-level verification for Bundler. https://github.com/rubysec/bundler-audit
|
15
|
+
\tgem "bundler-audit", require: false
|
16
|
+
\t# vulnerabity checker for Ruby itself. https://github.com/civisanalytics/ruby_audit
|
17
|
+
\tgem "ruby_audit", require: false
|
18
|
+
RUBY
|
19
|
+
insert_into_file "Gemfile", audit_gems_content, after: /group :development do/
|
20
|
+
run "bundle install"
|
21
|
+
end
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
@@ -10,14 +10,10 @@ module Boring
|
|
10
10
|
desc: "Skips adding bullet development configuration"
|
11
11
|
|
12
12
|
def add_bullet_gem
|
13
|
-
say "Adding
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
\tgem "bullet"
|
18
|
-
RUBY
|
19
|
-
insert_into_file "Gemfile", bullet_gem_content, after: /group :development do/
|
20
|
-
run "bundle install"
|
13
|
+
say "Adding bullet gem", :green
|
14
|
+
Bundler.with_unbundled_env do
|
15
|
+
run "bundle add bullet --group development"
|
16
|
+
end
|
21
17
|
end
|
22
18
|
|
23
19
|
def add_bullet_gem_configuration
|
@@ -16,14 +16,8 @@ module Boring
|
|
16
16
|
|
17
17
|
def add_devise_gem
|
18
18
|
say "Adding devise gem", :green
|
19
|
-
devise_gem = <<~RUBY
|
20
|
-
\n
|
21
|
-
# for authentication
|
22
|
-
gem 'devise', '~> 4.7'
|
23
|
-
RUBY
|
24
|
-
append_to_file "Gemfile", devise_gem
|
25
19
|
Bundler.with_unbundled_env do
|
26
|
-
run "bundle
|
20
|
+
run "bundle add devise"
|
27
21
|
end
|
28
22
|
end
|
29
23
|
|
@@ -8,14 +8,9 @@ module Boring
|
|
8
8
|
|
9
9
|
def add_font_awesome_sass_gem
|
10
10
|
say "Adding font_awesome_sass gem", :green
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# for adding font-awesome icons
|
15
|
-
gem 'font-awesome-sass', '~> 5.13'
|
16
|
-
RUBY
|
17
|
-
append_to_file "Gemfile", font_awesome_sass_gem
|
18
|
-
run "bundle install"
|
11
|
+
Bundler.with_unbundled_env do
|
12
|
+
run "bundle add font-awesome-sass"
|
13
|
+
end
|
19
14
|
end
|
20
15
|
|
21
16
|
def import_font_awesome_stylesheet
|
@@ -13,13 +13,9 @@ module Boring
|
|
13
13
|
|
14
14
|
def add_graphql_gem
|
15
15
|
say "Adding graphql gem", :green
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
gem 'graphql', '~> 1.11'
|
20
|
-
RUBY
|
21
|
-
append_to_file "Gemfile", graphql_gem
|
22
|
-
run "bundle install"
|
16
|
+
Bundler.with_unbundled_env do
|
17
|
+
run "bundle add graphql"
|
18
|
+
end
|
23
19
|
end
|
24
20
|
|
25
21
|
def run_graphql_generator
|
@@ -16,14 +16,8 @@ module Boring
|
|
16
16
|
|
17
17
|
def add_facebook_omniauth_gem
|
18
18
|
say "Adding Facebook OmniAuth gem", :green
|
19
|
-
facebook_omniauth_gem = <<~RUBY
|
20
|
-
\n
|
21
|
-
# for omniauth facebook
|
22
|
-
gem 'omniauth-facebook', '~> 8.0'
|
23
|
-
RUBY
|
24
|
-
append_to_file "Gemfile", facebook_omniauth_gem
|
25
19
|
Bundler.with_unbundled_env do
|
26
|
-
run "bundle
|
20
|
+
run "bundle add omniauth-facebook"
|
27
21
|
end
|
28
22
|
end
|
29
23
|
|
@@ -16,14 +16,8 @@ module Boring
|
|
16
16
|
|
17
17
|
def add_github_omniauth_gem
|
18
18
|
say "Adding GitHub OmniAuth gem", :green
|
19
|
-
github_omniauth_gem = <<~RUBY
|
20
|
-
\n
|
21
|
-
# for omniauth github
|
22
|
-
gem 'omniauth-github', '~> 1.4.0'
|
23
|
-
RUBY
|
24
|
-
append_to_file "Gemfile", github_omniauth_gem
|
25
19
|
Bundler.with_unbundled_env do
|
26
|
-
run "bundle
|
20
|
+
run "bundle add omniauth-github"
|
27
21
|
end
|
28
22
|
end
|
29
23
|
|
@@ -14,13 +14,19 @@ module Boring
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
say "Adding stripe
|
19
|
-
copy_file("controllers/
|
17
|
+
def add_checkouts_resources
|
18
|
+
say "Adding stripe checkout resources"
|
19
|
+
copy_file("controllers/stripe/checkouts_controller.rb", "app/controllers/stripe/checkouts_controller.rb")
|
20
|
+
copy_file("views/stripe/checkouts/create.js.erb", "app/views/stripe/checkouts/create.js.erb")
|
21
|
+
copy_file("views/stripe/checkouts/show.html.erb", "app/views/stripe/checkouts/show.html.erb")
|
20
22
|
end
|
21
23
|
|
22
24
|
def add_stripe_routes
|
23
|
-
route
|
25
|
+
route <<~ROUTE
|
26
|
+
namespace :stripe do
|
27
|
+
resource :checkout, only: [:create, :show]
|
28
|
+
end
|
29
|
+
ROUTE
|
24
30
|
end
|
25
31
|
|
26
32
|
def add_stripe_initializer
|
@@ -28,13 +34,6 @@ module Boring
|
|
28
34
|
copy_file("stripe.rb", "config/initializers/stripe.rb")
|
29
35
|
end
|
30
36
|
|
31
|
-
def add_stripe_views
|
32
|
-
say "Adding stripe views and layout"
|
33
|
-
copy_file("views/charges.html.erb", "app/views/layouts/charges.html.erb")
|
34
|
-
copy_file("views/new.html.erb", "app/views/charges/new.html.erb")
|
35
|
-
copy_file("views/create.html.erb", "app/views/charges/create.html.erb")
|
36
|
-
end
|
37
|
-
|
38
37
|
def show_readme
|
39
38
|
readme "README"
|
40
39
|
end
|
@@ -2,13 +2,20 @@
|
|
2
2
|
|
3
3
|
Some setup you must do manually if you haven't yet:
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
1. Register your Rails application on: https://dashboard.stripe.com/register
|
6
|
+
2. Update the stripe PUBLISHABLE_KEY in "config/initializers/stripe.rb"
|
7
|
+
For example:
|
8
|
+
|
9
|
+
Stripe.api_key = ENV['STRIPE_SECRET_KEY']
|
10
|
+
|
11
|
+
3. Update stripe PUBLISHABLE_KEY in the "views/stripe/checkouts/create.js.erb"
|
12
|
+
For example:
|
13
|
+
|
14
|
+
var stripe = Stripe(ENV["STRIPE_PUBLISHABLE_KEY"]);
|
15
|
+
|
16
|
+
4. Update "controllers/stripe/checkouts_controller.rb" with stripe checkout
|
17
|
+
line_items, success and failure callback URLs.
|
18
|
+
|
19
|
+
5. Go to: http://localhost:3000/stripe/checkout and try the checkout flow.
|
13
20
|
|
14
21
|
===============================================================================
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Stripe::CheckoutsController < ApplicationController
|
4
|
+
def create
|
5
|
+
begin
|
6
|
+
@stripe_session = Stripe::Checkout::Session.create(checkout_payload)
|
7
|
+
|
8
|
+
respond_to :js
|
9
|
+
rescue Stripe::CardError => e
|
10
|
+
puts "Status is: #{e.http_status}"
|
11
|
+
puts "Type is: #{e.error.type}"
|
12
|
+
puts "Charge ID is: #{e.error.charge}"
|
13
|
+
# The following fields are optional
|
14
|
+
puts "Code is: #{e.error.code}" if e.error.code
|
15
|
+
puts "Decline code is: #{e.error.decline_code}" if e.error.decline_code
|
16
|
+
puts "Param is: #{e.error.param}" if e.error.param
|
17
|
+
puts "Message is: #{e.error.message}" if e.error.message
|
18
|
+
rescue Stripe::RateLimitError => e
|
19
|
+
# Too many requests made to the API too quickly
|
20
|
+
rescue Stripe::InvalidRequestError => e
|
21
|
+
# Invalid parameters were supplied to Stripe's API
|
22
|
+
rescue Stripe::AuthenticationError => e
|
23
|
+
# Authentication with Stripe's API failed
|
24
|
+
# (maybe you changed API keys recently)
|
25
|
+
rescue Stripe::APIConnectionError => e
|
26
|
+
# Network communication with Stripe failed
|
27
|
+
rescue Stripe::StripeError => e
|
28
|
+
# Display a very generic error to the user, and maybe send
|
29
|
+
# yourself an email
|
30
|
+
rescue => e
|
31
|
+
# Something else happened, completely unrelated to Stripe
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def show
|
36
|
+
render
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
# In the payload, the line items consists of list of items the customer is purchasing.
|
41
|
+
# Refer the guides to learn more about parameters accepted by the <line_items>
|
42
|
+
# https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items
|
43
|
+
#
|
44
|
+
# Sample: <line_items> looks like as follows:
|
45
|
+
# line_items: [{
|
46
|
+
# price_data: {
|
47
|
+
# currency: 'usd', # Three-letter ISO currency code, in lowercase
|
48
|
+
# product: <product_id> # Product ID created on stripe.
|
49
|
+
# product_data: { name: 'T-shirt' }, # Product Data (Either product_data or product is requried).
|
50
|
+
# unit_amount: 2000, # A non-negative integer in cents representing how much to charge
|
51
|
+
# },
|
52
|
+
# quantity: 1,
|
53
|
+
# }]
|
54
|
+
def checkout_payload
|
55
|
+
{
|
56
|
+
payment_method_types: ['card'], # https://stripe.com/docs/api/payment_methods/object#payment_method_object-type
|
57
|
+
line_items: @line_items || [],
|
58
|
+
mode: 'payment',
|
59
|
+
success_url: root_url, # <custom_success_path>
|
60
|
+
cancel_url: root_url, # <custom_cancellation_path>
|
61
|
+
}
|
62
|
+
end
|
63
|
+
end
|
data/lib/generators/boring/payments/stripe/install/templates/views/stripe/checkouts/create.js.erb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// TODO: Please update the stripe publishable key here.
|
2
|
+
var stripe = Stripe(ENV["STRIPE_PUBLISHABLE_KEY"]);
|
3
|
+
|
4
|
+
stripe.redirectToCheckout({
|
5
|
+
sessionId: "<%= @stripe_session.id %>"
|
6
|
+
}).then(function(result) {
|
7
|
+
// If `redirectToCheckout` fails due to a browser or network
|
8
|
+
// error, you should display the localized error message to your
|
9
|
+
// customer using `error.message`.
|
10
|
+
if (result.error) {
|
11
|
+
alert(result.error.message);
|
12
|
+
}
|
13
|
+
});
|
data/lib/generators/boring/payments/stripe/install/templates/views/stripe/checkouts/show.html.erb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<div style="text-align:center;">
|
2
|
+
<h1>Checkout View</h1>
|
3
|
+
<h5>(from <a href="https://github.com/abhaynikam/boring_generators">Boring Generator Gem</a>)</h5>
|
4
|
+
|
5
|
+
<%= button_to "Try Checkout", stripe_checkout_path, remote: true, class: "btn btn-primary" %>
|
6
|
+
<script src="https://js.stripe.com/v3/"></script>
|
7
|
+
</div>
|
8
|
+
|
@@ -7,15 +7,10 @@ module Boring
|
|
7
7
|
source_root File.expand_path("templates", __dir__)
|
8
8
|
|
9
9
|
def add_bullet_gem
|
10
|
-
say "Adding
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
gem "pry"
|
15
|
-
gem "pry-rails"
|
16
|
-
RUBY
|
17
|
-
append_to_file "Gemfile", pry_gem_content
|
18
|
-
run "bundle install"
|
10
|
+
say "Adding pry gems", :green
|
11
|
+
Bundler.with_unbundled_env do
|
12
|
+
run "bundle add pry pry-rails"
|
13
|
+
end
|
19
14
|
end
|
20
15
|
|
21
16
|
def add_pryrc_configuration
|
@@ -14,14 +14,8 @@ module Boring
|
|
14
14
|
|
15
15
|
def add_pundit_gem
|
16
16
|
say "Adding Pundit gem", :green
|
17
|
-
pundit_gem = <<~RUBY
|
18
|
-
\n
|
19
|
-
# for authorization
|
20
|
-
gem 'pundit', '~> 2.1'
|
21
|
-
RUBY
|
22
|
-
append_to_file "Gemfile", pundit_gem
|
23
17
|
Bundler.with_unbundled_env do
|
24
|
-
run "bundle
|
18
|
+
run "bundle add pundit"
|
25
19
|
end
|
26
20
|
end
|
27
21
|
|
@@ -23,7 +23,9 @@ module Boring
|
|
23
23
|
\tgem "rubocop-performance", require: false
|
24
24
|
RUBY
|
25
25
|
insert_into_file "Gemfile", bullet_gem_content, after: /group :development do/
|
26
|
-
|
26
|
+
Bundler.with_unbundled_env do
|
27
|
+
run "bundle install"
|
28
|
+
end
|
27
29
|
end
|
28
30
|
|
29
31
|
def add_rails_prefered_rubocop_rules
|
@@ -15,13 +15,9 @@ module Boring
|
|
15
15
|
|
16
16
|
def add_bullet_gem
|
17
17
|
say "Adding SimpleForm gem", :green
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
gem 'simple_form', '~> 5.0'
|
22
|
-
RUBY
|
23
|
-
append_to_file "Gemfile", simple_form_content
|
24
|
-
run "bundle install"
|
18
|
+
Bundler.with_unbundled_env do
|
19
|
+
run "bundle add simple_form"
|
20
|
+
end
|
25
21
|
end
|
26
22
|
|
27
23
|
def run_simple_form_generator
|
@@ -29,7 +25,7 @@ module Boring
|
|
29
25
|
|
30
26
|
say "Running SimpleForm Generator", :green
|
31
27
|
if options[:css_framework].present? && ALLOWED_CSS_FRAMEWORK.include?(options[:css_framework])
|
32
|
-
run "rails generate simple_form:install --#{options[:css_framework]}"
|
28
|
+
run "DISABLE_SPRING=1 bundle exec rails generate simple_form:install --#{options[:css_framework]}"
|
33
29
|
elsif options[:css_framework].present?
|
34
30
|
say <<~WARNING, :red
|
35
31
|
ERROR: Invalid option css_framework: #{options[:css_framework]}. Generator allows css_framework: #{ALLOWED_CSS_FRAMEWORK.join(", ")}
|
@@ -8,13 +8,9 @@ module Boring
|
|
8
8
|
|
9
9
|
def add_twilio_ruby_gem
|
10
10
|
say "Adding Twilio gem", :green
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
gem 'twilio-ruby', '~> 5.47'
|
15
|
-
RUBY
|
16
|
-
append_to_file "Gemfile", twilio_gem_content
|
17
|
-
run "bundle install"
|
11
|
+
Bundler.with_unbundled_env do
|
12
|
+
run "bundle add twilio-ruby"
|
13
|
+
end
|
18
14
|
end
|
19
15
|
|
20
16
|
def add_twilio_configurations
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boring_generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abhay Nikam
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -97,11 +97,10 @@ files:
|
|
97
97
|
- lib/generators/boring/oauth/twitter/install/templates/omniauth_callbacks_controller.rb
|
98
98
|
- lib/generators/boring/payments/stripe/install/install_generator.rb
|
99
99
|
- lib/generators/boring/payments/stripe/install/templates/README
|
100
|
-
- lib/generators/boring/payments/stripe/install/templates/controllers/
|
100
|
+
- lib/generators/boring/payments/stripe/install/templates/controllers/stripe/checkouts_controller.rb
|
101
101
|
- lib/generators/boring/payments/stripe/install/templates/stripe.rb
|
102
|
-
- lib/generators/boring/payments/stripe/install/templates/views/
|
103
|
-
- lib/generators/boring/payments/stripe/install/templates/views/
|
104
|
-
- lib/generators/boring/payments/stripe/install/templates/views/new.html.erb
|
102
|
+
- lib/generators/boring/payments/stripe/install/templates/views/stripe/checkouts/create.js.erb
|
103
|
+
- lib/generators/boring/payments/stripe/install/templates/views/stripe/checkouts/show.html.erb
|
105
104
|
- lib/generators/boring/pry/install/install_generator.rb
|
106
105
|
- lib/generators/boring/pry/install/templates/pryrc
|
107
106
|
- lib/generators/boring/pundit/install/install_generator.rb
|
data/lib/generators/boring/payments/stripe/install/templates/controllers/charges_controller.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class ChargesController < ApplicationController
|
4
|
-
def new
|
5
|
-
render
|
6
|
-
end
|
7
|
-
|
8
|
-
def create
|
9
|
-
if create_stripe_customer && create_stripe_charge
|
10
|
-
redirect_to root_path, flash: { success: "Boring stripe setup is successful" }
|
11
|
-
else
|
12
|
-
redirect_to new_charge_path, flash: { error: "Ugh. Something went wrong in setup." }
|
13
|
-
end
|
14
|
-
rescue Stripe::CardError => e
|
15
|
-
flash[:error] = e.message
|
16
|
-
redirect_to new_charge_path
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
def create_stripe_customer
|
21
|
-
@customer = Stripe::Customer.create({
|
22
|
-
email: params[:stripeEmail],
|
23
|
-
source: params[:stripeToken],
|
24
|
-
})
|
25
|
-
end
|
26
|
-
|
27
|
-
def create_stripe_charge
|
28
|
-
# Amount in cents
|
29
|
-
@amount = 500
|
30
|
-
|
31
|
-
Stripe::Charge.create({
|
32
|
-
customer: customer.id,
|
33
|
-
amount: @amount,
|
34
|
-
description: 'Rails Stripe customer',
|
35
|
-
currency: 'usd',
|
36
|
-
})
|
37
|
-
end
|
38
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<h2>Thanks, you paid <strong>$5.00</strong>!</h2>
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<%= form_tag charges_path do %>
|
2
|
-
<article>
|
3
|
-
<% if flash[:error].present? %>
|
4
|
-
<div id="error_explanation">
|
5
|
-
<p><%= flash[:error] %></p>
|
6
|
-
</div>
|
7
|
-
<% end %>
|
8
|
-
|
9
|
-
<label class="amount">
|
10
|
-
<span>Amount: $5.00</span>
|
11
|
-
</label>
|
12
|
-
</article>
|
13
|
-
|
14
|
-
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
|
15
|
-
data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
|
16
|
-
data-description="A month's subscription"
|
17
|
-
data-amount="500"
|
18
|
-
data-locale="auto"></script>
|
19
|
-
<% end %>
|