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

Handle empty name values for a customer #268

Merged
merged 3 commits into from
Jul 23, 2024

Conversation

doncadavona
Copy link
Contributor

Gracefully throw an error for the case where there is no name set for the customer.

See #266.

Copy link
Member

@driesvints driesvints left a 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?

@doncadavona
Copy link
Contributor Author

I think so too. Yes, let me try and adjust the name to be nullable.

@doncadavona
Copy link
Contributor Author

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.

@doncadavona doncadavona marked this pull request as ready for review July 23, 2024 06:11
@driesvints
Copy link
Member

Amazing @doncadavona, thanks for that clean solution. Could we also update other places where we set the name like in the webhooks?

@doncadavona
Copy link
Contributor Author

doncadavona commented Jul 23, 2024

Hi @driesvints ,

I just updated this section in the webhook where the customer name was also being set:

fc522fe

Thanks for pointing that out too.

Copy link
Member

@driesvints driesvints left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. Thank you!

@taylorotwell taylorotwell merged commit 0657240 into laravel:2.x Jul 23, 2024
2 of 7 checks passed
@driesvints driesvints changed the title Throw an informative error when there is no name set for the customer Handle empty name values for a customer Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants