Utility package to retrieve Built for PS context and more
This package is available on Packagist, you can install it via Composer.
composer require prestashopcorp/module-lib-billing
Version | Status | Packagist - | Namespace | Repo | Docs | PHP Version |
---|---|---|---|---|---|---|
1.x | Security fixes | module-lib-billing |
PrestaShopCorp\Billing |
v1 | N/A | >=5.6 |
2.x | Security fixes | module-lib-billing |
PrestaShopCorp\Billing |
v2 | N/A | >=7.2.5 |
3.x | Latest | module-lib-billing |
PrestaShopCorp\Billing |
v3 | N/A | >=5.6 |
Beforehand, you must have defined PS Account services
Example :
services:
#####################
# PS Billing
ps_billings.context_wrapper:
class: 'PrestaShopCorp\Billing\Wrappers\BillingContextWrapper'
arguments:
- "@ps_accounts.facade"
- "@rbm_example.context"
- true # if true you are in sandbox mode, if false or empty not in sandbox
ps_billings.facade:
class: 'PrestaShopCorp\Billing\Presenter\BillingPresenter'
arguments:
- "@ps_billings.context_wrapper"
- "@rbm_example.module"
# Remove this if you don't need BillingService
ps_billings.service:
class: PrestaShopCorp\Billing\Services\BillingService
public: true
arguments:
- "@ps_billings.context_wrapper"
- "@rbm_example.module"
For example in your main module's class getContent
method.
// Load context for PsBilling
$billingFacade = $this->getService('ps_billings.facade');
// Remove this if you don't need to set an image
$partnerLogo = $this->getLocalPath() . ' views/img/partnerLogo.png';
// Billing
Media::addJsDef($billingFacade->present([
'logo' => $partnerLogo,
'tosLink' => 'https://yoururl/',
'privacyLink' => 'https://yoururl/',
'emailSupport' => 'you@email',
]));
php vendor/bin/php-cs-fixer fix
Please follow theses steps to launch unit tests
# Needs to have wget, for OS without wget pleae see the official website (or just visit this link)
PHP_VERSION=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")
if [[ ${PHP_VERSION} -gt "72" ]]; then
wget -O phpunit https://phar.phpunit.de/phpunit-9.phar
else
wget -O phpunit https://phar.phpunit.de/phpunit-8.phar
fi
chmod +x phpunit
# Should display the version
./phpunit --version
./phpunit tests
PrestaShop module system is not able to handle multiple version of the same library.
Here is an example:
- Module A requires the v1 of a libA
- Module B requires the v2 of this same libA
If someone install module A then module B, only the v1 of libA will be loaded for both Module A and Module B.
When introducing a breaking change to a class or method signature, you should instead create a new class rather to changing the existing one.
By creating a new class it will force the autoloader to use the last version of the lib.