mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Compare commits
41 commits
88347ece39
...
58e6f3beb7
Author | SHA1 | Date | |
---|---|---|---|
|
58e6f3beb7 | ||
|
c92969e0d4 | ||
|
098a79279d | ||
|
c54fe336d8 | ||
|
df34b7f5c3 | ||
|
c6f95af15f | ||
|
ef031e593c | ||
|
fb576e3839 | ||
|
b48534fb00 | ||
|
049b31b611 | ||
|
5d5775e02b | ||
|
3836771dae | ||
|
8825a88764 | ||
|
f5c9c4298a | ||
|
32afcda616 | ||
|
af71409850 | ||
|
c8ae55c6aa | ||
|
9d53b4ecf7 | ||
|
9c688efbeb | ||
|
3b80ec8333 | ||
|
54980aff73 | ||
|
8e8ad4ff28 | ||
|
d221544442 | ||
|
7905fe29ad | ||
|
46eeeb0b36 | ||
|
11ef14b13c | ||
|
6856448c63 | ||
|
1c2d7e032a | ||
|
d1afbe4a46 | ||
|
2925b73430 | ||
|
224900c6a4 | ||
|
720acca8a5 | ||
|
ddb0ae3b11 | ||
|
4c9ca19ec8 | ||
|
e2fb54c7a9 | ||
|
060a86f5c9 | ||
|
2ab3b5ef54 | ||
|
fef445c928 | ||
|
7cf0939953 | ||
|
f65b72e653 | ||
|
1262ed2c56 |
240 changed files with 1895 additions and 1152 deletions
82
README.md
82
README.md
|
@ -52,26 +52,56 @@ Visit our [official documentation](https://woocommerce.com/document/woocommerce-
|
|||
|
||||
## Development
|
||||
|
||||
### Install dependencies & build
|
||||
### Setup using DDEV (recommended)
|
||||
|
||||
You can install WooCommerce PayPal Payments locally using the dev environment of your preference, or you can use the DDEV setup provided in this repository. Which includes WordPress, WooCommerce and all development tools.
|
||||
|
||||
To set up the DDEV environment, follow these steps:
|
||||
|
||||
0. Install Docker and [DDEV](https://ddev.readthedocs.io/en/stable/).
|
||||
1. Edit the [configuration](https://docs.ddev.com/en/stable/users/configuration/config/#managing-configuration) in the [`.ddev/config.yml`](.ddev/config.yaml) file if needed.
|
||||
2. `$ ddev setup` to setup and orchestrate the plugin, WooCommerce and WordPress
|
||||
3. Open https://woocommerce-paypal-payments.ddev.site
|
||||
|
||||
Use `$ ddev reset` for reinstallation (will destroy all site data).
|
||||
You may also need `$ ddev restart` to apply the config changes.
|
||||
|
||||
#### Running tests and other tasks in the DDEV environment
|
||||
|
||||
Tests and code style:
|
||||
- `$ yarn ddev:unit-tests`
|
||||
- `$ yarn ddev:lint`
|
||||
- `$ yarn ddev:fix-lint`
|
||||
- `$ yarn ddev:lint-js`
|
||||
|
||||
See [package.json](/package.json) for other useful commands.
|
||||
|
||||
For debugging, see [the DDEV docs](https://ddev.readthedocs.io/en/stable/users/step-debugging/).
|
||||
Enable xdebug via `$ ddev xdebug enable`, and press `Start Listening for PHP Debug Connections` in PHPStorm.
|
||||
After creating the server in the PHPStorm dialog, you need to set the local project path for the server plugin path.
|
||||
Check [this article](https://docs.ddev.com/en/stable/users/debugging-profiling/step-debugging/#phpstorm-debugging-setup) for a detailed guide.
|
||||
|
||||
## Setup in other environments
|
||||
|
||||
#### Install dependencies & build
|
||||
|
||||
- `$ composer install`
|
||||
- `$ yarn install`
|
||||
|
||||
Optionally, change the `PAYPAL_INTEGRATION_DATE` constant to `gmdate( 'Y-m-d' )` to run the latest PayPal JavaScript SDK
|
||||
|
||||
### Unit tests and code style
|
||||
#### Unit tests and code style
|
||||
|
||||
1. `$ composer install`
|
||||
2. `$ ./vendor/bin/phpunit`
|
||||
3. `$ ./vendor/bin/phpcs`
|
||||
4. `$ ./vendor/bin/psalm`
|
||||
5. `$ wp-scripts lint-js`
|
||||
6. `$ yarn run test:unit-js` - Ensure node version is `18` or above
|
||||
1. `$ ./vendor/bin/phpunit`
|
||||
2. `$ ./vendor/bin/phpcs`
|
||||
3. `$ ./vendor/bin/psalm`
|
||||
4. `$ yarn run lint-js`
|
||||
5. `$ yarn run test:unit-js` - Ensure node version is `18` or above
|
||||
|
||||
### 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),
|
||||
(that can be used for deploying a new version on wordpress.org or manual installation on a WordPress website via ZIP uploading),
|
||||
follow these steps:
|
||||
|
||||
1. Clone the repository and `cd` into it.
|
||||
|
@ -88,38 +118,6 @@ or if using the DDEV setup:
|
|||
$ yarn run ddev:build-package
|
||||
```
|
||||
|
||||
## Setup
|
||||
|
||||
You can install WooCommerce PayPal Payments locally using the dev environment of your preference, or you can use the DDEV setup provided in this repository which includes WP, WC and all developments tools.
|
||||
|
||||
To set up the DDEV environment, follow these steps:
|
||||
|
||||
0. Install Docker and [DDEV](https://ddev.readthedocs.io/en/stable/).
|
||||
1. Edit the configuration in the [`.ddev/config.yml`](.ddev/config.yaml) file if needed.
|
||||
2. `$ ddev start`
|
||||
3. `$ ddev orchestrate` to install WP/WC.
|
||||
4. Open https://wc-pp.ddev.site
|
||||
|
||||
Use `$ ddev orchestrate -f` for reinstallation (will destroy all site data).
|
||||
You may also need `$ ddev restart` to apply the config changes.
|
||||
|
||||
### Running tests and other tasks in the DDEV environment
|
||||
|
||||
Tests and code style:
|
||||
- `$ yarn ddev:test`
|
||||
- `$ yarn ddev:lint`
|
||||
- `$ yarn ddev:fix-lint`
|
||||
- `$ yarn ddev:lint-js`
|
||||
|
||||
See [package.json](/package.json) for other useful commands.
|
||||
|
||||
For debugging, see [the DDEV docs](https://ddev.readthedocs.io/en/stable/users/step-debugging/).
|
||||
Enable xdebug via `$ ddev xdebug`, and press `Start Listening for PHP Debug Connections` in PHPStorm.
|
||||
After creating the server in the PHPStorm dialog, you need to set the local project path for the server plugin path.
|
||||
It should look [like this](https://i.imgur.com/ofsF1Mc.png).
|
||||
|
||||
See [tests/playwright](tests/playwright) for e2e (browser-based) tests.
|
||||
|
||||
## Test account setup
|
||||
|
||||
You will need a PayPal sandbox merchant and customer accounts to configure the plugin and make test purchases with it.
|
||||
|
@ -133,7 +131,7 @@ For testing webhooks locally, follow these steps to set up ngrok:
|
|||
0. Install [ngrok](https://ngrok.com/).
|
||||
|
||||
1.
|
||||
- If using DDEV, run our wrapper Bash script which will start `ddev share` and replace the URLs in the WP database:
|
||||
- If using DDEV, run our wrapper Bash script which will start `ddev share` and replace the URLs in the WordPress database:
|
||||
```
|
||||
$ .ddev/bin/share
|
||||
```
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
"container-interop/service-provider": "^0.4.0",
|
||||
"dhii/containers": "^0.1.0-alpha1",
|
||||
"inpsyde/modularity": "^1.7",
|
||||
"woocommerce/woocommerce-sniffs": "^0.1.0",
|
||||
"woocommerce/woocommerce-sniffs": "^1.0.0",
|
||||
"phpunit/phpunit": "^7.0 | ^8.0 | ^9.0",
|
||||
"brain/monkey": "^2.4",
|
||||
"php-stubs/wordpress-stubs": "^5.0@stable",
|
||||
|
|
302
composer.lock
generated
302
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "6ca9c2c7864d2649617db6d3850382c5",
|
||||
"content-hash": "fd277e5a82374078694b99b0e6aef07c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "container-interop/service-provider",
|
||||
|
@ -1263,35 +1263,38 @@
|
|||
},
|
||||
{
|
||||
"name": "dealerdirect/phpcodesniffer-composer-installer",
|
||||
"version": "v0.7.2",
|
||||
"version": "v1.1.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
|
||||
"reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db"
|
||||
"url": "https://github.com/PHPCSStandards/composer-installer.git",
|
||||
"reference": "e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db",
|
||||
"reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db",
|
||||
"url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1",
|
||||
"reference": "e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.0 || ^2.0",
|
||||
"php": ">=5.3",
|
||||
"composer-plugin-api": "^2.2",
|
||||
"php": ">=5.4",
|
||||
"squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "*",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.3.1",
|
||||
"phpcompatibility/php-compatibility": "^9.0"
|
||||
"composer/composer": "^2.2",
|
||||
"ext-json": "*",
|
||||
"ext-zip": "*",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.4.0",
|
||||
"phpcompatibility/php-compatibility": "^9.0",
|
||||
"yoast/phpunit-polyfills": "^1.0"
|
||||
},
|
||||
"type": "composer-plugin",
|
||||
"extra": {
|
||||
"class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
|
||||
"class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
|
||||
"PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
|
@ -1301,17 +1304,16 @@
|
|||
"authors": [
|
||||
{
|
||||
"name": "Franck Nijhof",
|
||||
"email": "franck.nijhof@dealerdirect.com",
|
||||
"homepage": "http://www.frenck.nl",
|
||||
"role": "Developer / IT Manager"
|
||||
"email": "opensource@frenck.dev",
|
||||
"homepage": "https://frenck.dev",
|
||||
"role": "Open source developer"
|
||||
},
|
||||
{
|
||||
"name": "Contributors",
|
||||
"homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors"
|
||||
"homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"description": "PHP_CodeSniffer Standards Composer Installer Plugin",
|
||||
"homepage": "http://www.dealerdirect.com",
|
||||
"keywords": [
|
||||
"PHPCodeSniffer",
|
||||
"PHP_CodeSniffer",
|
||||
|
@ -1331,10 +1333,29 @@
|
|||
"tests"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues",
|
||||
"source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer"
|
||||
"issues": "https://github.com/PHPCSStandards/composer-installer/issues",
|
||||
"security": "https://github.com/PHPCSStandards/composer-installer/security/policy",
|
||||
"source": "https://github.com/PHPCSStandards/composer-installer"
|
||||
},
|
||||
"time": "2022-02-04T12:51:07+00:00"
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/PHPCSStandards",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/jrfnl",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://opencollective.com/php_codesniffer",
|
||||
"type": "open_collective"
|
||||
},
|
||||
{
|
||||
"url": "https://thanks.dev/u/gh/phpcsstandards",
|
||||
"type": "thanks_dev"
|
||||
}
|
||||
],
|
||||
"time": "2025-07-17T20:45:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dhii/collections-interface",
|
||||
|
@ -2817,6 +2838,181 @@
|
|||
],
|
||||
"time": "2025-05-12T16:38:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpcsstandards/phpcsextra",
|
||||
"version": "1.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPCSStandards/PHPCSExtra.git",
|
||||
"reference": "fa4b8d051e278072928e32d817456a7fdb57b6ca"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/fa4b8d051e278072928e32d817456a7fdb57b6ca",
|
||||
"reference": "fa4b8d051e278072928e32d817456a7fdb57b6ca",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4",
|
||||
"phpcsstandards/phpcsutils": "^1.1.0",
|
||||
"squizlabs/php_codesniffer": "^3.13.0 || ^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-parallel-lint/php-console-highlighter": "^1.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.4.0",
|
||||
"phpcsstandards/phpcsdevcs": "^1.1.6",
|
||||
"phpcsstandards/phpcsdevtools": "^1.2.1",
|
||||
"phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4"
|
||||
},
|
||||
"type": "phpcodesniffer-standard",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-stable": "1.x-dev",
|
||||
"dev-develop": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-3.0-or-later"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Juliette Reinders Folmer",
|
||||
"homepage": "https://github.com/jrfnl",
|
||||
"role": "lead"
|
||||
},
|
||||
{
|
||||
"name": "Contributors",
|
||||
"homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"description": "A collection of sniffs and standards for use with PHP_CodeSniffer.",
|
||||
"keywords": [
|
||||
"PHP_CodeSniffer",
|
||||
"phpcbf",
|
||||
"phpcodesniffer-standard",
|
||||
"phpcs",
|
||||
"standards",
|
||||
"static analysis"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues",
|
||||
"security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy",
|
||||
"source": "https://github.com/PHPCSStandards/PHPCSExtra"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/PHPCSStandards",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/jrfnl",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://opencollective.com/php_codesniffer",
|
||||
"type": "open_collective"
|
||||
},
|
||||
{
|
||||
"url": "https://thanks.dev/u/gh/phpcsstandards",
|
||||
"type": "thanks_dev"
|
||||
}
|
||||
],
|
||||
"time": "2025-06-14T07:40:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpcsstandards/phpcsutils",
|
||||
"version": "1.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPCSStandards/PHPCSUtils.git",
|
||||
"reference": "f7eb16f2fa4237d5db9e8fed8050239bee17a9bd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/f7eb16f2fa4237d5db9e8fed8050239bee17a9bd",
|
||||
"reference": "f7eb16f2fa4237d5db9e8fed8050239bee17a9bd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0",
|
||||
"php": ">=5.4",
|
||||
"squizlabs/php_codesniffer": "^3.13.0 || ^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-filter": "*",
|
||||
"php-parallel-lint/php-console-highlighter": "^1.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.4.0",
|
||||
"phpcsstandards/phpcsdevcs": "^1.1.6",
|
||||
"yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0 || ^3.0.0"
|
||||
},
|
||||
"type": "phpcodesniffer-standard",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-stable": "1.x-dev",
|
||||
"dev-develop": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"PHPCSUtils/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-3.0-or-later"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Juliette Reinders Folmer",
|
||||
"homepage": "https://github.com/jrfnl",
|
||||
"role": "lead"
|
||||
},
|
||||
{
|
||||
"name": "Contributors",
|
||||
"homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"description": "A suite of utility functions for use with PHP_CodeSniffer",
|
||||
"homepage": "https://phpcsutils.com/",
|
||||
"keywords": [
|
||||
"PHP_CodeSniffer",
|
||||
"phpcbf",
|
||||
"phpcodesniffer-standard",
|
||||
"phpcs",
|
||||
"phpcs3",
|
||||
"phpcs4",
|
||||
"standards",
|
||||
"static analysis",
|
||||
"tokens",
|
||||
"utility"
|
||||
],
|
||||
"support": {
|
||||
"docs": "https://phpcsutils.com/",
|
||||
"issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues",
|
||||
"security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy",
|
||||
"source": "https://github.com/PHPCSStandards/PHPCSUtils"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/PHPCSStandards",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/jrfnl",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://opencollective.com/php_codesniffer",
|
||||
"type": "open_collective"
|
||||
},
|
||||
{
|
||||
"url": "https://thanks.dev/u/gh/phpcsstandards",
|
||||
"type": "thanks_dev"
|
||||
}
|
||||
],
|
||||
"time": "2025-08-10T01:04:45+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-common",
|
||||
"version": "2.2.0",
|
||||
|
@ -5737,74 +5933,77 @@
|
|||
},
|
||||
{
|
||||
"name": "woocommerce/woocommerce-sniffs",
|
||||
"version": "0.1.3",
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/woocommerce/woocommerce-sniffs.git",
|
||||
"reference": "4576d54595614d689bc4436acff8baaece3c5bb0"
|
||||
"reference": "3a65b917ff5ab5e65609e5dcb7bc62f9455bbef8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/4576d54595614d689bc4436acff8baaece3c5bb0",
|
||||
"reference": "4576d54595614d689bc4436acff8baaece3c5bb0",
|
||||
"url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/3a65b917ff5ab5e65609e5dcb7bc62f9455bbef8",
|
||||
"reference": "3a65b917ff5ab5e65609e5dcb7bc62f9455bbef8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
|
||||
"php": ">=7.0",
|
||||
"phpcompatibility/phpcompatibility-wp": "^2.1.0",
|
||||
"wp-coding-standards/wpcs": "^2.3.0"
|
||||
"wp-coding-standards/wpcs": "^3.0.0"
|
||||
},
|
||||
"type": "phpcodesniffer-standard",
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Claudio Sanches",
|
||||
"email": "claudio@automattic.com"
|
||||
}
|
||||
],
|
||||
"description": "WooCommerce sniffs",
|
||||
"keywords": [
|
||||
"phpcs",
|
||||
"standards",
|
||||
"static analysis",
|
||||
"woocommerce",
|
||||
"wordpress"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/woocommerce/woocommerce-sniffs/issues",
|
||||
"source": "https://github.com/woocommerce/woocommerce-sniffs/tree/0.1.3"
|
||||
"source": "https://github.com/woocommerce/woocommerce-sniffs/tree/1.0.0"
|
||||
},
|
||||
"time": "2022-02-17T15:34:51+00:00"
|
||||
"time": "2023-09-29T13:52:33+00:00"
|
||||
},
|
||||
{
|
||||
"name": "wp-coding-standards/wpcs",
|
||||
"version": "2.3.0",
|
||||
"version": "3.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/WordPress/WordPress-Coding-Standards.git",
|
||||
"reference": "7da1894633f168fe244afc6de00d141f27517b62"
|
||||
"reference": "d2421de7cec3274ae622c22c744de9a62c7925af"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62",
|
||||
"reference": "7da1894633f168fe244afc6de00d141f27517b62",
|
||||
"url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/d2421de7cec3274ae622c22c744de9a62c7925af",
|
||||
"reference": "d2421de7cec3274ae622c22c744de9a62c7925af",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-filter": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-tokenizer": "*",
|
||||
"ext-xmlreader": "*",
|
||||
"php": ">=5.4",
|
||||
"squizlabs/php_codesniffer": "^3.3.1"
|
||||
"phpcsstandards/phpcsextra": "^1.4.0",
|
||||
"phpcsstandards/phpcsutils": "^1.1.0",
|
||||
"squizlabs/php_codesniffer": "^3.13.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6",
|
||||
"php-parallel-lint/php-console-highlighter": "^1.0.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.4.0",
|
||||
"phpcompatibility/php-compatibility": "^9.0",
|
||||
"phpcsstandards/phpcsdevtools": "^1.0",
|
||||
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
|
||||
"phpcsstandards/phpcsdevtools": "^1.2.0",
|
||||
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
|
||||
},
|
||||
"suggest": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically."
|
||||
"ext-iconv": "For improved results",
|
||||
"ext-mbstring": "For improved results"
|
||||
},
|
||||
"type": "phpcodesniffer-standard",
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
|
@ -5821,6 +6020,7 @@
|
|||
"keywords": [
|
||||
"phpcs",
|
||||
"standards",
|
||||
"static analysis",
|
||||
"wordpress"
|
||||
],
|
||||
"support": {
|
||||
|
@ -5828,14 +6028,20 @@
|
|||
"source": "https://github.com/WordPress/WordPress-Coding-Standards",
|
||||
"wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki"
|
||||
},
|
||||
"time": "2020-05-13T23:57:56+00:00"
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://opencollective.com/php_codesniffer",
|
||||
"type": "custom"
|
||||
}
|
||||
],
|
||||
"time": "2025-07-24T20:08:31+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": {
|
||||
"php-stubs/wordpress-stubs": 0,
|
||||
"php-stubs/woocommerce-stubs": 0
|
||||
"php-stubs/woocommerce-stubs": 0,
|
||||
"php-stubs/wordpress-stubs": 0
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"prefer-lowest": false,
|
||||
|
@ -5843,7 +6049,7 @@
|
|||
"php": "^7.4 | ^8.0",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"platform-dev": {},
|
||||
"platform-overrides": {
|
||||
"php": "7.4"
|
||||
},
|
||||
|
|
115
docs/inbox-notifications-guide.md
Normal file
115
docs/inbox-notifications-guide.md
Normal file
|
@ -0,0 +1,115 @@
|
|||
# WooCommerce Home Inbox Notifications Development Guide
|
||||
|
||||
This guide explains how to create and manage inbox notifications that appear in the WooCommerce Admin dashboard.
|
||||
|
||||
## Overview
|
||||
|
||||
The WooCommerce PayPal Payments plugin uses a structured system to create inbox notes through three main components: note definitions, note objects, and registration handling.
|
||||
|
||||
## Architecture
|
||||
|
||||
### 1. Define Inbox Notes
|
||||
|
||||
Inbox notes are defined as service configurations in `modules/ppcp-wc-gateway/services.php` (Service name: `wcgateway.settings.inbox-notes`). The system creates an array of `InboxNote` objects with the following properties:
|
||||
|
||||
- `title`: The note headline
|
||||
- `content`: The note body text
|
||||
- `type`: Note type (e.g., `Note::E_WC_ADMIN_NOTE_INFORMATIONAL`)
|
||||
- `name`: Unique identifier for the note
|
||||
- `status`: Note status (e.g., `Note::E_WC_ADMIN_NOTE_UNACTIONED`)
|
||||
- `is_enabled`: Boolean function to control visibility
|
||||
- `action`: An `InboxNoteAction` object for user interactions
|
||||
|
||||
### 2. Create Inbox Note Objects
|
||||
|
||||
Each inbox note is created using the `InboxNoteFactory` and `InboxNote` class. The constructor requires all the properties listed above.
|
||||
|
||||
### 3. Register Inbox Notes
|
||||
|
||||
The `InboxNoteRegistrar` handles the registration process by:
|
||||
- Creating WooCommerce `Note` objects from `InboxNote` definitions
|
||||
- Saving notes to display in the admin inbox
|
||||
- Managing note lifecycle (creation/deletion based on conditions)
|
||||
|
||||
### 4. Registration Hook
|
||||
|
||||
Inbox notes are registered via the `register_woo_inbox_notes` method in `WCGatewayModule`, which hooks into the `admin_init` action.
|
||||
|
||||
## Implementation Example
|
||||
|
||||
```php
|
||||
// In services.php
|
||||
'inbox-note.example' => static function ( ContainerInterface $container ): InboxNote {
|
||||
return $container->get( 'inbox-note.factory' )->create_note(
|
||||
__( 'Example Note Title', 'woocommerce-paypal-payments' ),
|
||||
__( 'This is the note content that appears in the inbox.', 'woocommerce-paypal-payments' ),
|
||||
Note::E_WC_ADMIN_NOTE_INFORMATIONAL,
|
||||
'example-note-unique-name',
|
||||
Note::E_WC_ADMIN_NOTE_UNACTIONED,
|
||||
static function () use ( $container ): bool {
|
||||
// Conditional logic to determine when note should be shown
|
||||
return true; // or your condition
|
||||
},
|
||||
new InboxNoteAction(
|
||||
'apply_now',
|
||||
__( 'Apply now', 'woocommerce-paypal-payments' ),
|
||||
'http://example.com/',
|
||||
Note::E_WC_ADMIN_NOTE_UNACTIONED,
|
||||
true
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
```
|
||||
|
||||
## Content Limitations
|
||||
|
||||
WooCommerce inbox notes have several restrictions:
|
||||
|
||||
### Character Limit
|
||||
- Content is automatically truncated at **320 characters** with "..."
|
||||
- No expansion option available in the UI
|
||||
- Reference: [WooCommerce Developer Blog ↗](https://developer.woocommerce.com/2021/11/10/introducing-a-320-character-limit-to-inbox-notes/)
|
||||
|
||||
### HTML Restrictions
|
||||
Only basic HTML tags are allowed:
|
||||
- `<strong>`, `<em>` for emphasis
|
||||
- `<a>` for links (with `href`, `rel`, `name`, `target`, `download` attributes)
|
||||
- `<br>`, `<p>` for formatting
|
||||
- Tags like `<sup>`, `<sub>`, `<span>` are stripped
|
||||
|
||||
### Workarounds
|
||||
- Use asterisks (*) for emphasis when HTML tags aren't supported
|
||||
- Keep messages concise and prioritize essential information
|
||||
- Place most important content within the first 320 characters
|
||||
|
||||
## Automatic Cleanup
|
||||
|
||||
The system includes automatic cleanup functionality:
|
||||
- Notes are deleted when their `is_enabled` condition becomes `false` (`InboxNoteRegistrar.php`)
|
||||
- This prevents stale notifications from persisting in the admin
|
||||
|
||||
## Actions
|
||||
|
||||
Notes can include user actions defined through the `InboxNoteAction` class. Actions appear as buttons in the inbox note and can:
|
||||
- Navigate to specific admin pages
|
||||
- Trigger custom functionality
|
||||
- Dismiss or acknowledge the notification
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use descriptive, unique names** for note identification
|
||||
2. **Implement proper conditional logic** in the `is_enabled` function
|
||||
3. **Keep content concise** due to the 320-character limit
|
||||
4. **Test note visibility conditions** thoroughly
|
||||
5. **Provide clear, actionable next steps** through note actions
|
||||
6. **Consider cleanup scenarios** when notes should be removed
|
||||
|
||||
## Existing Examples
|
||||
|
||||
The codebase includes several inbox note implementations:
|
||||
- PayPal Working Capital note
|
||||
- Settings migration notices
|
||||
- Feature announcements
|
||||
|
||||
These examples demonstrate conditional logic based on feature flags, user settings, and other criteria.
|
296
docs/woocommerce-tasks-guide.md
Normal file
296
docs/woocommerce-tasks-guide.md
Normal file
|
@ -0,0 +1,296 @@
|
|||
# WooCommerce Tasks and Todos Development Guide
|
||||
|
||||
This guide explains how to create and manage task items that appear in WooCommerce's "Things to do next" section, as well as in the "Things to do next" section of the plugin’s overview tab. The PayPal Payments plugin uses two distinct systems to cover different use cases.
|
||||
|
||||
## Overview
|
||||
|
||||
The plugin uses two separate task systems:
|
||||
|
||||
1. **WooCommerce Native Tasks System** - Integrates with WooCommerce's built-in task list
|
||||
2. **Plugin's React-Based Todos System** - Custom implementation for the PayPal settings interface
|
||||
|
||||
## WooCommerce Native Tasks System
|
||||
|
||||
### Architecture
|
||||
|
||||
Native WooCommerce tasks are managed through the `TaskRegistrar` system and appear in WooCommerce's main admin "Things to do next" section.
|
||||
|
||||
### Implementation
|
||||
|
||||
Tasks are registered via the `register_wc_tasks` method in `WCGatewayModule.php`, which:
|
||||
|
||||
1. Hooks into the `init` action for proper timing
|
||||
2. Retrieves simple redirect tasks from the container
|
||||
3. Uses the `TaskRegistrar` to register tasks with the 'extended' list
|
||||
4. Includes error handling and logging for registration failures
|
||||
|
||||
```php
|
||||
protected function register_wc_tasks( ContainerInterface $container ): void {
|
||||
add_action(
|
||||
'init',
|
||||
static function () use ( $container ): void {
|
||||
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
||||
try {
|
||||
$simple_redirect_tasks = $container->get( 'wcgateway.settings.wc-tasks.simple-redirect-tasks' );
|
||||
if ( empty( $simple_redirect_tasks ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$task_registrar = $container->get( 'wcgateway.settings.wc-tasks.task-registrar' );
|
||||
$task_registrar->register( 'extended', $simple_redirect_tasks );
|
||||
} catch ( Exception $exception ) {
|
||||
$logger->error( "Failed to create a task in the 'Things to do next' section of WC. " . $exception->getMessage() );
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### Task Configuration
|
||||
|
||||
Tasks are defined in `services.php` as service definitions. Each task configuration includes:
|
||||
|
||||
- `id`: Unique identifier for the task
|
||||
- `title`: Display title in the task list
|
||||
- `description`: Explanatory text for what the task accomplishes
|
||||
- `redirect_url`: URL where users are taken when they click the task
|
||||
|
||||
```php
|
||||
// Example: Pay Later messaging configuration task
|
||||
'wcgateway.settings.wc-tasks.pay-later-task-config' => static function( ContainerInterface $container ): array {
|
||||
$section_id = Settings::CONNECTION_TAB_ID;
|
||||
$pay_later_tab_id = Settings::PAY_LATER_TAB_ID;
|
||||
|
||||
if ( $container->has( 'paylater-configurator.is-available' ) && $container->get( 'paylater-configurator.is-available' ) ) {
|
||||
return array(
|
||||
array(
|
||||
'id' => 'pay-later-messaging-task',
|
||||
'title' => __( 'Configure PayPal Pay Later messaging', 'woocommerce-paypal-payments' ),
|
||||
'description' => __( 'Decide where you want dynamic Pay Later messaging to show up and how you want it to look on your site.', 'woocommerce-paypal-payments' ),
|
||||
'redirect_url' => admin_url( "admin.php?page=wc-settings&tab=checkout§ion={$section_id}&ppcp-tab={$pay_later_tab_id}" ),
|
||||
),
|
||||
);
|
||||
}
|
||||
return array();
|
||||
},
|
||||
```
|
||||
|
||||
### Registration Process
|
||||
|
||||
The `TaskRegistrar` class handles task registration through the `register()` method:
|
||||
|
||||
```php
|
||||
public function register( string $list_id, array $tasks ): void {
|
||||
$task_lists = TaskLists::get_lists();
|
||||
if ( ! isset( $task_lists[ $list_id ] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( $tasks as $task ) {
|
||||
$added_task = TaskLists::add_task( $list_id, $task );
|
||||
if ( $added_task instanceof WP_Error ) {
|
||||
throw new RuntimeException( $added_task->get_error_message() );
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The registration process:
|
||||
- Validates the target task list exists
|
||||
- Iterates through task definitions
|
||||
- Uses WooCommerce's `TaskLists::add_task()` API
|
||||
- Handles registration errors with exceptions
|
||||
|
||||
## Plugin's React-Based Todos System
|
||||
|
||||
### Architecture
|
||||
|
||||
The custom todos system provides more advanced functionality and appears specifically in the PayPal Payments settings Overview tab.
|
||||
|
||||
### Components
|
||||
|
||||
1. **Backend Definition** - `TodosDefinition.php` contains todo configurations
|
||||
2. **REST API Endpoint** - `TodosRestEndpoint.php` handles CRUD operations
|
||||
3. **React Frontend** - `Todos.js` renders the user interface
|
||||
|
||||
### Todo Configuration
|
||||
|
||||
Each todo item in `TodosDefinition.php` requires the following properties:
|
||||
|
||||
```php
|
||||
public function get(): array {
|
||||
$eligibility_checks = $this->eligibilities->get_eligibility_checks();
|
||||
|
||||
$todo_items = array(
|
||||
'enable_fastlane' => array(
|
||||
'title' => __( 'Enable Fastlane', 'woocommerce-paypal-payments' ),
|
||||
'description' => __( 'Accelerate your guest checkout with Fastlane by PayPal', 'woocommerce-paypal-payments' ),
|
||||
'isEligible' => $eligibility_checks['enable_fastlane'],
|
||||
'action' => array(
|
||||
'type' => 'tab',
|
||||
'tab' => 'payment_methods',
|
||||
'section' => 'ppcp-axo-gateway',
|
||||
'highlight' => 'ppcp-axo-gateway',
|
||||
),
|
||||
'priority' => 1,
|
||||
),
|
||||
'enable_pay_later_messaging' => array(
|
||||
'title' => __( 'Enable Pay Later messaging', 'woocommerce-paypal-payments' ),
|
||||
'description' => __( 'Show Pay Later options to increase conversion.', 'woocommerce-paypal-payments' ),
|
||||
'isEligible' => $eligibility_checks['enable_pay_later_messaging'],
|
||||
'action' => array(
|
||||
'type' => 'tab',
|
||||
'tab' => 'pay_later',
|
||||
'section' => 'pay-later-messaging',
|
||||
),
|
||||
'priority' => 2,
|
||||
),
|
||||
// Additional todo items...
|
||||
);
|
||||
|
||||
return $todo_items;
|
||||
}
|
||||
```
|
||||
|
||||
### Advanced Features
|
||||
|
||||
The React-based system supports:
|
||||
|
||||
- **Eligibility Checks**: Dynamic visibility based on conditions
|
||||
- **Dismissal**: Users can dismiss individual todos
|
||||
- **Completion Tracking**: Automatic removal when tasks are completed
|
||||
- **Priority Ordering**: Control display order with priority values
|
||||
- **REST API**: Full CRUD operations via dedicated endpoints
|
||||
|
||||
### API Integration
|
||||
|
||||
The REST API provides endpoints for managing todos:
|
||||
|
||||
```php
|
||||
public function register_routes(): void {
|
||||
// GET/POST /todos - Get todos list and update dismissed todos
|
||||
register_rest_route(
|
||||
static::NAMESPACE,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_todos' ),
|
||||
'permission_callback' => array( $this, 'check_permission' ),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'update_todos' ),
|
||||
'permission_callback' => array( $this, 'check_permission' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// POST /todos/reset - Reset dismissed todos
|
||||
register_rest_route(
|
||||
static::NAMESPACE,
|
||||
'/' . $this->rest_base . '/reset',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'reset_todos' ),
|
||||
'permission_callback' => array( $this, 'check_permission' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
The endpoints handle:
|
||||
- **GET /todos**: Fetching current todo list with eligibility filtering
|
||||
- **POST /todos**: Updating dismissed todo status
|
||||
- **POST /todos/reset**: Restoring all dismissed todos
|
||||
|
||||
### Frontend Rendering
|
||||
|
||||
The React component provides a complete todo management interface:
|
||||
|
||||
```jsx
|
||||
const Todos = ( { todos, resetTodos, dismissTodo } ) => {
|
||||
const [ isResetting, setIsResetting ] = useState( false );
|
||||
const [ activeModal, setActiveModal ] = useState( null );
|
||||
|
||||
// Reset handler for restoring dismissed todos
|
||||
const resetHandler = useCallback( async () => {
|
||||
setIsResetting( true );
|
||||
try {
|
||||
await resetTodos();
|
||||
} finally {
|
||||
setIsResetting( false );
|
||||
}
|
||||
}, [ resetTodos ] );
|
||||
|
||||
if ( ! todos?.length ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<SettingsCard
|
||||
className="ppcp-r-tab-overview-todo"
|
||||
title={ __( 'Things to do next', 'woocommerce-paypal-payments' ) }
|
||||
description={
|
||||
<>
|
||||
<p>
|
||||
{ __(
|
||||
'Complete these tasks to keep your store updated with the latest products and services.',
|
||||
'woocommerce-paypal-payments'
|
||||
) }
|
||||
</p>
|
||||
<Button
|
||||
variant="tertiary"
|
||||
onClick={ resetHandler }
|
||||
disabled={ isResetting }
|
||||
>
|
||||
<Icon icon={ reusableBlock } size={ 18 } />
|
||||
{ isResetting
|
||||
? __( 'Restoring…', 'woocommerce-paypal-payments' )
|
||||
: __( 'Restore dismissed Things To Do', 'woocommerce-paypal-payments' ) }
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<TodoSettingsBlock
|
||||
todosData={ todos }
|
||||
setActiveModal={ setActiveModal }
|
||||
onDismissTodo={ dismissTodo }
|
||||
/>
|
||||
</SettingsCard>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
Key features:
|
||||
- **Restore Functionality**: Users can restore dismissed todos
|
||||
- **Modal Integration**: Support for detailed todo actions
|
||||
- **Dismissal Handling**: Individual todo dismissal with state management
|
||||
- **Loading States**: Visual feedback during operations
|
||||
|
||||
## Best Practices
|
||||
|
||||
### For WooCommerce Native Tasks
|
||||
|
||||
1. **Keep task definitions simple** - Use basic configuration only
|
||||
2. **Provide clear redirect URLs** - Direct users to relevant settings
|
||||
3. **Use descriptive IDs** - Include plugin prefix for uniqueness
|
||||
4. **Test with WooCommerce updates** - Ensure compatibility with core changes
|
||||
|
||||
### For Plugin React Todos
|
||||
|
||||
1. **Implement robust eligibility checks** - Prevent showing irrelevant todos
|
||||
2. **Use appropriate priority values** - Ensure logical ordering
|
||||
3. **Provide actionable descriptions** - Help users understand next steps
|
||||
4. **Handle edge cases** - Account for various plugin states
|
||||
5. **Test dismissal functionality** - Ensure proper state management
|
||||
|
||||
## Existing Examples
|
||||
|
||||
Both systems have multiple implementations in the codebase:
|
||||
- Onboarding completion tasks
|
||||
- Feature enablement todos
|
||||
- Configuration reminder items
|
||||
- Migration assistance tasks
|
||||
|
||||
These examples demonstrate various conditional logic patterns and user experience flows.
|
|
@ -49,7 +49,7 @@ class AdminNotices implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
|
||||
add_action(
|
||||
'admin_notices',
|
||||
function() use ( $renderer ) {
|
||||
function () use ( $renderer ) {
|
||||
$renderer->render();
|
||||
}
|
||||
);
|
||||
|
@ -113,11 +113,10 @@ class AdminNotices implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
|
||||
add_action(
|
||||
'woocommerce_init',
|
||||
function() {
|
||||
function () {
|
||||
if ( is_admin() && is_callable( array( WC(), 'is_wc_admin_active' ) ) && WC()->is_wc_admin_active() && class_exists( 'Automattic\WooCommerce\Admin\Notes\Notes' ) ) {
|
||||
MexicoInstallmentsNote::init();
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class MuteMessageEndpoint {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function nonce() : string {
|
||||
public static function nonce(): string {
|
||||
return self::ENDPOINT;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ class MuteMessageEndpoint {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle_request() : void {
|
||||
public function handle_request(): void {
|
||||
try {
|
||||
$data = $this->request_data->read_request( $this->nonce() );
|
||||
} catch ( RuntimeException $ex ) {
|
||||
|
|
|
@ -62,7 +62,7 @@ class Message {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message() : string {
|
||||
public function message(): string {
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ class Message {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function type() : string {
|
||||
public function type(): string {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ class Message {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_dismissible() : bool {
|
||||
public function is_dismissible(): bool {
|
||||
return $this->dismissible;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ class Message {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function wrapper() : string {
|
||||
public function wrapper(): string {
|
||||
return $this->wrapper;
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ class Message {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array() : array {
|
||||
public function to_array(): array {
|
||||
return array(
|
||||
'type' => $this->type,
|
||||
'message' => $this->message,
|
||||
|
@ -114,7 +114,7 @@ class Message {
|
|||
*
|
||||
* @return Message
|
||||
*/
|
||||
public static function from_array( array $data ) : Message {
|
||||
public static function from_array( array $data ): Message {
|
||||
return new Message(
|
||||
(string) ( $data['message'] ?? '' ),
|
||||
(string) ( $data['type'] ?? '' ),
|
||||
|
|
|
@ -47,7 +47,7 @@ class PersistentMessage extends Message {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function id( bool $with_db_prefix = false ) : string {
|
||||
public function id( bool $with_db_prefix = false ): string {
|
||||
if ( ! $this->message_id ) {
|
||||
return '';
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class PersistentMessage extends Message {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function to_array() : array {
|
||||
public function to_array(): array {
|
||||
$data = parent::to_array();
|
||||
$data['id'] = $this->message_id;
|
||||
|
||||
|
@ -70,7 +70,7 @@ class PersistentMessage extends Message {
|
|||
*
|
||||
* @return PersistentMessage
|
||||
*/
|
||||
public static function from_array( array $data ) : Message {
|
||||
public static function from_array( array $data ): Message {
|
||||
return new PersistentMessage(
|
||||
(string) ( $data['id'] ?? '' ),
|
||||
(string) ( $data['message'] ?? '' ),
|
||||
|
@ -84,7 +84,7 @@ class PersistentMessage extends Message {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_muted() : bool {
|
||||
public function is_muted(): bool {
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
if ( ! $this->message_id || ! $user_id ) {
|
||||
|
@ -99,7 +99,7 @@ class PersistentMessage extends Message {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function mute() : void {
|
||||
public function mute(): void {
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
if ( $this->message_id && $user_id && ! $this->is_muted() ) {
|
||||
|
@ -112,7 +112,7 @@ class PersistentMessage extends Message {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function clear_all() : void {
|
||||
public static function clear_all(): void {
|
||||
global $wpdb;
|
||||
|
||||
$wpdb->query(
|
||||
|
|
|
@ -95,7 +95,7 @@ class Renderer implements RendererInterface {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function enqueue_admin() : void {
|
||||
public function enqueue_admin(): void {
|
||||
if ( ! $this->can_mute_message ) {
|
||||
return;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class Renderer implements RendererInterface {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function script_data_for_admin() : array {
|
||||
protected function script_data_for_admin(): array {
|
||||
$ajax_url = admin_url( 'admin-ajax.php' );
|
||||
|
||||
return array(
|
||||
|
|
|
@ -26,5 +26,5 @@ interface RendererInterface {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_admin() : void;
|
||||
public function enqueue_admin(): void;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class Repository implements RepositoryInterface {
|
|||
*
|
||||
* @return Message[]
|
||||
*/
|
||||
public function current_message() : array {
|
||||
public function current_message(): array {
|
||||
return array_filter(
|
||||
/**
|
||||
* Returns the list of admin messages.
|
||||
|
@ -34,7 +34,7 @@ class Repository implements RepositoryInterface {
|
|||
self::NOTICES_FILTER,
|
||||
array()
|
||||
),
|
||||
function ( $element ) : bool {
|
||||
function ( $element ): bool {
|
||||
if ( $element instanceof PersistentMessage ) {
|
||||
return ! $element->is_muted();
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class Repository implements RepositoryInterface {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function persist( Message $message ) : void {
|
||||
public function persist( Message $message ): void {
|
||||
$persisted_notices = get_option( self::PERSISTED_NOTICES_OPTION ) ?: array();
|
||||
|
||||
$persisted_notices[] = $message->to_array();
|
||||
|
@ -64,7 +64,7 @@ class Repository implements RepositoryInterface {
|
|||
*
|
||||
* @return array|Message[]
|
||||
*/
|
||||
public function get_persisted_and_clear() : array {
|
||||
public function get_persisted_and_clear(): array {
|
||||
$notices = array();
|
||||
|
||||
$persisted_data = get_option( self::PERSISTED_NOTICES_OPTION ) ?: array();
|
||||
|
|
|
@ -86,7 +86,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Helper\EnvironmentConfig;
|
|||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
return array(
|
||||
'api.host' => static function( ContainerInterface $container ) : string {
|
||||
'api.host' => static function ( ContainerInterface $container ): string {
|
||||
$environment = $container->get( 'settings.environment' );
|
||||
assert( $environment instanceof Environment );
|
||||
|
||||
|
@ -96,25 +96,25 @@ return array(
|
|||
|
||||
return (string) $container->get( 'api.production-host' );
|
||||
},
|
||||
'api.paypal-host' => function( ContainerInterface $container ) : string {
|
||||
'api.paypal-host' => function ( ContainerInterface $container ): string {
|
||||
return PAYPAL_API_URL;
|
||||
},
|
||||
// It seems this 'api.paypal-website-url' key is always overridden in ppcp-onboarding/services.php.
|
||||
'api.paypal-website-url' => function( ContainerInterface $container ) : string {
|
||||
'api.paypal-website-url' => function ( ContainerInterface $container ): string {
|
||||
return PAYPAL_URL;
|
||||
},
|
||||
'api.factory.paypal-checkout-url' => function( ContainerInterface $container ) : callable {
|
||||
'api.factory.paypal-checkout-url' => function ( ContainerInterface $container ): callable {
|
||||
return function ( string $id ) use ( $container ): string {
|
||||
return $container->get( 'api.paypal-website-url' ) . '/checkoutnow?token=' . $id;
|
||||
};
|
||||
},
|
||||
'api.partner_merchant_id' => static function () : string {
|
||||
'api.partner_merchant_id' => static function (): string {
|
||||
return '';
|
||||
},
|
||||
'api.merchant_email' => function () : string {
|
||||
'api.merchant_email' => function (): string {
|
||||
return '';
|
||||
},
|
||||
'api.merchant_id' => function () : string {
|
||||
'api.merchant_id' => function (): string {
|
||||
return '';
|
||||
},
|
||||
'api.key' => static function (): string {
|
||||
|
@ -142,7 +142,7 @@ return array(
|
|||
$container->get( 'wcgateway.settings' )
|
||||
);
|
||||
},
|
||||
'api.endpoint.partners' => static function ( ContainerInterface $container ) : PartnersEndpoint {
|
||||
'api.endpoint.partners' => static function ( ContainerInterface $container ): PartnersEndpoint {
|
||||
return new PartnersEndpoint(
|
||||
$container->get( 'api.host' ),
|
||||
$container->get( 'api.bearer' ),
|
||||
|
@ -153,10 +153,10 @@ return array(
|
|||
$container->get( 'api.helper.failure-registry' )
|
||||
);
|
||||
},
|
||||
'api.factory.sellerstatus' => static function ( ContainerInterface $container ) : SellerStatusFactory {
|
||||
'api.factory.sellerstatus' => static function ( ContainerInterface $container ): SellerStatusFactory {
|
||||
return new SellerStatusFactory();
|
||||
},
|
||||
'api.endpoint.payment-token' => static function ( ContainerInterface $container ) : PaymentTokenEndpoint {
|
||||
'api.endpoint.payment-token' => static function ( ContainerInterface $container ): PaymentTokenEndpoint {
|
||||
return new PaymentTokenEndpoint(
|
||||
$container->get( 'api.host' ),
|
||||
$container->get( 'api.bearer' ),
|
||||
|
@ -166,14 +166,14 @@ return array(
|
|||
$container->get( 'api.repository.customer' )
|
||||
);
|
||||
},
|
||||
'api.endpoint.payment-tokens' => static function( ContainerInterface $container ) : PaymentTokensEndpoint {
|
||||
'api.endpoint.payment-tokens' => static function ( ContainerInterface $container ): PaymentTokensEndpoint {
|
||||
return new PaymentTokensEndpoint(
|
||||
$container->get( 'api.host' ),
|
||||
$container->get( 'api.bearer' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'api.endpoint.webhook' => static function ( ContainerInterface $container ) : WebhookEndpoint {
|
||||
'api.endpoint.webhook' => static function ( ContainerInterface $container ): WebhookEndpoint {
|
||||
|
||||
return new WebhookEndpoint(
|
||||
$container->get( 'api.host' ),
|
||||
|
@ -183,7 +183,7 @@ return array(
|
|||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'api.endpoint.partner-referrals' => static function ( ContainerInterface $container ) : PartnerReferrals {
|
||||
'api.endpoint.partner-referrals' => static function ( ContainerInterface $container ): PartnerReferrals {
|
||||
|
||||
return new PartnerReferrals(
|
||||
$container->get( 'api.host' ),
|
||||
|
@ -191,7 +191,7 @@ return array(
|
|||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'api.endpoint.partner-referrals-sandbox' => static function ( ContainerInterface $container ) : PartnerReferrals {
|
||||
'api.endpoint.partner-referrals-sandbox' => static function ( ContainerInterface $container ): PartnerReferrals {
|
||||
|
||||
return new PartnerReferrals(
|
||||
CONNECT_WOO_SANDBOX_URL,
|
||||
|
@ -199,7 +199,7 @@ return array(
|
|||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'api.endpoint.partner-referrals-production' => static function ( ContainerInterface $container ) : PartnerReferrals {
|
||||
'api.endpoint.partner-referrals-production' => static function ( ContainerInterface $container ): PartnerReferrals {
|
||||
|
||||
return new PartnerReferrals(
|
||||
CONNECT_WOO_URL,
|
||||
|
@ -207,7 +207,7 @@ return array(
|
|||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'api.endpoint.identity-token' => static function ( ContainerInterface $container ) : IdentityToken {
|
||||
'api.endpoint.identity-token' => static function ( ContainerInterface $container ): IdentityToken {
|
||||
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
$customer_repository = $container->get( 'api.repository.customer' );
|
||||
|
@ -232,7 +232,7 @@ return array(
|
|||
$logger
|
||||
);
|
||||
},
|
||||
'api.endpoint.login-seller' => static function ( ContainerInterface $container ) : LoginSeller {
|
||||
'api.endpoint.login-seller' => static function ( ContainerInterface $container ): LoginSeller {
|
||||
|
||||
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
||||
return new LoginSeller(
|
||||
|
@ -287,7 +287,7 @@ return array(
|
|||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'api.endpoint.billing-plans' => static function( ContainerInterface $container ): BillingPlans {
|
||||
'api.endpoint.billing-plans' => static function ( ContainerInterface $container ): BillingPlans {
|
||||
return new BillingPlans(
|
||||
$container->get( 'api.host' ),
|
||||
$container->get( 'api.bearer' ),
|
||||
|
@ -296,21 +296,21 @@ return array(
|
|||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'api.endpoint.billing-subscriptions' => static function( ContainerInterface $container ): BillingSubscriptions {
|
||||
'api.endpoint.billing-subscriptions' => static function ( ContainerInterface $container ): BillingSubscriptions {
|
||||
return new BillingSubscriptions(
|
||||
$container->get( 'api.host' ),
|
||||
$container->get( 'api.bearer' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'api.endpoint.payment-method-tokens' => static function( ContainerInterface $container ): PaymentMethodTokensEndpoint {
|
||||
'api.endpoint.payment-method-tokens' => static function ( ContainerInterface $container ): PaymentMethodTokensEndpoint {
|
||||
return new PaymentMethodTokensEndpoint(
|
||||
$container->get( 'api.host' ),
|
||||
$container->get( 'api.bearer' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'api.repository.partner-referrals-data' => static function ( ContainerInterface $container ) : PartnerReferralsData {
|
||||
'api.repository.partner-referrals-data' => static function ( ContainerInterface $container ): PartnerReferralsData {
|
||||
|
||||
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
||||
return new PartnerReferralsData( $dcc_applies );
|
||||
|
@ -320,11 +320,11 @@ return array(
|
|||
$merchant_id = $container->get( 'api.merchant_id' );
|
||||
return new PayeeRepository( $merchant_email, $merchant_id );
|
||||
},
|
||||
'api.repository.customer' => static function( ContainerInterface $container ): CustomerRepository {
|
||||
'api.repository.customer' => static function ( ContainerInterface $container ): CustomerRepository {
|
||||
$prefix = $container->get( 'api.prefix' );
|
||||
return new CustomerRepository( $prefix );
|
||||
},
|
||||
'api.repository.order' => static function( ContainerInterface $container ): OrderRepository {
|
||||
'api.repository.order' => static function ( ContainerInterface $container ): OrderRepository {
|
||||
return new OrderRepository(
|
||||
$container->get( 'api.endpoint.order' )
|
||||
);
|
||||
|
@ -345,10 +345,10 @@ return array(
|
|||
$container->get( 'settings.merchant-details' )
|
||||
);
|
||||
},
|
||||
'api.factory.payment-token' => static function ( ContainerInterface $container ) : PaymentTokenFactory {
|
||||
'api.factory.payment-token' => static function ( ContainerInterface $container ): PaymentTokenFactory {
|
||||
return new PaymentTokenFactory();
|
||||
},
|
||||
'api.factory.payment-token-action-links' => static function ( ContainerInterface $container ) : PaymentTokenActionLinksFactory {
|
||||
'api.factory.payment-token-action-links' => static function ( ContainerInterface $container ): PaymentTokenActionLinksFactory {
|
||||
return new PaymentTokenActionLinksFactory();
|
||||
},
|
||||
'api.factory.webhook' => static function ( ContainerInterface $container ): WebhookFactory {
|
||||
|
@ -485,25 +485,25 @@ return array(
|
|||
'api.factory.fraud-processor-response' => static function ( ContainerInterface $container ): FraudProcessorResponseFactory {
|
||||
return new FraudProcessorResponseFactory();
|
||||
},
|
||||
'api.factory.product' => static function( ContainerInterface $container ): ProductFactory {
|
||||
'api.factory.product' => static function ( ContainerInterface $container ): ProductFactory {
|
||||
return new ProductFactory();
|
||||
},
|
||||
'api.factory.billing-cycle' => static function( ContainerInterface $container ): BillingCycleFactory {
|
||||
'api.factory.billing-cycle' => static function ( ContainerInterface $container ): BillingCycleFactory {
|
||||
return new BillingCycleFactory( $container->get( 'api.shop.currency.getter' ) );
|
||||
},
|
||||
'api.factory.payment-preferences' => static function( ContainerInterface $container ):PaymentPreferencesFactory {
|
||||
'api.factory.payment-preferences' => static function ( ContainerInterface $container ): PaymentPreferencesFactory {
|
||||
return new PaymentPreferencesFactory( $container->get( 'api.shop.currency.getter' ) );
|
||||
},
|
||||
'api.factory.plan' => static function( ContainerInterface $container ): PlanFactory {
|
||||
'api.factory.plan' => static function ( ContainerInterface $container ): PlanFactory {
|
||||
return new PlanFactory(
|
||||
$container->get( 'api.factory.billing-cycle' ),
|
||||
$container->get( 'api.factory.payment-preferences' )
|
||||
);
|
||||
},
|
||||
'api.factory.card-authentication-result-factory' => static function( ContainerInterface $container ): CardAuthenticationResultFactory {
|
||||
'api.factory.card-authentication-result-factory' => static function ( ContainerInterface $container ): CardAuthenticationResultFactory {
|
||||
return new CardAuthenticationResultFactory();
|
||||
},
|
||||
'api.helpers.dccapplies' => static function ( ContainerInterface $container ) : DccApplies {
|
||||
'api.helpers.dccapplies' => static function ( ContainerInterface $container ): DccApplies {
|
||||
return new DccApplies(
|
||||
$container->get( 'api.dcc-supported-country-currency-matrix' ),
|
||||
$container->get( 'api.dcc-supported-country-card-matrix' ),
|
||||
|
@ -512,21 +512,21 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'api.shop.currency.getter' => static function ( ContainerInterface $container ) : CurrencyGetter {
|
||||
'api.shop.currency.getter' => static function ( ContainerInterface $container ): CurrencyGetter {
|
||||
return new CurrencyGetter();
|
||||
},
|
||||
'api.shop.country' => static function ( ContainerInterface $container ) : string {
|
||||
'api.shop.country' => static function ( ContainerInterface $container ): string {
|
||||
$location = wc_get_base_location();
|
||||
return $location['country'];
|
||||
},
|
||||
'api.shop.is-psd2-country' => static function ( ContainerInterface $container ) : bool {
|
||||
'api.shop.is-psd2-country' => static function ( ContainerInterface $container ): bool {
|
||||
return in_array(
|
||||
$container->get( 'api.shop.country' ),
|
||||
$container->get( 'api.psd2-countries' ),
|
||||
true
|
||||
);
|
||||
},
|
||||
'api.shop.is-currency-supported' => static function ( ContainerInterface $container ) : bool {
|
||||
'api.shop.is-currency-supported' => static function ( ContainerInterface $container ): bool {
|
||||
return in_array(
|
||||
$container->get( 'api.shop.currency.getter' )->get(),
|
||||
$container->get( 'api.supported-currencies' ),
|
||||
|
@ -593,7 +593,7 @@ return array(
|
|||
*
|
||||
* From https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/
|
||||
*/
|
||||
'api.supported-currencies' => static function ( ContainerInterface $container ) : array {
|
||||
'api.supported-currencies' => static function ( ContainerInterface $container ): array {
|
||||
return array(
|
||||
'AUD',
|
||||
'BRL',
|
||||
|
@ -626,7 +626,7 @@ return array(
|
|||
/**
|
||||
* The matrix which countries and currency combinations can be used for DCC.
|
||||
*/
|
||||
'api.dcc-supported-country-currency-matrix' => static function ( ContainerInterface $container ) : array {
|
||||
'api.dcc-supported-country-currency-matrix' => static function ( ContainerInterface $container ): array {
|
||||
$default_currencies = apply_filters(
|
||||
'woocommerce_paypal_payments_supported_currencies',
|
||||
array(
|
||||
|
@ -712,7 +712,7 @@ return array(
|
|||
/**
|
||||
* Which countries support which credit cards. Empty credit card arrays mean no restriction on currency.
|
||||
*/
|
||||
'api.dcc-supported-country-card-matrix' => static function ( ContainerInterface $container ) : array {
|
||||
'api.dcc-supported-country-card-matrix' => static function ( ContainerInterface $container ): array {
|
||||
$mastercard_visa_amex = array(
|
||||
'mastercard' => array(),
|
||||
'visa' => array(),
|
||||
|
@ -793,7 +793,7 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'api.psd2-countries' => static function ( ContainerInterface $container ) : array {
|
||||
'api.psd2-countries' => static function ( ContainerInterface $container ): array {
|
||||
return array(
|
||||
'AT',
|
||||
'BE',
|
||||
|
@ -826,7 +826,7 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'api.paylater-countries' => static function ( ContainerInterface $container ) : array {
|
||||
'api.paylater-countries' => static function ( ContainerInterface $container ): array {
|
||||
return apply_filters(
|
||||
'woocommerce_paypal_payments_supported_paylater_countries',
|
||||
array(
|
||||
|
@ -840,20 +840,20 @@ return array(
|
|||
)
|
||||
);
|
||||
},
|
||||
'api.order-helper' => static function( ContainerInterface $container ): OrderHelper {
|
||||
'api.order-helper' => static function ( ContainerInterface $container ): OrderHelper {
|
||||
return new OrderHelper();
|
||||
},
|
||||
'api.helper.order-transient' => static function( ContainerInterface $container ): OrderTransient {
|
||||
'api.helper.order-transient' => static function ( ContainerInterface $container ): OrderTransient {
|
||||
$cache = $container->get( 'api.paypal-bearer-cache' );
|
||||
$purchase_unit_sanitizer = $container->get( 'api.helper.purchase-unit-sanitizer' );
|
||||
return new OrderTransient( $cache, $purchase_unit_sanitizer );
|
||||
},
|
||||
'api.helper.failure-registry' => static function( ContainerInterface $container ): FailureRegistry {
|
||||
'api.helper.failure-registry' => static function ( ContainerInterface $container ): FailureRegistry {
|
||||
$cache = new Cache( 'ppcp-paypal-api-status-cache' );
|
||||
return new FailureRegistry( $cache );
|
||||
},
|
||||
'api.helper.purchase-unit-sanitizer' => SingletonDecorator::make(
|
||||
static function( ContainerInterface $container ): PurchaseUnitSanitizer {
|
||||
static function ( ContainerInterface $container ): PurchaseUnitSanitizer {
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
|
||||
|
@ -862,24 +862,24 @@ return array(
|
|||
return new PurchaseUnitSanitizer( $behavior, $line_name );
|
||||
}
|
||||
),
|
||||
'api.client-credentials' => static function( ContainerInterface $container ): ClientCredentials {
|
||||
'api.client-credentials' => static function ( ContainerInterface $container ): ClientCredentials {
|
||||
return new ClientCredentials(
|
||||
$container->get( 'wcgateway.settings' )
|
||||
);
|
||||
},
|
||||
'api.paypal-bearer-cache' => static function( ContainerInterface $container ): Cache {
|
||||
'api.paypal-bearer-cache' => static function ( ContainerInterface $container ): Cache {
|
||||
return new Cache( 'ppcp-paypal-bearer' );
|
||||
},
|
||||
'api.client-credentials-cache' => static function( ContainerInterface $container ): Cache {
|
||||
'api.client-credentials-cache' => static function ( ContainerInterface $container ): Cache {
|
||||
return new Cache( 'ppcp-client-credentials-cache' );
|
||||
},
|
||||
'api.user-id-token-cache' => static function( ContainerInterface $container ): Cache {
|
||||
'api.user-id-token-cache' => static function ( ContainerInterface $container ): Cache {
|
||||
return new Cache( 'ppcp-id-token-cache' );
|
||||
},
|
||||
'api.reference-transaction-status-cache' => static function( ContainerInterface $container ): Cache {
|
||||
'api.reference-transaction-status-cache' => static function ( ContainerInterface $container ): Cache {
|
||||
return new Cache( 'ppcp-reference-transaction-status-cache' );
|
||||
},
|
||||
'api.user-id-token' => static function( ContainerInterface $container ): UserIdToken {
|
||||
'api.user-id-token' => static function ( ContainerInterface $container ): UserIdToken {
|
||||
return new UserIdToken(
|
||||
$container->get( 'api.host' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' ),
|
||||
|
@ -887,7 +887,7 @@ return array(
|
|||
$container->get( 'api.user-id-token-cache' )
|
||||
);
|
||||
},
|
||||
'api.sdk-client-token' => static function( ContainerInterface $container ): SdkClientToken {
|
||||
'api.sdk-client-token' => static function ( ContainerInterface $container ): SdkClientToken {
|
||||
return new SdkClientToken(
|
||||
$container->get( 'api.host' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' ),
|
||||
|
@ -895,39 +895,39 @@ return array(
|
|||
$container->get( 'api.client-credentials-cache' )
|
||||
);
|
||||
},
|
||||
'api.paypal-host-production' => static function( ContainerInterface $container ) : string {
|
||||
'api.paypal-host-production' => static function ( ContainerInterface $container ): string {
|
||||
return PAYPAL_API_URL;
|
||||
},
|
||||
'api.paypal-host-sandbox' => static function( ContainerInterface $container ) : string {
|
||||
'api.paypal-host-sandbox' => static function ( ContainerInterface $container ): string {
|
||||
return PAYPAL_SANDBOX_API_URL;
|
||||
},
|
||||
'api.paypal-website-url-production' => static function( ContainerInterface $container ) : string {
|
||||
'api.paypal-website-url-production' => static function ( ContainerInterface $container ): string {
|
||||
return PAYPAL_URL;
|
||||
},
|
||||
'api.paypal-website-url-sandbox' => static function( ContainerInterface $container ) : string {
|
||||
'api.paypal-website-url-sandbox' => static function ( ContainerInterface $container ): string {
|
||||
return PAYPAL_SANDBOX_URL;
|
||||
},
|
||||
'api.partner_merchant_id-production' => static function( ContainerInterface $container ) : string {
|
||||
'api.partner_merchant_id-production' => static function ( ContainerInterface $container ): string {
|
||||
return CONNECT_WOO_MERCHANT_ID;
|
||||
},
|
||||
'api.partner_merchant_id-sandbox' => static function( ContainerInterface $container ) : string {
|
||||
'api.partner_merchant_id-sandbox' => static function ( ContainerInterface $container ): string {
|
||||
return CONNECT_WOO_SANDBOX_MERCHANT_ID;
|
||||
},
|
||||
'api.endpoint.login-seller-production' => static function ( ContainerInterface $container ) : LoginSeller {
|
||||
'api.endpoint.login-seller-production' => static function ( ContainerInterface $container ): LoginSeller {
|
||||
return new LoginSeller(
|
||||
$container->get( 'api.paypal-host-production' ),
|
||||
$container->get( 'api.partner_merchant_id-production' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'api.endpoint.login-seller-sandbox' => static function ( ContainerInterface $container ) : LoginSeller {
|
||||
'api.endpoint.login-seller-sandbox' => static function ( ContainerInterface $container ): LoginSeller {
|
||||
return new LoginSeller(
|
||||
$container->get( 'api.paypal-host-sandbox' ),
|
||||
$container->get( 'api.partner_merchant_id-sandbox' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'api.env.paypal-host' => static function ( ContainerInterface $container ) : EnvironmentConfig {
|
||||
'api.env.paypal-host' => static function ( ContainerInterface $container ): EnvironmentConfig {
|
||||
/**
|
||||
* Environment specific API host names.
|
||||
*
|
||||
|
@ -939,7 +939,7 @@ return array(
|
|||
$container->get( 'api.paypal-host-sandbox' )
|
||||
);
|
||||
},
|
||||
'api.env.endpoint.login-seller' => static function ( ContainerInterface $container ) : EnvironmentConfig {
|
||||
'api.env.endpoint.login-seller' => static function ( ContainerInterface $container ): EnvironmentConfig {
|
||||
/**
|
||||
* Environment specific LoginSeller API instances.
|
||||
*
|
||||
|
@ -951,7 +951,7 @@ return array(
|
|||
$container->get( 'api.endpoint.login-seller-sandbox' )
|
||||
);
|
||||
},
|
||||
'api.env.endpoint.partner-referrals' => static function ( ContainerInterface $container ) : EnvironmentConfig {
|
||||
'api.env.endpoint.partner-referrals' => static function ( ContainerInterface $container ): EnvironmentConfig {
|
||||
/**
|
||||
* Environment specific PartnerReferrals API instances.
|
||||
*
|
||||
|
@ -981,7 +981,7 @@ return array(
|
|||
|
||||
return CONNECT_WOO_URL;
|
||||
},
|
||||
'api.helper.partner-attribution' => static function ( ContainerInterface $container ) : PartnerAttribution {
|
||||
'api.helper.partner-attribution' => static function ( ContainerInterface $container ): PartnerAttribution {
|
||||
return new PartnerAttribution(
|
||||
'ppcp_bn_code',
|
||||
array(
|
||||
|
|
|
@ -66,7 +66,7 @@ class ApiModule implements ServiceModule, FactoryModule, ExtendingModule, Execut
|
|||
);
|
||||
add_filter(
|
||||
'ppcp_create_order_request_body_data',
|
||||
function( array $data ) use ( $c ) {
|
||||
function ( array $data ) use ( $c ) {
|
||||
|
||||
foreach ( ( $data['purchase_units'] ?? array() ) as $purchase_unit_index => $purchase_unit ) {
|
||||
foreach ( ( $purchase_unit['items'] ?? array() ) as $item_index => $item ) {
|
||||
|
|
|
@ -100,7 +100,7 @@ class PayPalBearer implements Bearer {
|
|||
* @throws RuntimeException When request fails.
|
||||
* @return Token
|
||||
*/
|
||||
public function bearer() : Token {
|
||||
public function bearer(): Token {
|
||||
try {
|
||||
$bearer = Token::from_json( (string) $this->cache->get( self::CACHE_KEY ) );
|
||||
|
||||
|
@ -115,7 +115,7 @@ class PayPalBearer implements Bearer {
|
|||
*
|
||||
* @return string The client ID from settings, or the key defined via constructor.
|
||||
*/
|
||||
private function get_key() : string {
|
||||
private function get_key(): string {
|
||||
if (
|
||||
$this->settings
|
||||
&& $this->settings->has( 'client_id' )
|
||||
|
@ -132,7 +132,7 @@ class PayPalBearer implements Bearer {
|
|||
*
|
||||
* @return string The client secret from settings, or the value defined via constructor.
|
||||
*/
|
||||
private function get_secret() : string {
|
||||
private function get_secret(): string {
|
||||
if (
|
||||
$this->settings
|
||||
&& $this->settings->has( 'client_secret' )
|
||||
|
@ -150,7 +150,7 @@ class PayPalBearer implements Bearer {
|
|||
* @throws RuntimeException When request fails.
|
||||
* @return Token
|
||||
*/
|
||||
private function newBearer() : Token {
|
||||
private function newBearer(): Token {
|
||||
$key = $this->get_key();
|
||||
$secret = $this->get_secret();
|
||||
$url = trailingslashit( $this->host ) . 'v1/oauth2/token?grant_type=client_credentials';
|
||||
|
|
|
@ -65,7 +65,7 @@ class BillingSubscriptions {
|
|||
* @throws RuntimeException If the request fails.
|
||||
* @throws PayPalApiException If the request fails.
|
||||
*/
|
||||
public function suspend( string $id ):void {
|
||||
public function suspend( string $id ): void {
|
||||
$data = array(
|
||||
'reason' => sprintf( 'Suspended by %s.', is_admin() ? 'merchant' : 'customer' ),
|
||||
);
|
||||
|
@ -214,6 +214,4 @@ class BillingSubscriptions {
|
|||
|
||||
return $json;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ class PartnersEndpoint {
|
|||
* @return SellerStatus
|
||||
* @throws RuntimeException When request could not be fulfilled.
|
||||
*/
|
||||
public function seller_status() : SellerStatus {
|
||||
public function seller_status(): SellerStatus {
|
||||
$url = trailingslashit( $this->host ) . 'v1/customer/partners/' . $this->partner_id . '/merchant-integrations/' . $this->merchant_id;
|
||||
$bearer = $this->bearer->bearer();
|
||||
$args = array(
|
||||
|
|
|
@ -203,7 +203,7 @@ class PaymentsEndpoint {
|
|||
* @throws RuntimeException If the request fails.
|
||||
* @throws PayPalApiException If the request fails.
|
||||
*/
|
||||
public function reauthorize( string $authorization_id, ?Money $amount = null ) : string {
|
||||
public function reauthorize( string $authorization_id, ?Money $amount = null ): string {
|
||||
$bearer = $this->bearer->bearer();
|
||||
$url = trailingslashit( $this->host ) . 'v2/payments/authorizations/' . $authorization_id . '/reauthorize';
|
||||
|
||||
|
@ -249,7 +249,7 @@ class PaymentsEndpoint {
|
|||
* @throws RuntimeException If the request fails.
|
||||
* @throws PayPalApiException If the request fails.
|
||||
*/
|
||||
public function refund( RefundCapture $refund ) : string {
|
||||
public function refund( RefundCapture $refund ): string {
|
||||
$bearer = $this->bearer->bearer();
|
||||
$url = trailingslashit( $this->host ) . 'v2/payments/captures/' . $refund->for_capture()->id() . '/refund';
|
||||
$args = array(
|
||||
|
@ -289,7 +289,7 @@ class PaymentsEndpoint {
|
|||
* @throws RuntimeException If the request fails.
|
||||
* @throws PayPalApiException If the request fails.
|
||||
*/
|
||||
public function void( Authorization $authorization ) : void {
|
||||
public function void( Authorization $authorization ): void {
|
||||
$bearer = $this->bearer->bearer();
|
||||
$url = trailingslashit( $this->host ) . 'v2/payments/authorizations/' . $authorization->id() . '/void';
|
||||
$args = array(
|
||||
|
|
|
@ -348,7 +348,7 @@ class WebhookEndpoint {
|
|||
if ( isset( $expected_headers[ $key ] ) ) {
|
||||
$expected_headers[ $key ] = $header;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
foreach ( $expected_headers as $key => $value ) {
|
||||
if ( ! empty( $value ) ) {
|
||||
|
|
|
@ -86,7 +86,7 @@ class Authorization {
|
|||
*
|
||||
* @return FraudProcessorResponse|null
|
||||
*/
|
||||
public function fraud_processor_response() : ?FraudProcessorResponse {
|
||||
public function fraud_processor_response(): ?FraudProcessorResponse {
|
||||
return $this->fraud_processor_response;
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ class Capture {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function id() : string {
|
||||
public function id(): string {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ class Capture {
|
|||
*
|
||||
* @return CaptureStatus
|
||||
*/
|
||||
public function status() : CaptureStatus {
|
||||
public function status(): CaptureStatus {
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ class Capture {
|
|||
*
|
||||
* @return Amount
|
||||
*/
|
||||
public function amount() : Amount {
|
||||
public function amount(): Amount {
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ class Capture {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function final_capture() : bool {
|
||||
public function final_capture(): bool {
|
||||
return $this->final_capture;
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ class Capture {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function invoice_id() : string {
|
||||
public function invoice_id(): string {
|
||||
return $this->invoice_id;
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ class Capture {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function custom_id() : string {
|
||||
public function custom_id(): string {
|
||||
return $this->custom_id;
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ class Capture {
|
|||
*
|
||||
* @return SellerReceivableBreakdown|null
|
||||
*/
|
||||
public function seller_receivable_breakdown() : ?SellerReceivableBreakdown {
|
||||
public function seller_receivable_breakdown(): ?SellerReceivableBreakdown {
|
||||
return $this->seller_receivable_breakdown;
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ class Capture {
|
|||
*
|
||||
* @return FraudProcessorResponse|null
|
||||
*/
|
||||
public function fraud_processor_response() : ?FraudProcessorResponse {
|
||||
public function fraud_processor_response(): ?FraudProcessorResponse {
|
||||
return $this->fraud_processor_response;
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ class Capture {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array() : array {
|
||||
public function to_array(): array {
|
||||
$data = array(
|
||||
'id' => $this->id(),
|
||||
'status' => $this->status()->name(),
|
||||
|
|
|
@ -204,7 +204,7 @@ class Item {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function url():string {
|
||||
public function url(): string {
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ class Item {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function image_url():string {
|
||||
public function image_url(): string {
|
||||
return $this->validate_image_url() ? $this->image_url : '';
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ class Item {
|
|||
*
|
||||
* @return float
|
||||
*/
|
||||
public function tax_rate():float {
|
||||
public function tax_rate(): float {
|
||||
return round( (float) $this->tax_rate, 2 );
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ class Item {
|
|||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function cart_item_key():?string {
|
||||
public function cart_item_key(): ?string {
|
||||
return $this->cart_item_key;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ class PaymentPreferences {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array():array {
|
||||
public function to_array(): array {
|
||||
return array(
|
||||
'setup_fee' => $this->setup_fee(),
|
||||
'auto_bill_outstanding' => $this->auto_bill_outstanding(),
|
||||
|
|
|
@ -124,5 +124,4 @@ class PaymentToken {
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ class Plan {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array():array {
|
||||
public function to_array(): array {
|
||||
return array(
|
||||
'id' => $this->id(),
|
||||
'name' => $this->name(),
|
||||
|
|
|
@ -119,7 +119,7 @@ class Refund {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function id() : string {
|
||||
public function id(): string {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ class Refund {
|
|||
*
|
||||
* @return RefundStatus
|
||||
*/
|
||||
public function status() : RefundStatus {
|
||||
public function status(): RefundStatus {
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ class Refund {
|
|||
*
|
||||
* @return Amount
|
||||
*/
|
||||
public function amount() : Amount {
|
||||
public function amount(): Amount {
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ class Refund {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function invoice_id() : string {
|
||||
public function invoice_id(): string {
|
||||
return $this->invoice_id;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ class Refund {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function custom_id() : string {
|
||||
public function custom_id(): string {
|
||||
return $this->custom_id;
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ class Refund {
|
|||
*
|
||||
* @return SellerPayableBreakdown|null
|
||||
*/
|
||||
public function seller_payable_breakdown() : ?SellerPayableBreakdown {
|
||||
public function seller_payable_breakdown(): ?SellerPayableBreakdown {
|
||||
return $this->seller_payable_breakdown;
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ class Refund {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function acquirer_reference_number() : string {
|
||||
public function acquirer_reference_number(): string {
|
||||
return $this->acquirer_reference_number;
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ class Refund {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function note_to_payer() : string {
|
||||
public function note_to_payer(): string {
|
||||
return $this->note_to_payer;
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ class Refund {
|
|||
*
|
||||
* @return RefundPayer|null
|
||||
*/
|
||||
public function payer() : ?RefundPayer {
|
||||
public function payer(): ?RefundPayer {
|
||||
return $this->payer;
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ class Refund {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array() : array {
|
||||
public function to_array(): array {
|
||||
$data = array(
|
||||
'id' => $this->id(),
|
||||
'status' => $this->status()->name(),
|
||||
|
|
|
@ -67,7 +67,7 @@ class RefundCapture {
|
|||
*
|
||||
* @return Capture
|
||||
*/
|
||||
public function for_capture() : Capture {
|
||||
public function for_capture(): Capture {
|
||||
return $this->capture;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ class RefundCapture {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function invoice_id() : string {
|
||||
public function invoice_id(): string {
|
||||
return $this->invoice_id;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class RefundCapture {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function note_to_payer() : string {
|
||||
public function note_to_payer(): string {
|
||||
return $this->note_to_payer;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ class RefundCapture {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array() : array {
|
||||
public function to_array(): array {
|
||||
$data = array(
|
||||
'invoice_id' => $this->invoice_id(),
|
||||
);
|
||||
|
|
|
@ -68,7 +68,7 @@ class SellerStatus {
|
|||
*
|
||||
* @return SellerStatusProduct[]
|
||||
*/
|
||||
public function products() : array {
|
||||
public function products(): array {
|
||||
return $this->products;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ class SellerStatus {
|
|||
*
|
||||
* @return SellerStatusCapability[]
|
||||
*/
|
||||
public function capabilities() : array {
|
||||
public function capabilities(): array {
|
||||
return $this->capabilities;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ class SellerStatus {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function country() : string {
|
||||
public function country(): string {
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
|
@ -95,16 +95,16 @@ class SellerStatus {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array() : array {
|
||||
public function to_array(): array {
|
||||
$products = array_map(
|
||||
function( SellerStatusProduct $product ) : array {
|
||||
function ( SellerStatusProduct $product ): array {
|
||||
return $product->to_array();
|
||||
},
|
||||
$this->products()
|
||||
);
|
||||
|
||||
$capabilities = array_map(
|
||||
function( SellerStatusCapability $capability ) : array {
|
||||
function ( SellerStatusCapability $capability ): array {
|
||||
return $capability->to_array();
|
||||
},
|
||||
$this->capabilities()
|
||||
|
|
|
@ -49,7 +49,7 @@ class SellerStatusCapability {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function name() : string {
|
||||
public function name(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ class SellerStatusCapability {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function status() : string {
|
||||
public function status(): string {
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
@ -67,11 +67,10 @@ class SellerStatusCapability {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array() : array {
|
||||
public function to_array(): array {
|
||||
return array(
|
||||
'name' => $this->name(),
|
||||
'status' => $this->status(),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ class SellerStatusProduct {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function name() : string {
|
||||
public function name(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ class SellerStatusProduct {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function vetting_status() : string {
|
||||
public function vetting_status(): string {
|
||||
return $this->vetting_status;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ class SellerStatusProduct {
|
|||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function capabilities() : array {
|
||||
public function capabilities(): array {
|
||||
return $this->capabilities;
|
||||
}
|
||||
|
||||
|
@ -96,13 +96,11 @@ class SellerStatusProduct {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array() : array {
|
||||
public function to_array(): array {
|
||||
return array(
|
||||
'name' => $this->name(),
|
||||
'vetting_status' => $this->vetting_status(),
|
||||
'capabilities' => $this->capabilities(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ class Shipping {
|
|||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function email_address() : ?string {
|
||||
public function email_address(): ?string {
|
||||
return $this->email_address;
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ class Shipping {
|
|||
*
|
||||
* @return null|Phone
|
||||
*/
|
||||
public function phone_number() : ?Phone {
|
||||
public function phone_number(): ?Phone {
|
||||
return $this->phone_number;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ class CaptureFactory {
|
|||
* @return Capture
|
||||
* @throws RuntimeException When capture amount data is invalid.
|
||||
*/
|
||||
public function from_paypal_response( \stdClass $data ) : Capture {
|
||||
public function from_paypal_response( \stdClass $data ): Capture {
|
||||
$reason = $data->status_details->reason ?? null;
|
||||
$seller_receivable_breakdown = isset( $data->seller_receivable_breakdown ) ?
|
||||
$this->seller_receivable_breakdown_factory->from_paypal_response( $data->seller_receivable_breakdown )
|
||||
|
|
|
@ -48,7 +48,7 @@ class ContactPreferenceFactory {
|
|||
* @param string $payment_source_key Name of the payment_source.
|
||||
* @return string|null
|
||||
*/
|
||||
public function from_state( string $payment_source_key ) : ?string {
|
||||
public function from_state( string $payment_source_key ): ?string {
|
||||
$payment_sources_with_contact = array( 'paypal', 'venmo' );
|
||||
|
||||
/**
|
||||
|
|
|
@ -214,7 +214,7 @@ class ExperienceContextBuilder {
|
|||
*
|
||||
* @param string|null $preference The new preference to apply.
|
||||
*/
|
||||
public function with_contact_preference( ?string $preference = null ) : ExperienceContextBuilder {
|
||||
public function with_contact_preference( ?string $preference = null ): ExperienceContextBuilder {
|
||||
$builder = clone $this;
|
||||
|
||||
$builder->experience_context = $builder->experience_context
|
||||
|
|
|
@ -53,7 +53,7 @@ class PatchCollectionFactory {
|
|||
$from,
|
||||
static function ( PurchaseUnit $unit ) use ( $purchase_unit_to ): bool {
|
||||
// Loose comparison needed to compare two objects.
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
|
||||
// phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
|
||||
return $unit == $purchase_unit_to;
|
||||
}
|
||||
)
|
||||
|
|
|
@ -41,7 +41,7 @@ class PaymentPreferencesFactory {
|
|||
* @param WC_Product $product WC product.
|
||||
* @return PaymentPreferences
|
||||
*/
|
||||
public function from_wc_product( WC_Product $product ):PaymentPreferences {
|
||||
public function from_wc_product( WC_Product $product ): PaymentPreferences {
|
||||
return new PaymentPreferences(
|
||||
array(
|
||||
'value' => $product->get_meta( '_subscription_sign_up_fee' ) ?: '0',
|
||||
|
|
|
@ -175,7 +175,8 @@ class PurchaseUnitFactory {
|
|||
|
||||
$shipping = null;
|
||||
$customer = \WC()->customer;
|
||||
if ( $this->shipping_needed( ... array_values( $items ) ) && is_a( $customer, \WC_Customer::class ) ) {
|
||||
/** @psalm-suppress RedundantConditionGivenDocblockType False positive. Ignored because $customer can be null as well. */
|
||||
if ( $this->shipping_needed( ...array_values( $items ) ) && is_a( $customer, \WC_Customer::class ) ) {
|
||||
$shipping = $this->shipping_factory->from_wc_customer( \WC()->customer, $with_shipping_options );
|
||||
$shipping_address = $shipping->address();
|
||||
if (
|
||||
|
@ -254,7 +255,7 @@ class PurchaseUnitFactory {
|
|||
$shipping = $this->shipping_factory->from_paypal_response( $data->shipping );
|
||||
}
|
||||
} catch ( RuntimeException $error ) {
|
||||
;
|
||||
$shipping = null;
|
||||
}
|
||||
$payments = null;
|
||||
try {
|
||||
|
@ -262,7 +263,7 @@ class PurchaseUnitFactory {
|
|||
$payments = $this->payments_factory->from_paypal_response( $data->payments );
|
||||
}
|
||||
} catch ( RuntimeException $error ) {
|
||||
;
|
||||
$payments = null;
|
||||
}
|
||||
|
||||
$purchase_unit = new PurchaseUnit(
|
||||
|
@ -333,7 +334,7 @@ class PurchaseUnitFactory {
|
|||
*
|
||||
* @return string The sanitized soft descriptor.
|
||||
*/
|
||||
private function sanitize_soft_descriptor( string $soft_descriptor ) : string {
|
||||
private function sanitize_soft_descriptor( string $soft_descriptor ): string {
|
||||
$decoded = html_entity_decode( $soft_descriptor, ENT_QUOTES, 'UTF-8' );
|
||||
$sanitized = preg_replace( '/[^a-zA-Z0-9 *\-.]/', '', $decoded ) ?: '';
|
||||
|
||||
|
@ -349,9 +350,9 @@ class PurchaseUnitFactory {
|
|||
* @return bool
|
||||
*/
|
||||
private function should_disable_shipping( array $items, ?Address $shipping_address ): bool {
|
||||
return ! $this->shipping_needed( ... array_values( $items ) ) ||
|
||||
! $shipping_address ||
|
||||
empty( $shipping_address->country_code() ) ||
|
||||
( ! $shipping_address->postal_code() && ! $this->country_without_postal_code( $shipping_address->country_code() ) );
|
||||
return ! $this->shipping_needed( ...array_values( $items ) ) ||
|
||||
! $shipping_address ||
|
||||
empty( $shipping_address->country_code() ) ||
|
||||
( ! $shipping_address->postal_code() && ! $this->country_without_postal_code( $shipping_address->country_code() ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class RefundFactory {
|
|||
* @return Refund
|
||||
* @throws RuntimeException When refund amount data is invalid.
|
||||
*/
|
||||
public function from_paypal_response( \stdClass $data ) : Refund {
|
||||
public function from_paypal_response( \stdClass $data ): Refund {
|
||||
$reason = $data->status_details->reason ?? null;
|
||||
$seller_payable_breakdown = isset( $data->seller_payable_breakdown ) ?
|
||||
$this->seller_payable_breakdown_factory->from_paypal_response( $data->seller_payable_breakdown )
|
||||
|
|
|
@ -25,9 +25,9 @@ class SellerStatusFactory {
|
|||
*
|
||||
* @return SellerStatus
|
||||
*/
|
||||
public function from_paypal_response( \stdClass $json ) : SellerStatus {
|
||||
public function from_paypal_response( \stdClass $json ): SellerStatus {
|
||||
$products = array_map(
|
||||
function( $json ) : SellerStatusProduct {
|
||||
function ( $json ): SellerStatusProduct {
|
||||
$product = new SellerStatusProduct(
|
||||
isset( $json->name ) ? (string) $json->name : '',
|
||||
isset( $json->vetting_status ) ? (string) $json->vetting_status : '',
|
||||
|
@ -39,7 +39,7 @@ class SellerStatusFactory {
|
|||
);
|
||||
|
||||
$capabilities = array_map(
|
||||
function( $json ) : SellerStatusCapability {
|
||||
function ( $json ): SellerStatusCapability {
|
||||
$capability = new SellerStatusCapability(
|
||||
isset( $json->name ) ? (string) $json->name : '',
|
||||
isset( $json->status ) ? (string) $json->status : ''
|
||||
|
|
|
@ -10,6 +10,9 @@ declare(strict_types=1);
|
|||
namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
|
||||
|
||||
use WC_Cart;
|
||||
use WC_Order;
|
||||
use WC_Order_Item_Product;
|
||||
use WC_Product;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ExperienceContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
|
||||
|
||||
|
@ -31,7 +34,8 @@ class ShippingPreferenceFactory {
|
|||
PurchaseUnit $purchase_unit,
|
||||
string $context,
|
||||
?WC_Cart $cart = null,
|
||||
string $funding_source = ''
|
||||
string $funding_source = '',
|
||||
?WC_Order $wc_order = null
|
||||
): string {
|
||||
$contains_physical_goods = $purchase_unit->contains_physical_goods();
|
||||
if ( ! $contains_physical_goods ) {
|
||||
|
@ -39,8 +43,12 @@ class ShippingPreferenceFactory {
|
|||
}
|
||||
|
||||
$has_shipping = null !== $purchase_unit->shipping();
|
||||
$needs_shipping = $cart && $cart->needs_shipping();
|
||||
$shipping_address_is_fixed = $needs_shipping && 'checkout' === $context;
|
||||
$needs_shipping = ( $wc_order && $this->wc_order_needs_shipping( $wc_order ) ) || ( $cart && $cart->needs_shipping() );
|
||||
$shipping_address_is_fixed = $needs_shipping && in_array( $context, array( 'checkout', 'pay-now' ), true );
|
||||
|
||||
if ( ! $needs_shipping ) {
|
||||
return ExperienceContext::SHIPPING_PREFERENCE_NO_SHIPPING;
|
||||
}
|
||||
|
||||
if ( $shipping_address_is_fixed ) {
|
||||
// Checkout + no address given? Probably something weird happened, like no form validation?
|
||||
|
@ -61,4 +69,26 @@ class ShippingPreferenceFactory {
|
|||
|
||||
return ExperienceContext::SHIPPING_PREFERENCE_GET_FROM_FILE;
|
||||
}
|
||||
|
||||
protected function wc_order_needs_shipping( WC_Order $wc_order ): bool {
|
||||
// WC 9.9.0+.
|
||||
if ( method_exists( $wc_order, 'needs_shipping' ) ) {
|
||||
return $wc_order->needs_shipping();
|
||||
}
|
||||
|
||||
if ( ! wc_shipping_enabled() || wc_get_shipping_method_count( true ) === 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $wc_order->get_items() as $item ) {
|
||||
if ( $item instanceof WC_Order_Item_Product ) {
|
||||
$product = $item->get_product();
|
||||
if ( $product instanceof WC_Product && $product->needs_shipping() ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ class Cache {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has( string $key ) : bool {
|
||||
public function has( string $key ): bool {
|
||||
$value = $this->get( $key );
|
||||
|
||||
return false !== $value;
|
||||
|
@ -59,7 +59,7 @@ class Cache {
|
|||
*
|
||||
* @param string $key The key.
|
||||
*/
|
||||
public function delete( string $key ) : void {
|
||||
public function delete( string $key ): void {
|
||||
delete_transient( $this->prefix . $key );
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class Cache {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function set( string $key, $value, int $expiration = 0 ) : bool {
|
||||
public function set( string $key, $value, int $expiration = 0 ): bool {
|
||||
return (bool) set_transient( $this->prefix . $key, $value, $expiration );
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ class Cache {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function flush() : void {
|
||||
public function flush(): void {
|
||||
global $wpdb;
|
||||
|
||||
// Get a list of all transients with the relevant "group prefix" from the DB.
|
||||
|
|
|
@ -94,7 +94,7 @@ class DccApplies {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function valid_cards() : array {
|
||||
public function valid_cards(): array {
|
||||
$cards = array();
|
||||
if ( ! isset( $this->country_card_matrix[ $this->country ] ) ) {
|
||||
return $cards;
|
||||
|
@ -122,7 +122,7 @@ class DccApplies {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function can_process_card( string $card ) : bool {
|
||||
public function can_process_card( string $card ): bool {
|
||||
if ( ! isset( $this->country_card_matrix[ $this->country ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -90,5 +90,4 @@ class FailureRegistry {
|
|||
private function cache_key( string $key ): string {
|
||||
return implode( '_', array( self::CACHE_KEY, $key ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -156,5 +156,4 @@ class OrderTransient {
|
|||
}
|
||||
return implode( '_', array( self::CACHE_KEY . $order->id() ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ class PartnerAttribution {
|
|||
* @param string $installation_path The installation path used to determine the BN Code.
|
||||
* @param bool $force_update Whether to force an update of the BN code if it already exists.
|
||||
*/
|
||||
public function initialize_bn_code( string $installation_path, bool $force_update = false ) : void {
|
||||
public function initialize_bn_code( string $installation_path, bool $force_update = false ): void {
|
||||
$selected_bn_code = $this->bn_codes[ $installation_path ] ?? '';
|
||||
if ( ! $selected_bn_code ) {
|
||||
return;
|
||||
|
@ -82,7 +82,7 @@ class PartnerAttribution {
|
|||
*
|
||||
* @return string The stored BN Code, or the default value if no path is detected.
|
||||
*/
|
||||
public function get_bn_code() : string {
|
||||
public function get_bn_code(): string {
|
||||
$bn_code = (string) ( get_option( $this->bn_code_option_name, $this->default_bn_code ) ?? $this->default_bn_code );
|
||||
|
||||
if ( ! in_array( $bn_code, $this->bn_codes, true ) ) {
|
||||
|
|
|
@ -93,7 +93,7 @@ abstract class ProductStatus {
|
|||
* @throws RuntimeException When the check failed.
|
||||
* @throws NotFoundException When a relevant service or setting was not found.
|
||||
*/
|
||||
abstract protected function check_local_state() : ?bool;
|
||||
abstract protected function check_local_state(): ?bool;
|
||||
|
||||
/**
|
||||
* Inspects the API response of the SellerStatus to determine feature eligibility.
|
||||
|
@ -105,7 +105,7 @@ abstract class ProductStatus {
|
|||
* @return bool
|
||||
* @throws RuntimeException When the check failed.
|
||||
*/
|
||||
abstract protected function check_active_state( SellerStatus $seller_status ) : bool;
|
||||
abstract protected function check_active_state( SellerStatus $seller_status ): bool;
|
||||
|
||||
/**
|
||||
* Clears the eligibility status from the local cache/DB to enforce a new
|
||||
|
@ -114,14 +114,14 @@ abstract class ProductStatus {
|
|||
* @param Settings|null $settings See description in {@see self::clear()}.
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function clear_state( ?Settings $settings = null ) : void;
|
||||
abstract protected function clear_state( ?Settings $settings = null ): void;
|
||||
|
||||
/**
|
||||
* Whether the merchant has access to the feature.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_active() : bool {
|
||||
public function is_active(): bool {
|
||||
if ( null !== $this->is_eligible ) {
|
||||
return $this->is_eligible;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ abstract class ProductStatus {
|
|||
* @return SellerStatus
|
||||
* @throws RuntimeException When the check failed.
|
||||
*/
|
||||
protected function get_seller_status_object() : SellerStatus {
|
||||
protected function get_seller_status_object(): SellerStatus {
|
||||
if ( null === self::$seller_status ) {
|
||||
// Check API failure registry to prevent multiple failed API requests.
|
||||
if ( $this->api_failure_registry->has_failure_in_timeframe( FailureRegistry::SELLER_STATUS_KEY, MINUTE_IN_SECONDS ) ) {
|
||||
|
@ -177,7 +177,7 @@ abstract class ProductStatus {
|
|||
*
|
||||
* @return bool True, if we can use the merchant API endpoints.
|
||||
*/
|
||||
public function is_onboarded() : bool {
|
||||
public function is_onboarded(): bool {
|
||||
return $this->is_connected;
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ abstract class ProductStatus {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has_request_failure() : bool {
|
||||
public function has_request_failure(): bool {
|
||||
return $this->has_request_failure;
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ abstract class ProductStatus {
|
|||
* @param Settings|null $settings The settings object.
|
||||
* @return void
|
||||
*/
|
||||
public function clear( ?Settings $settings = null ) : void {
|
||||
public function clear( ?Settings $settings = null ): void {
|
||||
$this->is_eligible = null;
|
||||
$this->has_request_failure = false;
|
||||
|
||||
|
|
|
@ -393,5 +393,4 @@ class PurchaseUnitSanitizer {
|
|||
public function set_last_message( string $message ): void {
|
||||
$this->last_message = $message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class PartnerReferralsData {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function nonce() : string {
|
||||
public function nonce(): string {
|
||||
return 'a1233wtergfsdt4365tzrshgfbaewa36AGa1233wtergfsdt4365tzrshgfbaewa36AG';
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ class PartnerReferralsData {
|
|||
string $onboarding_token = '',
|
||||
?bool $use_subscriptions = null,
|
||||
bool $use_card_payments = true
|
||||
) : array {
|
||||
): array {
|
||||
$in_acdc_country = $this->dcc_applies->for_country_currency();
|
||||
|
||||
if ( ! $products ) {
|
||||
|
|
|
@ -33,11 +33,11 @@ return array(
|
|||
$apm_applies = $container->get( 'applepay.helpers.apm-applies' );
|
||||
assert( $apm_applies instanceof ApmApplies );
|
||||
|
||||
return static function () use ( $apm_applies ) : bool {
|
||||
return static function () use ( $apm_applies ): bool {
|
||||
return $apm_applies->for_country() && $apm_applies->for_currency() && $apm_applies->for_merchant();
|
||||
};
|
||||
},
|
||||
'applepay.helpers.apm-applies' => static function ( ContainerInterface $container ) : ApmApplies {
|
||||
'applepay.helpers.apm-applies' => static function ( ContainerInterface $container ): ApmApplies {
|
||||
return new ApmApplies(
|
||||
$container->get( 'applepay.supported-countries' ),
|
||||
$container->get( 'applepay.supported-currencies' ),
|
||||
|
@ -45,7 +45,7 @@ return array(
|
|||
$container->get( 'api.shop.country' )
|
||||
);
|
||||
},
|
||||
'applepay.status-cache' => static function( ContainerInterface $container ): Cache {
|
||||
'applepay.status-cache' => static function ( ContainerInterface $container ): Cache {
|
||||
return new Cache( 'ppcp-paypal-apple-status-cache' );
|
||||
},
|
||||
|
||||
|
@ -82,7 +82,7 @@ return array(
|
|||
},
|
||||
|
||||
'applepay.apple-product-status' => SingletonDecorator::make(
|
||||
static function( ContainerInterface $container ): AppleProductStatus {
|
||||
static function ( ContainerInterface $container ): AppleProductStatus {
|
||||
return new AppleProductStatus(
|
||||
$container->get( 'wcgateway.settings' ),
|
||||
$container->get( 'api.endpoint.partners' ),
|
||||
|
@ -169,7 +169,7 @@ return array(
|
|||
/**
|
||||
* The list of which countries can be used for ApplePay.
|
||||
*/
|
||||
'applepay.supported-countries' => static function ( ContainerInterface $container ) : array {
|
||||
'applepay.supported-countries' => static function ( ContainerInterface $container ): array {
|
||||
/**
|
||||
* Returns which countries can be used for ApplePay.
|
||||
*/
|
||||
|
@ -225,7 +225,7 @@ return array(
|
|||
/**
|
||||
* The list of which currencies can be used for ApplePay.
|
||||
*/
|
||||
'applepay.supported-currencies' => static function ( ContainerInterface $container ) : array {
|
||||
'applepay.supported-currencies' => static function ( ContainerInterface $container ): array {
|
||||
/**
|
||||
* Returns which currencies can be used for ApplePay.
|
||||
*/
|
||||
|
|
|
@ -171,7 +171,7 @@ class ApplePayGateway extends WC_Payment_Gateway {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function process_payment( $order_id ) : array {
|
||||
public function process_payment( $order_id ): array {
|
||||
$wc_order = wc_get_order( $order_id );
|
||||
if ( ! is_a( $wc_order, WC_Order::class ) ) {
|
||||
return $this->handle_payment_failure(
|
||||
|
@ -234,7 +234,7 @@ class ApplePayGateway extends WC_Payment_Gateway {
|
|||
*
|
||||
* @return boolean True or false based on success, or a WP_Error object.
|
||||
*/
|
||||
public function process_refund( $order_id, $amount = null, $reason = '' ) : bool {
|
||||
public function process_refund( $order_id, $amount = null, $reason = '' ): bool {
|
||||
$order = wc_get_order( $order_id );
|
||||
if ( ! is_a( $order, WC_Order::class ) ) {
|
||||
return false;
|
||||
|
@ -250,7 +250,7 @@ class ApplePayGateway extends WC_Payment_Gateway {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_transaction_url( $order ) : string {
|
||||
public function get_transaction_url( $order ): string {
|
||||
$this->view_transaction_url = $this->transaction_url_provider->get_transaction_url_base( $order );
|
||||
|
||||
return parent::get_transaction_url( $order );
|
||||
|
|
|
@ -56,7 +56,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
// Clears product status when appropriate.
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_clear_apm_product_status',
|
||||
function( ?Settings $settings = null ) use ( $c ): void {
|
||||
function ( ?Settings $settings = null ) use ( $c ): void {
|
||||
$apm_status = $c->get( 'applepay.apple-product-status' );
|
||||
assert( $apm_status instanceof AppleProductStatus );
|
||||
$apm_status->clear( $settings );
|
||||
|
@ -174,7 +174,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_selected_button_locations',
|
||||
function( array $locations, string $setting_name ): array {
|
||||
function ( array $locations, string $setting_name ): array {
|
||||
$gateway = WC()->payment_gateways()->payment_gateways()[ ApplePayGateway::ID ] ?? '';
|
||||
if ( $gateway && $gateway->enabled === 'yes' && $setting_name === 'smart_button_locations' ) {
|
||||
$locations[] = 'checkout';
|
||||
|
@ -188,7 +188,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_rest_common_merchant_features',
|
||||
function( array $features ) use ( $c ): array {
|
||||
function ( array $features ) use ( $c ): array {
|
||||
$product_status = $c->get( 'applepay.apple-product-status' );
|
||||
assert( $product_status instanceof AppleProductStatus );
|
||||
|
||||
|
@ -204,7 +204,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
|
||||
add_filter(
|
||||
'ppcp_create_order_request_body_data',
|
||||
static function ( array $data, string $payment_method, array $request ) use ( $c ) : array {
|
||||
static function ( array $data, string $payment_method, array $request ) use ( $c ): array {
|
||||
|
||||
if ( $payment_method !== ApplePayGateway::ID ) {
|
||||
return $data;
|
||||
|
@ -294,7 +294,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
|
||||
add_action(
|
||||
'woocommerce_blocks_payment_method_type_registration',
|
||||
function( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void {
|
||||
function ( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void {
|
||||
$payment_method_registry->register( $c->get( 'applepay.blocks-payment-method' ) );
|
||||
}
|
||||
);
|
||||
|
@ -329,7 +329,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
// Adds ApplePay component to the backend button preview settings.
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_admin_gateway_settings',
|
||||
function( array $settings ) use ( $c ): array {
|
||||
function ( array $settings ) use ( $c ): array {
|
||||
if ( is_array( $settings['components'] ) ) {
|
||||
$settings['components'][] = 'applepay';
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
* @param bool $is_sandbox The environment for this merchant.
|
||||
* @return string
|
||||
*/
|
||||
public function validation_string( bool $is_sandbox ) : string {
|
||||
public function validation_string( bool $is_sandbox ): string {
|
||||
$sandbox_string = $this->sandbox_validation_string();
|
||||
$live_string = $this->live_validation_string();
|
||||
return $is_sandbox ? $sandbox_string : $live_string;
|
||||
|
|
|
@ -26,7 +26,8 @@ use WooCommerce\PayPalCommerce\Button\Helper\ContextTrait;
|
|||
* Class ApplePayButton
|
||||
*/
|
||||
class ApplePayButton implements ButtonInterface {
|
||||
use RequestHandlerTrait, ContextTrait;
|
||||
use RequestHandlerTrait;
|
||||
use ContextTrait;
|
||||
|
||||
/**
|
||||
* The settings.
|
||||
|
@ -222,7 +223,6 @@ class ApplePayButton implements ButtonInterface {
|
|||
return $options . '<li><label><input type="checkbox" id="ppcp-onboarding-apple" ' . $checked . ' data-onboarding-option="ppcp-onboarding-apple"> ' .
|
||||
__( 'Onboard with ApplePay', 'woocommerce-paypal-payments' ) . '
|
||||
</label></li>';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -445,7 +445,7 @@ class ApplePayButton implements ButtonInterface {
|
|||
} else {
|
||||
add_filter(
|
||||
'woocommerce_payment_successful_result',
|
||||
function ( array $result ) use ( $cart, $cart_item_key ) : array {
|
||||
function ( array $result ) use ( $cart, $cart_item_key ): array {
|
||||
$this->clear_current_cart( $cart, $cart_item_key );
|
||||
$this->reload_cart( $cart );
|
||||
return $result;
|
||||
|
@ -917,7 +917,7 @@ class ApplePayButton implements ButtonInterface {
|
|||
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_sdk_components_hook',
|
||||
function( array $components ) {
|
||||
function ( array $components ) {
|
||||
$components[] = 'applepay';
|
||||
return $components;
|
||||
}
|
||||
|
|
|
@ -361,7 +361,6 @@ class ApplePayDataObjectHttp {
|
|||
}
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -509,7 +508,7 @@ class ApplePayDataObjectHttp {
|
|||
* @param array $data The data.
|
||||
* @return void
|
||||
*/
|
||||
protected function update_simplified_contact( array $data ) : void {
|
||||
protected function update_simplified_contact( array $data ): void {
|
||||
$simplified_contact_info = array_map( 'sanitize_text_field', $data );
|
||||
$this->simplified_contact = $this->simplified_address(
|
||||
$simplified_contact_info
|
||||
|
@ -727,7 +726,7 @@ class ApplePayDataObjectHttp {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_nonce_valid():bool {
|
||||
public function is_nonce_valid(): bool {
|
||||
$nonce = filter_input( INPUT_POST, 'woocommerce-process-checkout-nonce', FILTER_SANITIZE_SPECIAL_CHARS );
|
||||
if ( ! $nonce ) {
|
||||
return false;
|
||||
|
|
|
@ -54,7 +54,7 @@ class AppleProductStatus extends ProductStatus {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
protected function check_local_state() : ?bool {
|
||||
protected function check_local_state(): ?bool {
|
||||
$status_override = apply_filters( 'woocommerce_paypal_payments_apple_pay_product_status', null );
|
||||
if ( null !== $status_override ) {
|
||||
return $status_override;
|
||||
|
@ -68,7 +68,7 @@ class AppleProductStatus extends ProductStatus {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
protected function check_active_state( SellerStatus $seller_status ) : bool {
|
||||
protected function check_active_state( SellerStatus $seller_status ): bool {
|
||||
// Check the seller status for the intended capability.
|
||||
$has_capability = false;
|
||||
foreach ( $seller_status->products() as $product ) {
|
||||
|
@ -101,7 +101,7 @@ class AppleProductStatus extends ProductStatus {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
protected function clear_state( ?Settings $settings = null ) : void {
|
||||
protected function clear_state( ?Settings $settings = null ): void {
|
||||
if ( null === $settings ) {
|
||||
$settings = $this->settings;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ class DataToAppleButtonScripts {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function apple_pay_script_data() : array {
|
||||
public function apple_pay_script_data(): array {
|
||||
if ( is_product() ) {
|
||||
return $this->data_for_product_page();
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class DataToAppleButtonScripts {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function apple_pay_script_data_for_admin() : array {
|
||||
public function apple_pay_script_data_for_admin(): array {
|
||||
return $this->data_for_admin_page();
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ class DataToAppleButtonScripts {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_apple_pay_data( array $product = array() ) : array {
|
||||
private function get_apple_pay_data( array $product = array() ): array {
|
||||
// true: Use Apple Pay as distinct gateway.
|
||||
// false: integrate it with the smart buttons.
|
||||
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
|
||||
|
@ -132,7 +132,7 @@ class DataToAppleButtonScripts {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function check_if_need_shipping( WC_Product $product ) : bool {
|
||||
protected function check_if_need_shipping( WC_Product $product ): bool {
|
||||
if (
|
||||
! wc_shipping_enabled()
|
||||
|| 0 === wc_get_shipping_method_count(
|
||||
|
@ -154,7 +154,7 @@ class DataToAppleButtonScripts {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function data_for_product_page() : array {
|
||||
protected function data_for_product_page(): array {
|
||||
$product = wc_get_product( get_the_id() );
|
||||
if ( ! $product ) {
|
||||
return array();
|
||||
|
@ -185,7 +185,7 @@ class DataToAppleButtonScripts {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function data_for_cart_page() : array {
|
||||
protected function data_for_cart_page(): array {
|
||||
$cart = WC()->cart;
|
||||
if ( ! $cart ) {
|
||||
return array();
|
||||
|
@ -206,7 +206,7 @@ class DataToAppleButtonScripts {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function data_for_admin_page() : array {
|
||||
protected function data_for_admin_page(): array {
|
||||
$data = $this->get_apple_pay_data(
|
||||
array(
|
||||
'needShipping' => false,
|
||||
|
|
|
@ -89,7 +89,7 @@ class ApmApplies {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function for_merchant() : bool {
|
||||
public function for_merchant(): bool {
|
||||
return apply_filters(
|
||||
'woocommerce_paypal_payments_is_eligible_for_applepay',
|
||||
true
|
||||
|
|
|
@ -141,7 +141,6 @@ class AvailabilityNotice {
|
|||
if ( ! $this->is_merchant_validated ) {
|
||||
$this->add_merchant_not_validated_notice();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,5 +286,4 @@ class AvailabilityNotice {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,6 @@ declare( strict_types = 1 );
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\AxoBlock;
|
||||
|
||||
return static function () : AxoBlockModule {
|
||||
return static function (): AxoBlockModule {
|
||||
return new AxoBlockModule();
|
||||
};
|
||||
|
|
|
@ -14,13 +14,13 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
|||
|
||||
return array(
|
||||
// If AXO Block is configured and onboarded.
|
||||
'axoblock.available' => static function ( ContainerInterface $container ) : bool {
|
||||
'axoblock.available' => static function ( ContainerInterface $container ): bool {
|
||||
return true;
|
||||
},
|
||||
'axoblock.url' => static function ( ContainerInterface $container ) : string {
|
||||
'axoblock.url' => static function ( ContainerInterface $container ): string {
|
||||
return plugins_url( '/modules/ppcp-axo-block/', $container->get( 'ppcp.path-to-plugin-main-file' ) );
|
||||
},
|
||||
'axoblock.method' => static function ( ContainerInterface $container ) : AxoBlockPaymentMethod {
|
||||
'axoblock.method' => static function ( ContainerInterface $container ): AxoBlockPaymentMethod {
|
||||
return new AxoBlockPaymentMethod(
|
||||
$container->get( 'axoblock.url' ),
|
||||
$container->get( 'ppcp.asset-version' ),
|
||||
|
|
|
@ -74,7 +74,7 @@ class AxoBlockModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
*/
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_sdk_components_hook',
|
||||
function( $components ) use ( $c ) {
|
||||
function ( $components ) use ( $c ) {
|
||||
if ( ! $c->has( 'axo.available' ) || ! $c->get( 'axo.available' ) ) {
|
||||
return $components;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ class AxoBlockModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
|
||||
add_action(
|
||||
'woocommerce_blocks_payment_method_type_registration',
|
||||
function( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void {
|
||||
function ( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void {
|
||||
/*
|
||||
* Only register the method if we are not in the admin or the customer is not logged in.
|
||||
*/
|
||||
|
|
|
@ -109,16 +109,16 @@ class AxoBlockPaymentMethod extends AbstractPaymentMethodType {
|
|||
* @param array $supported_country_card_type_matrix The supported country card type matrix for Axo.
|
||||
*/
|
||||
public function __construct(
|
||||
string $module_url,
|
||||
string $version,
|
||||
WC_Payment_Gateway $gateway,
|
||||
$smart_button,
|
||||
Settings $settings,
|
||||
CardPaymentsConfiguration $dcc_configuration,
|
||||
Environment $environment,
|
||||
string $wcgateway_module_url,
|
||||
array $payment_method_selected_map,
|
||||
array $supported_country_card_type_matrix
|
||||
string $module_url,
|
||||
string $version,
|
||||
WC_Payment_Gateway $gateway,
|
||||
$smart_button,
|
||||
Settings $settings,
|
||||
CardPaymentsConfiguration $dcc_configuration,
|
||||
Environment $environment,
|
||||
string $wcgateway_module_url,
|
||||
array $payment_method_selected_map,
|
||||
array $supported_country_card_type_matrix
|
||||
) {
|
||||
$this->name = AxoGateway::ID;
|
||||
$this->module_url = $module_url;
|
||||
|
@ -141,14 +141,14 @@ class AxoBlockPaymentMethod extends AbstractPaymentMethodType {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function is_active() : bool {
|
||||
public function is_active(): bool {
|
||||
return $this->gateway->is_available();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_payment_method_script_handles() : array {
|
||||
public function get_payment_method_script_handles(): array {
|
||||
$script_path = 'assets/js/index.js';
|
||||
$script_asset_path = trailingslashit( $this->module_url ) . 'assets/js/index.asset.php';
|
||||
$script_asset = file_exists( $script_asset_path )
|
||||
|
@ -199,7 +199,7 @@ class AxoBlockPaymentMethod extends AbstractPaymentMethodType {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
private function script_data() : array {
|
||||
private function script_data(): array {
|
||||
if ( is_admin() ) {
|
||||
return array();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ return array(
|
|||
|
||||
'wcgateway.settings.fields' => function ( array $fields, ContainerInterface $container ): array {
|
||||
|
||||
$insert_after = function( array $array, string $key, array $new ): array {
|
||||
$insert_after = function ( array $array, string $key, array $new ): array {
|
||||
$keys = array_keys( $array );
|
||||
$index = array_search( $key, $keys, true );
|
||||
$pos = false === $index ? count( $array ) : $index + 1;
|
||||
|
|
|
@ -34,11 +34,11 @@ return array(
|
|||
$axo_applies = $container->get( 'axo.service.axo-applies' );
|
||||
assert( $axo_applies instanceof AxoApplies );
|
||||
|
||||
return static function () use ( $axo_applies ) : bool {
|
||||
return static function () use ( $axo_applies ): bool {
|
||||
return $axo_applies->for_country_currency() && $axo_applies->for_merchant();
|
||||
};
|
||||
},
|
||||
'axo.service.axo-applies' => static function ( ContainerInterface $container ) : AxoApplies {
|
||||
'axo.service.axo-applies' => static function ( ContainerInterface $container ): AxoApplies {
|
||||
return new AxoApplies(
|
||||
$container->get( 'axo.supported-country-currency-matrix' ),
|
||||
$container->get( 'api.shop.currency.getter' ),
|
||||
|
@ -48,7 +48,7 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'axo.helpers.compatibility-checker' => static function ( ContainerInterface $container ) : CompatibilityChecker {
|
||||
'axo.helpers.compatibility-checker' => static function ( ContainerInterface $container ): CompatibilityChecker {
|
||||
return new CompatibilityChecker(
|
||||
$container->get( 'axo.fastlane-incompatible-plugin-names' ),
|
||||
$container->get( 'wcgateway.configuration.card-configuration' )
|
||||
|
@ -154,7 +154,7 @@ return array(
|
|||
/**
|
||||
* The matrix which countries and currency combinations can be used for AXO.
|
||||
*/
|
||||
'axo.supported-country-currency-matrix' => static function ( ContainerInterface $container ) : array {
|
||||
'axo.supported-country-currency-matrix' => static function ( ContainerInterface $container ): array {
|
||||
$matrix = array(
|
||||
'US' => array(
|
||||
'AUD',
|
||||
|
@ -185,7 +185,7 @@ return array(
|
|||
/**
|
||||
* The matrix which countries and card type combinations can be used for AXO.
|
||||
*/
|
||||
'axo.supported-country-card-type-matrix' => static function ( ContainerInterface $container ) : array {
|
||||
'axo.supported-country-card-type-matrix' => static function ( ContainerInterface $container ): array {
|
||||
$matrix = array(
|
||||
'US' => array(
|
||||
'VISA',
|
||||
|
@ -226,42 +226,42 @@ return array(
|
|||
$matrix
|
||||
);
|
||||
},
|
||||
'axo.settings-conflict-notice' => static function ( ContainerInterface $container ) : string {
|
||||
'axo.settings-conflict-notice' => static function ( ContainerInterface $container ): string {
|
||||
$compatibility_checker = $container->get( 'axo.helpers.compatibility-checker' );
|
||||
assert( $compatibility_checker instanceof CompatibilityChecker );
|
||||
|
||||
return $compatibility_checker->generate_settings_conflict_notice();
|
||||
},
|
||||
|
||||
'axo.checkout-config-notice' => static function ( ContainerInterface $container ) : string {
|
||||
'axo.checkout-config-notice' => static function ( ContainerInterface $container ): string {
|
||||
$compatibility_checker = $container->get( 'axo.helpers.compatibility-checker' );
|
||||
assert( $compatibility_checker instanceof CompatibilityChecker );
|
||||
|
||||
return $compatibility_checker->generate_checkout_notice();
|
||||
},
|
||||
|
||||
'axo.checkout-config-notice.raw' => static function ( ContainerInterface $container ) : string {
|
||||
'axo.checkout-config-notice.raw' => static function ( ContainerInterface $container ): string {
|
||||
$compatibility_checker = $container->get( 'axo.helpers.compatibility-checker' );
|
||||
assert( $compatibility_checker instanceof CompatibilityChecker );
|
||||
|
||||
return $compatibility_checker->generate_checkout_notice( true );
|
||||
},
|
||||
|
||||
'axo.incompatible-plugins-notice' => static function ( ContainerInterface $container ) : string {
|
||||
'axo.incompatible-plugins-notice' => static function ( ContainerInterface $container ): string {
|
||||
$settings_notice_generator = $container->get( 'axo.helpers.compatibility-checker' );
|
||||
assert( $settings_notice_generator instanceof CompatibilityChecker );
|
||||
|
||||
return $settings_notice_generator->generate_incompatible_plugins_notice();
|
||||
},
|
||||
|
||||
'axo.incompatible-plugins-notice.raw' => static function ( ContainerInterface $container ) : string {
|
||||
'axo.incompatible-plugins-notice.raw' => static function ( ContainerInterface $container ): string {
|
||||
$settings_notice_generator = $container->get( 'axo.helpers.compatibility-checker' );
|
||||
assert( $settings_notice_generator instanceof CompatibilityChecker );
|
||||
|
||||
return $settings_notice_generator->generate_incompatible_plugins_notice( true );
|
||||
},
|
||||
|
||||
'axo.smart-button-location-notice' => static function ( ContainerInterface $container ) : string {
|
||||
'axo.smart-button-location-notice' => static function ( ContainerInterface $container ): string {
|
||||
$dcc_configuration = $container->get( 'wcgateway.configuration.card-configuration' );
|
||||
assert( $dcc_configuration instanceof CardPaymentsConfiguration );
|
||||
|
||||
|
@ -310,7 +310,7 @@ return array(
|
|||
*
|
||||
* @returns array<array{name: string, is_active: bool}>
|
||||
*/
|
||||
'axo.fastlane-incompatible-plugins' => static function () : array {
|
||||
'axo.fastlane-incompatible-plugins' => static function (): array {
|
||||
/**
|
||||
* Filters the list of Fastlane incompatible plugins.
|
||||
*/
|
||||
|
@ -365,12 +365,12 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'axo.fastlane-incompatible-plugin-names' => static function ( ContainerInterface $container ) : array {
|
||||
'axo.fastlane-incompatible-plugin-names' => static function ( ContainerInterface $container ): array {
|
||||
$incompatible_plugins = $container->get( 'axo.fastlane-incompatible-plugins' );
|
||||
|
||||
$active_plugins_list = array_filter(
|
||||
$incompatible_plugins,
|
||||
function( array $plugin ): bool {
|
||||
function ( array $plugin ): bool {
|
||||
return (bool) $plugin['is_active'];
|
||||
}
|
||||
);
|
||||
|
@ -395,10 +395,10 @@ return array(
|
|||
}
|
||||
|
||||
$shipping_zones = \WC_Shipping_Zones::get_zones();
|
||||
$get_zone_locations = fn( \WC_Shipping_Zone $zone): array =>
|
||||
$get_zone_locations = fn( \WC_Shipping_Zone $zone ): array =>
|
||||
! empty( $zone->get_shipping_methods( true ) )
|
||||
? array_map(
|
||||
fn( object $location): string => $location->code,
|
||||
fn( object $location ): string => $location->code,
|
||||
$zone->get_zone_locations()
|
||||
)
|
||||
: array();
|
||||
|
@ -408,7 +408,7 @@ return array(
|
|||
...array_map(
|
||||
$get_zone_locations,
|
||||
array_map(
|
||||
fn( $zone): \WC_Shipping_Zone =>
|
||||
fn( $zone ): \WC_Shipping_Zone =>
|
||||
$zone instanceof \WC_Shipping_Zone ? $zone : new \WC_Shipping_Zone( $zone['id'] ),
|
||||
$shipping_zones
|
||||
)
|
||||
|
|
|
@ -190,7 +190,7 @@ class AxoManager {
|
|||
'email' => 'render',
|
||||
),
|
||||
// The amount is not available when setting the insights data, so we need to merge it here.
|
||||
'insights' => ( function( array $data ): array {
|
||||
'insights' => ( function ( array $data ): array {
|
||||
$data['amount']['value'] = WC()->cart->get_total( 'numeric' );
|
||||
return $data; } )( $this->insights_data ),
|
||||
'allowed_cards' => $this->supported_country_card_type_matrix,
|
||||
|
@ -270,5 +270,4 @@ class AxoManager {
|
|||
esc_html( $label )
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ class AxoModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
$listener->filter_settings(
|
||||
$dcc_configuration->use_fastlane(),
|
||||
'smart_button_locations',
|
||||
function( array $existing_setting_value ) {
|
||||
function ( array $existing_setting_value ) {
|
||||
$axo_forced_locations = array( 'cart-block', 'cart' );
|
||||
return array_unique( array_merge( $existing_setting_value, $axo_forced_locations ) );
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ class AxoModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
*/
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_sdk_components_hook',
|
||||
function( $components ) use ( $c ) {
|
||||
function ( $components ) use ( $c ) {
|
||||
$dcc_configuration = $c->get( 'wcgateway.configuration.card-configuration' );
|
||||
assert( $dcc_configuration instanceof CardPaymentsConfiguration );
|
||||
|
||||
|
|
|
@ -40,7 +40,9 @@ use DomainException;
|
|||
* Class AXOGateway.
|
||||
*/
|
||||
class AxoGateway extends WC_Payment_Gateway {
|
||||
use OrderMetaTrait, GatewaySettingsRendererTrait, ProcessPaymentTrait;
|
||||
use OrderMetaTrait;
|
||||
use GatewaySettingsRendererTrait;
|
||||
use ProcessPaymentTrait;
|
||||
|
||||
const ID = 'ppcp-axo-gateway';
|
||||
|
||||
|
@ -351,7 +353,7 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function process_3ds_return( WC_Order $wc_order, string $token ) : array {
|
||||
protected function process_3ds_return( WC_Order $wc_order, string $token ): array {
|
||||
try {
|
||||
$paypal_order = $this->order_endpoint->order( $token );
|
||||
|
||||
|
@ -424,7 +426,7 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
* @param Order $order The PayPal order.
|
||||
* @return string The payer action URL or an empty string if not found.
|
||||
*/
|
||||
private function get_payer_action_url( Order $order ) : string {
|
||||
private function get_payer_action_url( Order $order ): string {
|
||||
$links = $order->links();
|
||||
|
||||
if ( ! $links ) {
|
||||
|
@ -448,7 +450,7 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
*
|
||||
* @return Order The PayPal order.
|
||||
*/
|
||||
protected function create_paypal_order( WC_Order $wc_order, string $payment_token ) : Order {
|
||||
protected function create_paypal_order( WC_Order $wc_order, string $payment_token ): Order {
|
||||
$purchase_unit = $this->purchase_unit_factory->from_wc_order( $wc_order );
|
||||
|
||||
$shipping_preference = $this->shipping_preference_factory->from_state(
|
||||
|
@ -559,7 +561,7 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_transaction_url( $order ) : string {
|
||||
public function get_transaction_url( $order ): string {
|
||||
$this->view_transaction_url = $this->transaction_url_provider->get_transaction_url_base( $order );
|
||||
|
||||
return parent::get_transaction_url( $order );
|
||||
|
@ -593,7 +595,7 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
*
|
||||
* @return SettingsRenderer
|
||||
*/
|
||||
protected function settings_renderer() : SettingsRenderer {
|
||||
protected function settings_renderer(): SettingsRenderer {
|
||||
return $this->settings_renderer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class CompatibilityChecker {
|
|||
*
|
||||
* @return bool Whether the checkout uses Elementor.
|
||||
*/
|
||||
protected function has_elementor_checkout() : bool {
|
||||
protected function has_elementor_checkout(): bool {
|
||||
if ( $this->checkout_compatibility['has_elementor_checkout'] === null ) {
|
||||
$this->checkout_compatibility['has_elementor_checkout'] = CartCheckoutDetector::has_elementor_checkout();
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class CompatibilityChecker {
|
|||
*
|
||||
* @return bool Whether the checkout uses classic checkout.
|
||||
*/
|
||||
protected function has_classic_checkout() : bool {
|
||||
protected function has_classic_checkout(): bool {
|
||||
if ( $this->checkout_compatibility['has_classic_checkout'] === null ) {
|
||||
$this->checkout_compatibility['has_classic_checkout'] = CartCheckoutDetector::has_classic_checkout();
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class CompatibilityChecker {
|
|||
*
|
||||
* @return bool Whether the checkout uses block checkout.
|
||||
*/
|
||||
protected function has_block_checkout() : bool {
|
||||
protected function has_block_checkout(): bool {
|
||||
if ( $this->checkout_compatibility['has_block_checkout'] === null ) {
|
||||
$this->checkout_compatibility['has_block_checkout'] = CartCheckoutDetector::has_block_checkout();
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class CompatibilityChecker {
|
|||
*
|
||||
* @return string The full HTML code of the notification, or an empty string, or raw message.
|
||||
*/
|
||||
private function render_notice( string $message, bool $is_error = false, bool $raw_message = false ) : string {
|
||||
private function render_notice( string $message, bool $is_error = false, bool $raw_message = false ): string {
|
||||
if ( ! $message ) {
|
||||
return '';
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ class CompatibilityChecker {
|
|||
*
|
||||
* @return bool Whether the setup is compatible.
|
||||
*/
|
||||
public function is_fastlane_compatible() : bool {
|
||||
public function is_fastlane_compatible(): bool {
|
||||
// Check for incompatible plugins.
|
||||
if ( ! empty( $this->incompatible_plugin_names ) ) {
|
||||
return false;
|
||||
|
@ -156,7 +156,7 @@ class CompatibilityChecker {
|
|||
* @param bool $raw_message Whether to return raw message without HTML wrappers.
|
||||
* @return string
|
||||
*/
|
||||
public function generate_checkout_notice( bool $raw_message = false ) : string {
|
||||
public function generate_checkout_notice( bool $raw_message = false ): string {
|
||||
$notice_content = '';
|
||||
|
||||
// Check for checkout incompatibilities.
|
||||
|
@ -204,7 +204,7 @@ class CompatibilityChecker {
|
|||
* @param bool $raw_message Whether to return raw message without HTML wrappers.
|
||||
* @return string
|
||||
*/
|
||||
public function generate_incompatible_plugins_notice( bool $raw_message = false ) : string {
|
||||
public function generate_incompatible_plugins_notice( bool $raw_message = false ): string {
|
||||
if ( empty( $this->incompatible_plugin_names ) ) {
|
||||
return '';
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ class CompatibilityChecker {
|
|||
* @param bool $raw_message Whether to return raw message without HTML wrappers.
|
||||
* @return string
|
||||
*/
|
||||
public function generate_settings_conflict_notice( bool $raw_message = false ) : string {
|
||||
public function generate_settings_conflict_notice( bool $raw_message = false ): string {
|
||||
if ( $this->dcc_configuration->is_enabled() ) {
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -25,5 +25,4 @@ class PropertiesDictionary {
|
|||
'no' => __( 'No', 'woocommerce-paypal-payments' ),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ class AxoApplies {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function for_merchant() : bool {
|
||||
public function for_merchant(): bool {
|
||||
return apply_filters(
|
||||
'woocommerce_paypal_payments_is_eligible_for_axo',
|
||||
true
|
||||
|
@ -94,11 +94,11 @@ class AxoApplies {
|
|||
*/
|
||||
public function should_render_fastlane(): bool {
|
||||
return ! is_user_logged_in()
|
||||
&& CartCheckoutDetector::has_classic_checkout()
|
||||
&& $this->dcc_configuration->use_fastlane()
|
||||
&& ! $this->is_excluded_endpoint()
|
||||
&& is_checkout()
|
||||
&& ! $this->subscription_helper->cart_contains_subscription();
|
||||
&& CartCheckoutDetector::has_classic_checkout()
|
||||
&& $this->dcc_configuration->use_fastlane()
|
||||
&& ! $this->is_excluded_endpoint()
|
||||
&& is_checkout()
|
||||
&& ! $this->subscription_helper->cart_contains_subscription();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,7 @@ return array(
|
|||
},
|
||||
|
||||
'wcgateway.settings.fields' => function ( array $fields, ContainerInterface $container ): array {
|
||||
$insert_after = function( array $array, string $key, array $new ): array {
|
||||
$insert_after = function ( array $array, string $key, array $new ): array {
|
||||
$keys = array_keys( $array );
|
||||
$index = array_search( $key, $keys, true );
|
||||
$pos = false === $index ? count( $array ) : $index + 1;
|
||||
|
|
|
@ -103,8 +103,9 @@ if ( blockEnabled ) {
|
|||
edit: descriptionElement,
|
||||
placeOrderButtonLabel: config.placeOrderButtonText,
|
||||
ariaLabel: config.title,
|
||||
canMakePayment: () => {
|
||||
return true;
|
||||
canMakePayment: ( cartData ) => {
|
||||
const total = cartData?.cartTotals?.total_price;
|
||||
return parseInt( total ) > 0;
|
||||
},
|
||||
supports: {
|
||||
features,
|
||||
|
|
|
@ -40,7 +40,7 @@ return array(
|
|||
$container->get( 'wcgateway.all-funding-sources' ),
|
||||
);
|
||||
},
|
||||
'blocks.advanced-card-method' => static function( ContainerInterface $container ): AdvancedCardPaymentMethod {
|
||||
'blocks.advanced-card-method' => static function ( ContainerInterface $container ): AdvancedCardPaymentMethod {
|
||||
return new AdvancedCardPaymentMethod(
|
||||
$container->get( 'blocks.url' ),
|
||||
$container->get( 'ppcp.asset-version' ),
|
||||
|
@ -69,7 +69,7 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'blocks.add-place-order-method' => function ( ContainerInterface $container ) : bool {
|
||||
'blocks.add-place-order-method' => function ( ContainerInterface $container ): bool {
|
||||
/**
|
||||
* Whether to create a non-express method with the standard "Place order" button redirecting to PayPal.
|
||||
*/
|
||||
|
|
|
@ -68,7 +68,7 @@ class BlocksModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
|
||||
add_action(
|
||||
'woocommerce_blocks_payment_method_type_registration',
|
||||
function( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void {
|
||||
function ( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void {
|
||||
$payment_method_registry->register( $c->get( 'blocks.method' ) );
|
||||
|
||||
$settings = $c->get( 'wcgateway.settings' );
|
||||
|
@ -80,7 +80,7 @@ class BlocksModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
|
||||
woocommerce_store_api_register_payment_requirements(
|
||||
array(
|
||||
'data_callback' => function() use ( $c ): array {
|
||||
'data_callback' => function () use ( $c ): array {
|
||||
$smart_button = $c->get( 'button.smart-button' );
|
||||
assert( $smart_button instanceof SmartButtonInterface );
|
||||
|
||||
|
@ -143,7 +143,7 @@ class BlocksModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_sdk_components_hook',
|
||||
function( array $components, string $context ) {
|
||||
function ( array $components, string $context ) {
|
||||
if ( str_ends_with( $context, '-block' ) ) {
|
||||
$components[] = 'buttons';
|
||||
}
|
||||
|
|
|
@ -896,6 +896,9 @@ export default class PaymentButton {
|
|||
this.syncProductButtonsState();
|
||||
}
|
||||
);
|
||||
|
||||
// Ensure initial state is synced on page load
|
||||
this.syncProductButtonsState();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ return array(
|
|||
$logger
|
||||
);
|
||||
},
|
||||
'button.helper.early-order-handler' => static function ( ContainerInterface $container ) : EarlyOrderHandler {
|
||||
'button.helper.early-order-handler' => static function ( ContainerInterface $container ): EarlyOrderHandler {
|
||||
return new EarlyOrderHandler(
|
||||
$container->get( 'settings.flag.is-connected' ),
|
||||
$container->get( 'wcgateway.order-processor' ),
|
||||
|
@ -283,7 +283,7 @@ return array(
|
|||
$logger
|
||||
);
|
||||
},
|
||||
'button.endpoint.approve-subscription' => static function( ContainerInterface $container ): ApproveSubscriptionEndpoint {
|
||||
'button.endpoint.approve-subscription' => static function ( ContainerInterface $container ): ApproveSubscriptionEndpoint {
|
||||
return new ApproveSubscriptionEndpoint(
|
||||
$container->get( 'button.request-data' ),
|
||||
$container->get( 'api.endpoint.order' ),
|
||||
|
@ -305,7 +305,7 @@ return array(
|
|||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'button.endpoint.data-client-id' => static function( ContainerInterface $container ) : DataClientIdEndpoint {
|
||||
'button.endpoint.data-client-id' => static function ( ContainerInterface $container ): DataClientIdEndpoint {
|
||||
$request_data = $container->get( 'button.request-data' );
|
||||
$identity_token = $container->get( 'api.endpoint.identity-token' );
|
||||
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
||||
|
@ -315,7 +315,7 @@ return array(
|
|||
$logger
|
||||
);
|
||||
},
|
||||
'button.endpoint.vault-paypal' => static function( ContainerInterface $container ) : StartPayPalVaultingEndpoint {
|
||||
'button.endpoint.vault-paypal' => static function ( ContainerInterface $container ): StartPayPalVaultingEndpoint {
|
||||
return new StartPayPalVaultingEndpoint(
|
||||
$container->get( 'button.request-data' ),
|
||||
$container->get( 'api.endpoint.payment-token' ),
|
||||
|
|
|
@ -63,7 +63,8 @@ use WooCommerce\PayPalCommerce\WcGateway\Helper\CardPaymentsConfiguration;
|
|||
*/
|
||||
class SmartButton implements SmartButtonInterface {
|
||||
|
||||
use FreeTrialHandlerTrait, ContextTrait;
|
||||
use FreeTrialHandlerTrait;
|
||||
use ContextTrait;
|
||||
|
||||
/**
|
||||
* The Settings status helper.
|
||||
|
@ -438,7 +439,7 @@ class SmartButton implements SmartButtonInterface {
|
|||
$subscription_helper = $this->subscription_helper;
|
||||
add_filter(
|
||||
'woocommerce_credit_card_form_fields',
|
||||
function ( array $default_fields, $id ) use ( $subscription_helper ) : array {
|
||||
function ( array $default_fields, $id ) use ( $subscription_helper ): array {
|
||||
if (
|
||||
CreditCardGateway::ID === $id
|
||||
&& is_user_logged_in()
|
||||
|
@ -671,7 +672,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
|
|||
$enabled_on_cart = $this->settings_status->is_smart_button_enabled_for_location( 'cart' );
|
||||
add_action(
|
||||
$this->proceed_to_checkout_button_renderer_hook(),
|
||||
function() use ( $enabled_on_cart ) {
|
||||
function () use ( $enabled_on_cart ) {
|
||||
if ( ! is_cart() || ! $enabled_on_cart || $this->is_free_trial_cart() || $this->is_cart_price_total_zero() || isset( reset( WC()->cart->cart_contents )['subscription_switch'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
@ -700,7 +701,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
|
|||
/**
|
||||
* Determines whether the button component should be loaded.
|
||||
*/
|
||||
public function should_load_buttons() : bool {
|
||||
public function should_load_buttons(): bool {
|
||||
$pcp_gateway_enabled = $this->settings->has( 'enabled' ) && $this->settings->get( 'enabled' );
|
||||
if ( ! $pcp_gateway_enabled ) {
|
||||
return false;
|
||||
|
@ -726,7 +727,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
|
|||
/**
|
||||
* Determines whether the Pay Later messages component should be loaded.
|
||||
*/
|
||||
public function should_load_messages() : bool {
|
||||
public function should_load_messages(): bool {
|
||||
$pcp_gateway_enabled = $this->settings->has( 'enabled' ) && $this->settings->get( 'enabled' );
|
||||
if ( ! $pcp_gateway_enabled ) {
|
||||
return false;
|
||||
|
@ -768,7 +769,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
|
|||
/**
|
||||
* Whether DCC fields can be rendered.
|
||||
*/
|
||||
public function can_render_dcc() : bool {
|
||||
public function can_render_dcc(): bool {
|
||||
return $this->dcc_configuration->is_acdc_enabled()
|
||||
&& in_array(
|
||||
$this->context(),
|
||||
|
@ -1142,7 +1143,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
|
|||
*
|
||||
* @return bool True, if any cart item requires shipping.
|
||||
*/
|
||||
private function need_shipping() : bool {
|
||||
private function need_shipping(): bool {
|
||||
/**
|
||||
* Cart instance; might be null, esp. in customizer or in Block Editor.
|
||||
*
|
||||
|
@ -1599,7 +1600,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
private function bn_codes() : array {
|
||||
private function bn_codes(): array {
|
||||
|
||||
$bn_code = $this->partner_attribution->get_bn_code();
|
||||
|
||||
|
@ -1910,7 +1911,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
|
|||
* @psalm-suppress RedundantConditionGivenDocblockType
|
||||
*/
|
||||
protected function is_cart_price_total_zero(): bool {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
|
||||
// phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
|
||||
return WC()->cart && WC()->cart->get_total( 'numeric' ) == 0;
|
||||
}
|
||||
|
||||
|
@ -1928,7 +1929,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
|
|||
|
||||
$in_stock = $product->is_in_stock();
|
||||
|
||||
if ( ! $in_stock && $product->is_type( 'variable' ) ) {
|
||||
if ( $product->is_type( 'variable' ) ) {
|
||||
/**
|
||||
* The method is defined in WC_Product_Variable class.
|
||||
*
|
||||
|
@ -2045,7 +2046,6 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
|
|||
public function is_pay_later_button_enabled_for_location( string $location, array $context_data = array() ): bool {
|
||||
return $this->is_pay_later_filter_enabled_for_location( $location, $context_data )
|
||||
&& $this->settings_status->is_pay_later_button_enabled_for_location( $location );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2178,7 +2178,6 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
|
|||
},
|
||||
11
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -375,7 +375,7 @@ class ButtonModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
*/
|
||||
add_filter(
|
||||
'woocommerce_order_received_verify_known_shoppers',
|
||||
static function( $result ) {
|
||||
static function ( $result ) {
|
||||
if ( ! is_order_received_page() ) {
|
||||
return $result;
|
||||
}
|
||||
|
@ -417,8 +417,8 @@ class ButtonModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
add_filter(
|
||||
'woocommerce_order_email_verification_required',
|
||||
static function (
|
||||
$email_verification_required,
|
||||
$order
|
||||
$email_verification_required,
|
||||
$order
|
||||
) {
|
||||
if ( ! $order instanceof WC_Order ) {
|
||||
return $email_verification_required;
|
||||
|
|
|
@ -159,7 +159,7 @@ class ApproveOrderEndpoint implements EndpointInterface {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function nonce() : string {
|
||||
public static function nonce(): string {
|
||||
return self::ENDPOINT;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ class ApproveOrderEndpoint implements EndpointInterface {
|
|||
* @return bool
|
||||
* @throws RuntimeException When order not found or handling failed.
|
||||
*/
|
||||
public function handle_request() : bool {
|
||||
public function handle_request(): bool {
|
||||
try {
|
||||
$data = $this->request_data->read_request( self::nonce() );
|
||||
if ( ! isset( $data['order_id'] ) ) {
|
||||
|
@ -266,7 +266,7 @@ class ApproveOrderEndpoint implements EndpointInterface {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function toggle_final_review_enabled_setting() : void {
|
||||
protected function toggle_final_review_enabled_setting(): void {
|
||||
// TODO new-ux: This flag must also be updated in the new settings.
|
||||
$final_review_enabled_setting = $this->settings->has( 'blocks_final_review_enabled' ) && $this->settings->get( 'blocks_final_review_enabled' );
|
||||
$this->settings->set( 'blocks_final_review_enabled', ! $final_review_enabled_setting );
|
||||
|
@ -285,7 +285,7 @@ class ApproveOrderEndpoint implements EndpointInterface {
|
|||
* @param Order $order The PayPal order to inspect.
|
||||
* @throws RuntimeException When the 3DS check was rejected.
|
||||
*/
|
||||
protected function verify_three_d_secure( Order $order ) : void {
|
||||
protected function verify_three_d_secure( Order $order ): void {
|
||||
$payment_source = $order->payment_source();
|
||||
|
||||
if ( ! $payment_source ) {
|
||||
|
|
|
@ -367,7 +367,7 @@ class CreateOrderEndpoint implements EndpointInterface {
|
|||
if (
|
||||
! $this->early_order_handler->should_create_early_order()
|
||||
|| $this->registration_needed
|
||||
|| isset( $data['createaccount'] ) && '1' === $data['createaccount'] ) {
|
||||
|| ( isset( $data['createaccount'] ) && '1' === $data['createaccount'] ) ) {
|
||||
wp_send_json_success( $this->make_response( $order ) );
|
||||
}
|
||||
|
||||
|
@ -454,7 +454,8 @@ class CreateOrderEndpoint implements EndpointInterface {
|
|||
$this->purchase_unit,
|
||||
$this->parsed_request_data['context'],
|
||||
WC()->cart,
|
||||
$funding_source
|
||||
$funding_source,
|
||||
$wc_order
|
||||
);
|
||||
|
||||
$action = in_array( $this->parsed_request_data['context'], $this->pay_now_contexts, true ) ?
|
||||
|
|
|
@ -172,14 +172,11 @@ class SimulateCartEndpoint extends AbstractCartEndpoint {
|
|||
// Removes shutdown actions to prevent persisting session, transients and save cookies.
|
||||
remove_all_actions( 'shutdown' );
|
||||
unset( WC()->cart );
|
||||
} else {
|
||||
} elseif ( null !== $this->real_cart ) {
|
||||
// Restores cart, may lead to race conditions.
|
||||
if ( null !== $this->real_cart ) {
|
||||
WC()->cart = $this->real_cart;
|
||||
}
|
||||
WC()->cart = $this->real_cart;
|
||||
}
|
||||
|
||||
unset( $this->cart );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -281,5 +281,4 @@ class CartProductsHelper {
|
|||
public function cart_item_keys(): array {
|
||||
return $this->cart_item_keys;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ class DisabledFundingSources {
|
|||
* @param string $context The context.
|
||||
* @return string[] List of disabled sources
|
||||
*/
|
||||
public function sources( string $context ) : array {
|
||||
public function sources( string $context ): array {
|
||||
$block_contexts = array( 'checkout-block', 'cart-block' );
|
||||
$flags = array(
|
||||
'context' => $context,
|
||||
|
@ -104,7 +104,7 @@ class DisabledFundingSources {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_sources_from_settings() : array {
|
||||
private function get_sources_from_settings(): array {
|
||||
try {
|
||||
// Settings field present in the legacy UI.
|
||||
$disabled_funding = $this->settings->get( 'disable_funding' );
|
||||
|
@ -133,7 +133,7 @@ class DisabledFundingSources {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_sources_for_free_trial() : array {
|
||||
private function get_sources_for_free_trial(): array {
|
||||
// Disable all sources.
|
||||
$disable_funding = array_keys( $this->all_funding_sources );
|
||||
|
||||
|
@ -154,7 +154,7 @@ class DisabledFundingSources {
|
|||
* @param array $disable_funding The current disabled funding sources.
|
||||
* @return array
|
||||
*/
|
||||
private function apply_context_rules( array $disable_funding ) : array {
|
||||
private function apply_context_rules( array $disable_funding ): array {
|
||||
if ( 'MX' === $this->merchant_country && $this->dcc_configuration->is_bcdc_enabled() && CartCheckoutDetector::has_classic_checkout() && is_checkout() ) {
|
||||
return $disable_funding;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ class DisabledFundingSources {
|
|||
* @param array $disable_funding The current disabled funding sources.
|
||||
* @return array
|
||||
*/
|
||||
private function apply_block_checkout_rules( array $disable_funding ) : array {
|
||||
private function apply_block_checkout_rules( array $disable_funding ): array {
|
||||
/**
|
||||
* Block checkout only supports the following funding methods:
|
||||
* - PayPal
|
||||
|
@ -196,7 +196,7 @@ class DisabledFundingSources {
|
|||
* @param array $flags Decision flags.
|
||||
* @return string[]
|
||||
*/
|
||||
private function sanitize_and_filter_sources( array $disable_funding, array $flags ) : array {
|
||||
private function sanitize_and_filter_sources( array $disable_funding, array $flags ): array {
|
||||
/**
|
||||
* Filters the final list of disabled funding sources.
|
||||
*
|
||||
|
|
|
@ -61,7 +61,7 @@ class ThreeDSecure {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function proceed_with_order( Order $order ) : int {
|
||||
public function proceed_with_order( Order $order ): int {
|
||||
|
||||
do_action( 'woocommerce_paypal_payments_three_d_secure_before_check', $order );
|
||||
|
||||
|
@ -120,7 +120,7 @@ class ThreeDSecure {
|
|||
* @param Order $order The PayPal Order object.
|
||||
* @return int
|
||||
*/
|
||||
public function return_decision( int $decision, Order $order ) : int {
|
||||
public function return_decision( int $decision, Order $order ): int {
|
||||
$decision = apply_filters( 'woocommerce_paypal_payments_three_d_secure_decision', $decision, $order );
|
||||
do_action( 'woocommerce_paypal_payments_three_d_secure_after_check', $order, $decision );
|
||||
|
||||
|
@ -134,7 +134,7 @@ class ThreeDSecure {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
private function no_liability_shift( AuthResult $result ) : int {
|
||||
private function no_liability_shift( AuthResult $result ): int {
|
||||
$enrollment = $result->enrollment_status();
|
||||
$authentication = $result->authentication_result();
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ class CheckoutFormValidator extends WC_Checkout {
|
|||
}
|
||||
|
||||
// Some plugins call wc_add_notice directly.
|
||||
// We should retrieve such notices, and also clear them to avoid duplicates later.
|
||||
// We should retrieve such notices, and also clear them to avoid duplicates later.
|
||||
// TODO: Normally WC converts the messages from validate_checkout into notices,
|
||||
// maybe we should do the same for consistency, but it requires lots of changes in the way we handle/output errors.
|
||||
$messages = array_merge(
|
||||
|
|
|
@ -24,17 +24,17 @@ return array(
|
|||
$save_payment_methods_applies = $container->get( 'card-fields.helpers.save-payment-methods-applies' );
|
||||
assert( $save_payment_methods_applies instanceof CardFieldsApplies );
|
||||
|
||||
return static function () use ( $save_payment_methods_applies ) : bool {
|
||||
return static function () use ( $save_payment_methods_applies ): bool {
|
||||
return $save_payment_methods_applies->for_country() && $save_payment_methods_applies->for_merchant();
|
||||
};
|
||||
},
|
||||
'card-fields.helpers.save-payment-methods-applies' => static function ( ContainerInterface $container ) : CardFieldsApplies {
|
||||
'card-fields.helpers.save-payment-methods-applies' => static function ( ContainerInterface $container ): CardFieldsApplies {
|
||||
return new CardFieldsApplies(
|
||||
$container->get( 'card-fields.supported-country-matrix' ),
|
||||
$container->get( 'api.shop.country' )
|
||||
);
|
||||
},
|
||||
'card-fields.supported-country-matrix' => static function ( ContainerInterface $container ) : array {
|
||||
'card-fields.supported-country-matrix' => static function ( ContainerInterface $container ): array {
|
||||
return apply_filters(
|
||||
'woocommerce_paypal_payments_card_fields_supported_country_matrix',
|
||||
array(
|
||||
|
@ -82,7 +82,7 @@ return array(
|
|||
)
|
||||
);
|
||||
},
|
||||
'card-fields.service.card-capture-validator' => static function ( ContainerInterface $container ) : CardCaptureValidator {
|
||||
'card-fields.service.card-capture-validator' => static function ( ContainerInterface $container ): CardCaptureValidator {
|
||||
return new CardCaptureValidator();
|
||||
},
|
||||
);
|
||||
|
|
|
@ -53,7 +53,7 @@ class CardFieldsModule implements ServiceModule, ExtendingModule, ExecutableModu
|
|||
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_sdk_components_hook',
|
||||
static function( array $components ) use ( $c ) {
|
||||
static function ( array $components ) use ( $c ) {
|
||||
$dcc_config = $c->get( 'wcgateway.configuration.card-configuration' );
|
||||
assert( $dcc_config instanceof CardPaymentsConfiguration );
|
||||
|
||||
|
@ -104,7 +104,7 @@ class CardFieldsModule implements ServiceModule, ExtendingModule, ExecutableModu
|
|||
* @psalm-suppress MissingClosureReturnType
|
||||
* @psalm-suppress MissingClosureParamType
|
||||
*/
|
||||
function( $default_fields, $id ) use ( $c ) {
|
||||
function ( $default_fields, $id ) use ( $c ) {
|
||||
if ( ! $c->get( 'wcgateway.configuration.card-configuration' )->is_enabled() ) {
|
||||
return $default_fields;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ class CardFieldsModule implements ServiceModule, ExtendingModule, ExecutableModu
|
|||
|
||||
add_filter(
|
||||
'ppcp_create_order_request_body_data',
|
||||
function( array $data, string $payment_method ) use ( $c ): array {
|
||||
function ( array $data, string $payment_method ) use ( $c ): array {
|
||||
if ( ! $c->get( 'wcgateway.configuration.card-configuration' )->is_enabled() ) {
|
||||
return $data;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ class CardFieldsModule implements ServiceModule, ExtendingModule, ExecutableModu
|
|||
// Validates if an order with card payment source can be captured.
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_before_capture_order',
|
||||
function( Order $order ) use ( $c ) {
|
||||
function ( Order $order ) use ( $c ) {
|
||||
$validator = $c->get( 'card-fields.service.card-capture-validator' );
|
||||
assert( $validator instanceof CardCaptureValidator );
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class CardFieldsApplies {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function for_merchant() : bool {
|
||||
public function for_merchant(): bool {
|
||||
return apply_filters(
|
||||
'woocommerce_paypal_payments_is_eligible_for_card_fields',
|
||||
true
|
||||
|
|
|
@ -21,7 +21,7 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
|||
|
||||
return array(
|
||||
|
||||
'compat.ppec.mock-gateway' => static function( $container ) {
|
||||
'compat.ppec.mock-gateway' => static function ( $container ) {
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
$title = $settings->has( 'title' ) ? $settings->get( 'title' ) : __( 'PayPal', 'woocommerce-paypal-payments' );
|
||||
$title = sprintf(
|
||||
|
@ -40,13 +40,13 @@ return array(
|
|||
return new PPEC\SubscriptionsHandler( $ppcp_renewal_handler, $gateway );
|
||||
},
|
||||
|
||||
'compat.ppec.settings_importer' => static function( ContainerInterface $container ) : PPEC\SettingsImporter {
|
||||
'compat.ppec.settings_importer' => static function ( ContainerInterface $container ): PPEC\SettingsImporter {
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
|
||||
return new PPEC\SettingsImporter( $settings );
|
||||
},
|
||||
|
||||
'compat.plugin-script-names' => static function( ContainerInterface $container ) : array {
|
||||
'compat.plugin-script-names' => static function ( ContainerInterface $container ): array {
|
||||
return array(
|
||||
'ppcp-smart-button',
|
||||
'ppcp-oxxo',
|
||||
|
@ -61,7 +61,7 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'compat.plugin-script-file-names' => static function( ContainerInterface $container ) : array {
|
||||
'compat.plugin-script-file-names' => static function ( ContainerInterface $container ): array {
|
||||
return array(
|
||||
'button.js',
|
||||
'gateway-settings.js',
|
||||
|
@ -104,7 +104,7 @@ return array(
|
|||
return plugins_url( '/modules/ppcp-compat/', $container->get( 'ppcp.path-to-plugin-main-file' ) );
|
||||
},
|
||||
|
||||
'compat.assets' => function( ContainerInterface $container ) : CompatAssets {
|
||||
'compat.assets' => function ( ContainerInterface $container ): CompatAssets {
|
||||
return new CompatAssets(
|
||||
$container->get( 'compat.module.url' ),
|
||||
$container->get( 'ppcp.asset-version' ),
|
||||
|
@ -120,7 +120,7 @@ return array(
|
|||
*
|
||||
* @returns SettingsMap[]
|
||||
*/
|
||||
'compat.setting.new-to-old-map' => static function( ContainerInterface $container ) : array {
|
||||
'compat.setting.new-to-old-map' => static function ( ContainerInterface $container ): array {
|
||||
$are_new_settings_enabled = $container->get( 'wcgateway.settings.admin-settings-enabled' );
|
||||
if ( ! $are_new_settings_enabled ) {
|
||||
return array();
|
||||
|
@ -184,7 +184,7 @@ return array(
|
|||
),
|
||||
);
|
||||
},
|
||||
'compat.settings.settings_map_helper' => static function( ContainerInterface $container ) : SettingsMapHelper {
|
||||
'compat.settings.settings_map_helper' => static function ( ContainerInterface $container ): SettingsMapHelper {
|
||||
return new SettingsMapHelper(
|
||||
$container->get( 'compat.setting.new-to-old-map' ),
|
||||
$container->get( 'compat.settings.styling_map_helper' ),
|
||||
|
@ -195,19 +195,19 @@ return array(
|
|||
$container->get( 'wcgateway.settings.admin-settings-enabled' )
|
||||
);
|
||||
},
|
||||
'compat.settings.styling_map_helper' => static function() : StylingSettingsMapHelper {
|
||||
'compat.settings.styling_map_helper' => static function (): StylingSettingsMapHelper {
|
||||
return new StylingSettingsMapHelper();
|
||||
},
|
||||
'compat.settings.settings_tab_map_helper' => static function() : SettingsTabMapHelper {
|
||||
'compat.settings.settings_tab_map_helper' => static function (): SettingsTabMapHelper {
|
||||
return new SettingsTabMapHelper();
|
||||
},
|
||||
'compat.settings.subscription_map_helper' => static function( ContainerInterface $container ) : SubscriptionSettingsMapHelper {
|
||||
'compat.settings.subscription_map_helper' => static function ( ContainerInterface $container ): SubscriptionSettingsMapHelper {
|
||||
return new SubscriptionSettingsMapHelper( $container->get( 'wc-subscriptions.helper' ) );
|
||||
},
|
||||
'compat.settings.general_map_helper' => static function() : GeneralSettingsMapHelper {
|
||||
'compat.settings.general_map_helper' => static function (): GeneralSettingsMapHelper {
|
||||
return new GeneralSettingsMapHelper();
|
||||
},
|
||||
'compat.settings.payment_methods_map_helper' => static function() : PaymentMethodSettingsMapHelper {
|
||||
'compat.settings.payment_methods_map_helper' => static function (): PaymentMethodSettingsMapHelper {
|
||||
return new PaymentMethodSettingsMapHelper();
|
||||
},
|
||||
);
|
||||
|
|
|
@ -56,7 +56,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
|
||||
add_action(
|
||||
'woocommerce_init',
|
||||
function() use ( $c ) {
|
||||
function () use ( $c ) {
|
||||
$this->initialize_ppec_compat_layer( $c );
|
||||
$this->initialize_tracking_compat_layer( $c );
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
|
||||
add_action(
|
||||
'init',
|
||||
function() use ( $c ) {
|
||||
function () use ( $c ) {
|
||||
$asset_loader = $c->get( 'compat.assets' );
|
||||
assert( $asset_loader instanceof CompatAssets );
|
||||
|
||||
|
@ -118,7 +118,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
*/
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_gateway_migrate_on_update',
|
||||
static function() use ( $c ) {
|
||||
static function () use ( $c ) {
|
||||
if ( ! apply_filters(
|
||||
// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
|
||||
'woocommerce.feature-flags.woocommerce_paypal_payments.paylater_messaging_force_enabled',
|
||||
|
@ -177,7 +177,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
// Inbox note inviting merchant to disable PayPal Express Checkout.
|
||||
add_action(
|
||||
'woocommerce_init',
|
||||
function() {
|
||||
function () {
|
||||
if ( is_admin() && is_callable( array( WC(), 'is_wc_admin_active' ) ) && WC()->is_wc_admin_active() && class_exists( 'Automattic\WooCommerce\Admin\Notes\Notes' ) ) {
|
||||
PPEC\DeactivateNote::init();
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
protected function fix_page_builders(): void {
|
||||
add_action(
|
||||
'init',
|
||||
function() {
|
||||
function () {
|
||||
if (
|
||||
$this->is_block_theme_active()
|
||||
|| $this->is_elementor_pro_active()
|
||||
|
@ -387,7 +387,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
) {
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_single_product_renderer_hook',
|
||||
function(): string {
|
||||
function (): string {
|
||||
return 'woocommerce_after_add_to_cart_form';
|
||||
},
|
||||
5
|
||||
|
@ -444,7 +444,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
protected function set_elementor_checkout_context(): void {
|
||||
add_action(
|
||||
'wp',
|
||||
function() {
|
||||
function () {
|
||||
$page_id = get_the_ID();
|
||||
if ( ! is_numeric( $page_id ) || ! CartCheckoutDetector::has_elementor_checkout( (int) $page_id ) ) {
|
||||
return;
|
||||
|
@ -474,7 +474,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
// Siteground SG Optimize.
|
||||
add_filter(
|
||||
'sgo_js_minify_exclude',
|
||||
function( array $scripts ) use ( $ppcp_script_names ) {
|
||||
function ( array $scripts ) use ( $ppcp_script_names ) {
|
||||
return array_merge( $scripts, $ppcp_script_names );
|
||||
}
|
||||
);
|
||||
|
@ -482,7 +482,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
// LiteSpeed Cache.
|
||||
add_filter(
|
||||
'litespeed_optimize_js_excludes',
|
||||
function( array $excluded_js ) use ( $ppcp_script_file_names ) {
|
||||
function ( array $excluded_js ) use ( $ppcp_script_file_names ) {
|
||||
return array_merge( $excluded_js, $ppcp_script_file_names );
|
||||
}
|
||||
);
|
||||
|
@ -499,7 +499,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
* @return bool Whether to do tag minification.
|
||||
* @psalm-suppress MissingClosureParamType
|
||||
*/
|
||||
function( bool $do_tag_minification, string $script_tag, $file ) {
|
||||
function ( bool $do_tag_minification, string $script_tag, $file ) {
|
||||
if ( $file && strpos( $file, 'ppcp' ) !== false ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
protected function initialize_nyp_compat_layer(): void {
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_shipping_callback_cart_line_item_total',
|
||||
static function( string $total, array $cart_item ) {
|
||||
static function ( string $total, array $cart_item ) {
|
||||
if ( ! isset( $cart_item['nyp'] ) ) {
|
||||
return $total;
|
||||
}
|
||||
|
@ -596,7 +596,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
* @param ContainerInterface $container DI container instance.
|
||||
* @return void
|
||||
*/
|
||||
protected function legacy_ui_card_payment_mapping( ContainerInterface $container ) : void {
|
||||
protected function legacy_ui_card_payment_mapping( ContainerInterface $container ): void {
|
||||
$new_ui = $container->get( 'wcgateway.settings.admin-settings-enabled' );
|
||||
if ( $new_ui ) {
|
||||
return;
|
||||
|
@ -604,7 +604,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_is_acdc_active',
|
||||
static function ( bool $is_acdc ) use ( $container ) : bool {
|
||||
static function ( bool $is_acdc ) use ( $container ): bool {
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
|
||||
|
|
|
@ -116,5 +116,4 @@ class DeactivateNote {
|
|||
$note->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,5 +45,4 @@ class MockGateway extends \WC_Payment_Gateway {
|
|||
// Hide mock gateway, except on admin.
|
||||
return is_admin();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -117,5 +117,4 @@ class PPECHelper {
|
|||
&& self::site_has_ppec_subscriptions()
|
||||
&& apply_filters( 'woocommerce_paypal_payments_process_legacy_subscriptions', true );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -231,5 +231,4 @@ class SettingsImporter {
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ class SettingsMapHelper {
|
|||
* @param SettingsMap[] $settings_map The settings map to validate.
|
||||
* @throws RuntimeException When an old key has multiple mappings.
|
||||
*/
|
||||
protected function validate_settings_map( array $settings_map ) : void {
|
||||
protected function validate_settings_map( array $settings_map ): void {
|
||||
$seen_keys = array();
|
||||
|
||||
foreach ( $settings_map as $settings_map_instance ) {
|
||||
|
@ -172,7 +172,7 @@ class SettingsMapHelper {
|
|||
*
|
||||
* @return bool True if the key exists in the new settings, false otherwise.
|
||||
*/
|
||||
public function has_mapped_key( string $old_key ) : bool {
|
||||
public function has_mapped_key( string $old_key ): bool {
|
||||
if ( ! $this->new_settings_module_enabled ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ class SettingsMapHelper {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function ensure_map_initialized() : void {
|
||||
protected function ensure_map_initialized(): void {
|
||||
if ( $this->key_to_model === null ) {
|
||||
$this->initialize_key_map();
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ class SettingsMapHelper {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function initialize_key_map() : void {
|
||||
protected function initialize_key_map(): void {
|
||||
$this->key_to_model = array();
|
||||
|
||||
foreach ( $this->settings_map as $settings_map_instance ) {
|
||||
|
@ -264,7 +264,7 @@ class SettingsMapHelper {
|
|||
*
|
||||
* @return AbstractDataModel|null
|
||||
*/
|
||||
protected function get_payment_settings_model() : ?AbstractDataModel {
|
||||
protected function get_payment_settings_model(): ?AbstractDataModel {
|
||||
foreach ( $this->settings_map as $settings_map_instance ) {
|
||||
if ( $settings_map_instance->get_model() instanceof PaymentSettings ) {
|
||||
return $settings_map_instance->get_model();
|
||||
|
|
|
@ -31,7 +31,7 @@ return array(
|
|||
$is_available = $container->get( 'googlepay.available' );
|
||||
$is_referral = $container->get( 'googlepay.is_referral' );
|
||||
|
||||
$insert_after = function( array $array, string $key, array $new ): array {
|
||||
$insert_after = function ( array $array, string $key, array $new ): array {
|
||||
$keys = array_keys( $array );
|
||||
$index = array_search( $key, $keys, true );
|
||||
$pos = false === $index ? count( $array ) : $index + 1;
|
||||
|
|
|
@ -33,11 +33,11 @@ return array(
|
|||
$apm_applies = $container->get( 'googlepay.helpers.apm-applies' );
|
||||
assert( $apm_applies instanceof ApmApplies );
|
||||
|
||||
return static function () use ( $apm_applies ) : bool {
|
||||
return static function () use ( $apm_applies ): bool {
|
||||
return $apm_applies->for_country() && $apm_applies->for_currency() && $apm_applies->for_merchant();
|
||||
};
|
||||
},
|
||||
'googlepay.helpers.apm-applies' => static function ( ContainerInterface $container ) : ApmApplies {
|
||||
'googlepay.helpers.apm-applies' => static function ( ContainerInterface $container ): ApmApplies {
|
||||
return new ApmApplies(
|
||||
$container->get( 'googlepay.supported-countries' ),
|
||||
$container->get( 'googlepay.supported-currencies' ),
|
||||
|
@ -76,7 +76,7 @@ return array(
|
|||
},
|
||||
|
||||
'googlepay.helpers.apm-product-status' => SingletonDecorator::make(
|
||||
static function( ContainerInterface $container ): ApmProductStatus {
|
||||
static function ( ContainerInterface $container ): ApmProductStatus {
|
||||
return new ApmProductStatus(
|
||||
$container->get( 'wcgateway.settings' ),
|
||||
$container->get( 'api.endpoint.partners' ),
|
||||
|
@ -89,7 +89,7 @@ return array(
|
|||
/**
|
||||
* The list of which countries can be used for GooglePay.
|
||||
*/
|
||||
'googlepay.supported-countries' => static function ( ContainerInterface $container ) : array {
|
||||
'googlepay.supported-countries' => static function ( ContainerInterface $container ): array {
|
||||
/**
|
||||
* Returns which countries can be used for GooglePay.
|
||||
*/
|
||||
|
@ -145,7 +145,7 @@ return array(
|
|||
/**
|
||||
* The list of which currencies can be used for GooglePay.
|
||||
*/
|
||||
'googlepay.supported-currencies' => static function ( ContainerInterface $container ) : array {
|
||||
'googlepay.supported-currencies' => static function ( ContainerInterface $container ): array {
|
||||
/**
|
||||
* Returns which currencies can be used for GooglePay.
|
||||
*/
|
||||
|
|
|
@ -275,7 +275,7 @@ class Button implements ButtonInterface {
|
|||
*/
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_sdk_components_hook',
|
||||
function( $components ) {
|
||||
function ( $components ) {
|
||||
$components[] = 'googlepay';
|
||||
return $components;
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ class Button implements ButtonInterface {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function hide_gateway_until_eligible() : void {
|
||||
protected function hide_gateway_until_eligible(): void {
|
||||
?>
|
||||
<style data-hide-gateway='<?php echo esc_attr( GooglePayGateway::ID ); ?>'>
|
||||
.wc_payment_method.payment_method_ppcp-googlepay {
|
||||
|
|
|
@ -219,5 +219,4 @@ class UpdatePaymentDataEndpoint {
|
|||
WC()->session->set( 'chosen_shipping_methods', array( $rate_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
|
|||
// Clears product status when appropriate.
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_clear_apm_product_status',
|
||||
function( ?Settings $settings = null ) use ( $c ): void {
|
||||
function ( ?Settings $settings = null ) use ( $c ): void {
|
||||
$apm_status = $c->get( 'googlepay.helpers.apm-product-status' );
|
||||
assert( $apm_status instanceof ApmProductStatus );
|
||||
$apm_status->clear( $settings );
|
||||
|
@ -149,7 +149,7 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
|
|||
// Registers buttons on blocks pages.
|
||||
add_action(
|
||||
'woocommerce_blocks_payment_method_type_registration',
|
||||
function( PaymentMethodRegistry $payment_method_registry ) use ( $c, $button ): void {
|
||||
function ( PaymentMethodRegistry $payment_method_registry ) use ( $c, $button ): void {
|
||||
if ( SettingsModule::should_use_the_old_ui() && ! $button->is_enabled() ) {
|
||||
return;
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
|
|||
// Adds GooglePay component to the backend button preview settings.
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_admin_gateway_settings',
|
||||
function( array $settings ) use ( $c ): array {
|
||||
function ( array $settings ) use ( $c ): array {
|
||||
if ( is_array( $settings['components'] ) ) {
|
||||
$settings['components'][] = 'googlepay';
|
||||
}
|
||||
|
@ -178,7 +178,6 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
|
|||
$endpoint->handle_request();
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
1
|
||||
);
|
||||
|
@ -225,7 +224,7 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
|
|||
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_selected_button_locations',
|
||||
function( array $locations, string $setting_name ): array {
|
||||
function ( array $locations, string $setting_name ): array {
|
||||
$gateway = WC()->payment_gateways()->payment_gateways()[ GooglePayGateway::ID ] ?? '';
|
||||
if ( $gateway && $gateway->enabled === 'yes' && $setting_name === 'smart_button_locations' ) {
|
||||
$locations[] = 'checkout';
|
||||
|
@ -255,7 +254,7 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
|
|||
|
||||
add_filter(
|
||||
'ppcp_create_order_request_body_data',
|
||||
static function ( array $data, string $payment_method, array $request ) use ( $c ) : array {
|
||||
static function ( array $data, string $payment_method, array $request ) use ( $c ): array {
|
||||
|
||||
$funding_source = $request['funding_source'] ?? '';
|
||||
if ( $payment_method !== GooglePayGateway::ID && $funding_source !== 'googlepay' ) {
|
||||
|
|
|
@ -89,7 +89,7 @@ class ApmApplies {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function for_merchant() : bool {
|
||||
public function for_merchant(): bool {
|
||||
return apply_filters(
|
||||
'woocommerce_paypal_payments_is_eligible_for_googlepay',
|
||||
true
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue