diff --git a/.editorconfig b/.editorconfig index 5fa79dbc..8376dcbf 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,7 +12,7 @@ trim_trailing_whitespace = true [*.txt] trim_trailing_whitespace = false -[*.{md,json,yml}] +[*.{md,json,yaml,yml}] trim_trailing_whitespace = false indent_style = space indent_size = 2 diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a04c68ea..ce88e0d0 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -5,26 +5,22 @@ on: [ push, pull_request ] env: COMPOSER_NO_INTERACTION: 1 WP_TESTS_DB_PASS: password + php-version: '7.4' wp-version: '*' + phpunit-version: '^6.0' jobs: - coding-standards: - name: Coding Standards (PHP ${{ matrix.php-version }}) + phpcs: + name: PHP Coding Standards runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - php-version: - - 7.4 - steps: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: ${{ env.php-version }} extensions: bcmath, intl, mbstring, mysql ini-values: memory_limit=2048M tools: composer, phpcs @@ -54,32 +50,64 @@ jobs: - name: List Composer packages run: composer show - - name: PHPLint - run: composer run-script phplint - - name: PHP Code Sniffer run: composer run-script phpcs + phpmd: + name: PHP Mess Detector + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.php-version }} + extensions: bcmath, intl, mbstring, mysql + ini-values: memory_limit=2048M + tools: composer + coverage: none + + - name: Composer validation + run: composer validate --strict + + # https://github.com/actions/cache/blob/master/examples.md#php---composer + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + - uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Require WordPress + run: composer require --dev --no-update --no-progress --no-suggest roots/wordpress:${{ env.wp-version }} wp-phpunit/wp-phpunit:${{ env.wp-version }} + + - name: Install Composer dependencies + run: composer update --no-progress --no-suggest + + - name: List Composer packages + run: composer show + - name: PHP Mess Detector continue-on-error: true run: composer run-script phpmd - static-code-analysis: - name: Static Code Analysis (PHP ${{ matrix.php-version }}) + phpstan: + name: PHPStan runs-on: ubuntu-latest - strategy: - matrix: - php-version: - - 7.4 - steps: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: ${{ env.php-version }} extensions: bcmath, intl, mbstring, mysql ini-values: memory_limit=2048M tools: composer @@ -100,8 +128,11 @@ jobs: - name: Install Composer dependencies run: composer update --no-progress --no-suggest - - name: PHPStan static code analysis - run: composer bin phpstan install && composer run-script phpstan + - name: Install PHPStan + run: composer bin phpstan install + + - name: PHPStan + run: composer run-script phpstan tests: name: Tests — PHP ${{ matrix.php-version }} ${{ matrix.name }} @@ -215,16 +246,10 @@ jobs: run: composer run-script phpunit code-coverage: - name: Code Coverage (PHP ${{ matrix.php-version }}) + name: Code Coverage runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - php-version: - - 7.4 - services: mysql: image: mysql:5.7 @@ -241,7 +266,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: ${{ env.php-version }} extensions: bcmath, intl, mbstring, mysql ini-values: memory_limit=2048M tools: composer @@ -277,17 +302,19 @@ jobs: - name: PHPUnit test suite env: WP_TESTS_DB_HOST: 127.0.0.1:${{ job.services.mysql.ports['3306'] }} - run: composer run-script phpunit + run: composer run-script coverage - - name: Coveralls code coverage + - name: Publish coverage env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: | composer run-script coveralls bash <(curl -s https://codecov.io/bash) - es-sass-linting: - name: Scripts and Styles + es-lint: + name: Scripts runs-on: ubuntu-latest @@ -312,5 +339,28 @@ jobs: - name: ESLint run: npm run-script eslint - - name: Sass Lint - run: npm run-script sass-lint + sass-lint: + name: Styles + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + # https://github.com/actions/cache/blob/master/examples.md#macos-and-ubuntu + - uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - uses: actions/setup-node@v1 + with: + node-version: '12' + + - name: Install Node packages + run: npm install + + - name: Sass Lint + run: npm run-script sass-lint diff --git a/.scrutinizer.yml b/.scrutinizer.yml index bc3cfbd1..933ea71b 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,33 +1,37 @@ build: - environment: - php: 7.3.0 - variables: - WP_TESTS_DB_NAME: 'wp_phpunit_tests' - WP_TESTS_DB_USER: 'root' - WP_TESTS_DB_PASS: '' - WP_TESTS_DB_HOST: 'localhost' - project_setup: - before: - - mysql -e "CREATE DATABASE wp_phpunit_tests" - dependencies: - override: - - composer install --no-interaction nodes: analysis: tests: override: - - - command: phpcs-run - use_website_config: false + - php-scrutinizer-run coverage: tests: override: - - command: vendor/bin/phpunit + - command: ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml coverage: file: build/logs/clover.xml format: clover + environment: + php: 7.3.0 + variables: + WP_TESTS_DB_NAME: 'wp_phpunit_tests' + WP_TESTS_DB_USER: 'root' + WP_TESTS_DB_PASS: '' + WP_TESTS_DB_HOST: '127.0.0.1' + + services: + mysql: 5.7 + + dependencies: + override: + - composer install --ignore-platform-reqs --no-interaction + + project_setup: + before: + - mysql -e "CREATE DATABASE wp_phpunit_tests" + filter: excluded_paths: # Exclude the external `xmlseclibs.php` library. diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bd3fb82..b17aa391 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,25 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C ## [Unreleased][unreleased] - +## [3.0.0] - 2021-08-05 +### Changed +- Updated to `pronamic/wp-money` version ` 2.0.0`. +- No longer require taxed money in payments and subscriptions. +- Gateway in WordPress admin dashboard is now clickable. +- Updated subscription action URLs to include trailing slash. +- Made transaction ID searchable by inclusion in payment JSON post content. +- Updated hooks documentation. + +### Added +- Added support for SprayPay payment method. + +### Fixed +- Fixed payment form amount input styling with WordPress default theme. +- Fixed deprecated `block_categories` filter warning with WordPress 5.8. + +### Removed +- Removed [Shortcake (Shortcode UI)](https://wordpress.org/plugins/shortcode-ui/) support. + ## [2.7.2] - 2021-06-18 - Added payment method to subscription details when cancelling/renewing a subscription. - Added refunded amount in payments overview amount column. @@ -373,7 +392,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C ## 1.0.0 - First release. -[unreleased]: https://github.com/wp-pay/core/compare/2.7.2...HEAD +[unreleased]: https://github.com/wp-pay/core/compare/3.0.0...HEAD +[3.0.0]: https://github.com/wp-pay/core/compare/2.7.2...3.0.0 [2.7.2]: https://github.com/wp-pay/core/compare/2.7.1...2.7.2 [2.7.1]: https://github.com/wp-pay/core/compare/2.7.0...2.7.1 [2.7.0]: https://github.com/wp-pay/core/compare/2.6.2...2.7.0 diff --git a/composer.json b/composer.json index c14f2b83..18cbbf19 100644 --- a/composer.json +++ b/composer.json @@ -50,27 +50,26 @@ "pronamic/wp-datetime": "^1.2", "pronamic/wp-html": "^1.0", "pronamic/wp-http": "^1.0", - "pronamic/wp-money": "^1.2", + "pronamic/wp-money": "^2.0", "viison/address-splitter": "^0.3.4" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.4", - "dealerdirect/phpcodesniffer-composer-installer": "^0.7", "overtrue/phplint": "^2.2", "php-coveralls/php-coveralls": "^2.4", "php-stubs/wp-cli-stubs": "^2.4", - "phpcompatibility/php-compatibility": "^9.3", - "phpcompatibility/phpcompatibility-wp": "^2.1", "phpmd/phpmd": "^2.9", "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0", + "pronamic/wp-coding-standards": "^1.0", "roots/wordpress": "^5.6", - "squizlabs/php_codesniffer": "^3.5", "wp-cli/wp-cli": "^2.3", - "wp-coding-standards/wpcs": "^2.3", - "wp-phpunit/wp-phpunit": "^5.6", - "wpackagist-plugin/shortcode-ui": "^0.7" + "wp-phpunit/wp-phpunit": "^5.6" }, "scripts": { + "coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-clover build/logs/clover.xml --coverage-text", + "coverage-clover": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-clover build/logs/clover.xml", + "coverage-html": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html build/coverage-html", + "coverage-text": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text", "coveralls": "vendor/bin/php-coveralls -v", "phpcbf": "vendor/bin/phpcbf", "phpcs": "XDEBUG_MODE=off vendor/bin/phpcs -s -v", @@ -86,7 +85,7 @@ "@xmllint-phpcs" ], "build-docs": [ - "vendor/bin/wp-documentor parse src --format=markdown --relative=docs > docs/hooks.md" + "XDEBUG_MODE=off vendor/bin/wp-documentor parse src --format=markdown --relative=docs > docs/hooks.md" ] } } diff --git a/css/forms.css b/css/forms.css index 3662f5bb..7b601f55 100644 --- a/css/forms.css +++ b/css/forms.css @@ -8,7 +8,7 @@ padding: 0 0 10px; width: 100%; } -.pronamic-pay-form .pronamic-pay-amount-input { +.pronamic-pay-form .pronamic-pay-amount-input[type="text"] { width: auto; } diff --git a/css/forms.css.map b/css/forms.css.map index 0eddd9d6..5599cb76 100644 --- a/css/forms.css.map +++ b/css/forms.css.map @@ -1 +1,7 @@ -{"version":3,"sourceRoot":"","sources":["../scss/forms.scss","../scss/admin/_variables.scss"],"names":[],"mappings":"AAIC;EACC;;AAID;EACC;EAEA;EAEA;EACA;EAEA;;AAID;EACC;;;AAKF;EACC,OCFU;;;ADMX;EACC;;AAEA;AAAA;AAAA;EAGC;EAEA;EAEA;;;AAIF;EACC;EAEA;;;AAGD;AAAA;EAEC;;;AAGD;EACC;;;AAGD;EACC;;;AAID;EACC,YCjDuB;EDmDvB;EAEA;EAEA;EAEA;EAEA;EAEA","file":"forms.css"} \ No newline at end of file +{ +"version": 3, +"mappings": "AAIC,2BAAS;EACR,MAAM,EAAE,CAAC;;AAIV,yBAAO;EACN,aAAa,EAAE,iBAA0B;EAEzC,WAAW,EAAE,GAAG;EAEhB,MAAM,EAAE,WAAW;EACnB,OAAO,EAAE,QAAQ;EAEjB,KAAK,EAAE,IAAI;;AAIZ,0DAAwC;EACvC,KAAK,EAAE,IAAI;;;AAKb,gCAAiC;EAChC,KAAK,ECuDyB,IAAS;;;ADnDxC,sBAAuB;EACtB,MAAM,EAAE,QAAQ;;AAEhB;;6BAEO;EACN,aAAa,EAAE,CAAC;EAEhB,OAAO,EAAE,IAAI;EAEb,KAAK,EAAE,IAAI;;;AAIb,2BAA4B;EAC3B,KAAK,EAAE,IAAI;EAEX,MAAM,EAAE,QAAQ;;;AAGjB;2BAC4B;EAC3B,KAAK,EAAE,KAAK;;;AAGb,4BAA6B;EAC5B,KAAK,EAAE,IAAI;;;AAGZ,2BAA4B;EAC3B,KAAK,EAAE,KAAK;;;AAIb,mBAAoB;EACnB,UAAU,ECjDa,OAAO;EDmD9B,WAAW,EAAE,cAAmB;EAEhC,UAAU,EAAE,8BAA4B;EAExC,KAAK,EAAE,IAAI;EAEX,MAAM,EAAE,MAAM;EAEd,OAAO,EAAE,eAAe;EAExB,QAAQ,EAAE,QAAQ", +"sources": ["../scss/forms.scss","../scss/admin/_variables.scss"], +"names": [], +"file": "forms.css" +} diff --git a/css/forms.min.css b/css/forms.min.css index 6372d7a5..6c3618a6 100644 --- a/css/forms.min.css +++ b/css/forms.min.css @@ -1 +1 @@ -.pronamic-pay-form fieldset{border:0}.pronamic-pay-form legend{border-bottom:1px solid #ededed;font-weight:700;margin:10px 0 15px;padding:0 0 10px;width:100%}.pronamic-pay-form .pronamic-pay-amount-input{width:auto}.pronamic-pay-required-indicator{color:#a00}.pronamic-pay-form-row{margin:0 0 15px}.pronamic-pay-form-row input,.pronamic-pay-form-row select,.pronamic-pay-form-row textarea{border-radius:0;outline:none;width:100%}.pronamic-pay-form-row-wide{clear:both;margin:0 0 15px}.pronamic-pay-form-row-first,.pronamic-pay-form-row-last{width:48.5%}.pronamic-pay-form-row-first{float:left}.pronamic-pay-form-row-last{float:right}.pronamic-pay-error{background:#f9f9f9;border-left:4px solid #a00;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.125);box-shadow:0 1px 1px rgba(0,0,0,.125);clear:both;margin:15px 0;padding:1em 1em 1em 2em;position:relative} +.pronamic-pay-form fieldset{border:0}.pronamic-pay-form legend{border-bottom:1px solid #ededed;font-weight:700;margin:10px 0 15px;padding:0 0 10px;width:100%}.pronamic-pay-form .pronamic-pay-amount-input[type=text]{width:auto}.pronamic-pay-required-indicator{color:#a00}.pronamic-pay-form-row{margin:0 0 15px}.pronamic-pay-form-row input,.pronamic-pay-form-row select,.pronamic-pay-form-row textarea{border-radius:0;outline:none;width:100%}.pronamic-pay-form-row-wide{clear:both;margin:0 0 15px}.pronamic-pay-form-row-first,.pronamic-pay-form-row-last{width:48.5%}.pronamic-pay-form-row-first{float:left}.pronamic-pay-form-row-last{float:right}.pronamic-pay-error{background:#f9f9f9;border-left:4px solid #a00;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.125);box-shadow:0 1px 1px rgba(0,0,0,.125);clear:both;margin:15px 0;padding:1em 1em 1em 2em;position:relative} diff --git a/docs/hooks.md b/docs/hooks.md index 44ef3e30..02510c00 100644 --- a/docs/hooks.md +++ b/docs/hooks.md @@ -7,247 +7,495 @@ ### `pronamic_pay_update_payment` +*Payment updated.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$payment` | | +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [src/Payments/PaymentsDataStoreCPT.php](../src/Payments/PaymentsDataStoreCPT.php), [line 239](../src/Payments/PaymentsDataStoreCPT.php#L239-L239) +Source: [src/Payments/PaymentsDataStoreCPT.php](../src/Payments/PaymentsDataStoreCPT.php), [line 240](../src/Payments/PaymentsDataStoreCPT.php#L240-L245) ### `pronamic_pay_new_payment` +*New payment created.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$payment` | | +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. + +Source: [src/Payments/PaymentsDataStoreCPT.php](../src/Payments/PaymentsDataStoreCPT.php), [line 287](../src/Payments/PaymentsDataStoreCPT.php#L287-L292) + +### `pronamic_payment_status_update_{$source}_{$old_status}_to_{$new_status}` + +*Payment status updated for plugin integration source from old to new status.* + +**Source** -Source: [src/Payments/PaymentsDataStoreCPT.php](../src/Payments/PaymentsDataStoreCPT.php), [line 281](../src/Payments/PaymentsDataStoreCPT.php#L281-L281) +Plugin | Source +------ | ------ +Charitable | `charitable` +Contact Form 7 | `contact-form-7` +Event Espresso | `eventespresso` +Event Espresso (legacy) | `event-espresso` +Formidable Forms | `formidable-forms` +Give | `give` +Gravity Forms | `gravityformsideal` +MemberPress | `memberpress` +Ninja Forms | `ninja-forms` +s2Member | `s2member` +WooCommerce | `woocommerce` +WP eCommerce | `wp-e-commerce` -### `pronamic_payment_status_update_{$payment->source}_{$old}_to_{$new}` +**Action status** + +Status | Value +------ | ----- +(empty) | `unknown` +Cancelled | `cancelled` +Expired | `expired` +Failure | `failure` +Open | `open` +Reserved | `reserved` +Success | `success` + +**Payment status** + +Status | Value +------ | ----- +Cancelled | `Cancelled` +Expired | `Expired` +Failure | `Failure` +Open | `Open` +Reserved | `Reserved` +Success | `Success` **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$payment` | | -`$can_redirect` | | -`$previous_status` | | -`$payment->status` | | +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. +`$can_redirect` | `bool` | Flag to indicate if redirect is allowed after the payment update. +`$previous_status` | `null\|string` | Previous payment status. +`$updated_status` | `string` | Updated payment status. + +Source: [src/Payments/PaymentsDataStoreCPT.php](../src/Payments/PaymentsDataStoreCPT.php), [line 901](../src/Payments/PaymentsDataStoreCPT.php#L901-L949) + +### `pronamic_payment_status_update_{$source}` + +*Payment status updated for plugin integration source.* -Source: [src/Payments/PaymentsDataStoreCPT.php](../src/Payments/PaymentsDataStoreCPT.php), [line 882](../src/Payments/PaymentsDataStoreCPT.php#L882-L882) +**Source** -### `pronamic_payment_status_update_{$payment->source}` +Plugin | Source +------ | ------ +Charitable | `charitable` +Contact Form 7 | `contact-form-7` +Event Espresso | `eventespresso` +Event Espresso (legacy) | `event-espresso` +Formidable Forms | `formidable-forms` +Give | `give` +Gravity Forms | `gravityformsideal` +MemberPress | `memberpress` +Ninja Forms | `ninja-forms` +s2Member | `s2member` +WooCommerce | `woocommerce` +WP eCommerce | `wp-e-commerce` + +**Action status** + +Status | Value +------ | ----- +(empty) | `unknown` +Cancelled | `cancelled` +Expired | `expired` +Failure | `failure` +Open | `open` +Reserved | `reserved` +Success | `success` + +**Payment status** + +Status | Value +------ | ----- +Cancelled | `Cancelled` +Expired | `Expired` +Failure | `Failure` +Open | `Open` +Reserved | `Reserved` +Success | `Success` **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$payment` | | -`$can_redirect` | | -`$previous_status` | | -`$payment->status` | | +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. +`$can_redirect` | `bool` | Flag to indicate if redirect is allowed after the payment update. +`$previous_status` | `null\|string` | Previous payment status. +`$updated_status` | `string` | Updated payment status. -Source: [src/Payments/PaymentsDataStoreCPT.php](../src/Payments/PaymentsDataStoreCPT.php), [line 883](../src/Payments/PaymentsDataStoreCPT.php#L883-L883) +Source: [src/Payments/PaymentsDataStoreCPT.php](../src/Payments/PaymentsDataStoreCPT.php), [line 951](../src/Payments/PaymentsDataStoreCPT.php#L951-L999) ### `pronamic_payment_status_update` +*Payment status updated.* + +**Payment status** + +Status | Value +------ | ----- +Cancelled | `Cancelled` +Expired | `Expired` +Failure | `Failure` +Open | `Open` +Reserved | `Reserved` +Success | `Success` + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$payment` | | -`$can_redirect` | | -`$previous_status` | | -`$payment->status` | | +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. +`$can_redirect` | `bool` | Flag to indicate if redirect is allowed after the payment update. +`$previous_status` | `null\|string` | Previous payment status. +`$updated_status` | `string` | Updated payment status. -Source: [src/Payments/PaymentsDataStoreCPT.php](../src/Payments/PaymentsDataStoreCPT.php), [line 884](../src/Payments/PaymentsDataStoreCPT.php#L884-L884) +Source: [src/Payments/PaymentsDataStoreCPT.php](../src/Payments/PaymentsDataStoreCPT.php), [line 1001](../src/Payments/PaymentsDataStoreCPT.php#L1001-L1020) ### `pronamic_pay_privacy_register_exporters` +*Register privacy exporters.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$this` | | +`$privacy_manager` | `\Pronamic\WordPress\Pay\PrivacyManager` | Privacy manager. -Source: [src/PrivacyManager.php](../src/PrivacyManager.php), [line 52](../src/PrivacyManager.php#L52-L52) +Source: [src/PrivacyManager.php](../src/PrivacyManager.php), [line 54](../src/PrivacyManager.php#L54-L59) ### `pronamic_pay_privacy_register_erasers` +*Register privacy erasers.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$this` | | +`$privacy_manager` | `\Pronamic\WordPress\Pay\PrivacyManager` | Privacy manager. -Source: [src/PrivacyManager.php](../src/PrivacyManager.php), [line 68](../src/PrivacyManager.php#L68-L68) +Source: [src/PrivacyManager.php](../src/PrivacyManager.php), [line 77](../src/PrivacyManager.php#L77-L82) ### `pronamic_pay_license_check` +*Perform license check.* -Source: [src/Admin/AdminSettings.php](../src/Admin/AdminSettings.php), [line 288](../src/Admin/AdminSettings.php#L288-L288) + +Source: [src/Admin/AdminSettings.php](../src/Admin/AdminSettings.php), [line 288](../src/Admin/AdminSettings.php#L288-L291) ### `pronamic_subscription_renewal_notice_{$source}` +*Send renewal notice for source.* + +**Source** + +Plugin | Source +------ | ------ +Charitable | `charitable` +Contact Form 7 | `contact-form-7` +Event Espresso | `eventespresso` +Event Espresso (legacy) | `event-espresso` +Formidable Forms | `formidable-forms` +Give | `give` +Gravity Forms | `gravityformsideal` +MemberPress | `memberpress` +Ninja Forms | `ninja-forms` +s2Member | `s2member` +WooCommerce | `woocommerce` +WP eCommerce | `wp-e-commerce` + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$subscription` | | +`$subscription` | `\Pronamic\WordPress\Pay\Subscriptions\Subscription` | Subscription. -Source: [src/Subscriptions/SubscriptionsModule.php](../src/Subscriptions/SubscriptionsModule.php), [line 1012](../src/Subscriptions/SubscriptionsModule.php#L1012-L1012) +Source: [src/Subscriptions/SubscriptionsModule.php](../src/Subscriptions/SubscriptionsModule.php), [line 1026](../src/Subscriptions/SubscriptionsModule.php#L1026-L1048) ### `pronamic_pay_new_subscription` +*New subscription created.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$subscription` | | +`$subscription` | `\Pronamic\WordPress\Pay\Subscriptions\Subscription` | Subscription. + +Source: [src/Subscriptions/SubscriptionsDataStoreCPT.php](../src/Subscriptions/SubscriptionsDataStoreCPT.php), [line 279](../src/Subscriptions/SubscriptionsDataStoreCPT.php#L279-L284) + +### `pronamic_subscription_status_update_{$source}_{$old_status}_to_{$new_status}` + +*Subscription status updated for plugin integration source from old to new status.* + +**Source** + +Plugin | Source +------ | ------ +Charitable | `charitable` +Contact Form 7 | `contact-form-7` +Event Espresso | `eventespresso` +Event Espresso (legacy) | `event-espresso` +Formidable Forms | `formidable-forms` +Give | `give` +Gravity Forms | `gravityformsideal` +MemberPress | `memberpress` +Ninja Forms | `ninja-forms` +s2Member | `s2member` +WooCommerce | `woocommerce` +WP eCommerce | `wp-e-commerce` + +**Action status** -Source: [src/Subscriptions/SubscriptionsDataStoreCPT.php](../src/Subscriptions/SubscriptionsDataStoreCPT.php), [line 279](../src/Subscriptions/SubscriptionsDataStoreCPT.php#L279-L279) +Status | Value +------ | ----- +(empty) | `unknown` +Active | `active` +Cancelled | `cancelled` +Completed | `completed` +Expired | `expired` +Failure | `failure` +On Hold | `on_hold` +Open | `open` -### `pronamic_subscription_status_update_{$subscription->source}_{$old}_to_{$new}` +**Subscription status** + +Status | Value +------ | ----- +Active | `Active` +Cancelled | `Cancelled` +Completed | `Completed` +Expired | `Expired` +Failure | `Failure` +On Hold | `On Hold` +Open | `Open` **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$subscription` | | -`$can_redirect` | | -`$previous_status` | | -`$subscription->status` | | +`$subscription` | `\Pronamic\WordPress\Pay\Subscriptions\Subscription` | Subscription. +`$can_redirect` | `bool` | Flag to indicate if redirect is allowed after the subscription update. +`$previous_status` | `null\|string` | Previous subscription status. +`$updated_status` | `string` | Updated subscription status. + +Source: [src/Subscriptions/SubscriptionsDataStoreCPT.php](../src/Subscriptions/SubscriptionsDataStoreCPT.php), [line 752](../src/Subscriptions/SubscriptionsDataStoreCPT.php#L752-L802) + +### `pronamic_subscription_status_update_{$source}` + +*Subscription status updated for plugin integration source.* + +**Source** -Source: [src/Subscriptions/SubscriptionsDataStoreCPT.php](../src/Subscriptions/SubscriptionsDataStoreCPT.php), [line 741](../src/Subscriptions/SubscriptionsDataStoreCPT.php#L741-L741) +Plugin | Source +------ | ------ +Charitable | `charitable` +Contact Form 7 | `contact-form-7` +Event Espresso | `eventespresso` +Event Espresso (legacy) | `event-espresso` +Formidable Forms | `formidable-forms` +Give | `give` +Gravity Forms | `gravityformsideal` +MemberPress | `memberpress` +Ninja Forms | `ninja-forms` +s2Member | `s2member` +WooCommerce | `woocommerce` +WP eCommerce | `wp-e-commerce` -### `pronamic_subscription_status_update_{$subscription->source}` +**Action status** + +Status | Value +------ | ----- +(empty) | `unknown` +Active | `active` +Cancelled | `cancelled` +Completed | `completed` +Expired | `expired` +Failure | `failure` +On Hold | `on_hold` +Open | `open` + +**Subscription status** + +Status | Value +------ | ----- +Active | `Active` +Cancelled | `Cancelled` +Completed | `Completed` +Expired | `Expired` +Failure | `Failure` +On Hold | `On Hold` +Open | `Open` **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$subscription` | | -`$can_redirect` | | -`$previous_status` | | -`$subscription->status` | | +`$subscription` | `\Pronamic\WordPress\Pay\Subscriptions\Subscription` | Subscription. +`$can_redirect` | `bool` | Flag to indicate if redirect is allowed after the subscription update. +`$previous_status` | `null\|string` | Previous subscription status. +`$updated_status` | `string` | Updated subscription status. -Source: [src/Subscriptions/SubscriptionsDataStoreCPT.php](../src/Subscriptions/SubscriptionsDataStoreCPT.php), [line 742](../src/Subscriptions/SubscriptionsDataStoreCPT.php#L742-L742) +Source: [src/Subscriptions/SubscriptionsDataStoreCPT.php](../src/Subscriptions/SubscriptionsDataStoreCPT.php), [line 804](../src/Subscriptions/SubscriptionsDataStoreCPT.php#L804-L854) ### `pronamic_subscription_status_update` +*Subscription status updated.* + +**Subscription status** + +Status | Value +------ | ----- +Active | `Active` +Cancelled | `Cancelled` +Completed | `Completed` +Expired | `Expired` +Failure | `Failure` +On Hold | `On Hold` +Open | `Open` + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$subscription` | | -`$can_redirect` | | -`$previous_status` | | -`$subscription->status` | | +`$subscription` | `\Pronamic\WordPress\Pay\Subscriptions\Subscription` | Subscription. +`$can_redirect` | `bool` | Flag to indicate if redirect is allowed after the subscription update. +`$previous_status` | `null\|string` | Previous subscription status. +`$updated_status` | `string` | Updated subscription status. -Source: [src/Subscriptions/SubscriptionsDataStoreCPT.php](../src/Subscriptions/SubscriptionsDataStoreCPT.php), [line 743](../src/Subscriptions/SubscriptionsDataStoreCPT.php#L743-L743) +Source: [src/Subscriptions/SubscriptionsDataStoreCPT.php](../src/Subscriptions/SubscriptionsDataStoreCPT.php), [line 856](../src/Subscriptions/SubscriptionsDataStoreCPT.php#L856-L876) ## Filters -### `pronamic_payment_source_text_{$source}` +### `pronamic_payment_redirect_url` + +*Filters the payment return redirect URL.* **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$text` | | -`$this` | | +`$url` | | +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 332](../src/Payments/Payment.php#L332-L332) +Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 558](../src/Payments/Payment.php#L558-L564) -### `pronamic_payment_source_text` +### `pronamic_payment_source_text_{$source}` + +*Filters the payment source text by plugin integration source.* **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$text` | | -`$this` | | +`$text` | `string` | Source text. +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 333](../src/Payments/Payment.php#L333-L333) +Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 621](../src/Payments/Payment.php#L621-L627) -### `pronamic_payment_redirect_url` +### `pronamic_payment_source_text` + +*Filters the payment source text.* **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$url` | | -`$this` | | +`$text` | `string` | Source text. +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 579](../src/Payments/Payment.php#L579-L579) +Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 630](../src/Payments/Payment.php#L630-L636) ### `pronamic_payment_source_description` +*Filters the payment source description.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$description` | | -`$this` | | +`$description` | `string` | Source description. +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 624](../src/Payments/Payment.php#L624-L624) +Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 653](../src/Payments/Payment.php#L653-L659) -### `pronamic_payment_source_description_{$this->source}` +### `pronamic_payment_source_description_{$source}` + +*Filters the payment source description by plugin integration source.* **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$description` | | -`$this` | | +`$description` | `string` | Source description. +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 625](../src/Payments/Payment.php#L625-L625) +Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 662](../src/Payments/Payment.php#L662-L668) ### `pronamic_payment_source_url` +*Filters the payment source URL.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$url` | | -`$this` | | +`$url` | `null\|string` | Source URL. +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 638](../src/Payments/Payment.php#L638-L638) +Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 686](../src/Payments/Payment.php#L686-L692) -### `pronamic_payment_source_url_{$this->source}` +### `pronamic_payment_source_url_{$source}` + +*Filters the payment source URL by plugin integration source.* **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$url` | | -`$this` | | +`$url` | `null\|string` | Source URL. +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 639](../src/Payments/Payment.php#L639-L639) +Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 695](../src/Payments/Payment.php#L695-L701) ### `pronamic_payment_provider_url` +*Filters the payment provider URL.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$url` | | -`$this` | | +`$url` | `null\|string` | Provider URL. +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 652](../src/Payments/Payment.php#L652-L652) +Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 717](../src/Payments/Payment.php#L717-L723) ### `pronamic_payment_provider_url_{$gateway_id}` +*Filters the payment provider URL by gateway identifier.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$url` | | -`$this` | | +`$url` | `null\|string` | Provider URL. +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 670](../src/Payments/Payment.php#L670-L670) +Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 738](../src/Payments/Payment.php#L738-L744) ### `wp_doing_cron` @@ -255,62 +503,72 @@ Source: [src/Payments/Payment.php](../src/Payments/Payment.php), [line 670](../s Argument | Type | Description -------- | ---- | ----------- -`defined('DOING_CRON') && DOING_CRON` | | +`$wp_doing_cron` | | -Source: [src/Core/Util.php](../src/Core/Util.php), [line 141](../src/Core/Util.php#L141-L141) +Source: [src/Core/Util.php](../src/Core/Util.php), [line 143](../src/Core/Util.php#L143-L143) ### `pronamic_pay_google_analytics_ecommerce_item_name` +*Filters the item name for Google Analytics e-commerce tracking.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$line->get_name()` | | -`$line` | | +`$name` | `string` | Item name. +`$line` | `\Pronamic\WordPress\Pay\Payments\PaymentLine` | Payment line. -Source: [src/GoogleAnalyticsEcommerce.php](../src/GoogleAnalyticsEcommerce.php), [line 211](../src/GoogleAnalyticsEcommerce.php#L211-L211) +Source: [src/GoogleAnalyticsEcommerce.php](../src/GoogleAnalyticsEcommerce.php), [line 215](../src/GoogleAnalyticsEcommerce.php#L215-L222) ### `pronamic_pay_google_analytics_ecommerce_item_product_category` +*Filters the product category for Google Analytics e-commerce tracking.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$line->get_product_category()` | | -`$line` | | +`$product_category` | `string` | Product category. +`$line` | `\Pronamic\WordPress\Pay\Payments\PaymentLine` | Payment line. -Source: [src/GoogleAnalyticsEcommerce.php](../src/GoogleAnalyticsEcommerce.php), [line 247](../src/GoogleAnalyticsEcommerce.php#L247-L247) +Source: [src/GoogleAnalyticsEcommerce.php](../src/GoogleAnalyticsEcommerce.php), [line 262](../src/GoogleAnalyticsEcommerce.php#L262-L269) ### `pronamic_pay_return_should_redirect` +*Filter whether or not to allow redirects on payment return.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`true` | | -`$payment` | | +`$should_redirect` | `bool` | Flag to indicate if redirect is allowed on handling payment return. +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [src/Plugin.php](../src/Plugin.php), [line 434](../src/Plugin.php#L434-L434) +Source: [src/Plugin.php](../src/Plugin.php), [line 436](../src/Plugin.php#L436-L442) ### `pronamic_pay_gateways` +*Filters the gateway integrations.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`array()` | | +`$gateways` | `\Pronamic\WordPress\Pay\AbstractGatewayIntegration[]` | Gateway integrations. -Source: [src/Plugin.php](../src/Plugin.php), [line 591](../src/Plugin.php#L591-L591) +Source: [src/Plugin.php](../src/Plugin.php), [line 599](../src/Plugin.php#L599-L604) ### `pronamic_pay_plugin_integrations` +*Filters the plugin integrations.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`array()` | | +`$plugin_integrations` | `\Pronamic\WordPress\Pay\AbstractPluginIntegration[]` | Plugin integrations. -Source: [src/Plugin.php](../src/Plugin.php), [line 600](../src/Plugin.php#L600-L600) +Source: [src/Plugin.php](../src/Plugin.php), [line 614](../src/Plugin.php#L614-L619) ### `pronamic_payment_gateway_configuration_id` @@ -320,21 +578,23 @@ Source: [src/Plugin.php](../src/Plugin.php), [line 600](../src/Plugin.php#L600-L Argument | Type | Description -------- | ---- | ----------- -`$payment->get_config_id()` | | -`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | The payment resource data. +`$config_id` | `null\|int` | Gateway configuration ID. +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [src/Plugin.php](../src/Plugin.php), [line 963](../src/Plugin.php#L963-L969) +Source: [src/Plugin.php](../src/Plugin.php), [line 1001](../src/Plugin.php#L1001-L1007) ### `pronamic_payment_redirect_url_{$source}` +*Filters the payment redirect URL by plugin integration source.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$url` | | -`$payment` | | +`$url` | `null\|string` | Redirect URL. +`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment. -Source: [src/Plugin.php](../src/Plugin.php), [line 1163](../src/Plugin.php#L1163-L1163) +Source: [src/Plugin.php](../src/Plugin.php), [line 1203](../src/Plugin.php#L1203-L1209) ### `pronamic_gateway_configuration_display_value` @@ -354,7 +614,7 @@ Source: [src/Admin/AdminGatewayPostType.php](../src/Admin/AdminGatewayPostType.p *Filters the gateway configuration display value.* The dynamic portion of the hook name, `$id`, refers to the gateway ID. -For example, the gateway ID for Payvision is `payvision`, se the filter +For example, the gateway ID for Payvision is `payvision`, so the filter for that gateway would be: `pronamic_gateway_configuration_display_value_payvision` @@ -369,69 +629,81 @@ Source: [src/Admin/AdminGatewayPostType.php](../src/Admin/AdminGatewayPostType.p ### `pronamic_subscription_source_text_{$source}` +*Filters the subscription source text by plugin integration source.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$default_text` | | -`$this` | | +`$text` | `string` | Source text. +`$subscription` | `\Pronamic\WordPress\Pay\Subscriptions\Subscription` | Subscription. -Source: [src/Subscriptions/Subscription.php](../src/Subscriptions/Subscription.php), [line 367](../src/Subscriptions/Subscription.php#L367-L367) +Source: [src/Subscriptions/Subscription.php](../src/Subscriptions/Subscription.php), [line 370](../src/Subscriptions/Subscription.php#L370-L376) ### `pronamic_subscription_source_text` +*Filters the subscription source text.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$text` | | -`$this` | | +`$text` | `string` | Source text. +`$subscription` | `\Pronamic\WordPress\Pay\Subscriptions\Subscription` | Subscription. -Source: [src/Subscriptions/Subscription.php](../src/Subscriptions/Subscription.php), [line 368](../src/Subscriptions/Subscription.php#L368-L368) +Source: [src/Subscriptions/Subscription.php](../src/Subscriptions/Subscription.php), [line 379](../src/Subscriptions/Subscription.php#L379-L385) ### `pronamic_subscription_source_description_{$source}` +*Filters the subscription source description by plugin integration source.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$default_text` | | -`$this` | | +`$description` | `string` | Source description. +`$subscription` | `\Pronamic\WordPress\Pay\Subscriptions\Subscription` | Subscription. -Source: [src/Subscriptions/Subscription.php](../src/Subscriptions/Subscription.php), [line 383](../src/Subscriptions/Subscription.php#L383-L383) +Source: [src/Subscriptions/Subscription.php](../src/Subscriptions/Subscription.php), [line 403](../src/Subscriptions/Subscription.php#L403-L409) ### `pronamic_subscription_source_description` +*Filters the subscription source description.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$text` | | -`$this` | | +`$description` | `string` | Source description. +`$subscription` | `\Pronamic\WordPress\Pay\Subscriptions\Subscription` | Subscription. -Source: [src/Subscriptions/Subscription.php](../src/Subscriptions/Subscription.php), [line 384](../src/Subscriptions/Subscription.php#L384-L384) +Source: [src/Subscriptions/Subscription.php](../src/Subscriptions/Subscription.php), [line 412](../src/Subscriptions/Subscription.php#L412-L418) ### `pronamic_subscription_source_url` +*Filters the subscription source URL.* + **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$url` | | -`$this` | | +`$url` | `null\|string` | Source URL. +`$subscription` | `\Pronamic\WordPress\Pay\Subscriptions\Subscription` | Subscription. + +Source: [src/Subscriptions/Subscription.php](../src/Subscriptions/Subscription.php), [line 435](../src/Subscriptions/Subscription.php#L435-L441) -Source: [src/Subscriptions/Subscription.php](../src/Subscriptions/Subscription.php), [line 397](../src/Subscriptions/Subscription.php#L397-L397) +### `pronamic_subscription_source_url_{$source}` -### `pronamic_subscription_source_url_{$this->source}` +*Filters the subscription source URL by plugin integration source.* **Arguments** Argument | Type | Description -------- | ---- | ----------- -`$url` | | -`$this` | | +`$url` | `null\|string` | Source URL. +`$subscription` | `\Pronamic\WordPress\Pay\Subscriptions\Subscription` | Subscription. -Source: [src/Subscriptions/Subscription.php](../src/Subscriptions/Subscription.php), [line 398](../src/Subscriptions/Subscription.php#L398-L398) +Source: [src/Subscriptions/Subscription.php](../src/Subscriptions/Subscription.php), [line 444](../src/Subscriptions/Subscription.php#L444-L450) ### `pronamic_pay_subscription_next_payment_delivery_date` diff --git a/includes/functions.php b/includes/functions.php index 41dfa885..889302d1 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -142,6 +142,40 @@ function get_pronamic_payments_by_user_id( $user_id = null ) { return get_pronamic_payments_by_meta( null, null, array( 'author' => $user_id ) ); } +/** + * Get payments by the specified source and source ID. + * + * @param string $source The source to query for. + * @param string|null $source_id The source ID to query for. + * @return Payment[]|null + */ +function get_pronamic_payments_by_source( $source, $source_id = null ) { + // Meta query. + $meta_query = array( + array( + 'key' => '_pronamic_payment_source', + 'value' => $source, + ), + ); + + // Add source ID meta query condition. + if ( ! empty( $source_id ) ) { + $meta_query[] = array( + 'key' => '_pronamic_payment_source_id', + 'value' => $source_id, + ); + } + + // Return. + $args = array( + 'meta_query' => $meta_query, + 'order' => 'DESC', + 'orderby' => 'ID', + ); + + return get_pronamic_payments_by_meta( null, null, $args ); +} + /** * Get subscription by the specified post ID. * @@ -236,7 +270,7 @@ function get_pronamic_subscriptions_by_user_id( $user_id = null ) { } /** - * Get subscription by the specified source and value. + * Get subscriptions by the specified source and source ID. * * @param string $source The source to query for. * @param string|null $source_id The source ID to query for. diff --git a/package.json b/package.json index aa99a7bc..61f59d97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@wp-pay/core", - "version": "2.7.2", + "version": "3.0.0", "description": "Core components for the WordPress payment processing library.", "repository": { "type": "git", diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 1b4dbb4a..5a8476bc 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,35 +1,30 @@ - - - - . - - - - - includes/xmlseclibs/* - node_modules/* tests/bootstrap.php tests/wp-config.php - vendor/* - wordpress/* - ^wp-content/* - - - - + - - - + + + + + + + + + + + + + + @@ -42,10 +37,6 @@ /tests/UtilTest.php - - /src/Payments/Item.php - - /tests/phpstan-bootstrap.php @@ -54,8 +45,4 @@ /src/Admin/AdminGatewayPostType.php /src/Core/Gateway.php - - - /views/tab-extensions.php - diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 82700ecd..d090a6c3 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -11,15 +11,10 @@ parameters: - tests/phpstan/bootstrap.php paths: - src/ + - views/ ignoreErrors: # Uses func_get_args() - '#^Function apply_filters(_ref_array)? invoked with [34567] parameters, 2 required\.$#' - - - message: '#Function shortcode_ui_register_for_shortcode not found\.#' - path: src/Forms/FormShortcode.php - message: '#Function pll_home_url not found\.#' path: src/Payments/Payment.php - - - message: '#Call to an undefined method SoapClient::.+\(\)\.#' - path: src/VatNumbers/VatNumberViesValidator.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f2930844..8ecf3ad5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -20,10 +20,6 @@ - - - - diff --git a/scss/admin/_tabs.scss b/scss/admin/_tabs.scss index 1c89cb11..f0a652a7 100644 --- a/scss/admin/_tabs.scss +++ b/scss/admin/_tabs.scss @@ -36,15 +36,15 @@ } $wp_admin_colors: ( - fresh: #2271b1, - light: #888, - modern: #3858e9, - blue: #096484, - coffee: #c7a589, - ectoplasm: #a3b745, - midnight: #e14d43, - ocean: #9ebaa0, - sunrise: #dd823b + "fresh": #2271b1, + "light": #888, + "modern": #3858e9, + "blue": #096484, + "coffee": #c7a589, + "ectoplasm": #a3b745, + "midnight": #e14d43, + "ocean": #9ebaa0, + "sunrise": #dd823b ); @each $name, $color in $wp_admin_colors { diff --git a/scss/forms.scss b/scss/forms.scss index c3b3132f..bacc59df 100644 --- a/scss/forms.scss +++ b/scss/forms.scss @@ -19,7 +19,7 @@ } // Input - .pronamic-pay-amount-input { + .pronamic-pay-amount-input[type="text"] { width: auto; } } diff --git a/src/Admin/AdminDashboard.php b/src/Admin/AdminDashboard.php index 10a78c0d..bc76228b 100644 --- a/src/Admin/AdminDashboard.php +++ b/src/Admin/AdminDashboard.php @@ -83,28 +83,6 @@ public function setup() { * @return void */ public function status_widget() { - $counts = wp_count_posts( 'pronamic_payment' ); - - $states = array( - /* translators: %s: posts count value */ - 'payment_completed' => __( '%s completed', 'pronamic_ideal' ), - /* translators: %s: posts count value */ - 'payment_pending' => __( '%s pending', 'pronamic_ideal' ), - /* translators: %s: posts count value */ - 'payment_cancelled' => __( '%s cancelled', 'pronamic_ideal' ), - /* translators: %s: posts count value */ - 'payment_failed' => __( '%s failed', 'pronamic_ideal' ), - /* translators: %s: posts count value */ - 'payment_expired' => __( '%s expired', 'pronamic_ideal' ), - ); - - $url = add_query_arg( - array( - 'post_type' => 'pronamic_payment', - ), - admin_url( 'edit.php' ) - ); - include __DIR__ . '/../../views/widget-payments-status-list.php'; } } diff --git a/src/Admin/AdminGatewayPostType.php b/src/Admin/AdminGatewayPostType.php index 07ea0ac7..49d37c9b 100644 --- a/src/Admin/AdminGatewayPostType.php +++ b/src/Admin/AdminGatewayPostType.php @@ -148,7 +148,7 @@ public function custom_columns( $column, $post_id ) { * Filters the gateway configuration display value. * * The dynamic portion of the hook name, `$id`, refers to the gateway ID. - * For example, the gateway ID for Payvision is `payvision`, se the filter + * For example, the gateway ID for Payvision is `payvision`, so the filter * for that gateway would be: * `pronamic_gateway_configuration_display_value_payvision` * diff --git a/src/Admin/AdminHealth.php b/src/Admin/AdminHealth.php index a5d8d15a..6fea7a4b 100644 --- a/src/Admin/AdminHealth.php +++ b/src/Admin/AdminHealth.php @@ -402,8 +402,6 @@ public function test_extensions_support() { continue; } - $plugin_file = null; - foreach ( $extensions as $extension ) { // Requires at least. $requires_at_least = '0.0.0'; diff --git a/src/Admin/AdminModule.php b/src/Admin/AdminModule.php index 16d1c58e..1498d865 100644 --- a/src/Admin/AdminModule.php +++ b/src/Admin/AdminModule.php @@ -11,6 +11,7 @@ namespace Pronamic\WordPress\Pay\Admin; use Pronamic\WordPress\Money\Parser as MoneyParser; +use Pronamic\WordPress\Money\Money; use Pronamic\WordPress\Money\TaxedMoney; use Pronamic\WordPress\Pay\Address; use Pronamic\WordPress\Pay\AddressHelper; @@ -741,7 +742,7 @@ public function maybe_test_payment() { $line = $payment->lines->new_line(); - $price = new TaxedMoney( $amount, 'EUR' ); + $price = new Money( $amount, 'EUR' ); $line->set_name( __( 'Test', 'pronamic_ideal' ) ); $line->set_unit_price( $price ); diff --git a/src/Admin/AdminPaymentPostType.php b/src/Admin/AdminPaymentPostType.php index 3462c2f9..15056f4c 100644 --- a/src/Admin/AdminPaymentPostType.php +++ b/src/Admin/AdminPaymentPostType.php @@ -524,7 +524,17 @@ public function custom_columns( $column, $post_id ) { $config_id = get_post_meta( $post_id, '_pronamic_payment_config_id', true ); $config_id = intval( $config_id ); - if ( ! empty( $config_id ) ) { + $gateway_id = get_post_meta( $config_id, '_pronamic_gateway_id', true ); + + $integration = $this->plugin->gateway_integrations->get_integration( $gateway_id ); + + if ( null !== $integration ) { + printf( + '%2$s', + \esc_url( (string) \get_edit_post_link( $config_id ) ), + \esc_html( \get_the_title( $config_id ) ) + ); + } elseif ( ! empty( $config_id ) ) { echo esc_html( get_the_title( $config_id ) ); } else { echo '—'; diff --git a/src/Admin/AdminReports.php b/src/Admin/AdminReports.php index d67d46b8..cf8576c0 100644 --- a/src/Admin/AdminReports.php +++ b/src/Admin/AdminReports.php @@ -55,7 +55,9 @@ public function __construct( Plugin $plugin, AdminModule $admin ) { * @return void */ public function page_reports() { - $this->admin->render_page( 'reports' ); + $admin_reports = $this; + + include __DIR__ . '/../../views/page-reports.php'; } /** diff --git a/src/Admin/AdminSettings.php b/src/Admin/AdminSettings.php index eb3cf058..06fe1f95 100644 --- a/src/Admin/AdminSettings.php +++ b/src/Admin/AdminSettings.php @@ -285,6 +285,9 @@ public function input_checkbox( $args ) { * @return void */ public function input_license_key( $args ) { + /** + * Perform license check. + */ do_action( 'pronamic_pay_license_check' ); $this->input_element( $args ); diff --git a/src/Admin/AdminSubscriptionPostType.php b/src/Admin/AdminSubscriptionPostType.php index 4f4f3ebc..0b1a0f50 100644 --- a/src/Admin/AdminSubscriptionPostType.php +++ b/src/Admin/AdminSubscriptionPostType.php @@ -157,6 +157,8 @@ public function maybe_process_subscription_action() { ); \wp_safe_redirect( $url ); + + exit; } } @@ -184,6 +186,8 @@ public function maybe_process_subscription_action() { ); \wp_safe_redirect( $url ); + + exit; } } } diff --git a/src/Admin/AdminTour.php b/src/Admin/AdminTour.php index c7b333be..7944ad95 100644 --- a/src/Admin/AdminTour.php +++ b/src/Admin/AdminTour.php @@ -117,6 +117,8 @@ private function get_content( $file ) { if ( is_readable( $path ) ) { ob_start(); + $admin_tour = $this; + include $path; $content = ob_get_clean(); diff --git a/src/Blocks/BlocksModule.php b/src/Blocks/BlocksModule.php index 0bd01dbb..1a8d46a2 100644 --- a/src/Blocks/BlocksModule.php +++ b/src/Blocks/BlocksModule.php @@ -30,13 +30,19 @@ class BlocksModule { * @return void */ public function setup() { + global $wp_version; + // Initialize. add_action( 'init', array( $this, 'register_scripts' ) ); add_action( 'init', array( $this, 'register_block_types' ) ); add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_styles' ) ); - add_filter( 'block_categories', array( $this, 'block_categories' ), 10, 2 ); + add_filter( 'block_categories_all', array( $this, 'block_categories' ), 10, 2 ); + + if ( \version_compare( $wp_version, '5.8', '<' ) ) { + add_filter( 'block_categories', array( $this, 'block_categories' ), 10, 2 ); + } // Source text and description. add_filter( 'pronamic_payment_source_url_' . FormsSource::BLOCK_PAYMENT_FORM, array( $this, 'source_url' ), 10, 2 ); diff --git a/src/Core/Gateway.php b/src/Core/Gateway.php index 24f3bab4..7cbfbd9d 100644 --- a/src/Core/Gateway.php +++ b/src/Core/Gateway.php @@ -567,6 +567,7 @@ public function get_gender_field() { PaymentMethods::FOCUM, PaymentMethods::IN3, PaymentMethods::KLARNA_PAY_LATER, + PaymentMethods::SPRAYPAY, ); $payment_method = $this->get_payment_method(); @@ -605,6 +606,7 @@ public function get_birth_date_field() { PaymentMethods::FOCUM, PaymentMethods::IN3, PaymentMethods::KLARNA_PAY_LATER, + PaymentMethods::SPRAYPAY, ); $payment_method = $this->get_payment_method(); diff --git a/src/Core/PaymentMethods.php b/src/Core/PaymentMethods.php index 4b6cdaef..f1decbd9 100644 --- a/src/Core/PaymentMethods.php +++ b/src/Core/PaymentMethods.php @@ -11,6 +11,7 @@ namespace Pronamic\WordPress\Pay\Core; use Pronamic\WordPress\Pay\Plugin; +use WP_Post; use WP_Query; /** @@ -274,6 +275,14 @@ class PaymentMethods { */ const SOFORT = 'sofort'; + /** + * SprayPay + * + * @var string + * @since 2.8.0 + */ + const SPRAYPAY = 'spraypay'; + /** * Swish * @@ -341,6 +350,7 @@ public static function get_payment_methods() { self::PRZELEWY24 => __( 'Przelewy24', 'pronamic_ideal' ), self::SANTANDER => __( 'Santander', 'pronamic_ideal' ), self::SOFORT => __( 'SOFORT Banking', 'pronamic_ideal' ), + self::SPRAYPAY => __( 'SprayPay', 'pronamic_ideal' ), self::SWISH => __( 'Swish', 'pronamic_ideal' ), self::VIPPS => __( 'Vipps', 'pronamic_ideal' ), ); @@ -513,6 +523,10 @@ public static function update_active_payment_methods() { ); foreach ( $query->posts as $config_id ) { + if ( $config_id instanceof WP_Post ) { + $config_id = $config_id->ID; + } + $gateway = Plugin::get_gateway( $config_id ); if ( ! $gateway ) { diff --git a/src/Core/Util.php b/src/Core/Util.php index f79b6f91..2ad062fb 100644 --- a/src/Core/Util.php +++ b/src/Core/Util.php @@ -132,14 +132,15 @@ public static function doing_cron() { return \wp_doing_cron(); } + $wp_doing_cron = defined( 'DOING_CRON' ) && DOING_CRON; + /** * Filters whether the current request is a WordPress cron request. * - * @since 4.8.0 - * * @param bool $wp_doing_cron Whether the current request is a WordPress cron request. + * @since 4.8.0 */ - return apply_filters( 'wp_doing_cron', defined( 'DOING_CRON' ) && DOING_CRON ); + return apply_filters( 'wp_doing_cron', $wp_doing_cron ); } /** @@ -181,16 +182,16 @@ public static function no_cache() { * * @param float $amount The amount to convert to cents. * - * @deprecated 2.0.9 Use \Pronamic\WordPress\Money\Money::get_cents() instead. + * @deprecated 2.0.9 Use \Pronamic\WordPress\Money\Money::get_minor_units()->to_int() instead. * - * @return float + * @return int */ public static function amount_to_cents( $amount ) { - _deprecated_function( __FUNCTION__, '2.0.9', 'Pronamic\WordPress\Money\Money::get_cents()' ); + _deprecated_function( __FUNCTION__, '2.0.9', 'Pronamic\WordPress\Money\Money::get_minor_units()->to_int()' ); $money = new Money( $amount ); - return $money->get_cents(); + return $money->get_minor_units()->to_int(); } /** @@ -365,7 +366,7 @@ public static function get_remote_address() { * addresses. The first one is the original client. It can't be * trusted for authenticity, but we don't need to for this purpose. */ - $addresses = explode( ',', (string) filter_var( wp_unslash( $_SERVER[ $header ] ) ) ); + $addresses = explode( ',', \sanitize_text_field( wp_unslash( $_SERVER[ $header ] ) ) ); $addresses = array_slice( $addresses, 0, 1 ); diff --git a/src/CustomerHelper.php b/src/CustomerHelper.php index 644c3c3d..494ce8fa 100644 --- a/src/CustomerHelper.php +++ b/src/CustomerHelper.php @@ -138,7 +138,7 @@ public static function complement_customer( Customer $customer ) { * @link https://github.com/WordPress/WordPress/blob/4.9.4/wp-includes/comment.php#L1962-L1965 */ if ( null === $customer->get_user_agent() && isset( $_SERVER['HTTP_USER_AGENT'] ) ) { - $user_agent = filter_var( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); + $user_agent = \sanitize_text_field( \wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); if ( false !== $user_agent ) { $customer->set_user_agent( $user_agent ); diff --git a/src/Forms/FormPostType.php b/src/Forms/FormPostType.php index 23dbd6e2..342586d9 100644 --- a/src/Forms/FormPostType.php +++ b/src/Forms/FormPostType.php @@ -268,6 +268,10 @@ public function custom_columns( $column, $post_id ) { ) ); + if ( empty( $value ) ) { + $value = 0; + } + $money = new Money( $value, 'EUR' ); echo esc_html( $money->format_i18n() ); @@ -370,7 +374,7 @@ public function save_post( $post_id ) { continue; } - $data['_pronamic_payment_form_amount_choices'][ $i ] = $amount->get_cents(); + $data['_pronamic_payment_form_amount_choices'][ $i ] = $amount->get_minor_units()->to_int(); } // Remove empty choices. diff --git a/src/Forms/FormProcessor.php b/src/Forms/FormProcessor.php index e1893696..90c0797e 100644 --- a/src/Forms/FormProcessor.php +++ b/src/Forms/FormProcessor.php @@ -12,6 +12,7 @@ use Exception; use Pronamic\WordPress\Money\Parser as MoneyParser; +use Pronamic\WordPress\Money\Money; use Pronamic\WordPress\Money\TaxedMoney; use Pronamic\WordPress\Pay\Core\PaymentMethods; use Pronamic\WordPress\Pay\Customer; @@ -177,7 +178,7 @@ public function init() { } $payment->set_total_amount( - new TaxedMoney( + new Money( $amount, 'EUR' ) diff --git a/src/Forms/FormShortcode.php b/src/Forms/FormShortcode.php index bcdb029e..028c0770 100644 --- a/src/Forms/FormShortcode.php +++ b/src/Forms/FormShortcode.php @@ -34,8 +34,6 @@ public function __construct( $forms_module ) { $this->forms_module = $forms_module; add_shortcode( 'pronamic_payment_form', array( $this, 'shortcode_form' ) ); - - add_action( 'init', array( $this, 'shortcode_ui_register' ) ); } /** @@ -59,46 +57,10 @@ public function shortcode_form( $atts ) { 'pronamic_payment_form' ); - return $this->forms_module->get_form_output_by_id( $atts['id'] ); - } - - /** - * Shortcode user interface register. - * - * @return void - */ - public function shortcode_ui_register() { - if ( ! function_exists( 'shortcode_ui_register_for_shortcode' ) ) { - return; + if ( empty( $atts['id'] ) ) { + return ''; } - shortcode_ui_register_for_shortcode( - 'pronamic_payment_form', - array( - // Display label. String. Required. - 'label' => __( 'Payment Form', 'pronamic_ideal' ), - - // Icon/attachment for shortcode. Optional. src or dashicons-$icon. Defaults to carrot. - 'listItemImage' => 'dashicons-money', - - // Available shortcode attributes and default values. Required. Array. - // Attribute model expects 'attr', 'type' and 'label'. - // Supported field types: text, checkbox, textarea, radio, select, email, url, number, and date. - 'attrs' => array( - - array( - 'label' => __( 'Select Payment Form', 'pronamic_ideal' ), - 'attr' => 'id', - 'type' => 'post_select', - 'query' => array( - 'post_type' => 'pronamic_pay_form', - ), - 'multiple' => false, - ), - - ), - - ) - ); + return $this->forms_module->get_form_output_by_id( $atts['id'] ); } } diff --git a/src/GoogleAnalyticsEcommerce.php b/src/GoogleAnalyticsEcommerce.php index 48787951..11519d5e 100644 --- a/src/GoogleAnalyticsEcommerce.php +++ b/src/GoogleAnalyticsEcommerce.php @@ -10,8 +10,10 @@ namespace Pronamic\WordPress\Pay; +use Pronamic\WordPress\Money\TaxedMoney; use Pronamic\WordPress\Pay\Core\Gateway; use Pronamic\WordPress\Pay\Core\Server; +use Pronamic\WordPress\Pay\Payments\PaymentLine; use Pronamic\WordPress\Pay\Payments\PaymentStatus; use Pronamic\WordPress\Pay\Payments\Payment; @@ -133,25 +135,24 @@ public function send_transaction( $payment ) { 'ni' => 1, ); + $total_amount = $payment->get_total_amount(); + // Transaction Hit. $transaction = wp_parse_args( array( 't' => 'transaction', - 'tr' => sprintf( '%F', $payment->get_total_amount()->get_value() ), + 'tr' => $total_amount->number_format( null, '.', '' ), ), $defaults ); - // Currency. - if ( null !== $payment->get_total_amount()->get_currency()->get_alphabetic_code() ) { - /* - * Currency Code - * Optional. - * When present indicates the local currency for all transaction currency values. Value should be a valid ISO 4217 currency code. - * @link https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cu - */ - $transaction['cu'] = $payment->get_total_amount()->get_currency()->get_alphabetic_code(); - } + /* + * Currency Code + * Optional. + * When present indicates the local currency for all transaction currency values. Value should be a valid ISO 4217 currency code. + * @link https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cu + */ + $transaction['cu'] = $total_amount->get_currency()->get_alphabetic_code(); // Shipping. $shipping_amount = $payment->get_shipping_amount(); @@ -163,18 +164,18 @@ public function send_transaction( $payment ) { * Specifies the total shipping cost of the transaction. * @link https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ts */ - $transaction['ts'] = sprintf( '%F', $shipping_amount->get_value() ); + $transaction['ts'] = $shipping_amount->number_format( null, '.', '' ); } // Tax. - if ( $payment->get_total_amount()->has_tax() ) { + if ( $total_amount instanceof TaxedMoney ) { /* * Transaction Tax * Optional. * Specifies the total tax of the transaction. * @link https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#tt */ - $transaction['tt'] = sprintf( '%F', $payment->get_total_amount()->get_tax_value() ); + $transaction['tt'] = sprintf( '%F', $total_amount->get_tax_value() ); } wp_remote_post( @@ -206,9 +207,21 @@ public function send_transaction( $payment ) { /* * Item Name - Required for item hit type. - Specifies the item name. + * * @link https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#in */ - $item['in'] = \apply_filters( 'pronamic_pay_google_analytics_ecommerce_item_name', $line->get_name(), $line ); + $name = $line->get_name(); + + /** + * Filters the item name for Google Analytics e-commerce tracking. + * + * @param string $name Item name. + * @param PaymentLine $line Payment line. + * @link https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#in + */ + $name = \apply_filters( 'pronamic_pay_google_analytics_ecommerce_item_name', $name, $line ); + + $item['in'] = $name; /* * Item Price - Optional. - Specifies the price for a single item / unit. @@ -217,7 +230,7 @@ public function send_transaction( $payment ) { $unit_price = $line->get_unit_price(); if ( null !== $unit_price ) { - $item['ip'] = sprintf( '%F', $unit_price->get_value() ); + $item['ip'] = $unit_price->number_format( null, '.', '' ); } /* @@ -244,7 +257,16 @@ public function send_transaction( $payment ) { * Item Category - Optional. - Specifies the category that the item belongs to. * @link https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#iv */ - $product_category = \apply_filters( 'pronamic_pay_google_analytics_ecommerce_item_product_category', $line->get_product_category(), $line ); + $product_category = $line->get_product_category(); + + /** + * Filters the product category for Google Analytics e-commerce tracking. + * + * @param string $product_category Product category. + * @param PaymentLine $line Payment line. + * @link https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#iv + */ + $product_category = \apply_filters( 'pronamic_pay_google_analytics_ecommerce_item_product_category', $product_category, $line ); if ( null !== $product_category ) { $item['iv'] = $product_category; diff --git a/src/MoneyJsonTransformer.php b/src/MoneyJsonTransformer.php index b6d23173..2abcde64 100644 --- a/src/MoneyJsonTransformer.php +++ b/src/MoneyJsonTransformer.php @@ -10,8 +10,8 @@ namespace Pronamic\WordPress\Pay; -use InvalidArgumentException; use Pronamic\WordPress\Money\Money; +use Pronamic\WordPress\Money\TaxedMoney; /** * Money JSON transformer @@ -21,53 +21,54 @@ * @since 2.1.0 */ class MoneyJsonTransformer { - /** - * Convert money object to JSON. - * - * @param Money|null $money Money. - * - * @return null|object - */ - public static function to_json( Money $money = null ) { - if ( null === $money ) { - return null; - } - - $properties = array( - 'value' => $money->get_value(), - ); - - if ( null !== $money->get_currency()->get_alphabetic_code() ) { - $properties['currency'] = $money->get_currency()->get_alphabetic_code(); - } - - $object = (object) $properties; - - return $object; - } - /** * Convert JSON to money object. * * @param mixed $json JSON. * @return Money - * @throws InvalidArgumentException Throws invalid argument exception when JSON is not an object. + * @throws \InvalidArgumentException Throws invalid argument exception when JSON is not an object. */ public static function from_json( $json ) { if ( ! is_object( $json ) ) { - throw new InvalidArgumentException( 'JSON value must be an object.' ); + throw new \InvalidArgumentException( 'JSON value must be an object.' ); } + // Default arguments. + $value = 0; + $currency = null; + $tax_value = null; + $tax_percentage = null; + $money = new Money(); - if ( property_exists( $json, 'value' ) ) { - $money->set_value( $json->value ); + if ( \property_exists( $json, 'value' ) ) { + $value = $json->value; + } + + if ( \property_exists( $json, 'currency' ) ) { + $currency = $json->currency; + } + + if ( \property_exists( $json, 'tax_value' ) ) { + $tax_value = $json->tax_value; + } + + if ( \property_exists( $json, 'tax_percentage' ) ) { + $tax_percentage = $json->tax_percentage; + } + + /** + * In older versions of this library the currency could be empty, + * for backward compatibility we fall back to the euro. + */ + if ( null === $currency ) { + $currency = 'EUR'; } - if ( property_exists( $json, 'currency' ) ) { - $money->set_currency( $json->currency ); + if ( ! empty( $tax_value ) || ! empty( $tax_percentage ) ) { + return new TaxedMoney( $value, $currency, $tax_value, $tax_percentage ); } - return $money; + return new Money( $value, $currency ); } } diff --git a/src/Payments/Item.php b/src/Payments/Item.php deleted file mode 100644 index b0e4354d..00000000 --- a/src/Payments/Item.php +++ /dev/null @@ -1,186 +0,0 @@ - - * @copyright 2005-2021 Pronamic - * @license GPL-3.0-or-later - * @package Pronamic\WordPress\Pay\Payments - */ - -namespace Pronamic\WordPress\Pay\Payments; - -use Pronamic\WordPress\Money\Money; - -/** - * Item. - * - * @deprecated Use `PaymentLine`. - * @author Remco Tolsma - * @version 2.2.6 - */ -class Item { - /** - * The number. - * - * @var string - */ - private $number; - - /** - * The description. - * - * @var string - */ - private $description; - - /** - * The quantity. - * - * @var int - */ - private $quantity; - - /** - * The price. - * - * @var float - */ - private $price; - - /** - * Constructs and initialize a iDEAL basic item. - */ - public function __construct() { - $this->number = ''; - $this->description = ''; - $this->quantity = 1; - $this->price = 0.0; - } - - /** - * Call. - * - * @link http://php.net/manual/de/language.oop5.magic.php - * - * @param string $name Method name. - * @param array $arguments Method arguments. - * @return float|int|string|bool - */ - public function __call( $name, $arguments ) { - $map = array( - 'getNumber' => 'get_number', - 'setNumber' => 'set_number', - 'setDescription' => 'set_description', - 'getQuantity' => 'get_quantity', - 'setQuantity' => 'set_quantity', - 'getPrice' => 'get_price', - 'setPrice' => 'set_price', - ); - - if ( isset( $map[ $name ] ) ) { - $old_method = $name; - $new_method = $map[ $name ]; - - _deprecated_function( esc_html( __CLASS__ . '::' . $old_method ), '2.0.1', esc_html( __CLASS__ . '::' . $new_method ) ); - - $callable = array( $this, $new_method ); - - if ( is_callable( $callable ) ) { - return call_user_func_array( $callable, $arguments ); - } - } - - return trigger_error( esc_html( 'Call to undefined method ' . __CLASS__ . '::' . $name . '()' ), E_USER_ERROR ); - } - - /** - * Get the number / identifier of this item. - * - * @return string - */ - public function get_number() { - return $this->number; - } - - /** - * Set the number / identifier of this item. - * - * @param string $number Number. - * @return void - */ - public function set_number( $number ) { - $this->number = $number; - } - - /** - * Get the description of this item. - * - * @return string - */ - public function get_description() { - return $this->description; - } - - /** - * Set the description of this item. - * AN..max32 (AN = Alphanumeric, free text). - * - * @param string $description Description. - * @return void - */ - public function set_description( $description ) { - $this->description = substr( $description, 0, 32 ); - } - - /** - * Get the quantity of this item. - * - * @return int - */ - public function get_quantity() { - return $this->quantity; - } - - /** - * Set the quantity of this item - * - * @param int $quantity Quantity. - * @return void - */ - public function set_quantity( $quantity ) { - $this->quantity = $quantity; - } - - /** - * Get the price of this item. - * - * @return float - */ - public function get_price() { - return $this->price; - } - - /** - * Set the price of this item. - * - * @param float $price Price. - * @return void - */ - public function set_price( $price ) { - $this->price = $price; - } - - /** - * Get the amount. - * - * @return Money - */ - public function get_amount() { - $money = new Money( $this->get_price() ); - - $amount = $money->multiply( $this->get_quantity() ); - - return $amount; - } -} diff --git a/src/Payments/Items.php b/src/Payments/Items.php deleted file mode 100644 index 35dc266c..00000000 --- a/src/Payments/Items.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright 2005-2021 Pronamic - * @license GPL-3.0-or-later - * @package Pronamic\WordPress\Pay\Payments - */ - -namespace Pronamic\WordPress\Pay\Payments; - -use Pronamic\WordPress\Money\Money; - -/** - * Items - * - * @deprecated Use `PaymentLines`. - * @author Remco Tolsma - * @version 2.2.6 - * @implements \IteratorAggregate - */ -class Items implements \IteratorAggregate { - /** - * The items. - * - * @var Item[] - */ - private $items; - - /** - * Constructs and initialize a iDEAL basic object. - */ - public function __construct() { - $this->items = array(); - } - - /** - * Get iterator. - * - * @return \ArrayIterator - */ - public function getIterator() { - return new \ArrayIterator( $this->items ); - } - - /** - * Add item. - * - * @param Item $item The item to add. - * @return void - * @deprecated 2.0.8 - */ - public function addItem( Item $item ) { - _deprecated_function( __FUNCTION__, '2.0.8', 'Pronamic\WordPress\Pay\Payments\Items::add_item()' ); - - $this->add_item( $item ); - } - - /** - * Add item. - * - * @param Item $item The item to add. - * @return void - */ - public function add_item( Item $item ) { - $this->items[] = $item; - } - - /** - * Calculate the total amount of all items. - * - * @return Money - */ - public function get_amount() { - $amount = new Money( 0, 'EUR' ); - - foreach ( $this->items as $item ) { - $amount = $amount->add( $item->get_amount() ); - } - - return $amount; - } -} diff --git a/src/Payments/LegacyPaymentInfo.php b/src/Payments/LegacyPaymentInfo.php index 4eda1d9d..2d8399d9 100644 --- a/src/Payments/LegacyPaymentInfo.php +++ b/src/Payments/LegacyPaymentInfo.php @@ -78,9 +78,7 @@ public function set_amount( Money $amount ) { _deprecated_function( __FUNCTION__, '2.0.9', 'Payment::set_total_amount()' ); if ( \method_exists( $this, 'set_total_amount' ) ) { - $money = new TaxedMoney( $amount->get_value(), $amount->get_currency() ); - - $this->set_total_amount( $money ); + $this->set_total_amount( $amount ); } } diff --git a/src/Payments/Payment.php b/src/Payments/Payment.php index 7a91779f..25e748f3 100644 --- a/src/Payments/Payment.php +++ b/src/Payments/Payment.php @@ -13,13 +13,11 @@ use InvalidArgumentException; use Pronamic\WordPress\DateTime\DateTime; use Pronamic\WordPress\Money\Money; -use Pronamic\WordPress\Money\TaxedMoney; use Pronamic\WordPress\Pay\Address; use Pronamic\WordPress\Pay\Customer; use Pronamic\WordPress\Pay\MoneyJsonTransformer; use Pronamic\WordPress\Pay\Subscriptions\Subscription; use Pronamic\WordPress\Pay\Subscriptions\SubscriptionPeriod; -use Pronamic\WordPress\Pay\TaxedMoneyJsonTransformer; /** * Payment @@ -39,7 +37,7 @@ class Payment extends LegacyPayment { /** * The total amount of this payment. * - * @var TaxedMoney + * @var Money */ private $total_amount; @@ -264,7 +262,7 @@ public function __construct( $post_id = null ) { $this->set_status( PaymentStatus::OPEN ); - $this->set_total_amount( new TaxedMoney() ); + $this->set_total_amount( new Money() ); if ( null !== $post_id ) { pronamic_pay_plugin()->payments_data_store->read( $this ); @@ -312,29 +310,6 @@ public function add_note( $note ) { return $result; } - /** - * Get the source text of this payment. - * - * @return string - */ - public function get_source_text() { - $pieces = array( - $this->get_source(), - $this->get_source_id(), - ); - - $pieces = array_filter( $pieces ); - - $text = implode( '
', $pieces ); - - $source = $this->get_source(); - - $text = apply_filters( 'pronamic_payment_source_text_' . $source, $text, $this ); - $text = apply_filters( 'pronamic_payment_source_text', $text, $this ); - - return $text; - } - /** * Get the payment description. * @@ -366,7 +341,7 @@ public function get_transaction_id() { /** * Get total amount. * - * @return TaxedMoney + * @return Money */ public function get_total_amount() { return $this->total_amount; @@ -375,10 +350,10 @@ public function get_total_amount() { /** * Set total amount. * - * @param TaxedMoney $total_amount Total amount. + * @param Money $total_amount Total amount. * @return void */ - public function set_total_amount( TaxedMoney $total_amount ) { + public function set_total_amount( Money $total_amount ) { $this->total_amount = $total_amount; } @@ -576,7 +551,15 @@ public function set_expiry_date( $expiry_date ) { public function get_return_redirect_url() { $url = home_url( '/' ); - $url = apply_filters( 'pronamic_payment_redirect_url', $url, $this ); + $payment = $this; + + /** + * Filters the payment return redirect URL. + * + * @param string $text Redirect URL. + * @param Payment $payment Payment. + */ + $url = apply_filters( 'pronamic_payment_redirect_url', $url, $payment ); return $url; } @@ -613,16 +596,75 @@ public function get_edit_payment_url() { return $url; } + /** + * Get the source text of this payment. + * + * @return string + */ + public function get_source_text() { + $pieces = array( + $this->get_source(), + $this->get_source_id(), + ); + + $pieces = array_filter( $pieces ); + + $text = implode( '
', $pieces ); + + $source = $this->get_source(); + + $payment = $this; + + if ( null !== $source ) { + /** + * Filters the payment source text by plugin integration source. + * + * @param string $text Source text. + * @param Payment $payment Payment. + */ + $text = apply_filters( 'pronamic_payment_source_text_' . $source, $text, $payment ); + } + + /** + * Filters the payment source text. + * + * @param string $text Source text. + * @param Payment $payment Payment. + */ + $text = apply_filters( 'pronamic_payment_source_text', $text, $payment ); + + return $text; + } + /** * Get source description. * * @return string|null */ public function get_source_description() { - $description = $this->source; + $payment = $this; + + $source = $payment->get_source(); - $description = apply_filters( 'pronamic_payment_source_description', $description, $this ); - $description = apply_filters( 'pronamic_payment_source_description_' . $this->source, $description, $this ); + $description = $source; + + /** + * Filters the payment source description. + * + * @param string $description Source description. + * @param Payment $payment Payment. + */ + $description = apply_filters( 'pronamic_payment_source_description', $description, $payment ); + + if ( null !== $source ) { + /** + * Filters the payment source description by plugin integration source. + * + * @param string $description Source description. + * @param Payment $payment Payment. + */ + $description = apply_filters( 'pronamic_payment_source_description_' . $source, $description, $payment ); + } return $description; } @@ -635,8 +677,27 @@ public function get_source_description() { public function get_source_link() { $url = null; - $url = apply_filters( 'pronamic_payment_source_url', $url, $this ); - $url = apply_filters( 'pronamic_payment_source_url_' . $this->source, $url, $this ); + $payment = $this; + + $source = $payment->get_source(); + + /** + * Filters the payment source URL. + * + * @param null|string $url Source URL. + * @param Payment $payment Payment. + */ + $url = apply_filters( 'pronamic_payment_source_url', $url, $payment ); + + if ( null !== $source ) { + /** + * Filters the payment source URL by plugin integration source. + * + * @param null|string $url Source URL. + * @param Payment $payment Payment. + */ + $url = apply_filters( 'pronamic_payment_source_url_' . $source, $url, $payment ); + } return $url; } @@ -649,7 +710,15 @@ public function get_source_link() { public function get_provider_link() { $url = null; - $url = apply_filters( 'pronamic_payment_provider_url', $url, $this ); + $payment = $this; + + /** + * Filters the payment provider URL. + * + * @param null|string $url Provider URL. + * @param Payment $payment Payment. + */ + $url = apply_filters( 'pronamic_payment_provider_url', $url, $payment ); if ( null === $this->id ) { return $url; @@ -663,12 +732,16 @@ public function get_provider_link() { $gateway_id = get_post_meta( intval( $config_id ), '_pronamic_gateway_id', true ); - if ( empty( $gateway_id ) ) { - return $url; + if ( ! empty( $gateway_id ) ) { + /** + * Filters the payment provider URL by gateway identifier. + * + * @param null|string $url Provider URL. + * @param Payment $payment Payment. + */ + $url = apply_filters( 'pronamic_payment_provider_url_' . $gateway_id, $url, $payment ); } - $url = apply_filters( 'pronamic_payment_provider_url_' . $gateway_id, $url, $this ); - return $url; } @@ -836,7 +909,7 @@ public static function from_json( $json, $payment = null ) { PaymentInfoHelper::from_json( $json, $payment ); if ( isset( $json->total_amount ) ) { - $payment->set_total_amount( TaxedMoneyJsonTransformer::from_json( $json->total_amount ) ); + $payment->set_total_amount( MoneyJsonTransformer::from_json( $json->total_amount ) ); } if ( isset( $json->refunded_amount ) ) { @@ -874,6 +947,10 @@ public static function from_json( $json, $payment = null ) { $payment->set_origin_id( $json->origin_id ); } + if ( isset( $json->transaction_id ) ) { + $payment->set_transaction_id( $json->transaction_id ); + } + return $payment; } @@ -898,14 +975,14 @@ public function get_json() { $total_amount = $this->get_total_amount(); if ( null !== $total_amount ) { - $properties['total_amount'] = TaxedMoneyJsonTransformer::to_json( $total_amount ); + $properties['total_amount'] = $total_amount->jsonSerialize(); } // Refunded amount. $refunded_amount = $this->get_refunded_amount(); if ( null !== $refunded_amount ) { - $properties['refunded_amount'] = MoneyJsonTransformer::to_json( $refunded_amount ); + $properties['refunded_amount'] = $refunded_amount->jsonSerialize(); } // Periods. @@ -941,6 +1018,13 @@ public function get_json() { $properties['origin_id'] = $origin_id; } + // Transaction ID. + $transaction_id = $this->get_transaction_id(); + + if ( null !== $transaction_id ) { + $properties['transaction_id'] = $transaction_id; + } + $object = (object) $properties; return $object; diff --git a/src/Payments/PaymentInfoHelper.php b/src/Payments/PaymentInfoHelper.php index bf60f5d2..569a2cb0 100644 --- a/src/Payments/PaymentInfoHelper.php +++ b/src/Payments/PaymentInfoHelper.php @@ -16,7 +16,6 @@ use Pronamic\WordPress\Pay\Address; use Pronamic\WordPress\Pay\Customer; use Pronamic\WordPress\Pay\MoneyJsonTransformer; -use Pronamic\WordPress\Pay\TaxedMoneyJsonTransformer; /** * Payment info helper @@ -48,7 +47,7 @@ public static function to_json( PaymentInfo $payment_info ) { $shipping_amount = $payment_info->get_shipping_amount(); if ( null !== $shipping_amount ) { - $object->shipping_amount = MoneyJsonTransformer::to_json( $shipping_amount ); + $object->shipping_amount = $shipping_amount->jsonSerialize(); } $customer = $payment_info->get_customer(); diff --git a/src/Payments/PaymentLine.php b/src/Payments/PaymentLine.php index 2070f462..24f06390 100644 --- a/src/Payments/PaymentLine.php +++ b/src/Payments/PaymentLine.php @@ -14,7 +14,6 @@ use Pronamic\WordPress\Money\Money; use Pronamic\WordPress\Money\TaxedMoney; use Pronamic\WordPress\Pay\MoneyJsonTransformer; -use Pronamic\WordPress\Pay\TaxedMoneyJsonTransformer; /** * Payment line. @@ -71,7 +70,7 @@ class PaymentLine { /** * The unit price of this payment line. * - * @var TaxedMoney|null + * @var Money|null */ private $unit_price; @@ -85,7 +84,7 @@ class PaymentLine { /** * Total amount of this payment line. * - * @var TaxedMoney + * @var Money */ private $total_amount; @@ -121,7 +120,7 @@ class PaymentLine { * Payment line constructor. */ public function __construct() { - $this->set_total_amount( new TaxedMoney() ); + $this->set_total_amount( new Money() ); } /** @@ -241,7 +240,7 @@ public function set_quantity( $quantity ) { /** * Get unit price. * - * @return TaxedMoney|null + * @return Money|null */ public function get_unit_price() { return $this->unit_price; @@ -250,10 +249,10 @@ public function get_unit_price() { /** * Set unit price. * - * @param TaxedMoney|null $price Unit price. + * @param Money|null $price Unit price. * @return void */ - public function set_unit_price( TaxedMoney $price = null ) { + public function set_unit_price( Money $price = null ) { $this->unit_price = ( null === $price ? null : $price ); } @@ -282,7 +281,11 @@ public function set_discount_amount( Money $discount_amount = null ) { * @return Money|null */ public function get_tax_amount() { - $tax_value = $this->get_total_amount()->get_tax_value(); + if ( ! $this->total_amount instanceof TaxedMoney ) { + return null; + } + + $tax_value = $this->total_amount->get_tax_value(); if ( null === $tax_value ) { return null; @@ -297,7 +300,7 @@ public function get_tax_amount() { /** * Get total amount. * - * @return TaxedMoney + * @return Money */ public function get_total_amount() { return $this->total_amount; @@ -306,10 +309,10 @@ public function get_total_amount() { /** * Set total amount. * - * @param TaxedMoney $total_amount Total amount. + * @param Money $total_amount Total amount. * @return void */ - public function set_total_amount( TaxedMoney $total_amount ) { + public function set_total_amount( Money $total_amount ) { $this->total_amount = $total_amount; } @@ -428,7 +431,7 @@ public static function from_json( $json ) { } if ( isset( $json->unit_price ) ) { - $line->set_unit_price( TaxedMoneyJsonTransformer::from_json( $json->unit_price ) ); + $line->set_unit_price( MoneyJsonTransformer::from_json( $json->unit_price ) ); } if ( isset( $json->discount_amount ) ) { @@ -436,7 +439,7 @@ public static function from_json( $json ) { } if ( isset( $json->total_amount ) ) { - $line->set_total_amount( TaxedMoneyJsonTransformer::from_json( $json->total_amount ) ); + $line->set_total_amount( MoneyJsonTransformer::from_json( $json->total_amount ) ); } if ( property_exists( $json, 'product_url' ) ) { @@ -467,9 +470,9 @@ public function get_json() { 'name' => $this->get_name(), 'description' => $this->get_description(), 'quantity' => $this->get_quantity(), - 'unit_price' => TaxedMoneyJsonTransformer::to_json( $this->get_unit_price() ), - 'discount_amount' => MoneyJsonTransformer::to_json( $this->get_discount_amount() ), - 'total_amount' => TaxedMoneyJsonTransformer::to_json( $this->get_total_amount() ), + 'unit_price' => ( null === $this->unit_price ) ? null : $this->unit_price->jsonSerialize(), + 'discount_amount' => ( null === $this->discount_amount ) ? null : $this->discount_amount->jsonSerialize(), + 'total_amount' => $this->total_amount->jsonSerialize(), 'product_url' => $this->get_product_url(), 'image_url' => $this->get_image_url(), 'product_category' => $this->get_product_category(), diff --git a/src/Payments/PaymentLines.php b/src/Payments/PaymentLines.php index 57ed360e..ffbb7b2b 100644 --- a/src/Payments/PaymentLines.php +++ b/src/Payments/PaymentLines.php @@ -103,10 +103,12 @@ public function get_amount() { $total = $total->add( $line_total ); // Tax. - $line_tax = $line_total->get_tax_amount(); + if ( $line_total instanceof TaxedMoney ) { + $line_tax = $line_total->get_tax_amount(); - if ( null !== $line_tax ) { - $tax = $tax->add( $line_tax ); + if ( null !== $line_tax ) { + $tax = $tax->add( $line_tax ); + } } // Currency. diff --git a/src/Payments/PaymentsDataStoreCPT.php b/src/Payments/PaymentsDataStoreCPT.php index 7ae0eb0e..26025e57 100644 --- a/src/Payments/PaymentsDataStoreCPT.php +++ b/src/Payments/PaymentsDataStoreCPT.php @@ -12,6 +12,7 @@ use Pronamic\WordPress\DateTime\DateTime; use Pronamic\WordPress\DateTime\DateTimeZone; +use Pronamic\WordPress\Money\Money; use Pronamic\WordPress\Money\TaxedMoney; use Pronamic\WordPress\Pay\Customer; @@ -237,6 +238,11 @@ public function save_post_meta( $post_id, $post, $update ) { $this->update_post_meta( $payment ); + /** + * Payment updated. + * + * @param Payment $payment Payment. + */ do_action( 'pronamic_pay_update_payment', $payment ); } @@ -279,6 +285,11 @@ public function create( Payment $payment ) { return false; } + /** + * New payment created. + * + * @param Payment $payment Payment. + */ do_action( 'pronamic_pay_new_payment', $payment ); return true; @@ -734,7 +745,6 @@ protected function read_post_meta( $payment ) { $payment->method = $this->get_meta_string( $id, 'method' ); $payment->issuer = $this->get_meta_string( $id, 'issuer' ); $payment->order_id = $this->get_meta_string( $id, 'order_id' ); - $payment->transaction_id = $this->get_meta_string( $id, 'transaction_id' ); $payment->entrance_code = $this->get_meta_string( $id, 'entrance_code' ); $payment->action_url = $this->get_meta_string( $id, 'action_url' ); $payment->source = $this->get_meta_string( $id, 'source' ); @@ -754,6 +764,11 @@ protected function read_post_meta( $payment ) { // Legacy. parent::read_post_meta( $payment ); + // Transaction ID. + if ( empty( $payment->transaction_id ) ) { + $payment->transaction_id = $this->get_meta_string( $id, 'transaction_id' ); + } + // Amount. $amount = $payment->get_meta( 'amount' ); @@ -761,7 +776,7 @@ protected function read_post_meta( $payment ) { if ( empty( $amount_value ) && ! empty( $amount ) ) { $payment->set_total_amount( - new TaxedMoney( + new Money( $amount, $payment->get_meta( 'currency' ) ) @@ -796,7 +811,7 @@ protected function get_update_meta( $payment, $meta = array() ) { 'key' => $payment->key, 'order_id' => $payment->order_id, 'currency' => $payment->get_total_amount()->get_currency()->get_alphabetic_code(), - 'amount' => $payment->get_total_amount()->format(), + 'amount' => $payment->get_total_amount()->get_number()->get_value(), 'method' => $payment->method, 'issuer' => $payment->issuer, 'expiration_period' => null, @@ -870,19 +885,140 @@ public function update_meta_status( $payment ) { $this->update_meta( $id, 'status', $payment->status ); if ( $previous_status !== $payment->status ) { - $old = $previous_status; - $old = empty( $old ) ? 'unknown' : $old; - $old = strtolower( $old ); - - $new = $payment->status; - $new = empty( $new ) ? 'unknown' : $new; - $new = strtolower( $new ); + if ( empty( $previous_status ) ) { + $previous_status = null; + } $can_redirect = false; - do_action( 'pronamic_payment_status_update_' . $payment->source . '_' . $old . '_to_' . $new, $payment, $can_redirect, $previous_status, $payment->status ); - do_action( 'pronamic_payment_status_update_' . $payment->source, $payment, $can_redirect, $previous_status, $payment->status ); - do_action( 'pronamic_payment_status_update', $payment, $can_redirect, $previous_status, $payment->status ); + $source = $payment->source; + + $updated_status = $payment->status; + + $old_status = empty( $previous_status ) ? 'unknown' : strtolower( $previous_status ); + + $new_status = empty( $updated_status ) ? 'unknown' : strtolower( $updated_status ); + + /** + * Payment status updated for plugin integration source from old to new status. + * + * **Source** + * + * Plugin | Source + * ------ | ------ + * Charitable | `charitable` + * Contact Form 7 | `contact-form-7` + * Event Espresso | `eventespresso` + * Event Espresso (legacy) | `event-espresso` + * Formidable Forms | `formidable-forms` + * Give | `give` + * Gravity Forms | `gravityformsideal` + * MemberPress | `memberpress` + * Ninja Forms | `ninja-forms` + * s2Member | `s2member` + * WooCommerce | `woocommerce` + * WP eCommerce | `wp-e-commerce` + * + * **Action status** + * + * Status | Value + * ------ | ----- + * (empty) | `unknown` + * Cancelled | `cancelled` + * Expired | `expired` + * Failure | `failure` + * Open | `open` + * Reserved | `reserved` + * Success | `success` + * + * **Payment status** + * + * Status | Value + * ------ | ----- + * Cancelled | `Cancelled` + * Expired | `Expired` + * Failure | `Failure` + * Open | `Open` + * Reserved | `Reserved` + * Success | `Success` + * + * @param Payment $payment Payment. + * @param bool $can_redirect Flag to indicate if redirect is allowed after the payment update. + * @param null|string $previous_status Previous payment status. + * @param string $updated_status Updated payment status. + */ + do_action( 'pronamic_payment_status_update_' . $source . '_' . $old_status . '_to_' . $new_status, $payment, $can_redirect, $previous_status, $updated_status ); + + /** + * Payment status updated for plugin integration source. + * + * **Source** + * + * Plugin | Source + * ------ | ------ + * Charitable | `charitable` + * Contact Form 7 | `contact-form-7` + * Event Espresso | `eventespresso` + * Event Espresso (legacy) | `event-espresso` + * Formidable Forms | `formidable-forms` + * Give | `give` + * Gravity Forms | `gravityformsideal` + * MemberPress | `memberpress` + * Ninja Forms | `ninja-forms` + * s2Member | `s2member` + * WooCommerce | `woocommerce` + * WP eCommerce | `wp-e-commerce` + * + * **Action status** + * + * Status | Value + * ------ | ----- + * (empty) | `unknown` + * Cancelled | `cancelled` + * Expired | `expired` + * Failure | `failure` + * Open | `open` + * Reserved | `reserved` + * Success | `success` + * + * **Payment status** + * + * Status | Value + * ------ | ----- + * Cancelled | `Cancelled` + * Expired | `Expired` + * Failure | `Failure` + * Open | `Open` + * Reserved | `Reserved` + * Success | `Success` + * + * @param Payment $payment Payment. + * @param bool $can_redirect Flag to indicate if redirect is allowed after the payment update. + * @param null|string $previous_status Previous payment status. + * @param string $updated_status Updated payment status. + */ + do_action( 'pronamic_payment_status_update_' . $source, $payment, $can_redirect, $previous_status, $updated_status ); + + /** + * Payment status updated. + * + * **Payment status** + * + * Status | Value + * ------ | ----- + * Cancelled | `Cancelled` + * Expired | `Expired` + * Failure | `Failure` + * Open | `Open` + * Reserved | `Reserved` + * Success | `Success` + * + * @param Payment $payment Payment. + * @param bool $can_redirect Flag to indicate if redirect is allowed after the payment update. + * @param null|string $previous_status Previous payment status. + * @param string $updated_status Updated payment status. + */ + do_action( 'pronamic_payment_status_update', $payment, $can_redirect, $previous_status, $updated_status ); } } } diff --git a/src/Plugin.php b/src/Plugin.php index 7945fc23..743d225e 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -431,7 +431,15 @@ public function handle_returns() { } // Check if we should redirect. - $should_redirect = apply_filters( 'pronamic_pay_return_should_redirect', true, $payment ); + $should_redirect = true; + + /** + * Filter whether or not to allow redirects on payment return. + * + * @param bool $should_redirect Flag to indicate if redirect is allowed on handling payment return. + * @param Payment $payment Payment. + */ + $should_redirect = apply_filters( 'pronamic_pay_return_should_redirect', $should_redirect, $payment ); try { self::update_payment( $payment, $should_redirect ); @@ -586,8 +594,14 @@ public function plugins_loaded() { $this->admin = new Admin\AdminModule( $this ); } - // Gateway Integrations. - $gateways = apply_filters( 'pronamic_pay_gateways', array() ); + $gateways = array(); + + /** + * Filters the gateway integrations. + * + * @param AbstractGatewayIntegration[] $gateways Gateway integrations. + */ + $gateways = apply_filters( 'pronamic_pay_gateways', $gateways ); $this->gateway_integrations = new GatewayIntegrations( $gateways ); @@ -595,8 +609,14 @@ public function plugins_loaded() { $integration->setup(); } - // Plugin Integrations. - $this->plugin_integrations = apply_filters( 'pronamic_pay_plugin_integrations', array() ); + $plugin_integrations = array(); + + /** + * Filters the plugin integrations. + * + * @param AbstractPluginIntegration[] $plugin_integrations Plugin integrations. + */ + $this->plugin_integrations = apply_filters( 'pronamic_pay_plugin_integrations', $plugin_integrations ); foreach ( $this->plugin_integrations as $integration ) { $integration->setup(); @@ -716,6 +736,10 @@ public static function get_config_select_options( $payment_method = null ) { $options = array( __( '— Select Configuration —', 'pronamic_ideal' ) ); foreach ( $query->posts as $post ) { + if ( ! \is_object( $post ) ) { + continue; + } + $id = $post->ID; $options[ $id ] = sprintf( @@ -972,13 +996,15 @@ public static function start_payment( Payment $payment, $gateway = null ) { // Complement payment. self::complement_payment( $payment ); + $config_id = $payment->get_config_id(); + /** * Filters the payment gateway configuration ID. * - * @param int $configuration_id Gateway configuration ID. - * @param Payment $payment The payment resource data. + * @param null|int $config_id Gateway configuration ID. + * @param Payment $payment Payment. */ - $config_id = \apply_filters( 'pronamic_payment_gateway_configuration_id', $payment->get_config_id(), $payment ); + $config_id = \apply_filters( 'pronamic_payment_gateway_configuration_id', $config_id, $payment ); $payment->set_config_id( $config_id ); @@ -1174,6 +1200,12 @@ public function get_pages() { public function payment_redirect_url( $url, Payment $payment ) { $source = $payment->get_source(); + /** + * Filters the payment redirect URL by plugin integration source. + * + * @param null|string $url Redirect URL. + * @param Payment $payment Payment. + */ $url = \apply_filters( 'pronamic_payment_redirect_url_' . $source, $url, $payment ); return $url; diff --git a/src/PrivacyManager.php b/src/PrivacyManager.php index eb241e9c..c0205843 100644 --- a/src/PrivacyManager.php +++ b/src/PrivacyManager.php @@ -49,7 +49,14 @@ public function __construct() { * @return array */ public function register_exporters( $exporters ) { - do_action( 'pronamic_pay_privacy_register_exporters', $this ); + $privacy_manager = $this; + + /** + * Register privacy exporters. + * + * @param PrivacyManager $privacy_manager Privacy manager. + */ + do_action( 'pronamic_pay_privacy_register_exporters', $privacy_manager ); foreach ( $this->exporters as $id => $exporter ) { $exporters[ $id ] = $exporter; @@ -65,7 +72,14 @@ public function register_exporters( $exporters ) { * @return array */ public function register_erasers( $erasers ) { - do_action( 'pronamic_pay_privacy_register_erasers', $this ); + $privacy_manager = $this; + + /** + * Register privacy erasers. + * + * @param PrivacyManager $privacy_manager Privacy manager. + */ + do_action( 'pronamic_pay_privacy_register_erasers', $privacy_manager ); foreach ( $this->erasers as $id => $eraser ) { $erasers[ $id ] = $eraser; diff --git a/src/Subscriptions/Subscription.php b/src/Subscriptions/Subscription.php index ec065b9c..ff991327 100644 --- a/src/Subscriptions/Subscription.php +++ b/src/Subscriptions/Subscription.php @@ -360,12 +360,29 @@ public function get_source_text() { $pieces = array_filter( $pieces ); - $default_text = implode( '
', $pieces ); + $text = implode( '
', $pieces ); $source = $this->get_source(); - $text = apply_filters( 'pronamic_subscription_source_text_' . $source, $default_text, $this ); - $text = apply_filters( 'pronamic_subscription_source_text', $text, $this ); + $subscription = $this; + + if ( null !== $source ) { + /** + * Filters the subscription source text by plugin integration source. + * + * @param string $text Source text. + * @param Subscription $subscription Subscription. + */ + $text = apply_filters( 'pronamic_subscription_source_text_' . $source, $text, $subscription ); + } + + /** + * Filters the subscription source text. + * + * @param string $text Source text. + * @param Subscription $subscription Subscription. + */ + $text = apply_filters( 'pronamic_subscription_source_text', $text, $subscription ); return $text; } @@ -376,14 +393,31 @@ public function get_source_text() { * @return string */ public function get_source_description() { - $source = $this->get_source(); + $subscription = $this; - $default_text = $this->get_source(); + $source = $subscription->get_source(); - $text = apply_filters( 'pronamic_subscription_source_description_' . $source, $default_text, $this ); - $text = apply_filters( 'pronamic_subscription_source_description', $text, $this ); + $description = $source; - return $text; + if ( null !== $source ) { + /** + * Filters the subscription source description by plugin integration source. + * + * @param string $description Source description. + * @param Subscription $subscription Subscription. + */ + $description = apply_filters( 'pronamic_subscription_source_description_' . $source, $description, $subscription ); + } + + /** + * Filters the subscription source description. + * + * @param string $description Source description. + * @param Subscription $subscription Subscription. + */ + $description = apply_filters( 'pronamic_subscription_source_description', $description, $subscription ); + + return $description; } /** @@ -394,8 +428,27 @@ public function get_source_description() { public function get_source_link() { $url = null; - $url = apply_filters( 'pronamic_subscription_source_url', $url, $this ); - $url = apply_filters( 'pronamic_subscription_source_url_' . $this->source, $url, $this ); + $subscription = $this; + + $source = $subscription->get_source(); + + /** + * Filters the subscription source URL. + * + * @param null|string $url Source URL. + * @param Subscription $subscription Subscription. + */ + $url = apply_filters( 'pronamic_subscription_source_url', $url, $subscription ); + + if ( null !== $source ) { + /** + * Filters the subscription source URL by plugin integration source. + * + * @param null|string $url Source URL. + * @param Subscription $subscription Subscription. + */ + $url = apply_filters( 'pronamic_subscription_source_url_' . $source, $url, $subscription ); + } return $url; } @@ -412,7 +465,7 @@ public function get_cancel_url() { 'key' => $this->get_key(), 'action' => 'cancel', ), - home_url() + home_url( '/' ) ); return $cancel_url; @@ -430,7 +483,7 @@ public function get_renewal_url() { 'key' => $this->get_key(), 'action' => 'renew', ), - home_url() + home_url( '/' ) ); return $renewal_url; @@ -448,7 +501,7 @@ public function get_mandate_selection_url() { 'key' => $this->get_key(), 'action' => 'mandate', ), - home_url() + home_url( '/' ) ); return $url; diff --git a/src/Subscriptions/SubscriptionPeriod.php b/src/Subscriptions/SubscriptionPeriod.php index d32bbb18..ee02e5e4 100644 --- a/src/Subscriptions/SubscriptionPeriod.php +++ b/src/Subscriptions/SubscriptionPeriod.php @@ -11,8 +11,8 @@ namespace Pronamic\WordPress\Pay\Subscriptions; use Pronamic\WordPress\DateTime\DateTime; -use Pronamic\WordPress\Money\TaxedMoney; -use Pronamic\WordPress\Pay\TaxedMoneyJsonTransformer; +use Pronamic\WordPress\Money\Money; +use Pronamic\WordPress\Pay\MoneyJsonTransformer; /** * Subscription Period @@ -46,7 +46,7 @@ class SubscriptionPeriod { /** * The amount to pay for this period. * - * @var TaxedMoney + * @var Money */ private $amount; @@ -56,9 +56,9 @@ class SubscriptionPeriod { * @param SubscriptionPhase $phase Subscription phase. * @param DateTime $start_date Start date. * @param DateTime $end_date End date. - * @param TaxedMoney $amount Taxed amount. + * @param Money $amount Taxed amount. */ - public function __construct( SubscriptionPhase $phase, DateTime $start_date, DateTime $end_date, TaxedMoney $amount ) { + public function __construct( SubscriptionPhase $phase, DateTime $start_date, DateTime $end_date, Money $amount ) { $this->phase = $phase; $this->start_date = $start_date; $this->end_date = $end_date; @@ -105,7 +105,7 @@ public function get_end_date() { /** * Get amount. * - * @return TaxedMoney + * @return Money */ public function get_amount() { return $this->amount; @@ -192,7 +192,7 @@ public static function from_json( $json ) { $start_date = new DateTime( $json->start_date ); $end_date = new DateTime( $json->end_date ); - $amount = TaxedMoneyJsonTransformer::from_json( $json->amount ); + $amount = MoneyJsonTransformer::from_json( $json->amount ); return new self( $phase, $start_date, $end_date, $amount ); } @@ -229,7 +229,7 @@ public function to_json() { ), 'start_date' => $this->start_date->format( \DATE_ATOM ), 'end_date' => $this->end_date->format( \DATE_ATOM ), - 'amount' => TaxedMoneyJsonTransformer::to_json( $this->amount ), + 'amount' => $this->amount->jsonSerialize(), ); return $json; diff --git a/src/Subscriptions/SubscriptionPhase.php b/src/Subscriptions/SubscriptionPhase.php index cbb6b4d5..2dfad7a5 100644 --- a/src/Subscriptions/SubscriptionPhase.php +++ b/src/Subscriptions/SubscriptionPhase.php @@ -12,9 +12,8 @@ use DateTimeImmutable; use Pronamic\WordPress\DateTime\DateTime; -use Pronamic\WordPress\Money\TaxedMoney; +use Pronamic\WordPress\Money\Money; use Pronamic\WordPress\Pay\MoneyJsonTransformer; -use Pronamic\WordPress\Pay\TaxedMoneyJsonTransformer; /** * Subscription Phase @@ -48,7 +47,7 @@ class SubscriptionPhase implements \JsonSerializable { /** * Amount. * - * @var TaxedMoney + * @var Money */ private $amount; @@ -129,10 +128,10 @@ class SubscriptionPhase implements \JsonSerializable { * @param Subscription $subscription Subscription. * @param DateTimeImmutable $start_date Start date. * @param SubscriptionInterval $interval Interval. - * @param TaxedMoney $amount Amount. + * @param Money $amount Amount. * @return void */ - public function __construct( Subscription $subscription, DateTimeImmutable $start_date, SubscriptionInterval $interval, TaxedMoney $amount ) { + public function __construct( Subscription $subscription, DateTimeImmutable $start_date, SubscriptionInterval $interval, Money $amount ) { $this->subscription = $subscription; $this->start_date = $start_date; $this->interval = $interval; @@ -250,7 +249,7 @@ public function set_canceled_at( DateTimeImmutable $canceled_at = null ) { /** * Get amount. * - * @return TaxedMoney + * @return Money */ public function get_amount() { return $this->amount; @@ -259,7 +258,7 @@ public function get_amount() { /** * Set amount. * - * @param TaxedMoney $amount Amount. + * @param Money $amount Amount. * @return void */ public function set_amount( $amount ) { @@ -510,7 +509,7 @@ public function jsonSerialize() { 'sequence_number' => $this->get_sequence_number(), 'start_date' => $this->start_date->format( \DATE_ATOM ), 'interval' => $this->interval->get_specification(), - 'amount' => MoneyJsonTransformer::to_json( $this->amount ), + 'amount' => $this->amount->jsonSerialize(), // Numbers. 'total_periods' => $this->total_periods, 'periods_created' => $this->periods_created, @@ -560,7 +559,7 @@ public static function from_json( $json ) { $json->subscription, new \DateTimeImmutable( $json->start_date ), new SubscriptionInterval( $json->interval ), - TaxedMoneyJsonTransformer::from_json( $json->amount ) + MoneyJsonTransformer::from_json( $json->amount ) ); if ( property_exists( $json, 'total_periods' ) ) { diff --git a/src/Subscriptions/SubscriptionPhasesTrait.php b/src/Subscriptions/SubscriptionPhasesTrait.php index 10ea97bc..0e537a21 100644 --- a/src/Subscriptions/SubscriptionPhasesTrait.php +++ b/src/Subscriptions/SubscriptionPhasesTrait.php @@ -11,7 +11,7 @@ namespace Pronamic\WordPress\Pay\Subscriptions; use Pronamic\WordPress\DateTime\DateTime; -use Pronamic\WordPress\Money\TaxedMoney; +use Pronamic\WordPress\Money\Money; /** * Subscription Phases Trait @@ -61,9 +61,9 @@ public function add_phase( SubscriptionPhase $phase ) { /** * Create new phase for this subscription. * - * @param DateTime $start_date Start date. - * @param string $interval_spec Interval specification. - * @param TaxedMoney $amount Amount. + * @param DateTime $start_date Start date. + * @param string $interval_spec Interval specification. + * @param Money $amount Amount. * @return SubscriptionPhase */ public function new_phase( $start_date, $interval_spec, $amount ) { diff --git a/src/Subscriptions/SubscriptionsDataStoreCPT.php b/src/Subscriptions/SubscriptionsDataStoreCPT.php index b6d1ff25..9e10e222 100644 --- a/src/Subscriptions/SubscriptionsDataStoreCPT.php +++ b/src/Subscriptions/SubscriptionsDataStoreCPT.php @@ -13,11 +13,11 @@ use DatePeriod; use Pronamic\WordPress\DateTime\DateTime; use Pronamic\WordPress\DateTime\DateTimeZone; -use Pronamic\WordPress\Money\TaxedMoney; +use Pronamic\WordPress\Money\Money; use Pronamic\WordPress\Pay\Payments\LegacyPaymentsDataStoreCPT; use Pronamic\WordPress\Pay\Payments\PaymentStatus; use Pronamic\WordPress\Pay\Customer; -use Pronamic\WordPress\Pay\TaxedMoneyJsonTransformer; +use Pronamic\WordPress\Pay\MoneyJsonTransformer; /** * Title: Subscriptions data store CPT @@ -276,6 +276,11 @@ public function create( $subscription ) { $this->update_post_meta( $subscription ); + /** + * New subscription created. + * + * @param Subscription $subscription Subscription. + */ do_action( 'pronamic_pay_new_subscription', $subscription ); return true; @@ -380,13 +385,13 @@ public function read( $subscription ) { // Phases. if ( is_object( $json ) && ! property_exists( $json, 'phases' ) ) { // Amount. - $amount = new TaxedMoney( + $amount = new Money( (string) $this->get_meta( $id, 'amount' ), (string) $this->get_meta_string( $id, 'currency' ) ); if ( \property_exists( $json, 'total_amount' ) ) { - $amount = TaxedMoneyJsonTransformer::from_json( $json->total_amount ); + $amount = MoneyJsonTransformer::from_json( $json->total_amount ); } // Phase. @@ -704,7 +709,7 @@ private function update_post_meta( $subscription ) { if ( null !== $display_phase ) { $this->update_meta( $id, 'currency', $display_phase->get_amount()->get_currency()->get_alphabetic_code() ); - $this->update_meta( $id, 'amount', $display_phase->get_amount()->format() ); + $this->update_meta( $id, 'amount', $display_phase->get_amount()->get_number()->get_value() ); } $this->update_meta_status( $subscription ); @@ -728,19 +733,147 @@ public function update_meta_status( $subscription ) { $this->update_meta( $id, 'status', $subscription->status ); if ( $previous_status !== $subscription->status ) { - $old = $previous_status; - $old = empty( $old ) ? 'unknown' : $old; - $old = strtolower( $old ); - - $new = $subscription->status; - $new = empty( $new ) ? 'unknown' : $new; - $new = strtolower( $new ); + if ( empty( $previous_status ) ) { + $previous_status = null; + } $can_redirect = false; - do_action( 'pronamic_subscription_status_update_' . $subscription->source . '_' . $old . '_to_' . $new, $subscription, $can_redirect, $previous_status, $subscription->status ); - do_action( 'pronamic_subscription_status_update_' . $subscription->source, $subscription, $can_redirect, $previous_status, $subscription->status ); - do_action( 'pronamic_subscription_status_update', $subscription, $can_redirect, $previous_status, $subscription->status ); + $source = $subscription->source; + + $updated_status = $subscription->status; + + $old_status = empty( $previous_status ) ? 'unknown' : strtolower( $previous_status ); + $old_status = \str_replace( ' ', '_', $old_status ); + + $new_status = empty( $updated_status ) ? 'unknown' : strtolower( $updated_status ); + $new_status = \str_replace( ' ', '_', $new_status ); + + /** + * Subscription status updated for plugin integration source from old to new status. + * + * **Source** + * + * Plugin | Source + * ------ | ------ + * Charitable | `charitable` + * Contact Form 7 | `contact-form-7` + * Event Espresso | `eventespresso` + * Event Espresso (legacy) | `event-espresso` + * Formidable Forms | `formidable-forms` + * Give | `give` + * Gravity Forms | `gravityformsideal` + * MemberPress | `memberpress` + * Ninja Forms | `ninja-forms` + * s2Member | `s2member` + * WooCommerce | `woocommerce` + * WP eCommerce | `wp-e-commerce` + * + * **Action status** + * + * Status | Value + * ------ | ----- + * (empty) | `unknown` + * Active | `active` + * Cancelled | `cancelled` + * Completed | `completed` + * Expired | `expired` + * Failure | `failure` + * On Hold | `on_hold` + * Open | `open` + * + * **Subscription status** + * + * Status | Value + * ------ | ----- + * Active | `Active` + * Cancelled | `Cancelled` + * Completed | `Completed` + * Expired | `Expired` + * Failure | `Failure` + * On Hold | `On Hold` + * Open | `Open` + * + * @param Subscription $subscription Subscription. + * @param bool $can_redirect Flag to indicate if redirect is allowed after the subscription update. + * @param null|string $previous_status Previous subscription status. + * @param string $updated_status Updated subscription status. + */ + do_action( 'pronamic_subscription_status_update_' . $source . '_' . $old_status . '_to_' . $new_status, $subscription, $can_redirect, $previous_status, $updated_status ); + + /** + * Subscription status updated for plugin integration source. + * + * **Source** + * + * Plugin | Source + * ------ | ------ + * Charitable | `charitable` + * Contact Form 7 | `contact-form-7` + * Event Espresso | `eventespresso` + * Event Espresso (legacy) | `event-espresso` + * Formidable Forms | `formidable-forms` + * Give | `give` + * Gravity Forms | `gravityformsideal` + * MemberPress | `memberpress` + * Ninja Forms | `ninja-forms` + * s2Member | `s2member` + * WooCommerce | `woocommerce` + * WP eCommerce | `wp-e-commerce` + * + * **Action status** + * + * Status | Value + * ------ | ----- + * (empty) | `unknown` + * Active | `active` + * Cancelled | `cancelled` + * Completed | `completed` + * Expired | `expired` + * Failure | `failure` + * On Hold | `on_hold` + * Open | `open` + * + * **Subscription status** + * + * Status | Value + * ------ | ----- + * Active | `Active` + * Cancelled | `Cancelled` + * Completed | `Completed` + * Expired | `Expired` + * Failure | `Failure` + * On Hold | `On Hold` + * Open | `Open` + * + * @param Subscription $subscription Subscription. + * @param bool $can_redirect Flag to indicate if redirect is allowed after the subscription update. + * @param null|string $previous_status Previous subscription status. + * @param string $updated_status Updated subscription status. + */ + do_action( 'pronamic_subscription_status_update_' . $source, $subscription, $can_redirect, $previous_status, $updated_status ); + + /** + * Subscription status updated. + * + * **Subscription status** + * + * Status | Value + * ------ | ----- + * Active | `Active` + * Cancelled | `Cancelled` + * Completed | `Completed` + * Expired | `Expired` + * Failure | `Failure` + * On Hold | `On Hold` + * Open | `Open` + * + * @param Subscription $subscription Subscription. + * @param bool $can_redirect Flag to indicate if redirect is allowed after the subscription update. + * @param null|string $previous_status Previous subscription status. + * @param string $updated_status Updated subscription status. + */ + do_action( 'pronamic_subscription_status_update', $subscription, $can_redirect, $previous_status, $updated_status ); } } } diff --git a/src/Subscriptions/SubscriptionsModule.php b/src/Subscriptions/SubscriptionsModule.php index 15324251..80e9daf7 100644 --- a/src/Subscriptions/SubscriptionsModule.php +++ b/src/Subscriptions/SubscriptionsModule.php @@ -14,6 +14,7 @@ use Pronamic\WordPress\DateTime\DateTime; use Pronamic\WordPress\DateTime\DateTimeImmutable; use Pronamic\WordPress\DateTime\DateTimeZone; +use Pronamic\WordPress\Money\Money; use Pronamic\WordPress\Money\TaxedMoney; use Pronamic\WordPress\Pay\Core\Gateway; use Pronamic\WordPress\Pay\Core\PaymentMethods; @@ -334,7 +335,7 @@ private function handle_subscription_mandate( Subscription $subscription ) { $amount = 0.01; } - $total_amount = new TaxedMoney( + $total_amount = new Money( $amount, $payment->get_total_amount()->get_currency() ); @@ -1023,6 +1024,28 @@ public function send_subscription_renewal_notices() { // Send renewal notice. $source = $subscription->get_source(); + /** + * Send renewal notice for source. + * + * **Source** + * + * Plugin | Source + * ------ | ------ + * Charitable | `charitable` + * Contact Form 7 | `contact-form-7` + * Event Espresso | `eventespresso` + * Event Espresso (legacy) | `event-espresso` + * Formidable Forms | `formidable-forms` + * Give | `give` + * Gravity Forms | `gravityformsideal` + * MemberPress | `memberpress` + * Ninja Forms | `ninja-forms` + * s2Member | `s2member` + * WooCommerce | `woocommerce` + * WP eCommerce | `wp-e-commerce` + * + * @param Subscription $subscription Subscription. + */ do_action( 'pronamic_subscription_renewal_notice_' . $source, $subscription ); // Update renewal notice sent date meta. @@ -1131,8 +1154,8 @@ public function update_subscription_payments( $cli_test = false ) { if ( ! $gateway->supports( 'recurring' ) ) { $now = new DateTime(); - if ( PaymentStatus::COMPLETED !== $subscription->status && isset( $subscription->expiry_date ) && $subscription->expiry_date <= $now ) { - $subscription->status = PaymentStatus::EXPIRED; + if ( SubscriptionStatus::COMPLETED !== $subscription->status && isset( $subscription->expiry_date ) && $subscription->expiry_date <= $now ) { + $subscription->status = SubscriptionStatus::EXPIRED; $subscription->save(); diff --git a/src/Subscriptions/SubscriptionsPrivacy.php b/src/Subscriptions/SubscriptionsPrivacy.php index 7bb42879..a1cafc9c 100644 --- a/src/Subscriptions/SubscriptionsPrivacy.php +++ b/src/Subscriptions/SubscriptionsPrivacy.php @@ -198,7 +198,7 @@ public function subscriptions_anonymizer( $email_address, $page = 1 ) { $message = __( 'Subscription ID %s anonymized.', 'pronamic_ideal' ); // Anonymize completed and cancelled subscriptions. - if ( isset( $subscription_status ) && in_array( $subscription_status, array( PaymentStatus::COMPLETED, PaymentStatus::CANCELLED ), true ) ) { + if ( isset( $subscription_status ) && in_array( $subscription_status, array( SubscriptionStatus::COMPLETED, SubscriptionStatus::CANCELLED ), true ) ) { // Erase subscription meta. foreach ( $meta_keys as $meta_key => $meta_options ) { $meta_key = $data_store->meta_key_prefix . $meta_key; diff --git a/src/TaxedMoneyJsonTransformer.php b/src/TaxedMoneyJsonTransformer.php deleted file mode 100644 index de0b9f1b..00000000 --- a/src/TaxedMoneyJsonTransformer.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright 2005-2021 Pronamic - * @license GPL-3.0-or-later - * @package Pronamic\WordPress\Pay - */ - -namespace Pronamic\WordPress\Pay; - -use InvalidArgumentException; -use Pronamic\WordPress\Money\TaxedMoney; - -/** - * Taxed money JSON transformer - * - * @author Remco Tolsma - * @version 2.0.8 - * @since 2.0.8 - */ -class TaxedMoneyJsonTransformer { - /** - * Convert taxed money object to JSON. - * - * @param TaxedMoney|null $money Money. - * - * @return null|object - */ - public static function to_json( TaxedMoney $money = null ) { - if ( null === $money ) { - return null; - } - - $object = MoneyJsonTransformer::to_json( $money ); - - if ( null === $object ) { - return null; - } - - $properties = (array) $object; - - if ( null !== $money->get_tax_value() ) { - $properties['tax_value'] = $money->get_tax_value(); - } - - if ( null !== $money->get_tax_percentage() ) { - $properties['tax_percentage'] = $money->get_tax_percentage(); - } - - $object = (object) $properties; - - return $object; - } - - /** - * Convert JSON to taxed money object. - * - * @param mixed $json JSON. - * - * @return TaxedMoney - * - * @throws InvalidArgumentException Throws invalid argument exception when JSON is not an object. - */ - public static function from_json( $json ) { - if ( ! is_object( $json ) ) { - throw new InvalidArgumentException( 'JSON value must be an object.' ); - } - - // Default arguments. - $value = 0; - $currency = null; - $tax_value = null; - $tax_percentage = null; - - if ( property_exists( $json, 'value' ) ) { - $value = $json->value; - } - - if ( property_exists( $json, 'currency' ) ) { - $currency = $json->currency; - } - - if ( property_exists( $json, 'tax_value' ) ) { - $tax_value = $json->tax_value; - } - - if ( property_exists( $json, 'tax_percentage' ) ) { - $tax_percentage = $json->tax_percentage; - } - - $money = new TaxedMoney( $value, $currency, $tax_value, $tax_percentage ); - - return $money; - } -} diff --git a/src/Util.php b/src/Util.php index 09b8efc4..add7afff 100644 --- a/src/Util.php +++ b/src/Util.php @@ -63,16 +63,16 @@ public static function simplexml_load_string( $string ) { * * @param float $price The amount to convert to cents. * - * @deprecated 2.0.9 Use \Pronamic\WordPress\Money\Money::get_cents() instead. + * @deprecated 2.0.9 Use \Pronamic\WordPress\Money\Money::get_minor_units()->to_int() instead. * - * @return float + * @return int */ public static function amount_to_cents( $price ) { - _deprecated_function( __FUNCTION__, '2.0.9', 'Pronamic\WordPress\Money\Money::get_cents()' ); + _deprecated_function( __FUNCTION__, '2.0.9', 'Pronamic\WordPress\Money\Money::get_minor_units()->to_int()' ); $money = new Money( $price ); - return $money->get_cents(); + return $money->get_minor_units()->to_int(); } /** diff --git a/tests/json/money.json b/tests/json/money.json index 596ac56b..eb26a557 100644 --- a/tests/json/money.json +++ b/tests/json/money.json @@ -1,4 +1,4 @@ { - "value": 12.34, + "value": "12.34", "currency": "EUR" } diff --git a/tests/json/payment-line.json b/tests/json/payment-line.json index 729319c2..c7ce4d33 100644 --- a/tests/json/payment-line.json +++ b/tests/json/payment-line.json @@ -1,18 +1,18 @@ { "quantity":2, "unit_price":{ - "value":121, + "value":"121", "currency":"EUR", - "tax_value":21 + "tax_value":"21" }, "discount_amount":{ - "value":21, + "value":"21", "currency":"EUR" }, "total_amount":{ - "value":242, + "value":"242", "currency":"EUR", - "tax_value":42, - "tax_percentage":21 + "tax_value":"42", + "tax_percentage":"21" } } diff --git a/tests/json/payment-lines.json b/tests/json/payment-lines.json index eebf7a86..5b3fe092 100644 --- a/tests/json/payment-lines.json +++ b/tests/json/payment-lines.json @@ -4,7 +4,7 @@ "description":"Lorem ipsum dolor sit amet.", "quantity":50, "total_amount":{ - "value":39.99, + "value":"39.99", "currency":"EUR" } }, @@ -13,19 +13,19 @@ "description":"Lorem ipsum dolor sit amet.", "quantity":10, "total_amount":{ - "value":25, + "value":"25", "currency":"EUR" } }, { "total_amount":{ - "value":0, + "value":"0", "currency":"EUR" } }, { "total_amount":{ - "value":0, + "value":"0", "currency":"EUR" } } diff --git a/tests/json/payment.json b/tests/json/payment.json index 6f008074..8ac1e343 100644 --- a/tests/json/payment.json +++ b/tests/json/payment.json @@ -62,7 +62,7 @@ "description":"Lorem ipsum dolor sit amet.", "quantity":50, "total_amount":{ - "value":39.99, + "value":"39.99", "currency":"EUR" } }, @@ -71,10 +71,10 @@ "description":"Lorem ipsum dolor sit amet.", "quantity":10, "total_amount":{ - "value":25, + "value":"25", "currency":"EUR", - "tax_value":5.25, - "tax_percentage":21 + "tax_value":"5.25", + "tax_percentage":"21" } } ], @@ -104,10 +104,10 @@ "end_date": "2100-05-05T00:00:00+00:00", "expiry_date": "2005-05-05T00:30:00+00:00", "total_amount": { - "value": 242, + "value": "242", "currency": "EUR", - "tax_value": 42, - "tax_percentage": 21 + "tax_value": "42", + "tax_percentage": "21" }, "status":"Open", "failure_reason": { diff --git a/tests/src/MoneyJsonTransformerTest.php b/tests/src/MoneyJsonTransformerTest.php index c2593792..02bd8d42 100644 --- a/tests/src/MoneyJsonTransformerTest.php +++ b/tests/src/MoneyJsonTransformerTest.php @@ -39,20 +39,13 @@ public function test_json() { $json_data = json_decode( file_get_contents( $json_file, true ) ); - $json_string = wp_json_encode( MoneyJsonTransformer::to_json( $money ), JSON_PRETTY_PRINT ); + $json_string = wp_json_encode( $money, JSON_PRETTY_PRINT ); $this->assertEquals( wp_json_encode( $json_data, JSON_PRETTY_PRINT ), $json_string ); $this->assertJsonStringEqualsJsonFile( $json_file, strval( $json_string ) ); } - /** - * Test to JSON empty. - */ - public function test_to_json_empty() { - self::assertNull( MoneyJsonTransformer::to_json() ); - } - /** * Test from JSON invalid. */ diff --git a/tests/src/Payments/PaymentTest.php b/tests/src/Payments/PaymentTest.php index fcbdb0d5..0ce30f14 100644 --- a/tests/src/Payments/PaymentTest.php +++ b/tests/src/Payments/PaymentTest.php @@ -271,7 +271,7 @@ public function test_json() { $line->set_id( '1234' ); $line->set_description( 'Lorem ipsum dolor sit amet.' ); $line->set_quantity( 50 ); - $line->set_total_amount( new TaxedMoney( 39.99, 'EUR' ) ); + $line->set_total_amount( new Money( 39.99, 'EUR' ) ); $line = $lines->new_line(); $line->set_id( 5678 ); diff --git a/vendor-bin/phpdocumentor/composer.lock b/vendor-bin/phpdocumentor/composer.lock index 2d099426..fd0bcbcb 100644 --- a/vendor-bin/phpdocumentor/composer.lock +++ b/vendor-bin/phpdocumentor/composer.lock @@ -14,5 +14,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.1.0" } diff --git a/vendor-bin/phpstan/composer.lock b/vendor-bin/phpstan/composer.lock index d141c90d..9a30fb50 100644 --- a/vendor-bin/phpstan/composer.lock +++ b/vendor-bin/phpstan/composer.lock @@ -9,16 +9,16 @@ "packages-dev": [ { "name": "php-stubs/wordpress-stubs", - "version": "v5.7.1", + "version": "v5.8.0", "source": { "type": "git", "url": "https://github.com/php-stubs/wordpress-stubs.git", - "reference": "9705d1d0ac8e5000fdcdc96b4d5fd12e429c125d" + "reference": "794e6eedfd5f2a334d581214c007fc398be588fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/9705d1d0ac8e5000fdcdc96b4d5fd12e429c125d", - "reference": "9705d1d0ac8e5000fdcdc96b4d5fd12e429c125d", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/794e6eedfd5f2a334d581214c007fc398be588fe", + "reference": "794e6eedfd5f2a334d581214c007fc398be588fe", "shasum": "" }, "replace": { @@ -47,22 +47,22 @@ ], "support": { "issues": "https://github.com/php-stubs/wordpress-stubs/issues", - "source": "https://github.com/php-stubs/wordpress-stubs/tree/v5.7.1" + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v5.8.0" }, - "time": "2021-04-15T14:47:11+00:00" + "time": "2021-07-21T02:34:37+00:00" }, { "name": "phpstan/phpstan", - "version": "0.12.88", + "version": "0.12.94", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "464d1a81af49409c41074aa6640ed0c4cbd9bb68" + "reference": "3d0ba4c198a24e3c3fc489f3ec6ac9612c4be5d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/464d1a81af49409c41074aa6640ed0c4cbd9bb68", - "reference": "464d1a81af49409c41074aa6640ed0c4cbd9bb68", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/3d0ba4c198a24e3c3fc489f3ec6ac9612c4be5d6", + "reference": "3d0ba4c198a24e3c3fc489f3ec6ac9612c4be5d6", "shasum": "" }, "require": { @@ -93,13 +93,17 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.88" + "source": "https://github.com/phpstan/phpstan/tree/0.12.94" }, "funding": [ { "url": "https://github.com/ondrejmirtes", "type": "github" }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, { "url": "https://www.patreon.com/phpstan", "type": "patreon" @@ -109,7 +113,7 @@ "type": "tidelift" } ], - "time": "2021-05-17T12:24:49+00:00" + "time": "2021-07-30T09:05:27+00:00" }, { "name": "symfony/polyfill-php73", @@ -192,16 +196,16 @@ }, { "name": "szepeviktor/phpstan-wordpress", - "version": "v0.7.5", + "version": "v0.7.7", "source": { "type": "git", "url": "https://github.com/szepeviktor/phpstan-wordpress.git", - "reference": "90cf3c6a225a633889b1b3a556816911f42de4f7" + "reference": "bdbea69b2ba4a69998c3b6fe2b7106d78a23bd72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/90cf3c6a225a633889b1b3a556816911f42de4f7", - "reference": "90cf3c6a225a633889b1b3a556816911f42de4f7", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/bdbea69b2ba4a69998c3b6fe2b7106d78a23bd72", + "reference": "bdbea69b2ba4a69998c3b6fe2b7106d78a23bd72", "shasum": "" }, "require": { @@ -211,7 +215,7 @@ "symfony/polyfill-php73": "^1.12.0" }, "require-dev": { - "composer/composer": "^1.8.6", + "composer/composer": "^1.10.22", "dealerdirect/phpcodesniffer-composer-installer": "^0.7", "php-parallel-lint/php-parallel-lint": "^1.1", "phpstan/phpstan-strict-rules": "^0.12", @@ -227,7 +231,7 @@ }, "autoload": { "psr-4": { - "PHPStan\\WordPress\\": "src/" + "SzepeViktor\\PHPStan\\WordPress\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -244,7 +248,7 @@ ], "support": { "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", - "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v0.7.5" + "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v0.7.7" }, "funding": [ { @@ -252,7 +256,7 @@ "type": "custom" } ], - "time": "2021-03-19T21:23:23+00:00" + "time": "2021-07-14T09:19:15+00:00" } ], "aliases": [], @@ -262,5 +266,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.1.0" } diff --git a/vendor-bin/psalm/composer.lock b/vendor-bin/psalm/composer.lock index b4a52c16..77e45f6f 100644 --- a/vendor-bin/psalm/composer.lock +++ b/vendor-bin/psalm/composer.lock @@ -9,27 +9,27 @@ "packages-dev": [ { "name": "amphp/amp", - "version": "v2.5.2", + "version": "v2.6.0", "source": { "type": "git", "url": "https://github.com/amphp/amp.git", - "reference": "efca2b32a7580087adb8aabbff6be1dc1bb924a9" + "reference": "caa95edeb1ca1bf7532e9118ede4a3c3126408cc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/efca2b32a7580087adb8aabbff6be1dc1bb924a9", - "reference": "efca2b32a7580087adb8aabbff6be1dc1bb924a9", + "url": "https://api.github.com/repos/amphp/amp/zipball/caa95edeb1ca1bf7532e9118ede4a3c3126408cc", + "reference": "caa95edeb1ca1bf7532e9118ede4a3c3126408cc", "shasum": "" }, "require": { - "php": ">=7" + "php": ">=7.1" }, "require-dev": { "amphp/php-cs-fixer-config": "dev-master", "amphp/phpunit-util": "^1", "ext-json": "*", "jetbrains/phpstorm-stubs": "^2019.3", - "phpunit/phpunit": "^6.0.9 | ^7", + "phpunit/phpunit": "^7 | ^8 | ^9", "psalm/phar": "^3.11@dev", "react/promise": "^2" }, @@ -86,7 +86,7 @@ "support": { "irc": "irc://irc.freenode.org/amphp", "issues": "https://github.com/amphp/amp/issues", - "source": "https://github.com/amphp/amp/tree/v2.5.2" + "source": "https://github.com/amphp/amp/tree/v2.6.0" }, "funding": [ { @@ -94,7 +94,7 @@ "type": "github" } ], - "time": "2021-01-10T17:06:37+00:00" + "time": "2021-07-16T20:06:06+00:00" }, { "name": "amphp/byte-stream", @@ -329,21 +329,21 @@ }, { "name": "composer/xdebug-handler", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "964adcdd3a28bf9ed5d9ac6450064e0d71ed7496" + "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/964adcdd3a28bf9ed5d9ac6450064e0d71ed7496", - "reference": "964adcdd3a28bf9ed5d9ac6450064e0d71ed7496", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/84674dd3a7575ba617f5a76d7e9e29a7d3891339", + "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339", "shasum": "" }, "require": { "php": "^5.3.2 || ^7.0 || ^8.0", - "psr/log": "^1.0" + "psr/log": "^1 || ^2 || ^3" }, "require-dev": { "phpstan/phpstan": "^0.12.55", @@ -373,7 +373,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/2.0.1" + "source": "https://github.com/composer/xdebug-handler/tree/2.0.2" }, "funding": [ { @@ -389,7 +389,7 @@ "type": "tidelift" } ], - "time": "2021-05-05T19:37:51+00:00" + "time": "2021-07-31T17:03:58+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -430,20 +430,20 @@ }, { "name": "felixfbecker/advanced-json-rpc", - "version": "v3.2.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git", - "reference": "06f0b06043c7438959dbdeed8bb3f699a19be22e" + "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/06f0b06043c7438959dbdeed8bb3f699a19be22e", - "reference": "06f0b06043c7438959dbdeed8bb3f699a19be22e", + "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/b5f37dbff9a8ad360ca341f3240dc1c168b45447", + "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447", "shasum": "" }, "require": { - "netresearch/jsonmapper": "^1.0 || ^2.0", + "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", "php": "^7.1 || ^8.0", "phpdocumentor/reflection-docblock": "^4.3.4 || ^5.0.0" }, @@ -469,9 +469,9 @@ "description": "A more advanced JSONRPC implementation", "support": { "issues": "https://github.com/felixfbecker/php-advanced-json-rpc/issues", - "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/v3.2.0" + "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/v3.2.1" }, - "time": "2021-01-10T17:48:47+00:00" + "time": "2021-06-11T22:34:44+00:00" }, { "name": "felixfbecker/language-server-protocol", @@ -531,16 +531,16 @@ }, { "name": "netresearch/jsonmapper", - "version": "v2.1.0", + "version": "v4.0.0", "source": { "type": "git", "url": "https://github.com/cweiske/jsonmapper.git", - "reference": "e0f1e33a71587aca81be5cffbb9746510e1fe04e" + "reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/e0f1e33a71587aca81be5cffbb9746510e1fe04e", - "reference": "e0f1e33a71587aca81be5cffbb9746510e1fe04e", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d", + "reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d", "shasum": "" }, "require": { @@ -548,10 +548,10 @@ "ext-pcre": "*", "ext-reflection": "*", "ext-spl": "*", - "php": ">=5.6" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "~4.8.35 || ~5.7 || ~6.4 || ~7.0", + "phpunit/phpunit": "~7.5 || ~8.0 || ~9.0", "squizlabs/php_codesniffer": "~3.5" }, "type": "library", @@ -576,22 +576,22 @@ "support": { "email": "cweiske@cweiske.de", "issues": "https://github.com/cweiske/jsonmapper/issues", - "source": "https://github.com/cweiske/jsonmapper/tree/master" + "source": "https://github.com/cweiske/jsonmapper/tree/v4.0.0" }, - "time": "2020-04-16T18:48:43+00:00" + "time": "2020-12-01T19:48:11+00:00" }, { "name": "nikic/php-parser", - "version": "v4.10.5", + "version": "v4.12.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f" + "reference": "6608f01670c3cc5079e18c1dab1104e002579143" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4432ba399e47c66624bc73c8c0f811e5c109576f", - "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6608f01670c3cc5079e18c1dab1104e002579143", + "reference": "6608f01670c3cc5079e18c1dab1104e002579143", "shasum": "" }, "require": { @@ -632,9 +632,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.10.5" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.12.0" }, - "time": "2021-05-03T19:11:20+00:00" + "time": "2021-07-21T10:44:31+00:00" }, { "name": "openlss/lib-array2xml", @@ -1013,27 +1013,29 @@ }, { "name": "symfony/console", - "version": "v5.2.8", + "version": "v5.3.6", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "864568fdc0208b3eba3638b6000b69d2386e6768" + "reference": "51b71afd6d2dc8f5063199357b9880cea8d8bfe2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/864568fdc0208b3eba3638b6000b69d2386e6768", - "reference": "864568fdc0208b3eba3638b6000b69d2386e6768", + "url": "https://api.github.com/repos/symfony/console/zipball/51b71afd6d2dc8f5063199357b9880cea8d8bfe2", + "reference": "51b71afd6d2dc8f5063199357b9880cea8d8bfe2", "shasum": "" }, "require": { "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php73": "^1.8", - "symfony/polyfill-php80": "^1.15", + "symfony/polyfill-php80": "^1.16", "symfony/service-contracts": "^1.1|^2", "symfony/string": "^5.1" }, "conflict": { + "psr/log": ">=3", "symfony/dependency-injection": "<4.4", "symfony/dotenv": "<5.1", "symfony/event-dispatcher": "<4.4", @@ -1041,10 +1043,10 @@ "symfony/process": "<4.4" }, "provide": { - "psr/log-implementation": "1.0" + "psr/log-implementation": "1.0|2.0" }, "require-dev": { - "psr/log": "~1.0", + "psr/log": "^1|^2", "symfony/config": "^4.4|^5.0", "symfony/dependency-injection": "^4.4|^5.0", "symfony/event-dispatcher": "^4.4|^5.0", @@ -1090,7 +1092,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.2.8" + "source": "https://github.com/symfony/console/tree/v5.3.6" }, "funding": [ { @@ -1106,7 +1108,74 @@ "type": "tidelift" } ], - "time": "2021-05-11T15:45:21+00:00" + "time": "2021-07-27T19:10:22+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-03-23T23:28:01+00:00" }, { "name": "symfony/polyfill-ctype", @@ -1189,16 +1258,16 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.23.0", + "version": "v1.23.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "24b72c6baa32c746a4d0840147c9715e42bb68ab" + "reference": "16880ba9c5ebe3642d1995ab866db29270b36535" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/24b72c6baa32c746a4d0840147c9715e42bb68ab", - "reference": "24b72c6baa32c746a4d0840147c9715e42bb68ab", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/16880ba9c5ebe3642d1995ab866db29270b36535", + "reference": "16880ba9c5ebe3642d1995ab866db29270b36535", "shasum": "" }, "require": { @@ -1250,7 +1319,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.1" }, "funding": [ { @@ -1266,7 +1335,7 @@ "type": "tidelift" } ], - "time": "2021-05-27T09:17:38+00:00" + "time": "2021-05-27T12:26:48+00:00" }, { "name": "symfony/polyfill-intl-normalizer", @@ -1354,16 +1423,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.23.0", + "version": "v1.23.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1" + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2df51500adbaebdc4c38dea4c89a2e131c45c8a1", - "reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", "shasum": "" }, "require": { @@ -1414,7 +1483,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" }, "funding": [ { @@ -1430,7 +1499,7 @@ "type": "tidelift" } ], - "time": "2021-05-27T09:27:20+00:00" + "time": "2021-05-27T12:26:48+00:00" }, { "name": "symfony/polyfill-php73", @@ -1513,16 +1582,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.23.0", + "version": "v1.23.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0" + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/eca0bf41ed421bed1b57c4958bab16aa86b757d0", - "reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", "shasum": "" }, "require": { @@ -1576,7 +1645,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" }, "funding": [ { @@ -1592,7 +1661,7 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2021-07-28T13:41:28+00:00" }, { "name": "symfony/service-contracts", @@ -1675,16 +1744,16 @@ }, { "name": "symfony/string", - "version": "v5.2.8", + "version": "v5.3.3", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "01b35eb64cac8467c3f94cd0ce2d0d376bb7d1db" + "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/01b35eb64cac8467c3f94cd0ce2d0d376bb7d1db", - "reference": "01b35eb64cac8467c3f94cd0ce2d0d376bb7d1db", + "url": "https://api.github.com/repos/symfony/string/zipball/bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1", + "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1", "shasum": "" }, "require": { @@ -1738,7 +1807,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.2.8" + "source": "https://github.com/symfony/string/tree/v5.3.3" }, "funding": [ { @@ -1754,20 +1823,20 @@ "type": "tidelift" } ], - "time": "2021-05-10T14:56:10+00:00" + "time": "2021-06-27T11:44:38+00:00" }, { "name": "vimeo/psalm", - "version": "4.7.3", + "version": "4.9.2", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "38c452ae584467e939d55377aaf83b5a26f19dd1" + "reference": "00c062267d6e3229d91a1939992987e2d46f2393" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/38c452ae584467e939d55377aaf83b5a26f19dd1", - "reference": "38c452ae584467e939d55377aaf83b5a26f19dd1", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/00c062267d6e3229d91a1939992987e2d46f2393", + "reference": "00c062267d6e3229d91a1939992987e2d46f2393", "shasum": "" }, "require": { @@ -1786,7 +1855,7 @@ "felixfbecker/advanced-json-rpc": "^3.0.3", "felixfbecker/language-server-protocol": "^1.5", "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", - "nikic/php-parser": "^4.10.5", + "nikic/php-parser": "^4.12", "openlss/lib-array2xml": "^1.0", "php": "^7.1|^8", "sebastian/diff": "^3.0 || ^4.0", @@ -1805,10 +1874,10 @@ "phpmyadmin/sql-parser": "5.1.0||dev-master", "phpspec/prophecy": ">=1.9.0", "phpunit/phpunit": "^9.0", - "psalm/plugin-phpunit": "^0.13", + "psalm/plugin-phpunit": "^0.16", "slevomat/coding-standard": "^7.0", "squizlabs/php_codesniffer": "^3.5", - "symfony/process": "^4.3", + "symfony/process": "^4.3 || ^5.0", "weirdan/phpunit-appveyor-reporter": "^1.0.0", "weirdan/prophecy-shim": "^1.0 || ^2.0" }, @@ -1857,9 +1926,9 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/4.7.3" + "source": "https://github.com/vimeo/psalm/tree/4.9.2" }, - "time": "2021-05-24T04:09:51+00:00" + "time": "2021-08-01T01:15:26+00:00" }, { "name": "webmozart/assert", @@ -1977,5 +2046,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.1.0" } diff --git a/vendor-bin/wp-documentor/composer.lock b/vendor-bin/wp-documentor/composer.lock index e7a12377..c61ed662 100644 --- a/vendor-bin/wp-documentor/composer.lock +++ b/vendor-bin/wp-documentor/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "nikic/php-parser", - "version": "v4.10.5", + "version": "v4.12.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f" + "reference": "6608f01670c3cc5079e18c1dab1104e002579143" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4432ba399e47c66624bc73c8c0f811e5c109576f", - "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6608f01670c3cc5079e18c1dab1104e002579143", + "reference": "6608f01670c3cc5079e18c1dab1104e002579143", "shasum": "" }, "require": { @@ -58,9 +58,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.10.5" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.12.0" }, - "time": "2021-05-03T19:11:20+00:00" + "time": "2021-07-21T10:44:31+00:00" }, { "name": "phpdocumentor/reflection", @@ -278,16 +278,16 @@ }, { "name": "pronamic/wp-documentor", - "version": "1.1.0", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/pronamic/wp-documentor.git", - "reference": "12f09a2d9e5768f6188fc6104a1e0d8f68e98df4" + "reference": "886d98c3bf3ca7eba8dc84061e98a25cc98d6d0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pronamic/wp-documentor/zipball/12f09a2d9e5768f6188fc6104a1e0d8f68e98df4", - "reference": "12f09a2d9e5768f6188fc6104a1e0d8f68e98df4", + "url": "https://api.github.com/repos/pronamic/wp-documentor/zipball/886d98c3bf3ca7eba8dc84061e98a25cc98d6d0c", + "reference": "886d98c3bf3ca7eba8dc84061e98a25cc98d6d0c", "shasum": "" }, "require": { @@ -344,9 +344,9 @@ ], "support": { "issues": "https://github.com/pronamic/wp-documentor/issues", - "source": "https://github.com/pronamic/wp-documentor/tree/1.1.0" + "source": "https://github.com/pronamic/wp-documentor/tree/1.1.1" }, - "time": "2021-04-16T14:50:29+00:00" + "time": "2021-06-10T11:09:50+00:00" }, { "name": "psr/container", @@ -448,27 +448,29 @@ }, { "name": "symfony/console", - "version": "v5.2.8", + "version": "v5.3.6", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "864568fdc0208b3eba3638b6000b69d2386e6768" + "reference": "51b71afd6d2dc8f5063199357b9880cea8d8bfe2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/864568fdc0208b3eba3638b6000b69d2386e6768", - "reference": "864568fdc0208b3eba3638b6000b69d2386e6768", + "url": "https://api.github.com/repos/symfony/console/zipball/51b71afd6d2dc8f5063199357b9880cea8d8bfe2", + "reference": "51b71afd6d2dc8f5063199357b9880cea8d8bfe2", "shasum": "" }, "require": { "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php73": "^1.8", - "symfony/polyfill-php80": "^1.15", + "symfony/polyfill-php80": "^1.16", "symfony/service-contracts": "^1.1|^2", "symfony/string": "^5.1" }, "conflict": { + "psr/log": ">=3", "symfony/dependency-injection": "<4.4", "symfony/dotenv": "<5.1", "symfony/event-dispatcher": "<4.4", @@ -476,10 +478,10 @@ "symfony/process": "<4.4" }, "provide": { - "psr/log-implementation": "1.0" + "psr/log-implementation": "1.0|2.0" }, "require-dev": { - "psr/log": "~1.0", + "psr/log": "^1|^2", "symfony/config": "^4.4|^5.0", "symfony/dependency-injection": "^4.4|^5.0", "symfony/event-dispatcher": "^4.4|^5.0", @@ -525,7 +527,74 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.2.8" + "source": "https://github.com/symfony/console/tree/v5.3.6" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-07-27T19:10:22+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" }, "funding": [ { @@ -541,25 +610,26 @@ "type": "tidelift" } ], - "time": "2021-05-11T15:45:21+00:00" + "time": "2021-03-23T23:28:01+00:00" }, { "name": "symfony/filesystem", - "version": "v5.2.7", + "version": "v5.3.4", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "056e92acc21d977c37e6ea8e97374b2a6c8551b0" + "reference": "343f4fe324383ca46792cae728a3b6e2f708fb32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/056e92acc21d977c37e6ea8e97374b2a6c8551b0", - "reference": "056e92acc21d977c37e6ea8e97374b2a6c8551b0", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/343f4fe324383ca46792cae728a3b6e2f708fb32", + "reference": "343f4fe324383ca46792cae728a3b6e2f708fb32", "shasum": "" }, "require": { "php": ">=7.2.5", - "symfony/polyfill-ctype": "~1.8" + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.16" }, "type": "library", "autoload": { @@ -587,7 +657,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.2.7" + "source": "https://github.com/symfony/filesystem/tree/v5.3.4" }, "funding": [ { @@ -603,24 +673,25 @@ "type": "tidelift" } ], - "time": "2021-04-01T10:42:13+00:00" + "time": "2021-07-21T12:40:44+00:00" }, { "name": "symfony/finder", - "version": "v5.2.9", + "version": "v5.3.4", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "ccccb9d48ca42757dd12f2ca4bf857a4e217d90d" + "reference": "17f50e06018baec41551a71a15731287dbaab186" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ccccb9d48ca42757dd12f2ca4bf857a4e217d90d", - "reference": "ccccb9d48ca42757dd12f2ca4bf857a4e217d90d", + "url": "https://api.github.com/repos/symfony/finder/zipball/17f50e06018baec41551a71a15731287dbaab186", + "reference": "17f50e06018baec41551a71a15731287dbaab186", "shasum": "" }, "require": { - "php": ">=7.2.5" + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.16" }, "type": "library", "autoload": { @@ -648,7 +719,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.2.9" + "source": "https://github.com/symfony/finder/tree/v5.3.4" }, "funding": [ { @@ -664,7 +735,7 @@ "type": "tidelift" } ], - "time": "2021-05-16T13:07:46+00:00" + "time": "2021-07-23T15:54:19+00:00" }, { "name": "symfony/polyfill-ctype", @@ -747,16 +818,16 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.23.0", + "version": "v1.23.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "24b72c6baa32c746a4d0840147c9715e42bb68ab" + "reference": "16880ba9c5ebe3642d1995ab866db29270b36535" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/24b72c6baa32c746a4d0840147c9715e42bb68ab", - "reference": "24b72c6baa32c746a4d0840147c9715e42bb68ab", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/16880ba9c5ebe3642d1995ab866db29270b36535", + "reference": "16880ba9c5ebe3642d1995ab866db29270b36535", "shasum": "" }, "require": { @@ -808,7 +879,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.1" }, "funding": [ { @@ -824,7 +895,7 @@ "type": "tidelift" } ], - "time": "2021-05-27T09:17:38+00:00" + "time": "2021-05-27T12:26:48+00:00" }, { "name": "symfony/polyfill-intl-normalizer", @@ -912,16 +983,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.23.0", + "version": "v1.23.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1" + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2df51500adbaebdc4c38dea4c89a2e131c45c8a1", - "reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", "shasum": "" }, "require": { @@ -972,7 +1043,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" }, "funding": [ { @@ -988,7 +1059,7 @@ "type": "tidelift" } ], - "time": "2021-05-27T09:27:20+00:00" + "time": "2021-05-27T12:26:48+00:00" }, { "name": "symfony/polyfill-php73", @@ -1071,16 +1142,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.23.0", + "version": "v1.23.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0" + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/eca0bf41ed421bed1b57c4958bab16aa86b757d0", - "reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", "shasum": "" }, "require": { @@ -1134,7 +1205,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" }, "funding": [ { @@ -1150,7 +1221,7 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2021-07-28T13:41:28+00:00" }, { "name": "symfony/service-contracts", @@ -1233,16 +1304,16 @@ }, { "name": "symfony/string", - "version": "v5.2.8", + "version": "v5.3.3", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "01b35eb64cac8467c3f94cd0ce2d0d376bb7d1db" + "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/01b35eb64cac8467c3f94cd0ce2d0d376bb7d1db", - "reference": "01b35eb64cac8467c3f94cd0ce2d0d376bb7d1db", + "url": "https://api.github.com/repos/symfony/string/zipball/bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1", + "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1", "shasum": "" }, "require": { @@ -1296,7 +1367,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.2.8" + "source": "https://github.com/symfony/string/tree/v5.3.3" }, "funding": [ { @@ -1312,7 +1383,7 @@ "type": "tidelift" } ], - "time": "2021-05-10T14:56:10+00:00" + "time": "2021-06-27T11:44:38+00:00" }, { "name": "webmozart/assert", @@ -1381,5 +1452,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.1.0" } diff --git a/views/form.php b/views/form.php index 939a816f..9b8c021a 100644 --- a/views/form.php +++ b/views/form.php @@ -17,6 +17,10 @@ use Pronamic\WordPress\Pay\Plugin; use Pronamic\WordPress\Pay\Util; +if ( ! isset( $settings ) ) { + return; +} + $methods_with_choices = array( \Pronamic\WordPress\Pay\Forms\FormPostType::AMOUNT_METHOD_CHOICES_ONLY, \Pronamic\WordPress\Pay\Forms\FormPostType::AMOUNT_METHOD_CHOICES_AND_INPUT, diff --git a/views/meta-box-form-options.php b/views/meta-box-form-options.php index 20277c55..0aecb457 100644 --- a/views/meta-box-form-options.php +++ b/views/meta-box-form-options.php @@ -10,6 +10,10 @@ use Pronamic\WordPress\Money\Money; +if ( ! isset( $post ) ) { + return; +} + wp_nonce_field( 'pronamic_pay_save_form_options', 'pronamic_pay_nonce' ); ?> diff --git a/views/meta-box-payment-lines.php b/views/meta-box-payment-lines.php index 27801977..5364ea65 100644 --- a/views/meta-box-payment-lines.php +++ b/views/meta-box-payment-lines.php @@ -11,12 +11,14 @@ namespace Pronamic\WordPress\Pay; use Pronamic\WordPress\Money\Money; +use Pronamic\WordPress\Money\TaxedMoney; +use Pronamic\WordPress\Number\Number; use Pronamic\WordPress\Pay\Payments\PaymentLine; if ( empty( $lines ) ) : ?>

