-
Notifications
You must be signed in to change notification settings - Fork 1
3. Contributing
To contribute to the SyliusTpayPlugin you need to first download, install and setup the plugin together with test application.
- Download the repository:
# using HTTPS
git clone https://github.com/CommerceWeavers/SyliusTpayPlugin.git
# using SSH
git clone [email protected]:CommerceWeavers/SyliusTpayPlugin.git
# using GitHub CLI
gh repo clone CommerceWeavers/SyliusTpayPlugin
- Go into directory and install vendors
cd SyliusTpayPlugin
composer install
- Set Payum cypher defuse key
# generate key using command:
vendor/bin/generate-defuse-key
# will return defuse-key
# copy defuse-key into ./tests/Application/.env file
...
###> payum/payum ###
PAYUM_CYPHER_KEY=<defuse-key>
###< payum/payum ###
...
- Add environment variables (data is used to generate fixtures and for tests, they are not intended to be used in the end-app)
You can find these keys inside Tpay portal or see Configuring a new payment method in Admin Panel for detailed instructions.
# ./tests/Application/.env.dev
...
###> commerce-weavers/sylius-tpay-plugin ###
TPAY_CLIENT_ID=<edit_me>
TPAY_CLIENT_SECRET=<edit_me>
TPAY_CARDS_API=<edit_me>
TPAY_NOTIFICATION_SECURITY_CODE=<edit_me>
###< commerce-weavers/sylius-tpay-plugin ###
...
- (Optional) Google Pay
To use Google Pay you need to add TPAY_MERCHANT_ID
. You can find it on top right corner of Tpay Panel when logged in.
To find TPAY_GOOGLE_MERCHANT_ID
you need to create Google Merchant account, and use this link for further instructions.
Note: TPAY_GOOGLE_MERCHANT_ID
is only necessary for production purposes. For development/testing purposes you can set any value.
###> commerce-weavers/sylius-tpay-plugin ###
TPAY_MERCHANT_ID=<edit_me>
TPAY_GOOGLE_MERCHANT_ID=<edit_me>
###< commerce-weavers/sylius-tpay-plugin ###
- (Optional) Apple Pay
To use Apple Pay you need to add TPAY_APPLE_PAY_MERCHANT_ID
. To create account, use this link for further instructions.
###> commerce-weavers/sylius-tpay-plugin ###
TPAY_APPLE_PAY_MERCHANT_ID=<edit_me>
###< commerce-weavers/sylius-tpay-plugin ###
- Install test application
(cd tests/Application && yarn install)
(cd tests/Application && yarn build)
(cd tests/Application && bin/console assets:install)
(cd tests/Application && bin/console doctrine:database:create)
(cd tests/Application && bin/console doctrine:migrations:migrate -n)
Note: If you are using npm
over yarn
use:
(cd tests/Application && npm install)
(cd tests/Application && npm run build)
...
- Run Sylius with plugin
(cd tests/Application && bin/console sylius:fixtures:load)
(cd tests/Application && symfony serve)
- Your application is ready for use on address in
symfony serve
(default: 127.0.0.1:8000)
Running tests require you to create a database, set some environment variables and use a mocking service (we advise to use Mockoon).
- Creating test database
(cd tests/Application && APP_ENV=test bin/console doctrine:database:create)
(cd tests/Application && APP_ENV=test bin/console doctrine:migrations:migrate -n)
- Adding the environment variables
# ./tests/Application/.env.test
...
###> payum/payum ###
PAYUM_CYPHER_KEY=<defuse-key>
###< payum/payum ###
###> commerce-weavers/sylius-tpay-plugin ###
TPAY_API_URL=<your-mocking-server-address> (default: http://localhost:4000)
### commerce-weavers/sylius-tpay-plugin ###
...
Note: set the TPAY_API_URL
with address set on Mockoon. Inside of ./tests/Application/mockoon_tpay.json
you can find basic configuration for Mockoon.
- (Optional) Run Sylius with plugin in test environment
(cd tests/Application && APP_ENV=test bin/console sylius:fixtures:load)
(cd tests/Application && APP_ENV=test symfony serve)
- (Optional) Running E2E Panther tests
To run these tests you need to install few libraries required by panther. You can checkout how to install them here according to the system you are using.
If you are not using chrome browser you might also need to install it (as panther is using chrome and chromedriver to run tests).
- Now you can run tests with usual commands or by running one found in
makefile
.