简体   繁体   English

列出 Stripe 中的所有非订阅费用

[英]List all non-subscription charges in Stripe

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.我正在制作一个电子商务网络应用程序,用户可以通过Stripe购买实体产品,用户可以订阅不同的计划,例如 Lite、Premium、Standard 等。

case-1: For checkout of physical products, I use:案例 1:对于实体产品的结账,我使用:

stripe.charges.create()

case-2: For Subscriptions, I use:案例 2:对于订阅,我使用:

stripe.subscriptions.create()

What I want is to retrieve a list of ONLY checkout charges (made via case-1, not case-2), I use我想要的是检索仅结帐费用的列表(通过案例 1,而不是案例 2),我使用

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?我如何获得所有非订阅费用, Stripe 中是否有可用的过滤器或替代方法?

Unfortunately, the List Charges API doesn't have any parameters that you can use to specify that you only want charges associated with invoices:不幸的是,List Charges API 没有任何参数可用于指定您只需要与发票相关的费用:

https://stripe.com/docs/api/charges/list 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:与订阅相关的任何费用都将填充其invoice字段:

https://stripe.com/docs/api/charges/object#charge_object-invoice 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.这当然假设您没有手动创建一次性发票。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM