Skip to content
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

Unable to re-register a User in Laravel because of previous Customer record #281

Closed
devinfd opened this issue Sep 24, 2024 · 3 comments
Closed
Assignees

Comments

@devinfd
Copy link

devinfd commented Sep 24, 2024

Cashier Paddle Version

2.5.2

Laravel Version

11.23.5

PHP Version

8.3.11

Database Driver & Version

SingleStore

Description

Related to #274

I was getting a Paddle Customer already exists in the database error which didn't make sense to me. In my case the user was archived in Paddle. With the current code logic it seems that if a user cancels their account and their Paddle status becomes archived then that user can't return to the "service" as user again with the same email address?

Why is a LogicException thrown in ManagesCustomer@createAsCustomer? The doc blocks for createAsCustomer don't indicate that an exception will be thrown. Shouldn't the $customer object just be returned if one is found matching the Paddle ID? Then make an API PUT request to update the user status to 'active' if they are archived?

Steps To Reproduce

  1. Register a user in a Laravel application using Laravel/cashier-paddle.
  2. Delete the user and mark them as archived in Paddle.
  3. Try to register that user again in the Laravel Application.

I would be happy to submit a PR if this is acceptable.

@driesvints
Copy link
Member

driesvints commented Sep 27, 2024

It's because paddle_id needs to be unique:

If you have a user canceling their account and returning with the same email address then you should either restore their original user account or make sure the old paddle customer record isn't in the database anymore.

We need the unique paddle_id on the paddle customer table because it's a foundation of how the package works and maps subscriptions to it. It also doesn't makes sense to connect a paddle customer record to multiple users. One paddle customer record matches a single user.

@devinfd
Copy link
Author

devinfd commented Sep 27, 2024

@driesvints thank you, that makes sense. Just one follow up question: In addition to deleting the Customer if the user cancels their account, is it also advisable to keep the User and Customer models in sync? ie: if the User's name or email changes then the Customer modelname/email should change as well?

@driesvints
Copy link
Member

No these don't necessarily need to be the same. The email and name column on the customer record reflect's what's in paddle. You could have separate legal/billing name and email for invoicing and a separate email/name for your billable.

For example, You're Devin and your company is named Acme company with [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants