简体   繁体   English

Stripe API v3:何时使用 Invoice 与 PaymentIntent(节点 SDK)

[英]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允许您在收取“应用程序”或“平台”费用时指定目标帐户,因此您不必自己生成转账。

    • A PaymentIntent and Invoice can be processed at time of creation or deferred until later in your payment lifecycle. PaymentIntentInvoice可以在创建时处理,也可以推迟到付款生命周期的后期处理。

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:所以我的问题是:

  1. Why is there no destination account field for the Invoice ?为什么Invoice没有目的地帐户字段? Does it automatically get send to the platform's Stripe account and require you to manually create a transfer?它会自动发送到平台的 Stripe 帐户并要求您手动创建转账吗?
  2. Is there an easy way to get a transactionId from an Invoice ?有没有一种简单的方法可以从Invoice获取transactionId
  3. Is there a way to get a transactionId when creating a PaymentIntent and setting the confirm=true so the PaymentIntent gets processed immediately?在创建PaymentIntent并设置confirm=true以便立即处理PaymentIntent时,有没有办法获取transactionId
  4. For a platform that will have an invoicing flow and facilitate transactions on behalf of two parties, is it recommended to use payment intents, invoicing, or both?对于具有发票流程并代表双方促进交易的平台,是否建议使用付款意图、发票或两者兼而有之?
  5. What's the difference between a charge and transaction?收费和交易有什么区别? When paying an Invoice, a charge id gets returned in the response but when paying a payment intent, a transaction id gets returned.支付 Invoice 时,会在响应中返回费用 ID,但在支付付款意图时,会返回交易 ID。

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:总结一下:

  1. Yes there is, as explained above.是的,如上所述。
  2. Expand the invoice's payment intent object.展开发票的付款意向 object。
  3. I'm not used to work with transactions, but I guess you could leverage their metadata to reference your invoice or vice verse to help you retrieve the need object in needed time.我不习惯处理交易,但我想您可以利用他们的元数据来引用您的发票,反之亦然,以帮助您在需要的时间检索 object。
  4. As explained above, their is not dichotomy between those, if your invoicing your clients, the you should use stripe's invoicing system.如上所述,它们之间不是二分法,如果您为客户开发票,您应该使用 Stripe 的发票系统。
  5. From what I see in the docs, transactions only concern purchase 'internal' to stripe, with issued cards.从我在文档中看到的情况来看,交易只涉及使用发行卡的“内部”购买。 Charges are the attempts stripe will make to charge your bank account through the network, when a charge succeeds, the payment intent status is set to 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.简而言之,支付意图是费用的一个子集。

I hope this helped and didn't come too late, the answer might still be improve in the future, if others edit it or as I will learn more about stripe's issuing product. 我希望这会有所帮助并且没有来得太晚,如果其他人对其进行编辑或者我将了解更多有关 Stripe 发行产品的信息,将来答案可能仍然会有所改进。

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

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