Problem Subscriptions, test mode and billing option

Hi,

I’m trying to use subscriptions (pricing table) on my self hosted instance. I’ve setup and tested on Stripe test mode, however when I go to live, although it seems to work, the “billing” tab in my profile is now reporting an error.

:frowning:
Error
while trying to load /s/user/subscriptions
Something went wrong.

When I punch up the javascript console I see;

“a similar object exists in test mode, but a live mode key was used”

This makes me think there is a consistency issue when switching between modes. Now I know this is an issue, I can be careful about which accounts I test on, but my question is, how do I clear this issue for users who subscribed in test mode, who now want to make a real subscription in live mode?

(i.e. how do I clear this error)

Is there will be a database query I can run or something similar to clear down all subscriptions for a user, including those that might cause a problem?
Thanks.

Ok, so I think I’ve fixed it (!)

In summary, using test mode seems to have left artifacts against users who tried test subscriptions, I’m guessing the subscriptions weren’t cancelled in the right or expected way. On switching into production mode, the billing tab errors.

What I’ve tried …

First, don’t take this absolutely literally, I’m mostly guessing based on other posts and these are the commands I used however I might have used literals and had to repeat a few … but this is the general gist;

./launcher enter app
rails c
u = User.find_by_username(<username>)
c = DiscourseSubscriptions::Customer.find_by(user_id: u.id)
subscription = DiscourseSubscriptions::Subscription.where(customer_id: c[:customer_id])
subscription.destroy_all
c.destroy

It seems “subscription.destroy_all” removes hanging external references to Stripe, and “c.destroy” removes the local subscription. Was this Ok, or have I broken something under the hood?

3 Likes

Yep, totally okay for cleaning up test user subscriptions.

Incidentally one of the issues I has with Subscriptions is that it really only does subscriptions (!) it’s not so great at adding a bit of random Merch (mugs, T-shirts etc) … arguably is can do this, but the presentation using pricing tables doesn’t really work alongside actual subscriptions. (and there’s a 4-product limit)

To that end I’ve managed to come up with a way to add a “button” into a page that inserts “a” pricing table into “a” page, which removes limits on the number of pricing tables you can use and it means you can use them in-line in pages … which gives them some context. (The subscriptions page feels a little “out” of context in terms of making sure the user knows what they’re in for when they click on “buy” … :slight_smile: )

It’s about 25 lines and done via the UI as Admin … no external plugins necessary … feels like a generically useful solution that I couldn’t source elsewhere … where would be the best place to post it for public consumption?