#Sean Lanning - Invoices
1 messages · Page 1 of 1 (latest)
Hello! Can you give me the request ID for the API request to finalize the Invoice? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
So the Payment Method assigned to that Payment Intent is not the one you expected?
SO here is what we are attempting to do. We are creating the invoice int he dashboard as a draft
And subscripbing to the Invoice Update event so that we can call back and set the on behalf of and transfer data properties
In addition to adding meta data
var options = new InvoiceUpdateOptions
{
OnBehalfOf = connectedAccountId,
TransferData = new InvoiceTransferDataOptions() { Destination = connectedAccountId },
AutoAdvance = true,
CollectionMethod = "charge_automatically",
Metadata = new Dictionary<string, string>
{
{ "invoice_number", sbInvoiceNumber }
}
};
Why not create the Invoice using the API?
We then finalize the invoice and want it to get paid
Because it does not fit our current business case
Why?
Because the amount and custom field come from an external system we do not have an interface for
So they need to be manually entered by a person through the dashboard
Gotcha. Okay, so you're finalizing with the API and you said something about the wrong Payment Method being associated. Can we focus on that for a moment? The Payment Intent associated with the Invoice you mentioned has a Payment Method associated with it, but it's the wrong one?
It has the correct payment method assigned, but it had a message saying PaymentIntent status:
requires_confirmation
We would like fo it to automatically charge
Yeah, that's expected. But in your original message you said this:
but it is not properly assigning the Payment Method to the Payment Intent created during the Invoice Finalization
Can you clarify what isn't being properly assigned?
There are 2 issues
- We have a Payment Method assigned to a Customer. We then update and finalize and invoice related to that customer and the payment intent has not payment method assigned. I think this is happening because the payment method was assigned to the customer, but not tagged as default payment method.
- I updated the customer and set the payment method as default and the payment intent then had the payment method assigned, but has this message associatd to it - PaymentIntent status:
requires_confirmation
Okay, for #1 it sounds like you're probably correct, but I can help you investigate if that theory doesn't pan out. For #2 what you're seeing is expected behavior. Finalizing an Invoice does not trigger immediate payment. If you want immediate payment you need to tell the API to attempt to pay the Invoice: https://stripe.com/docs/api/invoices/pay
OK that is contrary to what the Implementation coordinator told us. She said we only need to finalize it. But I can look at that Pay documentation
As for #1 how do we ensure the Payment Method is set to default
We are using the Checkout Session functionality for gathing Payment methods for customers
You can set the Customer's invoice_settings.default_payment_method: https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
Who is the implementation coordinator you mentioned?
We were given this document
It said if Automatic collection was enabled the invoice should automatically be charged
It will be, but it's not immediate.
Finalizing an Invoice tells Stripe the Invoice is ready to go, but payment won't be attempted right at that moment.
Maybe that is the issue. Maybe it just needs more time
Do you know the typical timing on that?
There are details here: https://stripe.com/docs/invoicing/integration/workflow-transitions#finalized
But if the Payment Intent sat - PaymentIntent status:
requires_confirmation
WHat does that mean?
That means the Payment Intent hasn't been confirmed yet. A Payment Intent will not attempt payment until it's confirmed: https://stripe.com/docs/payments/intents
When using Invoices the Invoice will manage the underlying Payment Intent for you though.
Yeah, the Invoice will attempt to confirm the Payment Intent when it's ready to attempt payment.
When is the timing on that happening?
That depends on your integration. Do you have webhook endpoints set up that listen to Invoice events?
Or are you connected to a platform listening for those events?
We are attached to a platform account
But we also are listening to WebHook events
The invoice Update event is how we trigger the on bahlf up update and the finalize
As mentioned in the documentation I linked to all of the webhook endpoints (both on your account and on platforms you're connected to) need to respond successfully to the invoice.finalized event before anything else will happen. That's the first thing to check.
But, actually, rather than diving into the specific details of how Invoices work, it would probably be better if you told me what you're trying to build and then I can recommend the best approach.
We have already built everything LOL. We found out yesterday from Stripe that our funds would not properly flow to the proper connected account unless the invoice had the connected account included in the OnBehalfOf and TransferData properties. And that those fields could only be set via the API. So the solution was to create a Draft invoice, Listen to the Invoice Update event, trigger the InvoiceUpdate with those fields via the API call triggered by that event, and then finalize the invoice.
So all that seems to work other than the fact that the invoice does not appear to be in a state where it will be automatically charged
To be clear, finalizing the Invoice does put it in a state where it will be automatically charged if you have automatic collection turned on, it's just that it doesn't happen immediately like you're expecting.
If it's okay that it doesn't happen immediately then finalizing the Invoice + waiting probably about an hour will probably yield the results you want.
How can I verify automatic charging is tirned on?
If it's not okay that it doesn't happen immediately you should use the Pay Invoice endpoint I linked to earlier.
It's a property on the Invoice: https://stripe.com/docs/api/invoices/object#invoice_object-auto_advance
var options = new InvoiceUpdateOptions
{
OnBehalfOf = connectedAccountId,
TransferData = new InvoiceTransferDataOptions() { Destination = connectedAccountId },
AutoAdvance = true,
CollectionMethod = "charge_automatically",
Metadata = new Dictionary<string, string>
{
{ "invoice_number", sbInvoiceNumber }
}
};
I included the CollectionMethod as "charge_automatically"
And autoadvance = true
So I am ok if it does not happen immediately, but I do need some idea of timing for when ti will be charged. Mainly for our QA team as they test
Yep, then you're all set.
About an hour or less should suffice if all of the webhook endpoints involved are responding with success to Invoice events being sent to them.
OK that makes sense
It looks like I just hit that hour mark
But it failed?
This is the failed event - evt_1Ke6gTFXP9IgMuNp7vJdSopJ
Any idea how to tell why it failed?
Looking...
Looks like the connected account you set on-behalf-of to doesn't have the card_payments capability.
These are not Card payments
I think the error is a bit outdated, but the issue is the connected account doesn't have the correct capabilities.
This is US Bank and acss_debit
Looks like it only has transfers, so you can't do OBO.
Is that under the Capabilities Setting for the connected account?
yes
Yea, I see it on another Instance. It looks like our Dev instance was not properly setup
One other question. If the Customer has a single Payment Method, but it is not set as default, will it get picked up by the invoice on the "charge_automatically" option. Or does is a default payment method required?
it requires a default payment method to be set, either on the Customer, the Subscription or that Invoice, otherwise it's just ignored
So the Payment method is selected when the invoice is in draft, but it does not pick that up after the Finalize call is made from the API
We are capturing the Payment Method via the Checkout Session. Is there a parameter for creating the Checkout Session that will assign the payment method as the default?