Question

What would be the best way to give each invoice I generate through Stripe an invoice number? I understand that the system already assigns each invoice with a unique ID but for British accounting I need to figure out a way to have the first invoice i generate be numbered #1, the second #2 and so on.

I've considered maybe storing a count of generated invoices on my site and then subscribing to the webhook that's fired on invoice creation and using that to create some kind of metadata record of an invoice number but i'm not sure this is the most efficient method really.

I'm running a standard kind of LAMP set-up on my VPS and am now quite familiar with the Stripe API although i've never used webhooks before.

Was it helpful?

Solution

I'd create a database table for all your invoices. Then use webhooks to be notified of events and watch for invoice.created events. Store the invoice details in your database table, and you can internally use the automatically incremented primary key as your invoice ID, which will be in chronological order.

Cheers, Larry

PS I work on Support at Stripe.

OTHER TIPS

There are invoices and there are transactions. Those two shouldn't be mixed together.

You should store your invoices in your app (HDD, database, whatever) and assign each of them a transaction_id from stripe when it's paid.

Reasons to do that: - it's more scalable. Maybe one day your clients would like/have to pay with a check, or wire transfer - maybe you'll have to change the payment processor in the future - maybe one client would have to pay two invoices with one transaction and so on...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top