Skip to content

Instantly share code, notes, and snippets.

@tsabat
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save tsabat/79182f5627d2208f5651 to your computer and use it in GitHub Desktop.

Select an option

Save tsabat/79182f5627d2208f5651 to your computer and use it in GitHub Desktop.

OK, so the real gotcha with Stripe subscriptions has to do with historical data, as we discussed. There is no easy way to retrieve data about a subscription once it has been deleted. Here’s our use-case:

user flow

  1. customer created
  2. subscription added to user
  3. subscription canceled
  4. maybe user resubscribes

reporting flow

  1. loop through all users
  2. loop through subscriptions by user
  3. loop through charges or invoices related to the subscription
  • start date
  • end date
  • sub type
  • amount

It boils down to semantics in the API and what “delete” means in the context of a subscription. For step 3 in user flow above, I’m canceling a subscription, but I call subscription.delete, which is not what I really want. Because once we delete a subscription, it is no longer accessible via the API to handle our reporting flow.

In my ideal world, subscription.delete would act more like subscription.cancel, meaning we'd stop charging the user for their subscription, but we'd still be able to view historical data about the sub. Then we could use the subscriptions.all() endpoint to do the reporting flow I describe above.

We realize that if we'd been capturing the data via the web hooks and recording it in our own data store, this process would be trivial. But, we did not have the forethought to do so, and I'm sure we're not alone.

Also, in sharing this with my co-founders, here are some additional notes:

this is also an issue for third parties who import your stripe data. developers who are trying to build apps on top of stripe's api don't have access to historical subscription data. we can only store subscription data from the point we start importing your data. - Dee

there is no record of the user cancelling. we have to deduce it. - Alex

their api is geared toward charges, not for historical analysis. - Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment