Adding new controllers and routes to Discourse-subscriptions plugin

I need help, I’m used to create fullstack applications but regarding ember and rails I’m still a beginner.

I want to add another payment method (bank transfer) to the discourse-subscriptions plugin. I already managed to create some new routes and add some features to it, but I’m struggling to add a new controller to the /discourse_subscriptions/ controllers directory and make it work properly.

I want to set up a ruby controller that will act as a server and an ember template as my client the structure is as follows:


after creating the payment intent, the payment_intent controller must return the necessary payment instructions to the client.
more details: Stripe - accept bank transfers

I have already created new pages by adding methods in the subscribe_controller.rb file in the discourse_subscriptions/ controller folder but when I try to create another controller (the server) it doesn’t work, it displays a 404 error, however in the ember inspector I see that the route actually exists (yes it is really confusing).

NB I created all the corresponding routes and their method types in the route.rb and subscriptions-route-map.js files.

I created a ruby payment_intent controller and a corresponding route, the controller should receive a post request from the client and generate a Stripe payment intent based on the data received with the post request, after the payment intent is created it should return the necessary payment instructions to the client.
On the client side, I have a small form with a submit button.

I can’t establish the communication between this controller and the client page (server-client), the fact that there are two controllers( rails and ember) is a bit confusing.


Great progress. As your first foray into Discourse plugin dev, this is definitely ambitious. The upside of that is the sense of achievement and utility you will get once you get this working. The risk you run here is you are biting so much off in one go it might put you off continuing to work on the platform. The Ember/Rails combo is quite a lot to take on, especially initially, keep going!

Some tips for the time being:

  • Tackle things in chunks.
  • Pushing the fork to GitHub, then permalinking sections of code here might help the community see what you are doing more clearly.
  • First worry about the down data from your Rails controller, check that by addressing the rails route with .json on the end of the http address to see the raw data that is being passed down to the client. That will prove out the Rails side of the GET.
  • Think of the Ember Controller as the module to handle “in interface actions” and stuff that might have to be pushed back up to the back-end (You can handle actions on Routes too, but I digress! :D)
  • The Ember Router connects the back-end to the rest of the front end, setting up the model for the Template, it’s Components and/or Controller to consume.
  • Use prior art, go through all the official and Pavilion plugins on GitHub to see how things are done for similar actions/purposes. It’s all open source, leverage it, copy it, follow the conventions (especially those on Discourse core!)! :slight_smile:

Thank you, I will follow your advice and keep you informed :slightly_smiling_face:

1 Like

I have deleted all wath i did yesterday and i have started back from zero. Let me show you what i have already done up till now and the problem(s) i am currently facing. For the moment i don’t really care about editing the /locales .yml files i have hard-coded all the text, and i also decided to use classic html rather than handlebar (I’ll come back to it once I have something that works)

  1. I have added the bank transfer option
      <h3>Bank Transfer</h3>
      <form action="/payment_intent" method="post">
       <!-- some data-->
        <input type="submit" value="Next" class="btn btn-primary ">
  1. I have created a payment_intent controller
module DiscourseSubscriptions
    class PaymentIntentsController < ::ApplicationController
      include DiscourseSubscriptions::Stripe
      include DiscourseSubscriptions::Group
      before_action :set_api_key
      requires_login except: [:index, :contributors, :show]

      def create
        params.require([:source, :plan])
          #customer = find_or_create_customer(params[:source])
          # create a test payment intent
          bk_payment_intent = Stripe::PaymentIntent.create({
            amount: 1099,
            currency: 'eur'  

          render json: payment_intent
  1. It’s route
 resources :payment_intents, only: %i[create]

But when i run the project and go to the ember inspector it tells me the route doesn’t exist

And after that what would be the best way to handle the form submission ? should i create another ember controller,use the subscribe-show.js controller or add a script tag within the subscribe/show.hbs?

You need an Ember route for this screen and an Ember controller. I don’t see one here, so “another”?

Be sure to look at:

Ember.js Guides - Guides and Tutorials - Ember Guides (

And take a look at the code for the user preferences screens, which is a basic set of forms.


Ok. thank you for your reply