0
votes

I am making an e-commerce web app, users can purchase physical products via stripe and users can subscribe to different plans such as Lite, Premium, Standard, etc.

case-1: For checkout of physical products, I use:

stripe.charges.create()

case-2: For Subscriptions, I use:

stripe.subscriptions.create()

What I want is to retrieve a list of ONLY checkout charges (made via case-1, not case-2), I use

stripe.charges.list()

but It retrieves all charges including subscriptions which is not wanted.

How can I get all charges which are of non-subscription charges, is there any filter available in Stripe or an alternate method is available?

1

1 Answers

1
votes

Unfortunately, the List Charges API doesn't have any parameters that you can use to specify that you only want charges associated with invoices:

https://stripe.com/docs/api/charges/list

That being said though, you can list all the Charges within a given window and filter them manually. Any charge that is associated with a subscription will have its invoice field populated:

https://stripe.com/docs/api/charges/object#charge_object-invoice

That is, if the Charge is linked to an invoice then it (most likely) came from a subscription. Otherwise it was a Charge for a physical product. This of course assumes that you aren't creating one-off invoices manually.