Skip to content

Commit

Permalink
feat(checkout): verify with google recaptcha
Browse files Browse the repository at this point in the history
  • Loading branch information
castrolem committed Nov 21, 2019
1 parent ca4af38 commit f3a178b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/checkout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@
.StripeElement--webkit-autofill {
background-color: #fefde5 !important;
}

.g-recaptcha {
margin-bottom: 1rem;;
}
2 changes: 2 additions & 0 deletions app/controllers/subscription_charges_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def create

amount = (@subscription.plan.amount * 100).to_i

return unless verify_recaptcha(model: @subscription)

charge = Stripe::Charge.create(
customer: customer.id,
amount: amount, # amount in cents
Expand Down
4 changes: 2 additions & 2 deletions config/initializers/recaptcha.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

Recaptcha.configure do |config|
config.site_key = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
config.secret_key = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
config.site_key = ENV['RECAPTCHA_SITE_KEY']
config.secret_key = ENV['RECAPTCHA_SECRET_KEY']
end

0 comments on commit f3a178b

Please sign in to comment.