#Sairony-feedback
1 messages · Page 1 of 1 (latest)
Hi! The best way to submit feedback is on https://support.stripe.com/?contact=true
However can you clarify what you are trying to do?
Cool. Sure, lets say you have a user that's logged in, you now want to find the subscriptions for this user. This would be needed for a lot of things, like checking if there's an active one, or if there's a canceled / ended which can be renewed.
The problem is that the only way I can think of doing this is to to use the List API call restricting it to the current user with the customer parameter. To correctly implement this one you would have to call it potentially multiple times, even if you know that there's only ever 1 subscription which isn't in the incomplete / incomplete_expired state, since there can potentially be a ton of these. If I instead were able to restrict it to customer ID with the search function I could do a query which explicitly excludes these I could get the correct subset from the get go instead of having to filter out these on our side.
When you list subscriptions, you can pass a customer ID to only retreive subscription for a specific customer https://stripe.com/docs/api/subscriptions/list
I believe I've had similar issues with the invoices API functions
To correctly implement this one you would have to call it potentially multiple times
What do you mean?
Lets say we have a customer which is really hesitant to sign up, he enters the payment page for the subscription multiple times, this would create a lot of subscription objects which has the state incomplete, these will never go away it seems and later on transition to incomplete_expired. Now imagine he does this 101 times. If I call that list function with the max limit I would only get the first 100 entries, and would have to call it twice to get all the subcriptions ( another time to get that last entry ). Out of all these 101 subscription objects there will be only 1 which I actually want to look at, the other 100 ( which is in incomplete or incomplete_expired ), aren't needed. So actually less than 1% of the transfered subscription objects were what I was looking for
If I was using the search function instead and was able to something like NOT status:\'incomplete\' AND NOT status:\'incomplete_expired\' AND customer_id: 101 I'd be able to get exactly that subset I wanted and only get 1 object back instead of 101
With https://stripe.com/docs/api/subscriptions/list you can specify the customer ID and a status. For example you could only retrieve active subscription for a specific customer. Would that solve your issue?
and would have to call it twice
You could use the auto-pagination feature to avoid this: https://stripe.com/docs/api/pagination/auto
Sadly to get the relevant subscription I would have to call that function up to 6 times. Once for active, once for past_due, once for unpaid, once for canceled, once for trialing and lastly once for ended
Ah, had missed the pagination feature, that looks sweet, but would still require a lot of unneeded transfer in this case.
Got it. Another option would be to listen to listen to the webhook event customer.subscription.created and customer.subscription.updated, and store/udpate the subscriptions in your own database. This way you can easily retreive and filter them.