Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lucasfaria's avatar

Laravel Cashier sometimes does not create a customer with stripe_id

I'm using Laravel Breeze with laravel cashier. When user creates an account, it automatically creates a stripe customer. But for some accounts, stripe does not generate a stripe_id and does not create a customer (emails from these accounts looks ok). What can i do?

0 likes
6 replies
LaryAI's avatar
Level 58

It sounds like you're encountering an intermittent issue where Laravel Cashier is not always creating a Stripe customer and assigning a stripe_id to your users. This can happen due to various reasons, such as network issues, Stripe API rate limits, or even bugs in the code.

Here are some steps you can take to troubleshoot and resolve this issue:

  1. Check for Errors: Ensure that you are logging any errors that occur during the Stripe customer creation process. This will help you identify if there are any specific issues causing the failure.

  2. Ensure Idempotency: Make sure that the customer creation process is idempotent. This means that if the process fails, it can be safely retried without creating duplicate customers.

  3. Retry Mechanism: Implement a retry mechanism to handle transient failures. If the customer creation fails, you can retry the operation a few times before giving up.

  4. Manual Customer Creation: As a fallback, you can manually create a Stripe customer if the automatic process fails.

Here is an example of how you can implement these steps in your Laravel application:

In this example, the createStripeCustomer method attempts to create a Stripe customer and save the stripe_id to the user. If an error occurs, it logs the error and retries the operation up to three times using the retryCreateStripeCustomer method.

Make sure to adjust the retry logic and error handling to fit your specific needs. This should help mitigate the issue of Stripe customers not being created and ensure that your users have a stripe_id assigned.

1 like
vincent15000's avatar

stripe does not generate a stripe_id and create a customer

What do you mean ?

Does not generate a stripe_id AND does create a customer ?

1 like
vincent15000's avatar
Level 63

@lucasfaria I suggest you to catch any error coming from the Stripe API.

And to wrap your code inside a transaction, so that if any database query fails, all database queries will rollback.

1 like
lucasfaria's avatar

@vincent15000 I implemented this and it seems to have worked, I noticed that the get or create a customer function was missing. Thank you very much

1 like

Please or to participate in this conversation.