From 8be97f9f3f5ad8bb2110dda28bfb799bf3c48fe5 Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Wed, 26 Aug 2026 22:15:51 +0200 Subject: [PATCH] chore(deps): remove dead Stripe Checkout v1 code and gem --- Gemfile | 2 - Gemfile.lock | 3 -- app/assets/javascripts/payments.js | 48 ------------------ app/controllers/payments_controller.rb | 32 ------------ app/views/payments/create.html.haml | 1 - config/initializers/assets.rb | 1 - config/initializers/stripe.rb | 6 --- config/routes.rb | 1 - spec/controllers/payments_controller_spec.rb | 51 -------------------- 9 files changed, 145 deletions(-) delete mode 100644 app/assets/javascripts/payments.js delete mode 100644 app/controllers/payments_controller.rb delete mode 100644 app/views/payments/create.html.haml delete mode 100644 config/initializers/stripe.rb delete mode 100644 spec/controllers/payments_controller_spec.rb diff --git a/Gemfile b/Gemfile index 8f5e62ce8..d32c267f9 100644 --- a/Gemfile +++ b/Gemfile @@ -63,8 +63,6 @@ gem 'commonmarker' gem 'faraday' gem 'msgpack' -gem 'stripe' - gem 'rails-html-sanitizer', '~> 1.7.1' # Use the Puma web server [https://github.com/puma/puma] diff --git a/Gemfile.lock b/Gemfile.lock index ab76d6f92..3624f8f5e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -564,7 +564,6 @@ GEM ssrf_filter (1.5.0) stimulus-rails (1.3.4) railties (>= 6.0.0) - stripe (9.0.0) strong_migrations (2.8.0) activerecord (>= 7.2) sysexits (1.2.0) @@ -701,7 +700,6 @@ DEPENDENCIES solid_cache (~> 1.0) sprockets-rails stimulus-rails - stripe strong_migrations terser turbo-rails @@ -922,7 +920,6 @@ CHECKSUMS sprockets-rails (3.5.2) sha256=a9e88e6ce9f8c912d349aa5401509165ec42326baf9e942a85de4b76dbc4119e ssrf_filter (1.5.0) sha256=e03dcdb9d1730d7f6710532a606b3543df2a448a0293ce04a2d995523c5a97f6 stimulus-rails (1.3.4) sha256=765676ffa1f33af64ce026d26b48e8ffb2e0b94e0f50e9119e11d6107d67cb06 - stripe (9.0.0) sha256=71dda83b8428615c755b72b17469ad213e5ce6cf074aae2b45ce3ea1137abdde strong_migrations (2.8.0) sha256=cb9c0f8160e60f3e9c0e76098d57a6f61825b9618e8eb41cebbd1c1079874439 sysexits (1.2.0) sha256=598241c4ae57baa403c125182dfdcc0d1ac4c0fb606dd47fbed57e4aaf795662 temple (0.10.7) sha256=369fe560adb6534674ce232899c2232df614bcb29c5359b05efedff7a57ed9c0 diff --git a/app/assets/javascripts/payments.js b/app/assets/javascripts/payments.js deleted file mode 100644 index 7bfbd27d3..000000000 --- a/app/assets/javascripts/payments.js +++ /dev/null @@ -1,48 +0,0 @@ -$(function() { - var handler = StripeCheckout.configure({ - key: stripePublishableKey, - image: "https://avatars1.githubusercontent.com/u/5642384?v=3&s=300", - currency: 'GBP', - token: function(token) { - var name = $('#payment_name').val(); - var amount = $('#payment_amount').val(); - $.ajax({ - type: "POST", - url: '/payments', - data: { - payment: { - amount: amount*100, - name: name, - stripe_email: token.email, - stripe_token_id: token.id - } - } - }).done(function(response) { - $('.payment-container').html(response); - }).fail(function(xhr, status, e){ - $('.message').html("Your transaction has not been succesful. Please try again."); - }); - } - }); - - $('#donate').on('click', function(e) { - var amount = $('#payment_amount').val(); - if (!$.isNumeric(amount)) { - $('.message').html("You have not entered a valid amount."); - return; - } - - $('.message').html(""); - - handler.open({ - name: 'codebar', - description: 'Donation of £' + amount, - amount: amount*100 - }); - e.preventDefault(); - }); - - $(window).on('popstate', function() { - handler.close(); - }); -}); diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb deleted file mode 100644 index 702fd755d..000000000 --- a/app/controllers/payments_controller.rb +++ /dev/null @@ -1,32 +0,0 @@ -class PaymentsController < ApplicationController - before_action :require_login - - def new; end - - def create - payment_params = params.expect(payment: %i[amount name stripe_email stripe_token_id]) - - @amount = payment_params[:amount] - - customer = Stripe::Customer.create( - email: payment_params[:stripe_email], - description: payment_params[:name], - source: payment_params[:stripe_token_id] - ) - - charge_customer(customer, @amount) - - render layout: false - end - - private - - def charge_customer(customer, amount) - Stripe::Charge.create( - amount: amount, - description: 'Payment to codebar', - currency: 'gbp', - customer: customer.id - ) - end -end diff --git a/app/views/payments/create.html.haml b/app/views/payments/create.html.haml deleted file mode 100644 index cff40047b..000000000 --- a/app/views/payments/create.html.haml +++ /dev/null @@ -1 +0,0 @@ -Payment processed diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index ab4ccd063..5c2dc7b81 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -6,6 +6,5 @@ # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path Rails.application.config.assets.precompile += %w( - payments.js admin/tom-select-init.js ) diff --git a/config/initializers/stripe.rb b/config/initializers/stripe.rb deleted file mode 100644 index b0e479a0b..000000000 --- a/config/initializers/stripe.rb +++ /dev/null @@ -1,6 +0,0 @@ -Rails.configuration.stripe = { - publishable_key: ENV['STRIPE_PUBLISHABLE_KEY'], - secret_key: ENV['STRIPE_SECRET_KEY'] -} - -Stripe.api_key = Rails.configuration.stripe[:secret_key] diff --git a/config/routes.rb b/config/routes.rb index a7f8ded7c..ebcd1a730 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -173,7 +173,6 @@ resources :sponsors, only: [:index] resources :donations, only: %i[new] - resources :payments, only: %i[new create] get 'cookie-policy' => 'pages#show', id: 'cookie-policy' get 'privacy-policy' => 'pages#show', id: 'privacy-policy' diff --git a/spec/controllers/payments_controller_spec.rb b/spec/controllers/payments_controller_spec.rb deleted file mode 100644 index 026f75492..000000000 --- a/spec/controllers/payments_controller_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -RSpec.describe PaymentsController do - let(:member) { Fabricate(:member) } - - before do - login(member) - allow(Stripe::Customer).to receive(:create).and_return(double(id: 'cus_123')) - allow(Stripe::Charge).to receive(:create).and_return(true) - end - - describe 'POST #create' do - context 'with valid parameters' do - it 'creates a Stripe customer and charge' do - allow(Stripe::Customer).to receive(:create).with( - email: 'john@example.com', - description: 'John Doe', - source: 'tok_123' - ).and_return(double(id: 'cus_123')) - - post :create, params: { - payment: { - amount: '1000', - name: 'John Doe', - stripe_email: 'john@example.com', - stripe_token_id: 'tok_123' - } - } - expect(response).to be_successful - expect(Stripe::Customer).to have_received(:create).with( - email: 'john@example.com', - description: 'John Doe', - source: 'tok_123' - ) - end - end - - context 'with parameter filtering' do - it 'filters unpermitted parameters' do - post :create, params: { - payment: { - amount: '1000', - name: 'John', - stripe_email: 'john@example.com', - stripe_token_id: 'tok_123' - }, - hacker_field: 'malicious' - } - expect(response).to be_successful - end - end - end -end