All Projects → sburina → laravel-whmcs-up

sburina / laravel-whmcs-up

Licence: MIT license
WHMCS API client and user provider for Laravel

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to laravel-whmcs-up

laravel-whmcs
WHMCS API for Laravel
Stars: ✭ 41 (+86.36%)
Mutual labels:  whmcs, whmcs-api
WHMCS-Action-Hook-Factory
Free collection of Action Hooks, Reports and Modules to perfect your WHMCS
Stars: ✭ 120 (+445.45%)
Mutual labels:  whmcs
MugglePay
Make Crypto Payment Easy 让数字货币支付更简单
Stars: ✭ 176 (+700%)
Mutual labels:  whmcs
WHMCS-Discord-Notifications
A hook to push a range of different WHMCS notifications instantly to a Discord channel.
Stars: ✭ 52 (+136.36%)
Mutual labels:  whmcs
SHOUTcast-Manager
[DEPRECATED] NO LONGER MAINTAINED - A PHP SHOUTcast hosting tool with support for PHP 5.x & 7.x with SHOUTcast v1 & v2)
Stars: ✭ 24 (+9.09%)
Mutual labels:  whmcs
QQConnent-For-WHMCS
WHMCS的QQ互联的模块。
Stars: ✭ 28 (+27.27%)
Mutual labels:  whmcs
docker-whmcs
Docker container ready-to-use for WHMCS environment.
Stars: ✭ 47 (+113.64%)
Mutual labels:  whmcs
WHMCS-zh-CN
WHMCS系统7.9.2-8.5.0前后台简体中文汉化
Stars: ✭ 103 (+368.18%)
Mutual labels:  whmcs
Leap
Free & Open alternative to WHMCS. Let's see if we can make it
Stars: ✭ 270 (+1127.27%)
Mutual labels:  whmcs
WHMCS-JSJ-API-Pay-Gateway
WHMCS 财务系统对接金莎云免签支付API(你们怎么用,与我无瓜好吧:)
Stars: ✭ 58 (+163.64%)
Mutual labels:  whmcs
whmcs-addon
GOGETSSL WHMCS SSL Addon
Stars: ✭ 28 (+27.27%)
Mutual labels:  whmcs
f2faliPay-For-WHMCS
aliPay face to face Pay!
Stars: ✭ 15 (-31.82%)
Mutual labels:  whmcs
whmcs autoauth
Automatic authentication via link in WHMCS template emails.
Stars: ✭ 25 (+13.64%)
Mutual labels:  whmcs
whmcs
WHMCS Module for Pterodactyl (v0.7.3 and higher)
Stars: ✭ 127 (+477.27%)
Mutual labels:  whmcs
PUQ WHMCS-Public-Nextcloud
Module for the WHMCS system. For manage NextCloud users as a product.
Stars: ✭ 17 (-22.73%)
Mutual labels:  whmcs
SolusVM-Premium-For-WHMCS
NeWorld SolusVM Premium Server Module For WHMCS
Stars: ✭ 20 (-9.09%)
Mutual labels:  whmcs
whmcs-vultr
Vultr Module for WHMCS
Stars: ✭ 86 (+290.91%)
Mutual labels:  whmcs

Laravel WHMCS-UP

Latest Stable Version Total Downloads License

This package provides several useful functions for integration of your Laravel application with WHMCS:

  • WHMCS API client
  • WHMCS user provider
  • WHMCS Auto-Login

Installation

Install the package through Composer.

  • Run the Composer require command from the Terminal:
composer require sburina/laravel-whmcs-up
  • Run composer update to pull in the files.

After Laravel 5.5

No additional steps required.

Before Laravel 5.5

  • Add the service provider and alias of the package. To do this, open your config/app.php file.

  • Add a new line to the providers array:

Sburina\Whmcs\WhmcsServiceProvider::class
  • And optionally add a new line to the aliases array:
'Whmcs' => Sburina\Whmcs\Facades\Whmcs::class,
  • From the command-line run:
php artisan vendor:publish --provider=Sburina\Whmcs\WhmcsServiceProvider
  • Open config\whmcs.php to see the available configuration options. The preferred way of configuring the package is via the environment variables in your project's .env file.

Now you can use the package in your Laravel project.

Usage

This package defines several important WHMCS methods with custom signature, providing somewhat easier use and code completion. These methods are:

// Getters
sbGetProducts($pid = null, $gid = null, $module = null);
sbGetClients($limitstart = null, $limitnum = null, $sorting = null, $search = null);
sbGetClientsDetails($email = null, $clientid = null, $stats = false);

// Login
sbValidateLogin($email, $password2);

// AutoLogin
getAutoLoginUrl($goto = null);
redirectAutoLogin($goto = null);

All other WHMCS API methods can be used magically by calling the \Whmcs::{WHMCS_API_METHOD} facade. This also works with all the custom API functions stored in your WHMCS API folder. For complete specification of WHMCS API methods please take a look at the WHMCS API Index.

Examples

Get user's detail using our method:

\Whmcs::sbGetClientsDetails($email);

The same thing, using the original WHMCS API method via a magic call:

\Whmcs::GetClientsDetails([
    'email' => '[email protected]'
]);

Obtain a list of client purchased products

\Whmcs::GetClientsProducts([
    'clientid' => 18122013
]);

Retrieve a specific invoice

\Whmcs::GetInvoice([
    'invoiceid' => 100001
]);

If you for any reason don't like facades, you can use the app() helper.

$whmcs = app('whmcs');
$whmcs->GetInvoice([
    'invoiceid' => 100001
]);

Authenticating against WHMCS user base

If your Laravel application doesn't have its own user base, but you still need to authenticate users before allowing them to access certain pages (NOT WHMCS pages), there are few additional steps to take:

  • Register the user provider in your AuthServiceProvider boot() method:
	public function boot()
	{
		$this->registerPolicies();

		Auth::provider('whmcs', function () {
			return new \Sburina\Whmcs\UserProvider();
		});
	}
  • In config/auth.php define the new provider:
	'providers' => [
		 'users' => [
		     'driver' => 'whmcs',
		 ],
  • in the same file, the web guard is already configured to use users provider, so there's no need to change anything. You could decide to give the provider a different name, in which case you'd need to define the same name for the appropriate guard.

Now you can simply use the existing Laravel Auth::routes() with already provided auth pages, exactly the same way as if you had a local user base.

On successful login, the session_key named in config/whmcs.php (default: user) will be populated with user data retrieved from WHMCS, and the login session will start as usual. auth()->check() and auth()->guest() will work, and auth()->user() will return the instance of WhmcsUser class with attributes populated with user's data. User's data won't be retrieved from WHMCS again while the login session is in progress and the session key user exists.

On logout, the session key user will be destroyed and the login session will end.

Remote login / redirect

User that logged in into your Laravel application this way will not be automatically logged in to WHMCS! To redirect the authenticated user to any protected WHMCS page and log them into WHMCS automatically at the same time, you can use:

return \Whmcs::redirectAutoLogin();

config/whmcs.php option autoauth.goto determines the default URI for such redirects. You can override the default by adding the argument to this method:

return \Whmcs::redirectAutoLogin('cart.php');

If you'd prefer just getting the login URL and sending it to the user from your own code, you can do it like so:

$url = \Whmcs::getAutoLoginUrl();

Again, you can override the default URI:

$url = \Whmcs::getAutoLoginUrl('cart.php');

To learn more about this feature and how to enable it in WHMCS, see WHMCS AutoAuth.

Support

Please open an issue in github

License

This package is released under the MIT License. See the bundled LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].