- +

@@ -25,29 +27,29 @@ - - - - + + + + - + - + @@ -77,93 +79,60 @@ @@ -175,17 +144,17 @@ function( PaymentLine $line ) { - - + + - + diff --git a/views/tab-system_status.php b/views/tab-system_status.php index f890ab35..88647d31 100644 --- a/views/tab-system_status.php +++ b/views/tab-system_status.php @@ -108,10 +108,10 @@
%s', - esc_attr__( 'Unit price with discount including tax.', 'pronamic_ideal' ), - esc_html__( 'Unit Price', 'pronamic_ideal' ) + \esc_attr__( 'Unit price with discount including tax.', 'pronamic_ideal' ), + \esc_html__( 'Unit Price', 'pronamic_ideal' ) ); ?> %s', - esc_attr__( 'Total discount.', 'pronamic_ideal' ), - esc_html__( 'Discount', 'pronamic_ideal' ) + \esc_attr__( 'Total discount.', 'pronamic_ideal' ), + \esc_html__( 'Discount', 'pronamic_ideal' ) ); ?> @@ -55,15 +57,15 @@ %s', - esc_attr__( 'Total amount with discount including tax.', 'pronamic_ideal' ), - esc_html__( 'Total Amount', 'pronamic_ideal' ) + \esc_attr__( 'Total amount with discount including tax.', 'pronamic_ideal' ), + \esc_html__( 'Total Amount', 'pronamic_ideal' ) ); ?>
get_quantity(); - }, - $lines->get_array() - ); + $quantity_total = new Number( 0 ); - echo esc_html( array_sum( $quantities ) ); + foreach ( $lines as $line ) { + $quantity = $line->get_quantity(); + + if ( null !== $quantity ) { + $quantity_total = $quantity_total->add( Number::from_int( $quantity ) ); + } + } + + echo \esc_html( $quantity_total->format_i18n() ); ?> get_discount_amount() ) { - return $line->get_discount_amount()->get_value(); - } + $discount_amount = $line->get_discount_amount(); + + return ( null === $discount_amount ) ? null : $discount_amount->get_value(); }, $lines->get_array() ); - $discount_amount = new Money( array_sum( $values ), $lines->get_amount()->get_currency() ); + $discount_amount = new Money( \array_sum( $values ), $lines->get_amount()->get_currency() ); - echo esc_html( $discount_amount ); + echo \esc_html( $discount_amount->format_i18n() ); ?> - get_total_amount()->get_excluding_tax()->get_value(); - }, - $lines->get_array() - ); - - $total_exclusive = new Money( array_sum( $values ), $lines->get_amount()->get_currency() ); - - $tip = array( - sprintf( - /* translators: %s: price excluding tax */ - __( 'Exclusive tax: %s', 'pronamic_ideal' ), - $total_exclusive - ), - ); - - if ( $lines->get_amount()->has_tax() ) { - $values = array_map( - function ( PaymentLine $line ) { - return $line->get_total_amount()->get_including_tax()->get_value(); - }, - $lines->get_array() - ); - - $total_inclusive = new Money( array_sum( $values ), $lines->get_amount()->get_currency() ); - - $tip[] = sprintf( - /* translators: %s: price including tax */ - __( 'Inclusive tax: %s', 'pronamic_ideal' ), - $total_inclusive - ); - } - - printf( - '%s', - esc_attr( implode( '
', $tip ) ), - esc_html( $total_exclusive ) - ); - - ?> + get_amount()->format_i18n() ); ?>
get_total_amount()->get_tax_value(); + $total_amount = $line->get_total_amount(); + + if ( $total_amount instanceof TaxedMoney ) { + return $total_amount->get_tax_value(); + } + + return null; }, $lines->get_array() ); - $tax_amount = new Money( array_sum( $values ), $lines->get_amount()->get_currency()->get_alphabetic_code() ); + $tax_amount = new Money( \array_sum( $values ), $lines->get_amount()->get_currency() ); - echo esc_html( $tax_amount ); + echo \esc_html( $tax_amount->format_i18n() ); ?>
get_id() ); ?>get_sku() ); ?>get_id() ); ?>get_sku() ); ?> get_image_url(); if ( ! empty( $image_url ) ) { - printf( + \printf( '', - esc_url( $image_url ) + \esc_url( $image_url ) ); } @@ -209,23 +178,23 @@ function( PaymentLine $line ) { $classes[] = 'pronamic-pay-tip'; } - printf( + \printf( '%4$s', - esc_attr( implode( ' ', $classes ) ), - esc_url( $line->get_product_url() ), - esc_attr( $line_title ), - esc_html( $line->get_name() ) + \esc_attr( \implode( ' ', $classes ) ), + \esc_url( $line->get_product_url() ), + \esc_attr( $line_title ), + \esc_html( $line->get_name() ) ); } elseif ( ! empty( $description ) ) { // Description without product URL. - printf( + \printf( '%2$s', - esc_attr( $line->get_description() ), - esc_html( $line->get_name() ) + \esc_attr( $line->get_description() ), + \esc_html( $line->get_name() ) ); } else { // No description and no product URL. - echo esc_html( $line->get_name() ); + echo \esc_html( $line->get_name() ); } ?> @@ -233,40 +202,46 @@ function( PaymentLine $line ) { get_unit_price() ) { + $unit_price = $line->get_unit_price(); - $tip = array( - sprintf( - /* translators: %s: price excluding tax */ - __( 'Exclusive tax: %s', 'pronamic_ideal' ), - $line->get_unit_price()->get_excluding_tax() - ), + if ( null !== $unit_price ) { + $tips = array( + \__( 'No tax information.', 'pronamic_ideal' ), ); - if ( $line->get_unit_price()->has_tax() ) { - $tip[] = sprintf( - /* translators: %s: price including tax */ - __( 'Inclusive tax: %s', 'pronamic_ideal' ), - $line->get_unit_price()->get_including_tax() + if ( $unit_price instanceof TaxedMoney ) { + $tips = array( + \sprintf( + /* translators: %s: price excluding tax */ + \__( 'Exclusive tax: %s', 'pronamic_ideal' ), + $unit_price->get_excluding_tax() + ), + \sprintf( + /* translators: %s: price including tax */ + \__( 'Inclusive tax: %s', 'pronamic_ideal' ), + $unit_price->get_including_tax() + ), ); } - printf( + \printf( '%s', - esc_attr( implode( '
', $tip ) ), - esc_html( $line->get_unit_price()->get_excluding_tax() ) + \esc_attr( \implode( '
', $tips ) ), + \esc_html( $unit_price->format_i18n() ) ); } ?>
get_quantity() ); ?>get_quantity() ); ?> get_discount_amount() ) { - echo esc_html( $line->get_discount_amount() ); + $discount_amount = $line->get_discount_amount(); + + if ( null !== $discount_amount ) { + echo \esc_html( $discount_amount ); } ?> @@ -274,26 +249,31 @@ function( PaymentLine $line ) { get_total_amount()->get_excluding_tax() - ), + $line_total = $line->get_total_amount(); + + $tips = array( + \__( 'No tax information.', 'pronamic_ideal' ), ); - if ( $line->get_total_amount()->has_tax() ) { - $tip[] = sprintf( - /* translators: %s: price including tax */ - __( 'Inclusive tax: %s', 'pronamic_ideal' ), - $line->get_total_amount()->get_including_tax() + if ( $line_total instanceof TaxedMoney ) { + $tips = array( + \sprintf( + /* translators: %s: price excluding tax */ + \__( 'Exclusive tax: %s', 'pronamic_ideal' ), + $line->get_total_amount()->get_excluding_tax() + ), + \sprintf( + /* translators: %s: price including tax */ + \__( 'Inclusive tax: %s', 'pronamic_ideal' ), + $line->get_total_amount()->get_including_tax() + ), ); } - printf( + \printf( '%s', - esc_attr( implode( '
', $tip ) ), - esc_html( $line->get_total_amount()->get_excluding_tax() ) + \esc_attr( \implode( '
', $tips ) ), + \esc_html( $line_total->format_i18n() ) ); ?> @@ -301,20 +281,17 @@ function( PaymentLine $line ) {
get_total_amount()->get_tax_amount(); - - if ( null === $line->get_total_amount()->get_tax_percentage() ) { - - echo esc_html( $tax_amount ); - - } else { - - printf( - '%s', - esc_attr( number_format_i18n( $line->get_total_amount()->get_tax_percentage() ) . '%' ), - esc_html( $tax_amount ) - ); + if ( $line_total instanceof TaxedMoney ) { + $tax_amount = $line_total->get_tax_amount(); + $tax_percentage = $line_total->get_tax_percentage(); + if ( null !== $tax_amount ) { + \printf( + '%s', + \esc_attr( \number_format_i18n( $tax_percentage ) . '%' ), + \esc_html( $tax_amount->format_i18n() ) + ); + } } ?> diff --git a/views/meta-box-payment-update.php b/views/meta-box-payment-update.php index 2700b056..4d67b023 100644 --- a/views/meta-box-payment-update.php +++ b/views/meta-box-payment-update.php @@ -12,6 +12,10 @@ use Pronamic\WordPress\Pay\Payments\PaymentPostType; use Pronamic\WordPress\Pay\Plugin; +if ( ! isset( $post ) ) { + return; +} + $states = PaymentPostType::get_payment_states(); $payment = get_pronamic_payment( get_the_ID() ); diff --git a/views/meta-box-subscription-info.php b/views/meta-box-subscription-info.php index 21a3c776..c246ffe4 100644 --- a/views/meta-box-subscription-info.php +++ b/views/meta-box-subscription-info.php @@ -13,6 +13,10 @@ use Pronamic\WordPress\Pay\Subscriptions\SubscriptionStatus; use Pronamic\WordPress\Pay\Util; +if ( ! isset( $subscription ) ) { + return; +} + $subscription_id = $subscription->get_id(); $customer = $subscription->get_customer(); diff --git a/views/meta-box-subscription-payments.php b/views/meta-box-subscription-payments.php index 8b486141..9d415dca 100644 --- a/views/meta-box-subscription-payments.php +++ b/views/meta-box-subscription-payments.php @@ -11,6 +11,14 @@ use Pronamic\WordPress\Pay\Plugin; use Pronamic\WordPress\Pay\Subscriptions\SubscriptionStatus; +if ( ! isset( $periods ) ) { + return; +} + +if ( ! isset( $subscription ) ) { + return; +} + ?> diff --git a/views/meta-box-subscription-update.php b/views/meta-box-subscription-update.php index e4b74430..5479922a 100644 --- a/views/meta-box-subscription-update.php +++ b/views/meta-box-subscription-update.php @@ -10,6 +10,10 @@ use Pronamic\WordPress\Pay\Subscriptions\SubscriptionPostType; +if ( ! isset( $post ) ) { + return; +} + $states = SubscriptionPostType::get_states(); // WordPress by default doesn't allow `post_author` values of `0`, that's why we use a dash (`-`). diff --git a/views/notice-license.php b/views/notice-license.php index 41829cb8..77063cc2 100644 --- a/views/notice-license.php +++ b/views/notice-license.php @@ -12,6 +12,10 @@ die; } +if ( ! isset( $data ) ) { + return; +} + $class = ( 'valid' === $data->license ) ? 'updated' : 'error'; ?> diff --git a/views/notice-upgrade.php b/views/notice-upgrade.php index fd0ce59f..457e5d1e 100644 --- a/views/notice-upgrade.php +++ b/views/notice-upgrade.php @@ -30,7 +30,7 @@

- +

diff --git a/views/page-dashboard.php b/views/page-dashboard.php index 4a10606e..4cdf4937 100644 --- a/views/page-dashboard.php +++ b/views/page-dashboard.php @@ -19,7 +19,7 @@ -
+
@@ -314,7 +314,7 @@ -
+
diff --git a/views/page-reports.php b/views/page-reports.php index 5e90cf7a..9f26a702 100644 --- a/views/page-reports.php +++ b/views/page-reports.php @@ -11,6 +11,10 @@ use Pronamic\WordPress\Money\Money; use Pronamic\WordPress\Pay\Util; +if ( ! isset( $admin_reports ) ) { + return; +} + ?>

@@ -27,7 +31,7 @@
    - reports->get_reports() as $i => $serie ) : ?> + get_reports() as $i => $serie ) : ?> diff --git a/views/pointer-dashboard.php b/views/pointer-dashboard.php index 472efe93..ee815ebe 100644 --- a/views/pointer-dashboard.php +++ b/views/pointer-dashboard.php @@ -8,6 +8,10 @@ * @package Pronamic\WordPress\Pay */ +if ( ! isset( $admin_tour ) ) { + return; +} + ?>

    @@ -19,8 +23,8 @@
    - + - +
    diff --git a/views/pointer-forms.php b/views/pointer-forms.php index 90081b5c..69ff9930 100644 --- a/views/pointer-forms.php +++ b/views/pointer-forms.php @@ -8,6 +8,10 @@ * @package Pronamic\WordPress\Pay */ +if ( ! isset( $admin_tour ) ) { + return; +} + ?>

    @@ -35,11 +39,11 @@

    - + - + - +
    diff --git a/views/pointer-gateways.php b/views/pointer-gateways.php index 829a68ae..b3ee7222 100644 --- a/views/pointer-gateways.php +++ b/views/pointer-gateways.php @@ -8,6 +8,10 @@ * @package Pronamic\WordPress\Pay */ +if ( ! isset( $admin_tour ) ) { + return; +} + ?>

    @@ -18,11 +22,11 @@

    - + - + - +
    diff --git a/views/pointer-payments.php b/views/pointer-payments.php index fc7e3f46..3eaad84a 100644 --- a/views/pointer-payments.php +++ b/views/pointer-payments.php @@ -8,6 +8,10 @@ * @package Pronamic\WordPress\Pay */ +if ( ! isset( $admin_tour ) ) { + return; +} + ?>

    @@ -18,11 +22,11 @@

    - + - + - +
    diff --git a/views/pointer-reports.php b/views/pointer-reports.php index 0aef9b59..f6e43a8c 100644 --- a/views/pointer-reports.php +++ b/views/pointer-reports.php @@ -8,6 +8,10 @@ * @package Pronamic\WordPress\Pay */ +if ( ! isset( $admin_tour ) ) { + return; +} + ?>

    @@ -17,9 +21,9 @@

    - + - +
    diff --git a/views/pointer-settings.php b/views/pointer-settings.php index e26a42af..61f7181b 100644 --- a/views/pointer-settings.php +++ b/views/pointer-settings.php @@ -8,6 +8,10 @@ * @package Pronamic\WordPress\Pay */ +if ( ! isset( $admin_tour ) ) { + return; +} + ?>

    @@ -17,11 +21,11 @@

    - + - + - +
    diff --git a/views/pointer-start.php b/views/pointer-start.php index 5dc350df..c6f2d9d9 100644 --- a/views/pointer-start.php +++ b/views/pointer-start.php @@ -8,6 +8,10 @@ * @package Pronamic\WordPress\Pay */ +if ( ! isset( $admin_tour ) ) { + return; +} + ?>

    @@ -17,8 +21,8 @@
    - + - +
    diff --git a/views/subscription-mandate.php b/views/subscription-mandate.php index 8059bc9e..79a7f234 100644 --- a/views/subscription-mandate.php +++ b/views/subscription-mandate.php @@ -11,6 +11,10 @@ use Pronamic\WordPress\Pay\Cards; use Pronamic\WordPress\Pay\Core\PaymentMethods; +if ( ! isset( $subscription ) ) { + return; +} + $subscription_id = $subscription->get_id(); $mollie_customer_id = \get_post_meta( $subscription_id, '_pronamic_subscription_mollie_customer_id', true ); diff --git a/views/tab-extensions.php b/views/tab-extensions.php index 0e6a342e..f3168158 100644 --- a/views/tab-extensions.php +++ b/views/tab-extensions.php @@ -16,11 +16,16 @@ $extensions_json_path = Plugin::$dirname . '/other/extensions.json'; -if ( ! file_exists( $extensions_json_path ) ) : +if ( ! file_exists( $extensions_json_path ) ) { return; -endif; +} + +$data = file_get_contents( $extensions_json_path, true ); + +if ( false === $data ) { + return; +} -$data = file_get_contents( $extensions_json_path ); $extensions = json_decode( $data ); ?> @@ -49,7 +54,7 @@
- + name ); ?>
- + - + - + diff --git a/views/widget-payments-status-list.php b/views/widget-payments-status-list.php index bd3b5f7e..7dbab6f1 100644 --- a/views/widget-payments-status-list.php +++ b/views/widget-payments-status-list.php @@ -8,25 +8,47 @@ * @package Pronamic\WordPress\Pay */ +$counts = \wp_count_posts( 'pronamic_payment' ); + +$states = array( + /* translators: %s: posts count value */ + 'payment_completed' => __( '%s completed', 'pronamic_ideal' ), + /* translators: %s: posts count value */ + 'payment_pending' => __( '%s pending', 'pronamic_ideal' ), + /* translators: %s: posts count value */ + 'payment_cancelled' => __( '%s cancelled', 'pronamic_ideal' ), + /* translators: %s: posts count value */ + 'payment_failed' => __( '%s failed', 'pronamic_ideal' ), + /* translators: %s: posts count value */ + 'payment_expired' => __( '%s expired', 'pronamic_ideal' ), +); + +$url = \add_query_arg( + array( + 'post_type' => 'pronamic_payment', + ), + \admin_url( 'edit.php' ) +); + ?>