# Subscriptions: Deleted data in Stripe, now plugin errors

**URL:** https://meta.discourse.org/t/subscriptions-deleted-data-in-stripe-now-plugin-errors/175528
**Category:** Support
**Tags:** subscriptions
**Created:** [January 8, 2021, 5:59pm UTC](https://meta.discourse.org/t/subscriptions-deleted-data-in-stripe-now-plugin-errors/175528 "2021-01-08T17:59:08Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![thethirdpudding](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thethirdpudding/32/86901_2.png) [@thethirdpudding](https://meta.discourse.org/u/thethirdpudding)
#### Post date: [January 8, 2021, 5:59pm UTC](https://meta.discourse.org/t/subscriptions-deleted-data-in-stripe-now-plugin-errors/175528/1 "2021-01-08T17:59:08Z")

</div>

Hi,

I’m currently trying out this plugin for future usage on my instance and had an issue.

My Stripe account is new and not verified which means it’s using test data that I can wipe on the Stripe dashboard \> Developers.  
The issue is that wiping the data on Stripe doesn’t delete the same data on the forum instance. This can result in a crash of the Billing \> Payment page of a user.

### Step to reproduce

1. Create a subscription plan
2. Subscribe a user to the plan. Stripe will give him a `customer_id` such as `cus_abcd1234567890`
3. Wipe the data on the Stripe dashboard
4. Retry to open the user’s Billing page will result to a crash while loading `/s/user/payment` with the following response text in the web browser console:  
`{\"errors\":[\"No such customer: 'cus_abcd1234567890'\"]}`

* * *

After exploring the database of my instance, I can find previous data from multiple wipes I did in the following tables:

- `discourse_subscriptions_customers` : causes a crash for user billing page
- `discourse_subscriptions_products`
- `discourse_subscriptions_subscriptions`

The last 2 tables don’t seem to trigger a crash. However, they still contain expired data.

Manually deleting the problematic row(s) in `discourse_subscriptions_customers` fixes the crash of the user. But having to do it via SQL request is complicated and dangerous, especially for inexperienced users.

It can be also noted that this issue doesn’t occur when manually deleting the user info from Stripe dashboard. Stripe still keep archived info about him and mark him as “permanently deleted”.

### Proposed solutions

If possible, make a way for Stripe to let Discourse know that the test data was wiped, and it should delete the data in those tables.

Or,

In the plugin options, create a button to “wipe the test data” with a big red warning label to make sure the admin knows what he’s doing.

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [January 8, 2021, 6:04pm UTC](https://meta.discourse.org/t/subscriptions-deleted-data-in-stripe-now-plugin-errors/175528/2 "2021-01-08T18:04:09Z")

</div>

This seems like a bit of an edge case, and not something I’m at this time interested in handling in the plugin. To fix the errors you’re seeing, you’ll have to do this from inside the container:

```plaintext
rails c
DiscourseSubscriptions::Customer.destroy_all
DiscourseSubscriptions::Products.destroy_all
DiscourseSubscriptions::Subscriptions.destroy_all

```

This will reset all the local models, which are used to compare to Stripe.

My recommendation going forward: delete data from Discourse versus from Stripe. If model records don’t exist in Discourse, it won’t pull in the data from Stripe.

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [January 8, 2021, 7:09pm UTC](https://meta.discourse.org/t/subscriptions-deleted-data-in-stripe-now-plugin-errors/175528/3 "2021-01-08T19:09:23Z")

</div>

A post was split to a new topic: [Issue with /s/user/payments](https://meta.discourse.org/t/issue-with-s-user-payments/175536)

---

<div class="post-metadata">

### Author: ![thethirdpudding](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thethirdpudding/32/86901_2.png) [@thethirdpudding](https://meta.discourse.org/u/thethirdpudding)
#### Post date: [January 10, 2021, 6:08pm UTC](https://meta.discourse.org/t/subscriptions-deleted-data-in-stripe-now-plugin-errors/175528/4 "2021-01-10T18:08:56Z")

</div>

Thanks for the suggestion. I tested it and it works beside a small typo: there’s no `s` at the end of `::Product` and `::Subscription`. Otherwise, it can’t find them.

Corrected commands:

```plaintext
rails c
DiscourseSubscriptions::Customer.destroy_all
DiscourseSubscriptions::Product.destroy_all
DiscourseSubscriptions::Subscription.destroy_all

```

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [January 10, 2021, 10:21pm UTC](https://meta.discourse.org/t/subscriptions-deleted-data-in-stripe-now-plugin-errors/175528/5 "2021-01-10T22:21:34Z")

</div>

You’re right - my bad there!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [February 9, 2021, 10:21pm UTC](https://meta.discourse.org/t/subscriptions-deleted-data-in-stripe-now-plugin-errors/175528/6 "2021-02-09T22:21:46Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
