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. 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.
Processing an Invoice creates a PaymentIntent
under the hood and and initiates payment right away. What I don't understand is why is there no destination account field for the 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?
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
and Invoice
can be processed at time of creation or deferred until later in your payment lifecycle.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.
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).
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).
So the questions I have are:
Invoice
? Does it automatically get send to the platform's Stripe account and require you to manually create a transfer?transactionId
from an Invoice
?transactionId
when creating a PaymentIntent
and setting the confirm=true
so the PaymentIntent
gets processed immediately?Thanks in advance!
The PaymentIntent encapsulates details about the transaction, such as the supported payment methods, the amount to collect, and the desired currency.
From Stripe Docs. clientSecret: The client secret of this PaymentIntent. Used for client-side retrieval using a publishable key. The client secret can be used to complete a payment from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer.
Once required actions are handled, the PaymentIntent moves to processing . While for some payment methods (for example, cards) processing can be quick, other types of payment methods can take up to a few days to process. A PaymentIntent with a status of succeeded means that the payment flow it is driving is complete.
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]
. 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. In short payment intents are a subset of charges.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With