diff --git a/README.md b/README.md index 2085679..326b7d4 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,12 @@ In the admin, add a new Product. Once you have a product saved, you can add plan If you take a look at your [Stripe Dashboard](https://dashboard.stripe.com), you'll see all those products and plans are listed. Discourse Subscriptions does not create them locally. They are created in Stripe. +## Enable Webhooks + +You'll need to tell Stripe where your end points are. You can enter this in your Stripe dashboard. + +The address for webhooks is: `/s/hooks` + ## Testing Test with these credit card numbers: diff --git a/app/controllers/hooks_controller.rb b/app/controllers/hooks_controller.rb new file mode 100644 index 0000000..926f01d --- /dev/null +++ b/app/controllers/hooks_controller.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module DiscourseSubscriptions + class HooksController < ::ApplicationController + def create + head 200 + end + end +end diff --git a/config/routes.rb b/config/routes.rb index 13cb24c..06d8469 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,6 +18,7 @@ DiscourseSubscriptions::Engine.routes.draw do end resources :customers, only: [:create] + resources :hooks, only: [:create] resources :invoices, only: [:index] resources :payments, only: [:create] resources :plans, only: [:index] diff --git a/plugin.rb b/plugin.rb index 84db1c6..67d8cf9 100644 --- a/plugin.rb +++ b/plugin.rb @@ -2,7 +2,7 @@ # name: discourse-subscriptions # about: Integrates Stripe into Discourse to allow visitors to subscribe -# version: 2.7.0 +# version: 2.7.1 # url: https://github.com/rimian/discourse-subscriptions # authors: Rimian Perkins @@ -44,7 +44,7 @@ after_initialize do ::Stripe.set_app_info( 'Discourse Subscriptions', - version: '2.7.0', + version: '2.7.1', url: 'https://github.com/rimian/discourse-subscriptions' ) @@ -60,6 +60,7 @@ after_initialize do "../app/controllers/user/payments_controller", "../app/controllers/user/subscriptions_controller", "../app/controllers/customers_controller", + "../app/controllers/hooks_controller", "../app/controllers/invoices_controller", "../app/controllers/plans_controller", "../app/controllers/payments_controller", diff --git a/spec/requests/hooks_controller_spec.rb b/spec/requests/hooks_controller_spec.rb new file mode 100644 index 0000000..f7687d8 --- /dev/null +++ b/spec/requests/hooks_controller_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'rails_helper' + +module DiscourseSubscriptions + RSpec.describe HooksController do + it "responds ok" do + post "/s/hooks.json" + expect(response.status).to eq 200 + end + end +end