#Sean Lanning - Invoices

1 messages · Page 1 of 1 (latest)

rose peak
errant finch
#

This is the invoice id - in_1Ke5amFXP9IgMuNpU3gdbLOG

#

req_cYey4opcWddNrs

rose peak
#

So the Payment Method assigned to that Payment Intent is not the one you expected?

errant finch
#

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 }
}
};

rose peak
#

Why not create the Invoice using the API?

errant finch
#

We then finalize the invoice and want it to get paid

#

Because it does not fit our current business case

rose peak
#

Why?

errant finch
#

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

rose peak
#

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?

errant finch
#

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

rose peak
#

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?

errant finch
#

There are 2 issues

#
  1. 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.
#
  1. 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
rose peak
#

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

errant finch
#

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

rose peak
#

Who is the implementation coordinator you mentioned?

errant finch
#

It said if Automatic collection was enabled the invoice should automatically be charged

rose peak
#

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.

errant finch
#

Maybe that is the issue. Maybe it just needs more time

#

Do you know the typical timing on that?

rose peak
errant finch
#

But if the Payment Intent sat - PaymentIntent status:
requires_confirmation

#

WHat does that mean?

rose peak
#

When using Invoices the Invoice will manage the underlying Payment Intent for you though.

errant finch
#

So how does the PI confirmation happen?

#

Is that automatic?

rose peak
#

Yeah, the Invoice will attempt to confirm the Payment Intent when it's ready to attempt payment.

errant finch
#

When is the timing on that happening?

rose peak
#

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?

errant finch
#

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

rose peak
#

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.

errant finch
#

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

rose peak
#

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.

errant finch
#

How can I verify automatic charging is tirned on?

rose peak
#

If it's not okay that it doesn't happen immediately you should use the Pay Invoice endpoint I linked to earlier.

errant finch
#

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

rose peak
#

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.

errant finch
#

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?

rose peak
#

Looking...

#

Looks like the connected account you set on-behalf-of to doesn't have the card_payments capability.

errant finch
#

These are not Card payments

rose peak
#

I think the error is a bit outdated, but the issue is the connected account doesn't have the correct capabilities.

errant finch
#

This is US Bank and acss_debit

rose peak
#

Looks like it only has transfers, so you can't do OBO.

errant finch
#

Is that under the Capabilities Setting for the connected account?

trail cypress
#

yes

errant finch
#

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?

trail cypress
#

it requires a default payment method to be set, either on the Customer, the Subscription or that Invoice, otherwise it's just ignored

errant finch
#

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?