#Stefano Mariuzzi
1 messages ยท Page 1 of 1 (latest)
Hi ๐ there isn't a way to list Subscriptions based on coupon/discount, you will need to loop through all of your Subscriptions.
Hi toby, thank you for your reply!
It is ok. Is the coupon in the discount field the one that will be applied to the next payment?
You may not be able to search for coupon directly, but you could potentially update the metadata on the Subscription e.g. {coupon: 123}
Then you can use the subscription.search function with the query parameter.
e.g.
const subscription = await stripe.subscriptions.search({
query: 'status:\'active\' AND metadata[\'coupon\']:\'123\'',
});
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
The limit is 100 results, default is 10 - so you would need to create some sort of pagination.
or alternatively you can retrieve all subscriptions and filter it out yourself like toby suggested
Ah, I forgot about searching, that is a good option to explore also, but it would require work (as suggested) to get the necessary data in place to serve as a filter.
Yes, the discount field holds the Discount object that will be considered when calculating prices for the Subscription. If you're using coupons that only apply to specific products, then you'll want to keep that in mind and check whether the Subscription has the targeted products.