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

WHMCS AddClient API Returning Null on Success #298

Open
lindiarm opened this issue Oct 4, 2024 · 0 comments
Open

WHMCS AddClient API Returning Null on Success #298

lindiarm opened this issue Oct 4, 2024 · 0 comments

Comments

@lindiarm
Copy link

lindiarm commented Oct 4, 2024

Issue Description:

We are using the AddClient API from WHMCS, which has been working as expected until recently. We encountered an issue where, after the action is executed successfully, the API returns null in the response instead of the expected result.

Code Implementation:

AddClient Action:

class AddClient extends Action implements ActionInterface
{
    public function handle($data = [])
    {
        $params = array_merge([
            'action' => 'AddClient',
        ], $data);

        return Whmcs::getClient($params)->json();
    }
}

AddClientRequest Validation Rules:

public function rules()
{
    return [
        'firstname' => 'required|string|max:255',
        'lastname' => 'required|string',
        'email' => 'required|string|email|max:255',
        'phonenumber' => 'required|string',
        'companyname' => 'nullable|string',
        'address1' => 'required|string',
        'address2' => 'nullable|string',
        'city' => 'required|string',
        'state' => 'required|string',
        'postcode' => 'required|string',
        'country' => 'required|string|max:2',
        'marketingoptin' => 'nullable|boolean',
        'password2' => ['required', 'confirmed', Rules\Password::defaults()],
        'consent' => 'required|boolean|accepted',
    ];
}

Problem:

Upon calling the AddClient action, the API returns null in the response, even though the user and client accounts are successfully created in the database. The expected output should be:

{
    "result": "success",
    "clientid": "1"
}

However, it currently returns null while still saving the client and user data in the system.

Store Method Implementation:

public function store(AddClientRequest $request)
{
    $data = AddClient::run($request->validated());

    if ($data['result'] === 'error') {
        return back()->with('error', $data['message']);
    }

    // Other logic if success...
}
@lindiarm lindiarm changed the title WHMCS AddClient API Returning Null on Success WHMCS version 8.10.1 AddClient API Returning Null on Success Oct 4, 2024
@lindiarm lindiarm changed the title WHMCS version 8.10.1 AddClient API Returning Null on Success WHMCS AddClient API Returning Null on Success Oct 4, 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

No branches or pull requests

1 participant