The module ps_accounts is the interface between your module and PrestaShop's services. It manages:
- Shop association/dissociation process;
- Providing tokens to communicate safely with PrestaShop services;
- Synchronize basic informations about the shops (ex: shop URLs, name, ...).
This module is a basis for other modules using PrestaShop services.
If you need to install and test the module, you can download the desired zip here.
We aims to follow partially the Prestashop compatibility charts
- Compatibility Chart Prestashop 1.6 & 1.7
- Compatibility Chart Prestashop 8.0
- Compatibility Chart Prestashop 9.0
ps_accounts version | Prestashop Version | PHP Version |
---|---|---|
^7.0.9 | >=1.6 && <= 9.x | PHP 5.6 - 8 |
7.x | >=1.6 && <9.x | PHP 5.6 - 8 |
If you are integrating a module, you should have a look on the PrestaShop Integration Framework Documentation.
- doesn't manage dependencies between modules;
- doesn't manage composer dependencies globally.
- check by yourself that the PsAccounts module is installed;
- ensure your vendor dependencies won't collide with existing ones.
(loaded by other modules OR coming from the PrestaShop Core)
The presenter will give basic informations to the components through contextPsAccounts
object accessible on the page.
// My_module.php
// /!\ TODO: Starting here you are responsible to check that the module is installed
/** @var Ps_accounts $module */
$module = \Module::getModuleIdByName('ps_accounts');
/** @var \PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter $presenter */
$presenter = $module->getService(\PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter::class);
Media::addJsDef([
'contextPsAccounts' => $presenter->present((string) $this->name),
]);
return $this->display(__FILE__, 'views/templates/admin/app.tpl');
Alternatively you can still use : PrestaShop Accounts Installer for more details on how to setup Installer.
For detailed usage you can follow the component's documentation : prestashop_accounts_vue_components
All the JWT tokens exposed follow the OpenId Connect Token and Access Tokens Specs.
This module provides the following tokens:
- ShopToken (legacy Firebase tokens)
This token can be used to act as the shop. It should be used only for machine to machine communication without user interaction - OwnerToken (legacy Firebase tokens)
This token is created for the shop owner who associate the shop. - ShopAccessToken (provided by Prestashop OpenId Connect Provider)
For machine to machine calls. (also used to keep up to date legacy Shop and Owner tokens
// /!\ TODO: Starting here you are responsible to check that the module is installed
/** @var Ps_accounts $module */
$module = \Module::getModuleIdByName('ps_accounts');
/** @var \PrestaShop\Module\PsAccounts\Service\PsAccountsService $service */
$service = $module->getService(\PrestaShop\Module\PsAccounts\Service\PsAccountsService::class);
// With this one you can call your API's as the PrestaShop Account Shop
$jwtShop = $service->getOrRefreshToken();
// With this one you can call your API's as the PrestaShop Account Shop Owner
$jwtOwner = $service->getUserToken();
That way you will retrieve an up to date Shop Token
const response = await fetch("https://<shop-admin-url>/index.php", {
ajax: true,
controller: 'AdminAjaxPsAccounts',
action: 'getOrRefreshAccessToken',
token: '<admin_token>',
});
With the given response :
{
"token": "<access_token>"
}
Here are listed custom hooks provided with this module:
hook | params | description |
---|---|---|
actionShopAccountLinkAfter | shopId, shopUuid | Triggered after link shop acknowledged |
actionShopAccountUnlinkAfter | shopId, shopUuid | Triggered after unlink shop acknowledged |
actionShopAccessTokenRefreshAfter | token | Triggered after OAuth access token refreshed |
In case you need to build a zip by yourself :
cp config.dist.php config.php
make
OR with multiple environments :
cp config.dist.php config.myenv.php
BUNDLE_ENV=myenv make