[英]Stripe API v3: When to use Invoice vs PaymentIntent (Node SDK)
I've been reading Stripe's api documentation (v3) and it's not apparent to me when to use Stripe's Invoice vs PaymentIntent objects.我一直在阅读 Stripe 的 api 文档(v3),我不清楚何时使用 Stripe 的 Invoice 与 PaymentIntent 对象。 From reading the documentation, here's what I understand:
通过阅读文档,这是我的理解:
Stripe sees payment intents being the primary way of facilitating payments through their API going forward and Charges will be deprecated at some point. Stripe 认为付款意图是通过其 API 促进付款的主要方式,收费将在某个时候被弃用。
Processing an Invoice creates a PaymentIntent
under the hood and and initiates payment right away.处理发票会在后台创建一个
PaymentIntent
并立即开始付款。 What I don't understand is why is there no destination account field for the Invoice
?我不明白为什么
Invoice
没有目的地帐户字段? If the Invoice is defaulted to be sent to the platform's Stripe account (this is an assumption I am making since there is no destination field), why there is an application_fee_amount
field which is essentially the platform's "cut" of the transaction?如果发票默认发送到平台的 Stripe 账户(这是我的假设,因为没有目标字段),为什么会有一个
application_fee_amount
字段,它本质上是平台对交易的“切割”?
A PaymentIntent
allow you to specify a destination account while taking an "application" or "platform" fee so you don't have to generate a transfer yourself. PaymentIntent
允许您在收取“应用程序”或“平台”费用时指定目标帐户,因此您不必自己生成转账。
PaymentIntent
and Invoice
can be processed at time of creation or deferred until later in your payment lifecycle. PaymentIntent
和Invoice
可以在创建时处理,也可以推迟到付款生命周期的后期处理。 My use case requires me to conduct payments between two parties and take a "platform fee" for each transaction.我的用例要求我在两方之间进行支付,并为每笔交易收取“平台费”。 I have successfully done this by creating a PaymentIntent and using the connected Customer account's credit card on file and populating the
transfer_data
field with the amount to send to the 2nd party involved in the transaction.我通过创建 PaymentIntent 并使用存档的已连接客户帐户的信用卡并使用要发送给交易中涉及的第二方的金额填充
transfer_data
字段来成功完成此操作。
I started looking into Stripe's invoicing api since I am planning on building an invoicing solution for my platform and thought it'd be best to leverage what Stripe has to offer, but I'm failing to see a benefit for me to leverage it since I also need to keep track of transaction ids for the payment intents and taxes based on zip code (it looks like Stripe doesn't do this automatically so I might be out of luck here).我开始研究 Stripe 的发票 api 因为我计划为我的平台构建发票解决方案,并认为最好利用 Stripe 提供的功能,但我没有看到利用它对我有什么好处,因为我还需要根据 zip 代码跟踪付款意图和税款的交易 ID(看起来 Stripe 不会自动执行此操作,所以我可能在这里不走运)。
I couldn't find a way to get a transactionId
for processing an Invoice but I see that the chargeId
gets returned as part of the response when you confirm a PaymentIntent
( https://stripe.com/docs/api/payment_intents/confirm ).我找不到用于处理 Invoice 的
transactionId
的方法,但我看到当您确认PaymentIntent
( https://stripe.com/docs/api/payment_intents/confirm ) 时, chargeId
作为响应的一部分返回.
So the questions I have are:所以我的问题是:
Invoice
?Invoice
没有目的地帐户字段? Does it automatically get send to the platform's Stripe account and require you to manually create a transfer?transactionId
from an Invoice
?Invoice
获取transactionId
?transactionId
when creating a PaymentIntent
and setting the confirm=true
so the PaymentIntent
gets processed immediately?PaymentIntent
并设置confirm=true
以便立即处理PaymentIntent
时,有没有办法获取transactionId
? Thanks in advance!提前致谢!
You can think of invoices as subsets of payment intent, kind of the same way subscriptions are subsets of invoices.您可以将发票视为付款意图的子集,就像订阅是发票的子集一样。
What I don't understand is why is there no destination account field for the Invoice?
我不明白的是为什么发票没有目的地帐户字段?
Actually there is one, but the field is transfer_data[destination]
.实际上有一个,但字段是
transfer_data[destination]
。 Also, note that whenever an invoice is finalized, it will contain a payment intent, which is expandable, and with which you should be able to solve most of the issues you rose in your question.另外,请注意,每当最终确定发票时,它将包含一个可扩展的付款意图,并且您应该能够解决您在问题中提出的大多数问题。
To sum up:总结一下:
succeeded
otherwise the payment intent might attempt more charges or stop trying at some point, and the payment intent will be set to canceled
more about payment intent statuses here .succeeded
,否则付款意图可能会尝试更多费用或停止尝试,并且付款意图将是在此处设置为canceled
有关付款意图状态的更多信息。 In short payment intents are a subset of charges.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.