diff --git a/README.md b/README.md index d23faeb..67a4858 100644 --- a/README.md +++ b/README.md @@ -1,112 +1,54 @@

- - - + logo alma +

-

Plugin Skeleton

+

Sylius Alma Payment Plugin

-

Skeleton for starting Sylius plugins.

+

Integrate Alma installments and pay later payments with your Sylius shop

## Documentation -For a comprehensive guide on Sylius Plugins development please go to Sylius documentation, -there you will find the Plugin Development Guide, that is full of examples. - -## Quickstart Installation - -1. Run `composer create-project sylius/plugin-skeleton ProjectName`. - -2. From the plugin skeleton root directory, run the following commands: - - ```bash - $ (cd tests/Application && yarn install) - $ (cd tests/Application && yarn build) - $ (cd tests/Application && APP_ENV=test bin/console assets:install public) - - $ (cd tests/Application && APP_ENV=test bin/console doctrine:database:create) - $ (cd tests/Application && APP_ENV=test bin/console doctrine:schema:create) - ``` - -To be able to setup a plugin's database, remember to configure you database credentials in `tests/Application/.env` and `tests/Application/.env.test`. - -## Usage - -### Running plugin tests - - - PHPUnit - - ```bash - vendor/bin/phpunit - ``` - - - PHPSpec - - ```bash - vendor/bin/phpspec run - ``` - - - Behat (non-JS scenarios) - - ```bash - vendor/bin/behat --strict --tags="~@javascript" - ``` - - - Behat (JS scenarios) - - 1. [Install Symfony CLI command](https://symfony.com/download). - - 2. Start Headless Chrome: - - ```bash - google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 - ``` - - 3. Install SSL certificates (only once needed) and run test application's webserver on `127.0.0.1:8080`: - - ```bash - symfony server:ca:install - APP_ENV=test symfony server:start --port=8080 --dir=tests/Application/public --daemon - ``` - - 4. Run Behat: - - ```bash - vendor/bin/behat --strict --tags="@javascript" - ``` - - - Static Analysis - - - Psalm - - ```bash - vendor/bin/psalm - ``` - - - PHPStan - - ```bash - vendor/bin/phpstan analyse -c phpstan.neon -l max src/ - ``` - - - Coding Standard - - ```bash - vendor/bin/ecs check src - ``` - -### Opening Sylius with your plugin - -- Using `test` environment: - - ```bash - (cd tests/Application && APP_ENV=test bin/console sylius:fixtures:load) - (cd tests/Application && APP_ENV=test bin/console server:run -d public) - ``` - -- Using `dev` environment: - - ```bash - (cd tests/Application && APP_ENV=dev bin/console sylius:fixtures:load) - (cd tests/Application && APP_ENV=dev bin/console server:run -d public) - ``` +### Installation +Use Composer to install the plugin: + +``` +$ composer require alma/sylius-payment-plugin +``` + +Update your shop's translation catalogs: + +``` +$ php bin/console translation:update --dump-messages fr AlmaSyliusPaymentPlugin +$ php bin/console translation:update --dump-messages en AlmaSyliusPaymentPlugin +``` + +Finally, clear your cache: + +``` +$ php bin/console cache:clear +``` + +### Requirements +Alma currently accepts Euros only; make sure you activate your payment method on channels that use that currency, else +you won't see it at checkout. + +Your Alma payment methods will only show for eligible carts. Eligibility is mainly based on the purchased amount, which +by default should be between 100€ and 2000€; if you want those limits changed, you can talk to your sales representative +at Alma, or contact [support@getalma.eu](mailto:support@getalma.eu). + +### Usage +1. Go to the Payment Methods admin page and choose to create a new "Alma Payments" method + +2. Grab your API keys [from your dashboard](https://dashboard.getalma.eu/api) and paste them into the appropriate fields + +3. Choose the installments count to apply for this payment method. If you want to offer multiple installments counts to + your customers, you can create one Alma payment method per installments count. + +4. Set the API mode to Test if you want to first test the integration with a fake credit card, on your preproduction + servers for instance. + When you're ready for production, set the API mode to Live. + +5. Choose a name for your method in the languages relevant to your shop. + +6. You're done! Save the payment method to start accepting instalments payments on your shop! diff --git a/UPGRADE.md b/UPGRADE.md deleted file mode 100644 index 8c28fba..0000000 --- a/UPGRADE.md +++ /dev/null @@ -1,122 +0,0 @@ -# UPGRADE FROM `v1.3.X` TO `v1.4.0` - -First step is upgrading Sylius with composer - -- `composer require sylius/sylius:~1.4.0` - -### Test application database - -#### Migrations - -If you provide migrations with your plugin, take a look at following changes: - -* Change base `AbstractMigration` namespace to `Doctrine\Migrations\AbstractMigration` -* Add `: void` return types to both `up` and `down` functions - -#### Schema update - -If you don't use migrations, just run `(cd tests/Application && bin/console doctrine:schema:update --force)` to update the test application's database schema. - -### Dotenv - -* `composer require symfony/dotenv:^4.2 --dev` -* Follow [Symfony dotenv update guide](https://symfony.com/doc/current/configuration/dot-env-changes.html) to incorporate required changes in `.env` files structure. Remember - they should be done on `tests/Application/` level! Optionally, you can take a look at [corresponding PR](https://github.com/Sylius/PluginSkeleton/pull/156/) introducing these changes in **PluginSkeleton** (this PR also includes changes with Behat - see below) - -Don't forget to clear the cache (`tests/Application/bin/console cache:clear`) to be 100% everything is loaded properly. - -### Test application kernel - -The kernel of the test application needs to be replaced with this [file](https://github.com/Sylius/PluginSkeleton/blob/1.4/tests/Application/Kernel.php). -The location of the kernel is: `tests/Application/Kernel.php` (replace the content with the content of the file above). -The container cleanup method is removed in the new version and keeping it will cause problems with for example the `TagAwareAdapter` which will call `commit()` on its pool from its destructor. If its pool is `TraceableAdapter` with pool `ArrayAdapter`, then the pool property of `TraceableAdapter` will be nullified before the destructor is executed and cause an error. - ---- - -### Behat - -If you're using Behat and want to be up-to-date with our configuration - -* Update required extensions with `composer require friends-of-behat/symfony-extension:^2.0 friends-of-behat/page-object-extension:^0.3 --dev` -* Remove extensions that are not needed yet with `composer remove friends-of-behat/context-service-extension friends-of-behat/cross-container-extension friends-of-behat/service-container-extension --dev` -* Update your `behat.yml` - look at the diff [here](https://github.com/Sylius/Sylius-Standard/pull/322/files#diff-7bde54db60a6e933518d8b61b929edce) -* Add `SymfonyExtensionBundle` to your `tests/Application/config/bundles.php`: - ```php - return [ - //... - FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true], - ]; - ``` -* If you use our Travis CI configuration, follow [these changes](https://github.com/Sylius/PluginSkeleton/pull/156/files#diff-354f30a63fb0907d4ad57269548329e3) introduced in `.travis.yml` file -* Create `tests/Application/config/services_test.yaml` file with the following code and add these your own Behat services as well: - ```yaml - imports: - - { resource: "../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" } - ``` -* Remove all `__symfony__` prefixes in your Behat services -* Remove all `` tags from your Behat services -* Make your Behat services public by default with `` -* Change `contexts_services ` in your suite definitions to `contexts` -* Take a look at [SymfonyExtension UPGRADE guide](https://github.com/FriendsOfBehat/SymfonyExtension/blob/master/UPGRADE-2.0.md) if you have any more problems - -### Phpstan - -* Fix the container XML path parameter in the `phpstan.neon` file as done [here](https://github.com/Sylius/PluginSkeleton/commit/37fa614dbbcf8eb31b89eaf202b4bd4d89a5c7b3) - -# UPGRADE FROM `v1.2.X` TO `v1.4.0` - -Firstly, check out the [PluginSkeleton 1.3 upgrade guide](https://github.com/Sylius/PluginSkeleton/blob/1.4/UPGRADE-1.3.md) to update Sylius version step by step. -To upgrade to Sylius 1.4 follow instructions from [the previous section](https://github.com/Sylius/PluginSkeleton/blob/1.4/UPGRADE-1.4.md#upgrade-from-v13x-to-v140) with following changes: - -### Doctrine migrations - -* Change namespaces of copied migrations to `Sylius\Migrations` - -### Dotenv - -* These changes are not required, but can be done as well, if you've changed application directory structure in `1.2.x` to `1.3` update - -### Behat - -* Add `\FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle()` to your bundles lists in `tests/Application/AppKernel.php` (preferably only in `test` environment) -* Import Sylius Behat services in `tests/Application/config/config_test.yml` and your own Behat services as well: - ```yaml - imports: - - { resource: "../../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" } - ``` -* Specify test application's kernel path in `behat.yml`: - ```yaml - FriendsOfBehat\SymfonyExtension: - kernel: - class: AppKernel - path: tests/Application/app/AppKernel.php - ``` - - -# UPGRADE FROM `v1.2.X` TO `v1.3.0` - -## Application - -* Run `composer require sylius/sylius:~1.3.0 --no-update` - -* Add the following code in your `behat.yml(.dist)` file: - - ```yaml - default: - extensions: - FriendsOfBehat\SymfonyExtension: - env_file: ~ - ``` - -* Incorporate changes from the following files into plugin's test application: - - * [`tests/Application/package.json`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/package.json) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-726e1353c14df7d91379c0dea6b30eef)) - * [`tests/Application/.babelrc`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/.babelrc) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-a2527d9d8ad55460b2272274762c9386)) - * [`tests/Application/.eslintrc.js`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/.eslintrc.js) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-396c8c412b119deaa7dd84ae28ae04ca)) - -* Update PHP and JS dependencies by running `composer update` and `(cd tests/Application && yarn upgrade)` - -* Clear cache by running `(cd tests/Application && bin/console cache:clear)` - -* Install assets by `(cd tests/Application && bin/console assets:install web)` and `(cd tests/Application && yarn build)` - -* optionally, remove the build for PHP 7.1. in `.travis.yml` diff --git a/composer.json b/composer.json index 1b7e207..fa39cf9 100644 --- a/composer.json +++ b/composer.json @@ -1,80 +1,68 @@ { - "name": "alma/sylius-installment-plugin", - "type": "sylius-plugin", - "keywords": [ - "sylius", - "sylius-plugin" + "name": "alma/sylius-payment-plugin", + "type": "sylius-plugin", + "keywords": [ + "alma", + "buy now pay later", + "bnpl", + "installments", + "payment", + "sylius", + "sylius-plugin" + ], + "description": "Payment plugin to integrate Alma installments and pay later payments with your Sylius shop", + "license": "MIT", + "require": { + "php": "^7.1", + "alma/alma-php-client": "^1.0", + "sylius/sylius": "^1.6.9", + "ext-json": "*" + }, + "require-dev": { + "behat/behat": "^3.6.1", + "behat/mink-selenium2-driver": "^1.4", + "dmore/behat-chrome-extension": "^1.3", + "dmore/chrome-mink-driver": "^2.7", + "friends-of-behat/mink": "^1.8", + "friends-of-behat/mink-browserkit-driver": "^1.4", + "friends-of-behat/mink-extension": "^2.4", + "friends-of-behat/page-object-extension": "^0.3", + "friends-of-behat/suite-settings-extension": "^1.0", + "friends-of-behat/symfony-extension": "^2.1", + "friends-of-behat/variadic-extension": "^1.3", + "lakion/mink-debug-extension": "^1.2.3", + "phpspec/phpspec": "^6.1", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "0.12.25", + "phpstan/phpstan-doctrine": "0.12.13", + "phpstan/phpstan-strict-rules": "^0.12.0", + "phpstan/phpstan-webmozart-assert": "0.12.4", + "phpunit/phpunit": "^8.5", + "sensiolabs/security-checker": "^6.0", + "sylius-labs/coding-standard": "^3.1", + "symfony/browser-kit": "^4.4", + "symfony/debug-bundle": "^4.4|^5.0", + "symfony/dotenv": "^4.4|^5.0", + "symfony/intl": "^4.4|^5.0", + "symfony/web-profiler-bundle": "^4.4|^5.0", + "symfony/web-server-bundle": "^4.4|^5.0", + "vimeo/psalm": "3.11.4" + }, + "autoload": { + "psr-4": { + "Alma\\SyliusPaymentPlugin\\": "src/" + } + }, + "autoload-dev": { + "classmap": [ + "tests/Application/Kernel.php" ], - "description": "Plugin allowing to pay with Alma", - "license": "MIT", - "require": { - "php": "^7.1", - "alma/alma-php-client": "^1.0", - "sylius/sylius": "1.6.9", - "ext-json": "*" - }, - "conflict": { - "api-platform/core": ">=2.6.0" - }, - "require-dev": { - "behat/behat": "^3.6.1", - "behat/mink-selenium2-driver": "^1.4", - "dmore/behat-chrome-extension": "^1.3", - "dmore/chrome-mink-driver": "^2.7", - "friends-of-behat/mink": "^1.8", - "friends-of-behat/mink-browserkit-driver": "^1.4", - "friends-of-behat/mink-extension": "^2.4", - "friends-of-behat/page-object-extension": "^0.3", - "friends-of-behat/suite-settings-extension": "^1.0", - "friends-of-behat/symfony-extension": "^2.1", - "friends-of-behat/variadic-extension": "^1.3", - "lakion/mink-debug-extension": "^1.2.3", - "phpspec/phpspec": "^6.1", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.25", - "phpstan/phpstan-doctrine": "0.12.13", - "phpstan/phpstan-strict-rules": "^0.12.0", - "phpstan/phpstan-webmozart-assert": "0.12.4", - "phpunit/phpunit": "^8.5", - "sensiolabs/security-checker": "^6.0", - "sylius-labs/coding-standard": "^3.1", - "symfony/browser-kit": "^4.4", - "symfony/debug-bundle": "^4.4|^5.0", - "symfony/dotenv": "^4.4|^5.0", - "symfony/intl": "^4.4|^5.0", - "symfony/web-profiler-bundle": "^4.4|^5.0", - "symfony/web-server-bundle": "^4.4|^5.0", - "vimeo/psalm": "3.11.4" - }, - "autoload": { - "psr-4": { - "Alma\\SyliusPaymentPlugin\\": "src/", - "Tests\\Alma\\SyliusPaymentPlugin\\App\\": "tests/Application/src/", - "Tests\\Alma\\SyliusPaymentPlugin\\": "tests/" - } - }, - "autoload-dev": { - "classmap": [ - "tests/Application/Kernel.php" - ] - }, - "extra": { - "branch-alias": { - "dev-master": "1.8-dev" - } - }, - "config": { - "sort-packages": true - }, - "scripts": { - "post-install-cmd": [ - "php bin/create_node_symlink.php" - ], - "post-update-cmd": [ - "php bin/create_node_symlink.php" - ], - "post-create-project-cmd": [ - "php bin/create_node_symlink.php" - ] + "psr-4": { + "Tests\\Alma\\SyliusPaymentPlugin\\App\\": "tests/Application/src/", + "Tests\\Alma\\SyliusPaymentPlugin\\": "tests/" } + }, + "config": { + "sort-packages": true + } }