Skip to content

Commit

Permalink
Merge pull request #12 from PrestaShopCorp/alpha-lib
Browse files Browse the repository at this point in the history
Support PrestaShop 8
  • Loading branch information
jmcollin authored Sep 27, 2022
2 parents f86b556 + ab4b8e3 commit 5154b37
Show file tree
Hide file tree
Showing 12 changed files with 1,294 additions and 629 deletions.
40 changes: 32 additions & 8 deletions .github/workflows/billing-qc-php.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,57 @@
name: PsBilling Quality Control PHP

concurrency:
group: qc-${{ github.ref }}

on: [push]

jobs:
php-linter:
name: PHP Syntax check 5.6|7.2|7.3
name: PHP Syntax check 7.2|7.3|7.4|8.0|8.1
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: PHP syntax checker 5.6
uses: prestashop/github-action-php-lint/5.6@master
uses: actions/checkout@v3
- name: PHP syntax checker 7.2
uses: prestashop/github-action-php-lint/7.2@master
- name: PHP syntax checker 7.3
uses: prestashop/github-action-php-lint/7.3@master
- name: PHP syntax checker 7.4
uses: prestashop/github-action-php-lint/7.4@master
- name: PHP syntax checker 8.0
uses: prestashop/github-action-php-lint/8.0@master
- name: PHP syntax checker 8.1
uses: prestashop/github-action-php-lint/8.1@master

php-cs-fixer:
name: PHP-CS-FIXER
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.0.0
uses: actions/checkout@v3
- name: Run PHP-CS-Fixer
uses: prestashopcorp/github-action-php-cs-fixer@master

phpunit:
name: PHPUNIT
strategy:
matrix:
os: [ubuntu-latest]
version: [7.2, 7.3, 7.4, 8.0, 8.1]
runs-on: ubuntu-latest
steps:
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '7.3'
php-version: ${{ matrix.version }}
- name: Checkout
uses: actions/[email protected]
uses: actions/checkout@v3

- name: Get PHP version
id: php_version
run: |
PHP_VERSION=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")
echo ::set-output name=VERSION::$PHP_VERSION
- name: Cache vendor folder
uses: actions/cache@v1
Expand All @@ -48,11 +65,18 @@ jobs:
path: ~/.composer/cache
key: php-composer-cache

- name: Update dependencies
run: composer update

- name: Install dependencies
run: composer install

- name: PHPUnit tests
run: |
wget -O phpunit https://phar.phpunit.de/phpunit-5.phar
if [[ ${{ steps.php_version.outputs.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
./phpunit tests
63 changes: 49 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# prestashop-rbm-installer
# PrestaShop Billing Lib

Utility package to retrieve SasS App module context and more

[![Latest Stable Version](https://img.shields.io/packagist/v/prestashopcorp/module-lib-billing.svg?style=flat-square)](https://packagist.org/packages/prestashop/prestashopcorp/module-lib-billing) [![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.2.5-8892BF.svg?style=flat-square)](https://php.net/) [![Quality Control Status](https://img.shields.io/github/workflow/status/prestashopcorp/module-lib-billing/PsBilling%20Quality%20Control%20PHP?style=flat-square)](https://github.com/PrestaShopCorp/module-lib-billing/actions/workflows/billing-qc-php.yml)

Utility package to present data from psx configuration page.

## Installation

Expand All @@ -11,6 +14,16 @@ you can install it via [Composer](https://getcomposer.org).
composer require prestashopcorp/module-lib-billing
```

## Version Guidance

| Version | Status | Packagist -| Namespace | Repo | Docs | PHP Version |
|---------|----------------|----------------------|--------------|---------------------|---------------------|--------------|
| 1.x | Security fixes | `module-lib-billing` | `PrestaShopCorp\Billing` | [v1][lib-1-repo] | N/A | >=5.6 |
| 2.x | Latest | `module-lib-billing` | `PrestaShopCorp\Billing` | [v2][lib-2-repo] | N/A | >=7.2.5 |

[lib-1-repo]: https://github.com/PrestaShopCorp/module-lib-billing/tree/1.x
[lib-2-repo]: https://github.com/PrestaShopCorp/module-lib-billing

## Register as a service in your PSx container

Beforehand, you must have defined [PS Account services](https://github.com/PrestaShopCorp/prestashop-accounts-installer#register-as-a-service-in-your-psx-container-recommended)
Expand All @@ -21,13 +34,26 @@ 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_accounts.facade'
- '@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'
- '@rbm_example.context'
```
## How to use it
Expand All @@ -37,15 +63,19 @@ services:
For example in your main module's class `getContent` method.

```php
Media::addJsDef($this->getService('ps_billings.facade')
->present([
'sandbox' => true,
'billingEnv' => 'preprod',
'logo' => '//yoururl.com/logo.svg',
'tosLink' => 'https://yoururl.com/tos',
'emailSupport' => '[email protected]',
])
);
// 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',
]));
```

## Contribute
Expand All @@ -64,7 +94,12 @@ 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)
wget -O phpunit https://phar.phpunit.de/phpunit-5.phar
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

Expand Down
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
]
},
"require": {
"php": ">=5.6",
"guzzlehttp/guzzle": "~6"
"php": "^7.2.5 || ^8.0",
"prestashop/module-lib-guzzle-adapter": "^0"
},
"require-dev": {
"prestashop/php-dev-tools": "^4.2"
"prestashop/php-dev-tools": "^4.2",
"php-http/mock-client": "^1.5",
"guzzlehttp/guzzle": "^7.4"
}
}
Loading

0 comments on commit 5154b37

Please sign in to comment.