Skip to content

3. Contributing

arti0090 edited this page Oct 17, 2024 · 4 revisions

Install to Contribute

To contribute to the SyliusTpayPlugin you need to first download, install and setup the plugin together with test application.

  1. 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
  1. Go into directory and install vendors
cd SyliusTpayPlugin
composer install
  1. 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 ###
...
  1. Add environment variables (data is used to generate fixtures and for tests)

You can find these keys inside Tpay portal or see Configuring a new payment method in Admin Panel for detailed instructions.

# ./tests/Application/.env
...
###> 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 ###
...
  1. (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 ###
  1. 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)
...
  1. Run Sylius with plugin
(cd tests/Application && bin/console sylius:fixtures:load)
(cd tests/Application && symfony serve)
  1. Your application is ready for use on address in symfony serve (default: 127.0.0.1:8000)

Test environment setup

Running tests require you to create a database, set some environment variables and use a mocking service (we advise to use Mockoon).

  1. 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)
  1. 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>
### 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.

  1. (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)
  1. Now you can run tests with usual commands or by running one found in makefile.
Clone this wiki locally