בעיות במנויים, מצב בדיקה ואופציית חיוב

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 לייקים

Yep, totally okay for cleaning up test user subscriptions.

אגב, אחת הבעיות שהיו לי עם המנויים היא שזה באמת עושה רק מנויים (!) זה לא כל כך טוב בהוספת קצת סחורה אקראית (ספלים, חולצות וכו’).. אפשר לומר שזה יכול לעשות את זה, אבל ההצגה באמצעות טבלאות מחירים לא באמת עובדת יחד עם המנויים האמיתיים. (ויש מגבלה של 4 מוצרים)

לכן, הצלתי למצוא דרך להוסיף כפתור שמתאים לדף המאפשר להכניס טבלת מחירים לדף, מה שמסיר את הגבולות על מספר טבלאות המחירים שניתן להשתמש בהן וזה מאפשר להשתמש בהן בתוך הדפים עצמם.. מה שמקנה להן הקשר כלשהו. (דף המנויים מרגיש קצת ‘מחוץ’ להקשר מבחינת ההבנה של המשתמש למה הוא נכנס כשמחנים על ‘קנה’.. :חייכן: )

זה בערך 25 שורות ומבוצע דרך הממשק כמנהל.. בלי תוספים חיצוניים.. מרגיש כמו פתרון שימושי כללי שלא הצלחתי למצוא במקום אחר.. איפה יהיה המקום הטוב ביותר לפרסמו לציבור?