Closed shettytejas closed 5 months ago
Paddle don't allow you to create multiple customers with the same email address, which is why you are getting a customer_already_exists
error - https://developer.paddle.com/errors/customers/customer_already_exists
@deanpcmad While I agree that Paddle doesn't allow to create multiple customers, my aim to point this out is a use case where the user objects have same email but in different tenant context. The paddle customer they'll be pointing to would be the same (or different Pay::Customer objects, but with same customer_id).
Maybe the best way around that might be to have a separate model in your app just for Pay, and your Users/Accounts (whatever model you use), would link with that for billing?
You can set up your application to handle this as needed outside of Pay.
Describe the Bug:
In a multi-tenant application (with acts_as_tenant) where each Account can have multiple Users, users with the same email can exist across different accounts but not within the same account. During the billing process, when trying to initialize a customer for a user with the same email address that already exists as a customer in a different account, the system fails to create a new customer record. This issue persists even after attempting to tenant the customer table due to existing validation constraints.
To Reproduce:
Expected Behavior:
The system should allow the initialization of a customer for the user under Account B, independent of the existing customer record for the same email under Account A.
Actual Behavior:
The system fails to initialize a customer for the user under Account B due to a validation constraint that prevents multiple customer records for the same email across different accounts.
Screenshots (if applicable):
Environment:
Pay gem version: 7.2.1 Ruby version: 3.3.3 Rails version: 7.1.3.4 Operating System: Windows + WSL2
Possible Fix:
Line number 14 here can be either modified or be made optional.
Labels to Apply:
bug
Checklist: