#Murder

1 messages ยท Page 1 of 1 (latest)

zealous chasmBOT
reef meadow
civic shore
#

Ohhh, is the a way to just create the invoice the that customer without sending it?

reef meadow
civic shore
#

Ah okay, and keep the same collection method?

reef meadow
#

Yeah

civic shore
#

Okay, and if i set the auto_advance to False, can i then use stripe.Invoice.send_invoice if i need to send the invoice depending on a if statement?

reef meadow
#

Which client library is that function in?

#

I'm just not sure which API that calls so it's hard to be sure.

civic shore
#

Not sure i understand what you mean by client library ๐Ÿ˜…

reef meadow
#

What programming language are you using?

civic shore
#

Oh

#

Python

reef meadow
#

Okay great ๐Ÿ˜ .

Yes that function will trigger the sending of an invoice where auto_advance is false.

civic shore
#

Ah okay lovely

#

Just to double check, this is how i would do it right:?

reef meadow
#

Yes that is looking correct to me. Of course I recommend a robust set of tests to ensure you get the fully behavior you expect.

#

But that should do what you expect.

civic shore
#

Ah okay, thank you for the help!

reef meadow
#

Happy to do it ๐Ÿ™‚

civic shore
#

Im still getting the same error

#

Should i print the invoice and see what its sending?

#

Oh wait i cant because it doesnt get sent

reef meadow
#

Can you share the request ID in the error?

civic shore
#

req_m7o9hRx7qj6DwA

reef meadow
#

Oh, sorry I still forget. Even with auto_advance set to False you will still need to provide an email.

#

At the time of creation

civic shore
#

oh

reef meadow
#

It's the way the validators are set up

#

Sorry I missed that

civic shore
#

So theres no way to be able to create a invoice without a email?

#

No worrys

reef meadow
#

Well you can use a dummy one but no, if you are using send_invoice it requires an email

civic shore
#

Could i not use a different collection method?

#

Ah ok, yeah i dont really want to use a dummy one

reef meadow
#

You could use Charge automatically but then your customers would just get charged and emailed a paid invoice

civic shore
#

Which would still require an email

reef meadow
#

But I don't think it's required immediately.

civic shore
#

Yeah but i dont want to charge the users automatically

#

Is there a way to just create the invoice and then just supply like a link to the user, to pay?

reef meadow
#

Yes. Hold on and let me try this out.

civic shore
#

Oh lovely nice

#

Cause im tryna make a system where its optional to supply a email but still be able to send an invoice to a user. (This is for a discord bot)

reef meadow
#

Okay so here's the flow that works for me. I create an Invoice Item first (Customer + Price + Quantity)
https://stripe.com/docs/api/invoiceitems/create

Then I create an invoice with auto_advance=False and collection_method="charge_automatically" for that same Customer. It automatically pulls in the Invoice Item in the Line Items for that Invoice. At this point the Invoice has a status: draft

#

When I review the Invoice and decide it looks right I finalize the Invoice using
stripe.Invoice.finalize_invoice()
This moves it to open status. It's still not charging the Customer

#

Once the Invoice is open, there is a link to a Hosted Invoice Page

#

This is a Stripe hosted page where the customer can enter their payment details to pay the invoice

#

That process allows you to share a link your customer can use to pay the invoice.

civic shore
#

Okay damn yeah ive just implemented all of that, time to test it and check it works

#

Above that i add the item

#

Then i create the invoice, check if the user has a email, if they do, i send the invoice, if they don't i finalize it

reef meadow
#

You might need to call the finalize_invoice() method before calling send_invoice() if the customer has an email

#

I don't think Stripe will allow sending an Invoice in a draft state

civic shore
#

So i have the finalize and then send?

reef meadow
#

Yeah.

#

I thought you wanted to just use the URL?

civic shore
#

If they dont have an email yes

#

but if they do have an email, then may as well send one

reef meadow
#

Okay then that should work

civic shore
#

Alright, will test right now

reef meadow
#

You can access the URL on the finalized invoice at the hosted_invoice_url property

civic shore
#

I need to remove days_until_due right?

#

Yeah

civic shore
reef meadow
#

The number of days from when the invoice is created until it is due. Valid only for invoices where collection_method=send_invoice.
This is what our docs say about it

civic shore
#

Yeah

reef meadow
#

So it's due the day it's created otherwise

civic shore
#

So with the charge_automatically, it would just wait indefinetely for the user to pay?

#

Oh okay, with that collection method?

reef meadow
#

Yeah

civic shore
#

Okay thats fine

reef meadow
#

Well you might want to think through the flow a little more. Emails can take a minute or two to land in the customers inbox and not everyone checks their emails right away. That's one of the reasons why we have a feature like days_until_due that only applies to send_invoice.

#

But if you have the user interacting with your code directly, it might be better to send them to the hosted invoice page directly with the link

#

It's ultimately up to you and what you think fits your integration best

civic shore
#

Yeah, basically, a staff member can generate a invoice for the user, whch will DM the user and notify them with a link to pay and if they have an email, send them an email

#

Works though :))))

reef meadow
#

Nice!

civic shore
#

So if i didnt pay this and it passed 24 hours, what would happen if they didnt have an email?

reef meadow
#

It would remain open

civic shore
#

Okay, and if they had an email, whould it stay open and i assume send them an email reminding them?

reef meadow
civic shore
#

Ah okay that works

reef meadow
#

You can also send_invoice to re-send the invoice

civic shore
#

So, just to clear up, if they have no email i just need to finalize, if they do i can finalize and i can send it?

#

If so, can I send_invoice for a user tht has an email and charge_automatically for a user with no email

reef meadow
#

Well you said you weren't actually charging automatically. So when the customer does not have an email you were going to share the hosted_invoice_url from the finalized invoice

civic shore
#

Yes

reef meadow
#

So yes that will work.

civic shore
#

Alright lovely

#

Will test them both one more time

civic shore
#

Looks like it all works perfectly after a couple bug fixes ๐Ÿ‘

#

Well, thank you so much for all the help!!