#Murder
1 messages ยท Page 1 of 1 (latest)
You are using the collection_method: send_invoice. This does not mean you send the invoice. It mean Stripe will email the invoice to the customer. You need to provide the email to send the invoice to when specifying send_invoice.
https://stripe.com/docs/api/invoices/create#create_invoice-collection_method
Ohhh, is the a way to just create the invoice the that customer without sending it?
Sure, you would need to set auto_advance to false. This will prevent Stripe from trying to collect payment.
https://stripe.com/docs/api/invoices/create#create_invoice-auto_advance
Ah okay, and keep the same collection method?
Yeah
In that case you could even use Stripe to send the email if you wanted. You would just use this API call when you wanted to send the invoice:
https://stripe.com/docs/api/invoices/pay
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?
Which client library is that function in?
I'm just not sure which API that calls so it's hard to be sure.
Not sure i understand what you mean by client library ๐
What programming language are you using?
Okay great ๐ .
Yes that function will trigger the sending of an invoice where auto_advance is false.
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.
Ah okay, thank you for the help!
Happy to do it ๐
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
Can you share the request ID in the error?
req_m7o9hRx7qj6DwA
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
oh
Well you can use a dummy one but no, if you are using send_invoice it requires an email
Could i not use a different collection method?
Ah ok, yeah i dont really want to use a dummy one
You could use Charge automatically but then your customers would just get charged and emailed a paid invoice
Which would still require an email
But I don't think it's required immediately.
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?
Yes. Hold on and let me try this out.
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)
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.
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
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
So i have the finalize and then send?
If they dont have an email yes
but if they do have an email, then may as well send one
Okay then that should work
Alright, will test right now
You can access the URL on the finalized invoice at the hosted_invoice_url property
Would that mean the user can just pay when they want?
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
Yeah
So it's due the day it's created otherwise
So with the charge_automatically, it would just wait indefinetely for the user to pay?
Oh okay, with that collection method?
Yeah
Okay thats fine
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
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 :))))
Nice!
So if i didnt pay this and it passed 24 hours, what would happen if they didnt have an email?
It would remain open
Okay, and if they had an email, whould it stay open and i assume send them an email reminding them?
That would be dependent on how you configure the automatic emails for your account: https://stripe.com/docs/invoicing/send-email
Ah okay that works
You can also send_invoice to re-send the invoice
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
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
Yes
So yes that will work.