#iam2327_code

1 messages ¡ Page 1 of 1 (latest)

wise anchorBOT
#

👋 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/1366856675918872646

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

shy wyvern
#

Hello
Based on the syntax you seem to be using python.. Can you share the exact code you're using to update the Customer object?

To be clear, modify shouldn't create a new customer object

supple jungle
#

Hi,
Yes I am using python.
I also checked and there were two customers with old and new email not sure why.

Code:

First verify if the customer exists in Stripe

try:
customer = stripe.Customer.retrieve(account.customer_id)
if not customer:
print(f"Warning: Customer {account.customer_id} not found in Stripe, skipping")
not_found_count += 1
continue
except stripe.error.InvalidRequestError:
print(f"Warning: Customer {account.customer_id} not found in Stripe, skipping")
not_found_count += 1
continue

Create new email format using a different format that Stripe will accept

Using a dot instead of plus for better compatibility

new_email = f"{organization.id}+{account.user.email}"

Update Stripe customer

stripe.Customer.modify(
account.customer_id,
email=new_email
)

shy wyvern
#

It's possible both customers with the same email existed prior to your code changes.

Can you try creating a new customer object with diff email and updating that?

supple jungle
#

sure on it.

#

Just tested and working as expected thanks.