Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/vendor/
/node_modules/
/composer.lock

/etc/build/*
!/etc/build/.gitignore

/tests/Application/yarn.lock

/behat.yml
/phpspec.yml
77 changes: 77 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
language: php

dist: trusty

sudo: false

php:
- 7.2
- 7.3

cache:
yarn: true
directories:
- ~/.composer/cache/files
- $SYLIUS_CACHE_DIR

env:
global:
- APP_ENV=test
- SYLIUS_CACHE_DIR=$HOME/.sylius-cache
- SYLIUS_BUILD_DIR=etc/build

before_install:
- phpenv config-rm xdebug.ini
- echo "memory_limit=4096M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- mkdir -p "${SYLIUS_CACHE_DIR}"
- mkdir -p tests/Application/web/media/image

install:
- composer install --no-interaction --prefer-dist
- (cd tests/Application && yarn install)

before_script:
- (cd tests/Application && bin/console doctrine:database:create -vvv)
- (cd tests/Application && bin/console doctrine:schema:create -vvv)
- (cd tests/Application && bin/console assets:install public -vvv)
- (cd tests/Application && bin/console cache:warmup -vvv)
- (cd tests/Application && yarn build)

# Configure display
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1680x1050x16
- export DISPLAY=:99

# Download and configure ChromeDriver
- |
if [ ! -f $SYLIUS_CACHE_DIR/chromedriver ] || [ "$($SYLIUS_CACHE_DIR/chromedriver --version | grep -c 2.34)" = "0" ]; then
curl http://chromedriver.storage.googleapis.com/2.34/chromedriver_linux64.zip > chromedriver.zip
unzip chromedriver.zip
chmod +x chromedriver
mv chromedriver $SYLIUS_CACHE_DIR
fi

# Run ChromeDriver
- $SYLIUS_CACHE_DIR/chromedriver > /dev/null 2>&1 &

# Download and configure Selenium
- |
if [ ! -f $SYLIUS_CACHE_DIR/selenium.jar ] || [ "$(java -jar $SYLIUS_CACHE_DIR/selenium.jar --version | grep -c 3.4.0)" = "0" ]; then
curl http://selenium-release.storage.googleapis.com/3.4/selenium-server-standalone-3.4.0.jar > selenium.jar
mv selenium.jar $SYLIUS_CACHE_DIR
fi

# Run Selenium
- java -Dwebdriver.chrome.driver=$SYLIUS_CACHE_DIR/chromedriver -jar $SYLIUS_CACHE_DIR/selenium.jar > /dev/null 2>&1 &

# Run webserver
- (cd tests/Application && bin/console server:run 127.0.0.1:8080 --quiet > /dev/null 2>&1 &)

script:
- composer validate --strict

- vendor/bin/phpunit
- vendor/bin/phpspec run
- vendor/bin/behat --strict -vvv --no-interaction || vendor/bin/behat --strict -vvv --no-interaction --rerun

after_failure:
- vendor/lakion/mink-debug-extension/travis/tools/upload-textfiles "${SYLIUS_BUILD_DIR}/*.log"
109 changes: 109 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
## Overview

This plugin allows you to integrate PayPlug payment with Sylius platform app.

## Installation

Add a package to your private repository and add the repository to `composer.json`:

```json
{
"minimum-stability": "dev",
"repositories": [
{
"type": "vcs",
"url": "<your URL to private repository>"
}
]
}
```

1. Require plugin with composer:

```bash
composer require payplug/payplug-plugin
```

2. Import configuration in your `config/packages/_sylius.yaml` file:

```yaml
imports:
- { resource: "@PayPlugSyliusPayPlugPlugin/Resources/config/config.yml" }
```

3. Add plugin class to your `config/bundles.php` file:

```php
$bundles = [
PayPlug\SyliusPayPlugPlugin\PayPlugSyliusPayPlugPlugin::class => ['all' => true],
];
```

4. Clear cache:

```bash
bin/console cache:clear
```

## Requirements

In the channel settings, the base currency must be set to EUR because the payment gateway only works in this currency. The plugin in the local environment will not work properly because you will not be notified of the status of payments from the payment gateway

## Cron job

In the case when the IPN is blocked, you can set cron job every minute that updates the payment status.

For example:

```bash
* * * * * bin/console payplug:update-payment-state
```

## Logs

If you want to follow the logs in the production environment, you need to add the configuration in `config/packages/prod/monolog.yaml`, logs should be in `var/log/prod.log` which can be searched after the phrase `[Payum]` or `[PayPlug]`:

```yaml
monolog:
handlers:
...

payum:
level: debug
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
```

## IPN testing on the local machine

In the configuration of the payment gateway in the admin panel, set your url (eg from [ngrok](https://ngrok.com/)) to notifications in the field `Notification url for environment dev`. This url will only work in the dev environment.

## Customization

### Available services you can [decorate](https://symfony.com/doc/current/service_container/service_decoration.html) and forms you can [extend](http://symfony.com/doc/current/form/create_form_type_extension.html)

Run the below command to see what Symfony services are shared with this plugin:

```bash
$ bin/console debug:container payplug_sylius_payplug_plugin
```

## Testing

```bash
$ composer install
$ cd tests/Application
$ yarn install
$ yarn run gulp
$ bin/console assets:install web -e test
$ bin/console doctrine:database:create -e test
$ bin/console doctrine:schema:create -e test
$ bin/console server:run 127.0.0.1:8080 -d web -e test
$ open http://localhost:8080
$ bin/behat
$ bin/phpspec run
```

## Contribution

Learn more about our contribution workflow on http://docs.sylius.org/en/latest/contributing/.
28 changes: 28 additions & 0 deletions UPGRADE-1.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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`
86 changes: 86 additions & 0 deletions UPGRADE-1.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# 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.

---

### 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 `<tag name="fob.context_service" />` tags from your Behat services
* Make your Behat services public by default with `<defaults public="true" />`
* 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
```
47 changes: 47 additions & 0 deletions behat.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
imports:
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml
- tests/Behat/Resources/suites.yml

default:
extensions:
Lakion\Behat\MinkDebugExtension:
directory: etc/build
clean_start: false
screenshot: true

Behat\MinkExtension:
files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/"
base_url: "http://localhost:8080/"
default_session: symfony
javascript_session: chrome
sessions:
symfony:
symfony: ~
chrome:
selenium2:
browser: chrome
capabilities:
browserName: chrome
browser: chrome
version: ""
marionette: null # https://github.com/Behat/MinkExtension/pull/311
chrome:
switches:
- "start-fullscreen"
- "start-maximized"
- "no-sandbox"
firefox:
selenium2:
browser: firefox
show_auto: false

FriendsOfBehat\SymfonyExtension:
bootstrap: tests/Application/config/bootstrap.php
kernel:
class: Tests\PayPlug\SyliusPayPlugPlugin\Application\Kernel

FriendsOfBehat\VariadicExtension: ~

FriendsOfBehat\SuiteSettingsExtension:
paths:
- "features"
Loading