diff --git a/app/controllers/patrons_controller.rb b/app/controllers/patrons_controller.rb
deleted file mode 100644
index 8fedefe..0000000
--- a/app/controllers/patrons_controller.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-# frozen_string_literal: true
-
-module DiscourseSubscriptions
- class PatronsController < ::ApplicationController
- include DiscourseSubscriptions::Stripe
-
- skip_before_action :verify_authenticity_token, only: [:create]
- before_action :set_api_key
-
- def index
- result = { email: '' }
-
- if current_user
- result[:email] = current_user.email
- end
-
- render json: result
- end
-
- def create
- begin
-
- response = ::Stripe::PaymentIntent.create(
- amount: param_currency_to_number,
- currency: SiteSetting.discourse_subscriptions_currency,
- payment_method_types: ['card'],
- payment_method: params[:payment_method_id],
- description: SiteSetting.discourse_patrons_payment_description,
- receipt_email: params[:receipt_email],
- confirm: true,
- metadata: { user_id: user_id }
- )
-
- rescue ::Stripe::InvalidRequestError => e
- response = { error: e }
- rescue ::Stripe::CardError => e
- response = { error: 'Card Declined' }
- end
-
- render json: response
- end
-
- private
-
- def param_currency_to_number
- params[:amount].to_s.sub('.', '').to_i
- end
-
- def user_id
- if current_user
- current_user.id
- end
- end
- end
-end
diff --git a/assets/javascripts/discourse/templates/components/donation-form.hbs b/assets/javascripts/discourse/templates/components/donation-form.hbs
deleted file mode 100644
index 6a060f2..0000000
--- a/assets/javascripts/discourse/templates/components/donation-form.hbs
+++ /dev/null
@@ -1,110 +0,0 @@
-
-{{#if confirmation}}
- {{#d-modal closeModal=(action "closeModal") modalStyle="inline-modal" title=(i18n "discourse_subscriptions.one_time.payment.payment_confirmation")}}
- {{#d-modal-body}}
-
-
-
-
- {{i18n 'discourse_subscriptions.billing.name'}} |
- {{billing.name}} |
-
-
- {{i18n 'discourse_subscriptions.billing.email'}} |
- {{billing.email}} |
-
-
- {{i18n 'discourse_subscriptions.billing.phone'}} |
- {{billing.phone}} |
-
-
-
-
-
-
- {{i18n 'discourse_subscriptions.confirmation.amount'}} |
- {{format-curency amount}} |
-
-
- {{i18n 'discourse_subscriptions.confirmation.last4'}} |
- .... .... .... {{last4}} |
-
-
-
-
- {{/d-modal-body}}
-
-
-
- {{/d-modal}}
-
- {{#if paymentError}}
-
- {{/if}}
-
-{{else}}
-
-
-
{{i18n 'discourse_subscriptions.one_time.payment.your_information'}}
-
-
-
-
- {{i18n 'discourse_subscriptions.billing.name'}}
-
-
- {{input value=billing.name}}
-
{{i18n 'discourse_subscriptions.one_time.payment.optional'}}
-
-
-
-
- {{i18n 'discourse_subscriptions.billing.email'}}
-
-
- {{input type="email" value=billing.email}}
-
{{i18n 'discourse_subscriptions.one_time.payment.receipt_info'}}
-
-
-
-
- {{i18n 'discourse_subscriptions.billing.phone'}}
-
-
- {{input value=billing.phone}}
-
{{i18n 'discourse_subscriptions.one_time.payment.optional'}}
-
-
-
-
-
-
-
{{i18n 'discourse_subscriptions.one_time.payment.payment_information'}}
-
-
-
-
- {{i18n 'discourse_subscriptions.one_time.amount'}}
- {{siteSettings.discourse_subscriptions_currency}}
-
-
- {{combo-box valueAttribute="value" content=amounts value=amount}}
-
-
-
-
- {{stripe-card
- amount=amount
- currency=currency
- billing=billing
- handleConfirmStripeCard=(action "handleConfirmStripeCard")
- }}
-
-
-{{/if}}
diff --git a/spec/controllers/discourse_patrons/patrons_controller_spec.rb b/spec/controllers/discourse_patrons/patrons_controller_spec.rb
deleted file mode 100644
index 970c9dd..0000000
--- a/spec/controllers/discourse_patrons/patrons_controller_spec.rb
+++ /dev/null
@@ -1,107 +0,0 @@
-# frozen_string_literal: true
-
-require 'rails_helper'
-
-module DiscourseSubscriptions
- RSpec.describe PatronsController, type: :controller do
- routes { DiscourseSubscriptions::Engine.routes }
-
- describe 'index' do
- it 'responds ok' do
- get :index, format: :json
- expect(response).to have_http_status(200)
- end
-
- it 'has a current user email' do
- user = Fabricate(:user, email: 'hello@example.com')
- controller.expects(:current_user).at_least(1).returns(user)
-
- get :index, format: :json
-
- expect(JSON.parse(response.body)['email']).to eq 'hello@example.com'
- end
-
- it 'has no current user email' do
- get :index, format: :json
- expect(JSON.parse(response.body)['email']).to be_empty
- end
- end
-
- describe 'create' do
- let!(:current_user) { Fabricate(:user) }
-
- let(:payment) do
- {
- id: 'xyz-1234',
- charges: { url: '/v1/charges?payment_intent=xyz-1234' },
- amount: 9000,
- receipt_email: 'hello@example.com',
- currency: 'aud',
- metadata: { user_id: current_user.id }
- }
- end
-
- before do
- SiteSetting.stubs(:discourse_subscriptions_currency).returns('AUD')
- SiteSetting.stubs(:discourse_subscriptions_secret_key).returns('xyz-678')
- controller.stubs(:current_user).returns(current_user)
- end
-
- it 'responds ok' do
- ::Stripe::PaymentIntent.expects(:create).returns(payment)
- post :create, params: { receipt_email: 'hello@example.com', amount: '20.00' }, format: :json
- expect(response).to have_http_status(200)
- end
-
- it 'has no user' do
- controller.stubs(:current_user).returns(nil)
- ::Stripe::PaymentIntent.expects(:create).returns(payment)
- post :create, format: :json
- expect(response).to have_http_status(200)
- end
-
- it 'has the correct amount' do
- ::Stripe::PaymentIntent.expects(:create).with(has_entry(:amount, 2000)).returns(payment)
- post :create, params: { amount: '20.00' }, format: :json
- expect(response).to have_http_status(200)
- end
-
- it 'has no amount' do
- ::Stripe::PaymentIntent.expects(:create).with(has_entry(:amount, 0)).returns(payment)
- post :create, params: {}, format: :json
- expect(response).to have_http_status(200)
- end
-
- it 'has curency' do
- ::Stripe::PaymentIntent.expects(:create).with(has_entry(:currency, 'AUD')).returns(payment)
- post :create, params: {}, format: :json
- expect(response).to have_http_status(200)
- end
-
- it 'has the user id' do
- ::Stripe::PaymentIntent.expects(:create).with(has_entry(:metadata, user_id: current_user.id)).returns(payment)
- post :create, params: {}, format: :json
- expect(response).to have_http_status(200)
- end
-
- it 'has a receipt email' do
- ::Stripe::PaymentIntent.expects(:create).with(has_entry(:receipt_email, 'hello@example.com')).returns(payment)
- post :create, params: { receipt_email: 'hello@example.com' }, format: :json
- expect(response).to have_http_status(200)
- end
-
- it 'has a payment method' do
- ::Stripe::PaymentIntent.expects(:create).with(has_entry(:payment_method, 'xyz-1234')).returns(payment)
- post :create, params: { payment_method_id: 'xyz-1234' }, format: :json
- expect(response).to have_http_status(200)
- end
-
- it 'has a description' do
- SiteSetting.stubs(:discourse_patrons_payment_description).returns('hello-world')
- ::Stripe::PaymentIntent.expects(:create).with(has_entry(:description, 'hello-world')).returns(payment)
- post :create, params: {}, format: :json
- expect(response).to have_http_status(200)
- end
- end
- end
-end
diff --git a/test/javascripts/components/donation-form-test.js.es6 b/test/javascripts/components/donation-form-test.js.es6
deleted file mode 100644
index fcb21fe..0000000
--- a/test/javascripts/components/donation-form-test.js.es6
+++ /dev/null
@@ -1,49 +0,0 @@
-import componentTest from "helpers/component-test";
-
-moduleForComponent("donation-form", { integration: true });
-
-componentTest("Discourse Patrons donation form has content", {
- template: `{{donation-form}}`,
-
- beforeEach() {
- this.registry.register(
- "component:stripe-card",
- Ember.Component.extend({ tagName: "dummy-component-tag" })
- );
- Discourse.SiteSettings.discourse_patrons_amounts = "1.00|2.01";
- },
-
- async test(assert) {
- assert.ok(
- find(".discourse-patrons-section-columns").length,
- "The card section renders"
- );
- assert.ok(
- find("dummy-component-tag").length,
- "The stripe component renders"
- );
- }
-});
-
-componentTest("donation form has a confirmation", {
- template: `{{donation-form confirmation=confirmation}}`,
-
- beforeEach() {
- this.registry.register("component:stripe-card", Ember.Component.extend());
- Discourse.SiteSettings.discourse_patrons_amounts = "1.00|2.01";
- },
-
- async skip(assert) {
- this.set("confirmation", { card: { last4: "4242" } });
-
- const confirmExists = find(".discourse-patrons-confirmation").length;
-
- assert.ok(confirmExists, "The confirmation form renders");
-
- const last4 = find(".discourse-patrons-last4")
- .text()
- .trim();
-
- assert.equal(last4, ".... .... .... 4242", "The last 4 digits are correct");
- }
-});