#AlienSoft

1 messages ยท Page 1 of 1 (latest)

smoky urchinBOT
wind finch
#

Hi there

valid idol
#

Hi

wind finch
#

You are looking for the total number of Customers on your account?

valid idol
#

yes

wind finch
#

Sigma is likely going to be the easiest thing for this.

valid idol
#

sigma?

wind finch
#

Otherwise you need to just list Customers using the API

#

Err actually you can likely just export this from your Dashboard

#

Yeah that is going to be easiest

valid idol
#

whoa sigma seems cool... but i need this done in php ( as in not manually me finding it out)

#

basically after a successful payment, I need to get no of customers to generate an Invoice NO

#

so like a unique serialized no

wind finch
#

Gotcha well to get the current amount I'd just export from your Dashboard, then you will want to ingest data going forward either using Webhooks or listing via the API

#

Hmm we already provide you an Invoice number

#

And why does that Invoice number need to be related to number of Customers?

#

You just want a UUID no?

valid idol
#

well, i just need a serialized number that is incremented on each purchase

#

and i though number of customers is the way forward

wind finch
#

Hmm yeah that seems like a lot more work than you need. Just track your own number in your database. No real need to involve number of Customers at all

valid idol
#

(cos i'm creating a custom invoice) rather than having one generated from stripe

#

i don't really have a database.. that's the thing ๐Ÿ™‚

#

perhaps the customer object can show/pull no of customers right ?

wind finch
#

No we don't aggregate the number of Customers you have in the API

valid idol
#

๐Ÿ˜ฎ

wind finch
#

You can store this data via metadata on a Customer though

#

So whenever you create a Customer just set corresponding metadata for how you want the Invoice numbering to work

valid idol
#

well even as metadata i still need to keep track of it to increment the metadata

#

the idea is for me not to have an sql table with all customers

#

then pull data from there

#

i thought i can just do that through stripe/customers

#

can't i just enumerate all customers ?

#

for each user in customers.....

wind finch
#

Not sure what you mean exactly?

valid idol
#

basically run a loop to pull all customers

#

then i can just increment the variable in the loop and we'll have total customers

wind finch
#

Sure but you don't want to do that every single time

#

Like you can definitely do that once and then set corresponding metadata if you want and then go that route

valid idol
#

isn't there something else internal that tracks/increments on each payment?

wind finch
#

My recommendation would be to just create a system where you set metadata on the Customer as the "prefix" and increment that Metadata when you create a new Customer. Then set metadata on each PaymentIntent using that "prefix" and a "suffix" for the Invoice number which you increment each time on a per-customer basis for each PaymentIntent.

wind finch
valid idol
#

but even with your recommendation somehow we still need to pull the data from somewhere to set the METADATA ๐Ÿ™‚

#

i/e say person a made a purchase. that's meta1

#

when customer 2 comes, how do i know i'm on meta1

#

to increase it to meta2

wind finch
#

You list your Customers

#

And look at the most recent Customer

#

Overall this isn't foolproof. You can run into a race condition here

#

Really you should have your own database and not use Stripe as a database here for your own custom invoices

valid idol
#

that's what i mentioned earlier ๐Ÿ™‚ but you said: "Sure but you don't want to do that every single time"

wind finch
#

I was under the impression you meant you were going to loop through all of your customers each time instead of setting metadata and doing one list request

#

Apologies if that was lost in translation ๐Ÿ™‚

valid idol
#

pfff im starting to rethink the whole process now!

#

having a database just for incrementing purposes would be silly.

#

why have a separate database of customers when stripe already provides that ๐Ÿ˜„

wind finch
#

There are many reasons you would want a database really. You are going to run into many future concerns/desires that having your own database would solve. Our API is not meant to work as a database and is going to be limiting in terms of working with your data overall.

valid idol
#

that just means a total redesign from my end. to have to populate a database, then pull info from there to populate invoice..etc etc..

wind finch
#

If you don't want to do that then you should go the metadata route and use that metadata as your "database" and check against it.

#

There isn't really another way here as far as I know.

valid idol
#

๐Ÿ‘