2020-10-08 20:03:07 -03:00
# WooCommerce PayPal Payments
2020-03-19 16:47:08 +01:00
2021-03-09 13:43:24 +02:00
PayPal's latest complete payments processing solution. Accept PayPal, Pay Later, credit/debit cards, alternative digital wallets local payment types and bank accounts. Turn on only PayPal options or process a full suite of payment methods. Enable global transaction with extensive currency and country coverage.
2020-03-19 16:47:08 +01:00
2021-12-08 16:33:10 -03:00
## Dependencies
2020-03-19 16:47:08 +01:00
2021-08-18 15:40:55 +02:00
* PHP >= 7.1
2020-10-08 07:36:52 +03:00
* WordPress >=5.3
* WooCommerce >=4.5
2020-03-19 16:47:08 +01:00
2020-10-08 07:36:52 +03:00
## Development
2020-03-19 16:47:08 +01:00
2021-12-08 16:33:10 -03:00
### Install dependencies & build
- `$ composer install`
- `$ yarn run build:dev`
Optionally, change the `PAYPAL_INTEGRATION_DATE` constant to `gmdate( 'Y-m-d' )` to run the latest PayPal JavaScript SDK
2020-03-19 16:47:08 +01:00
2020-10-08 07:36:52 +03:00
### Unit tests and code style
2020-03-19 16:47:08 +01:00
2020-10-08 07:36:52 +03:00
1. `$ composer install`
2. `$ ./vendor/bin/phpunit`
2021-08-19 10:12:15 +03:00
3. `$ ./vendor/bin/phpcs`
2021-10-13 17:42:39 +03:00
4. `$ ./vendor/bin/psalm`
2020-03-19 16:47:08 +01:00
2021-12-08 16:33:10 -03:00
### Building a release package
If you want to build a release package
(that can be used for deploying a new version on wordpress.org or manual installation on a WP website via ZIP uploading),
follow these steps:
1. Clone the repository and `cd` into it.
2. Make sure you have the version in the plugin root file updated.
3. Update the PayPal JavaScript SDK integration date by using the current date for the `PAYPAL_INTEGRATION_DATE` constant.
4. The following command should get you a ZIP file ready to be used on a WordPress site:
```
$ yarn run build
```
2022-01-03 17:05:40 +02:00
or if using the Docker setup:
```
$ yarn run docker:build-package
```
2021-12-08 16:33:10 -03:00
## Setup
2021-08-19 17:49:54 +03:00
2021-12-08 16:33:10 -03:00
You can install WooCommerce PayPal Payments locally using the dev environment of your preference, or you can use the Docker environment which includes WP, WC and all developments tools.
To set up the Docker environment, follow these steps:
2021-08-19 17:49:54 +03:00
0. Install Docker and Docker Compose.
1. `$ cp .env.example .env` and edit the configuration in the `.env` file if needed.
2. `$ yarn run docker:build` (or copy the commands from [package.json ](/package.json ) if you do not have `yarn` ).
2021-08-30 16:57:02 +03:00
3. `$ yarn run docker:install`
4. `$ yarn run docker:start`
2021-08-19 17:49:54 +03:00
5. Add `127.0.0.1 wc-pp.myhost` to your `hosts` file and open http://wc-pp.myhost (the default value of `WP_DOMAIN` in `.env` ).
2021-12-08 16:33:10 -03:00
### Running tests in the Docker environment
2021-08-19 17:49:54 +03:00
Tests and code style:
2021-12-08 16:33:10 -03:00
- `$ yarn run docker:test`
2021-08-19 17:49:54 +03:00
- `$ yarn run docker:lint`
After some changes in `.env` (such as PHP, WP versions) you may need to rebuild the Docker image:
1. `$ yarn run docker:destroy` (all data will be lost)
2. `$ yarn run docker:build`
See [package.json ](/package.json ) for other useful commands.
2021-12-08 16:33:10 -03:00
## Test account setup
You will need a PayPal sandbox merchant and customer accounts to configure the plugin and make test purchases with it.
For setting up test accounts follow [these instructions ](https://github.com/woocommerce/woocommerce-paypal-payments/wiki/Testing-Setup ).
## Webhooks
2021-10-12 12:45:53 +03:00
For testing webhooks locally, follow these steps to set up ngrok:
0. Install [ngrok ](https://ngrok.com/ ).
1. Run
```
ngrok http -host-header=rewrite wc-pp.myhost
```
2. In your environment variables (accessible to the web server), add `NGROK_HOST` with the host that you got from `ngrok` , like `abcd1234.ngrok.io` .
- For the Docker environment: set `NGROK_HOST` in the `.env` file and restart the web server. (`yarn run docker:stop && yarn run docker:start` )
3. Complete onboarding or resubscribe webhooks on the Webhooks Status page.
Currently, ngrok is used only for the webhook listening URL.
The URLs displayed on the WordPress pages, used in redirects, etc. will still remain local.
2020-10-08 07:36:52 +03:00
## License
2020-03-19 16:47:08 +01:00
2020-10-08 07:36:52 +03:00
[GPL-2.0 License ](LICENSE )
2020-03-19 16:47:08 +01:00
## Contributing
2020-10-08 20:03:07 -03:00
All feedback / bug reports / pull requests are welcome.