-
Notifications
You must be signed in to change notification settings - Fork 57
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
Handle empty name values for a customer #268
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm if name
is nullable
then I'd rather follow the behaviour from Paddle and make the database column nullable. Can you make that adjustment?
I think so too. Yes, let me try and adjust the |
…t is not set in Paddle.
Hi @driesvints , I have finally found a clean way of handling the issue, instead of throwing an error (as I initially thought of) when the name is not set in Paddle, like so: // File src/Concerns/ManagesCustomer.php
if (is_null($response['name'])) {
throw new LogicException("The Paddle customer [{$response['id']}] has no name. You may need to set the name of the customer in the Paddle dasbhboard.");
} We could simply have the customer name as an empty string, if it is empty in Paddle, like so: // File src/Concerns/ManagesCustomer.php at line 54
$customer->name = $response['name'] ?? ''; Please check my latest commit in this MR. |
Amazing @doncadavona, thanks for that clean solution. Could we also update other places where we set the name like in the webhooks? |
… it is not set in Paddle.
Hi @driesvints , I just updated this section in the webhook where the customer name was also being set: Thanks for pointing that out too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect. Thank you!
Gracefully throw an error for the case where there is no name set for the customer.
See #266.