-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createAsCustomerIfNotExists #219
Comments
Thanks @haszzam. Would maybe not filtering on status be the solution here to fetch all customers? |
Hi @driesvints I checked the other discussion and it's the same issue I'm having here. In your reply here #218 (comment) The issue arise when you delete the customer from the database and leave the billable and then try to run The best way to understand this issue is to reproduce it locally on your end with the following steps:
The last command should fail, because the a customer with this email So the whole point of this method Again, It's unlikely anyone gonna have this issue in a production environment, It's mostly gonna happen in development where you clear the database for whatever reason. So This method would only make development a little easier, I don't know if it would make sense to add it to the library but I don't think it would hurt anyway to have available as an option. |
Hi @driesvints. Thanks! |
Hey @haszzam , I just recently deleted a users from my prod db directly ( my account ) and i was getting this error due to the same as you messaged here. What can i do delete customer from Paddle ?? |
Hi @bluzeey As far as I know you cannot delete a customer from Paddle, You can only archive it but it would still exist in Paddle and you cannot use the same email to create a new user. But the problem you're having was solved after I posted this issue, Now Cashier checks if the customer exists first before attempting to create a new one, and if it exists it uses the existing customer and just link it to the user in your database. If you're using an older version of Paddle Cashier, try updating the composer package and you shouldn't get this error again. |
Hey @haszzam , I have been facing this error , even after updating composer to 2.5.1 the latest versions. . It shows me this error for two of the users in my production database. I create a customer if there isn't and i am facing the error on checkout method.
|
Hi, I don't know if this feature would make sense in production apps or not, But I ran through the following issue while developing and I believe others have too.
Problem:
While developing we usually create test subscriptions and each subscription creates a customer inside Paddle dashboard.
But when for example you delete the laravel database user or run
php artisan migrate:fresh
and delete all the users the customers still remains inside Paddle dashboard and you cannot delete it manually, You can archive it but you cannot delete.And when you try to run
createAsCustomer()
on a user with an email that already exists as a Paddle customer you get an exeption like soI ran into this issue while developing, I don't think it's likely anyone is gonna have this issue in a production environment since you tepically would not delete the user and try to sign it up again and make it as customer, but this is very common in development.
Solution:
I created a new method
createAsCustomerIfNotExists()
which performs the same actions ascreateAsCustomer()
but first it checks to see if the user's email address already exists as a customer inside Paddle and if so it will user the existing customer details instead of attempting to create a new one which will fail and through the above exception.I added the following method to the
Billable
model, in my case theUser
model.This was just a quick fix I created, and as I mentioned in the code comments, I had to send two separate requests to Paddle to check if the customer exists, One request for each status
active
andarchived
.Idealy it should only be one request by passing the status as a comma separated list like so
'status' => 'active,archived'
as stated in the Paddle Docs, But this doesn't work for now and I tried contacting them but I got no response, Maybe you can reach them.Thanks!
The text was updated successfully, but these errors were encountered: