#nextplayerrr_python-sdk-service-pattern
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1387390245170974792
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
def generate_stripe_customer_id(first_name: str, last_name: str, email: str):
client = StripeClient(api_key=key)
stripe_customer = client.customers.create(
name=first_name + " " + last_name,
email=email,
)
stripe_customer_id = stripe_customer.id
return stripe_customer_id
hi there!
File "/Users/andremaytorena/Desktop/order-fulfillment-dashboard/backend/test.py", line 15, in <module>
print(generate_stripe_customer_id("Julian", "Senti", "juliansenti98@gmail.com"))
File "/Users/andremaytorena/Desktop/order-fulfillment-dashboard/backend/test.py", line 8, in generate_stripe_customer_id
stripe_customer = client.customers.create(
TypeError: CustomerService.create() got an unexpected keyword argument 'name'```
Hey!
you could set your API key in each individual requests? you can see an example of this here: https://github.com/stripe/stripe-python?tab=readme-ov-file#per-request-configuration
Yeah that's what I tried
But it get the error I sent above
the code you shared and the code I shared are quite different. the API key is directly set in teh API call itself:
client.customers.list(
options={
"api_key": "sk_test_...",
}
)
Ohh let me try that
def generate_stripe_customer_id(first_name: str, last_name: str, email: str):
client = StripeClient(api_key=key)
stripe_customer = client.customers.create(
name=first_name + " " + last_name,
email=email,
options={
"api_key": "sk_test...",
}
)
stripe_customer_id = stripe_customer.id
return stripe_customer_id```
So like this?
yeah I have my real key i just retyped it in chat
File "/Users/andremaytorena/Desktop/order-fulfillment-dashboard/backend/test.py", line 18, in <module>
print(generate_stripe_customer_id("Julian", "Senti", "juliansenti98@gmail.com"))
File "/Users/andremaytorena/Desktop/order-fulfillment-dashboard/backend/test.py", line 8, in generate_stripe_customer_id
stripe_customer = client.customers.create(
TypeError: CustomerService.create() got an unexpected keyword argument 'name'```
But I still get this error, I also upgraded the pip stripe version to the latest
can you try something simpler, like just client.customers.list() to see if it works?
and client.customers.create() (with no parameters)
Checking one sec
Ok that worked
So I assume I'll need to then update the client and set the name and email?
and now if you try with a hardcoded name? client.customers.create(name="test")?
which version of stripe-python are you using?
Name: stripe
Version: 12.2.0```
that's the latest version. not sure why you get that error. thinking...
Hi ๐
I'm stepping in as my colleague needs to go soon
Can you try make two changes to your customer creatiion code? Can you try the following
customer = stripe.Customer.create(name="Testy Testface")
Oh sorry, that is using the older, resource pattern. Since you are instantiating the StripeClient class you will want to pass all your parameters in a dictionary.
customer = client.customer.create({'name': 'Test'})
I see Iโll try that now
Ok perfect that worked, I assume all endpoints then follow the same structure using this new system?
We document the new shape of requests using this approach here
Slightly different. For requests that expect an ID as the first parameter, that is still separate.
For example
customer = client.customers.update(
"cus_123",
params={
"description": "new description",
}
)
Ok I see, i'll begin changing the rest of my stripe endpoints and test for bugs
It can get a little confusing if you've used the older pattern for a long time (it trips me up often ๐ )