#_obo_

1 messages · Page 1 of 1 (latest)

serene flumeBOT
radiant stirrup
#

I do have example users if it helps

red socket
#

You just want to get all the Subscriptions that have been cancelled? Do you want to do that as a batch request to the API? Or would listening to customer.subscription.deleted suffice?

radiant stirrup
#

So the user is "technically" still subscribed, but stripe stopped trying to charge them awhile ago

red socket
#

OKay, so I have no context on what churnbuster is, so can you elaborate on what you want to happen? Preferably a step-by-step explanation of the preferred workflow

radiant stirrup
#

sorry, churnbuster basically just gets webhooks from stripe and then cancels the customer in 30 days if they don't pay

#

I mainly provided reference there to state, this isn't a problem moving forward, we just need to locate these historical orphaned customers

red socket
#

Okay, so you want a list of Customer objects who have had their Subscriptions canceled by Churnbuster?

radiant stirrup
#

what I'm looking for is a way I can query your API to get users who are in a state like the example users I provided. To be more specific:

  • they had a payment fail in the past
  • stripe recognized that failure and instead of trying to charge them each month, stripe just makes a draft invoice and never attempts to charge it
  • that user is still subscribed even though they haven't paid in months
#

if you scroll down to the invoices section on each user you'll see it's just draft invoices for multiple months

red socket
#

Got it. So it's worth mentioning the Customer object has no state on Subscription statuses. So you'll probably want to do something like make a List All Invoices API call to get all the invoices that are in a draft state. You can do that by filtering on status: https://stripe.com/docs/api/invoices/list

Once you have that, you'll want to compare each Invoice's created date against the current date: https://stripe.com/docs/api/invoices/object#invoice_object-created, then cache the ones that were created >30 days ago (or whatever numebr of days is important to you).

Once you've done that it might be worth checking if each Invoice's Customer has other active Subscriptions that are in a good state (see status of the Subscription here: https://stripe.com/docs/api/subscriptions/object#subscription_object-status) to make sure that you don't remove access to active subscriptions

#

That's just one way of many to accomplish this. Another way would be to look at the list of Subscriptions on the Customer object and then check the status of each Subscription in the list, then cache those Customers and do further analysis to determine if they have orphaned subscriptions.

radiant stirrup
#

is there a specific status that is unique to subscriptions in this state?

#

"unpaid" seems to be a good candidate?

red socket
#

I think past_due would probably be better in this case

#

Since you want Subscriptions that had a Invoice payment attempt that failed and that failure persisted beyond the due date

radiant stirrup
red socket
radiant stirrup
#

got it, thanks for the help

red socket
#

Sure thing!