#jskitz - Get or Create

1 messages ยท Page 1 of 1 (latest)

eternal schooner
#

Hi ๐Ÿ‘‹
We don't have that functionality in the API currently so you've got to use the approach that convenience method is a wrapper for

#

You're referencing the Django model method, right?

devout sand
#

yeah similar to that. But really I'm looking for, if I try to create a new customer with an email address that's already in Stripe, it just returns that existing customer ID. Is the only thing that is unique in Stripe customer is the ID?

eternal schooner
#

The reason I reference the Django method is it still makes the 2 SQL queries. First to get a record and, if that record does not exist, then to create it.

You would need to do the same thing with our APIs. Make a GET request to the Customer List API filtering on email and, if the response was an empty list, create a customer

devout sand
#

that makes sense. I think it would be nice from an API perspective if you could say this identifier is unique (email, username, phone number). Don't create more objects if this identifier is used in a create. But I get why you want the API to be lean without having these constraints

#

thanks for the help!

eternal schooner
#

Sure thing, happy to help ๐Ÿ™‚