Forcing a discourse subscription to be a one-off payment

AI-generated summary

The discussion revolves around forcing a Discourse subscription to be a one-off payment. MrDavis97 initially asks if it’s possible to change an existing subscription to a one-off payment by modifying settings in Stripe. justin responds that Discourse allows one-time payments by unchecking the recurring checkbox when creating a plan.

However, MrDavis97 clarifies that he wants a one-off payment that terminates after a set period, similar to a “day-pass.” justin states that this is not currently possible.

[pfaffman](/t/-/182582/5 and /t/-/182582/6) offers a potential solution by creating a custom plugin that adds a user to a group and then removes them after a set period. He also provides an example of how to implement this using Rails callbacks.

Alex_王 reports that they have solved the problem by modifying the Discourse subscription plugin. However, they also mention an issue with deleting products, which pfaffman advises is not necessary as they serve as a record of sold items.

anon65426961 notes that Stripe products cannot be deleted but can be deactivated/archived. In a later post, anon65426961 inquires about the status of MrDavis97’s initial question, suggesting that implementing a “day-pass” system might require a custom solution.

Regarding the Discourse Subscriptions plugin, what would happen if I changed some settings from Stripe itself? For example, from Discourse it’s not possible to make a plan for a product a one-off payment. It has to be a day, week, month, or year-long subscription. But if I go into stripe.com I can change an existing subscription to a one-off payment. Can I do this? How would this change how that plan functions in Discourse? Would it then be a one-off payment?

It most definitely is possible! If you uncheck the recurring checkbox in the plan creation screen, it will be a one time payment.

However, you cannot change existing plans once they’re created.

You’re right! I had a brain fart. What I actually meant to ask is whether it’s possible or not to have a one-off payment that terminates, and doesn’t go on indefinitely. For example, something like a “day-pass,” where you pay $5 and are put into a special group, and then after, say, a day, the subscription terminates and you’re then eliminated from the group until you pay again. Is this possible?

It is not at this time, unfortunately.

I do something like that in a plugin. I (loosely) add to the user_group model an action that when a user is added to the subscription group, does an action, and then removes the user from the group. In your case, you’d make it so when the subscription added the user to the one-off-weeklong group it would

  • add the user to the weeklong group that gives permission to whatever categories
  • add a job that will delete them from the weeklong group when the week is up
  • add a user custom field with the date the week started so you could delete them if you have some redis disaster
  • remove them from the one-off-weeklong group.

If you’re interested in such, you can contact me or post in Marketplace .

But that’s silly. Instead, just add a callback for the subscription (if it’s subscription) or customer (if it’s a one-time payment). Customer is sort of a misnomer. It has the stripe customer ID and the stripe product ID. So do something like

add_model_callback(DiscourseSubscriptions::Subscription, :after_save) do
      Rails.logger.warn("Now got a subscription #{self.external_id} for #{self.customer_id}")
      # do stuff
end

  add_model_callback(DiscourseSubscriptions::Customer, :after_save) do
    Rails.logger.warn("Customer #{self.product_id} for #{self.user_id}")
    # do more stuuff
end

Hi have you solved this problem?

Can you provide more guidance? like how to implement this feature. I’m not familiar with Rails..thanks!

I think that’s my best free answer.

I have solved it by modify the discourse subscription plugin. Thanks.

But I found that I cannot delete products even using the original discourse subscription plugin. Do you have any idea?

You don’t need to delete them. They don’t hurt anything. They are needed as a record of things they you have sold. You should be able to delete them from the stripe console.

Stripe doesn’t allow products to be deleted either, but they can be deactivated/archived.

They say:

Don’t know if this is still something you want to achieve, or if you’ve found a way to do this? Sounds like it isn’t something that is built in to be automated with discourse, but may be some other way to do this. Seems sort of like a coffee shop kind of deal where you have to buy a new beverage every day to be able to sit at one of their tables.