diff --git a/.github/workflows/parallel-lint.yml b/.github/workflows/parallel-lint.yml new file mode 100644 index 0000000..c7b53fa --- /dev/null +++ b/.github/workflows/parallel-lint.yml @@ -0,0 +1,37 @@ +name: parallel-lint + +on: + push: + branches: + - '*.x' + pull_request: + +permissions: + contents: read + +jobs: + tests: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: [8.1, 8.2, 8.3, 8.4] + + name: PHP ${{ matrix.php }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Install Composer dependencies + run: composer install --prefer-dist --no-interaction --no-progress + + - name: Execute parallel-lint + run: composer run parallel-lint diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..772f726 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,37 @@ +name: PHPStan + +on: + push: + branches: + - '*.x' + pull_request: + +permissions: + contents: read + +jobs: + tests: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: [8.1, 8.2, 8.3, 8.4] + + name: PHP ${{ matrix.php }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Install Composer dependencies + run: composer install --prefer-dist --no-interaction --no-progress + + - name: Execute PHPStan + run: composer run phpstan diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 9e8168b..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,591 +0,0 @@ -# Changelog - - - -## [3.8.0] - 2023-02-08 - -### Added - -- Add scheme transaction id to debit and preauthorize transactions - ([#31](https://github.com/ixopay/php-ixopay/pull/31), X2980) (by @adamjanovic) - -## [3.7.0] - 2023-01-18 - -### Changed - -- Improve stringify for level 2 and level 3 data ([#30](https://github.com/ixopay/php-ixopay/pull/30)) (by @rhoferixo) - -## [3.6.0] - 2023-01-18 - -### Added - -- Add `transactionToken` to `Deregister` ([#23](https://github.com/ixopay/php-ixopay/pull/23)) (by @marcod85) - -## [3.5.0] - 2022-12-15 - -### Added - -- Add exemption indicator to `ThreeDSecureData` ([#29](https://github.com/ixopay/php-ixopay/pull/29)) (by @SPie) - -## [3.4.0] - 2022-10-19 - -### Changed - -- Deprecate `firstSixDigits` getters and setters (by @mkappelixo) - -### Added - -- Add `binDigits` as a future replacement for `firstSixDigits` (by @mkappelixo) -- Add level 2 and level 3 data to: capture, debit, incremental authorization, payout, preauthorize, refund and register - transactions ([#25](https://github.com/ixopay/php-ixopay/pull/25)) (by @rhoferixo) - -### Removed - -- Remove `firstSixDigits` property (by @mkappelixo) - -## [3.3.1] - 2022-10-03 - -### Fixed - -- Fix wrong JSON key for mapping surcharge amounts ([#27](https://github.com/ixopay/php-ixopay/pull/27)) (by @SPie) - -## [3.3.0] - 2022-09-29 - -### Added - -- Add surcharge amount to debit and preauthorize transaction ([#26](https://github.com/ixopay/php-ixopay/pull/26)) (by @SPie) - -## [3.2.0] - 2022-08-23 - -### Added - -- Add DCC data ([#21](https://github.com/ixopay/php-ixopay/pull/21)) (by @SPie) -- Add schedule update API -- Add `callbackUrl` to schedule data -- Add `transactionIndicator` for register transactions - -### Fixed - -- Fix card-on-file merchant initiated constant ([#20](https://github.com/ixopay/php-ixopay/pull/20)) (by @AidasK) - -## [3.1.0] - 2022-05-16 - -### Changed - -- Allow all `psr/log` versions ([#11](https://github.com/ixopay/php-ixopay/pull/11)) (by @AidasK) - -### Added - -- Add redirect QR-code to transaction result ([#19](https://github.com/ixopay/php-ixopay/pull/19)) (by @rhoferIxo) - -## [3.0.6] - 2022-04-12 - -### Added - -- Add `Amountable` trait to `VoidTransaction` for partial void transactions - -## [3.0.5] - 2022-03-16 - -### Added - -- Send description for capture transactions - -### Fixed - -- Fix error parsing of status requests - -## [3.0.4] - 2022-01-03 - -### Changed - -- Refactor transaction indicator into trait and interface - -## [3.0.3] - 2021-12-28 - -### Fixed - -- Fix `payByLink` dependency for incremental authorization - -## [3.0.2] - 2021-12-09 - -### Changed - -- Allow any `psr/log` version as dependency - -### Added - -- Add send and receive transaction splits - -## [3.0.1] - 2021-11-22 - -### Added - -- Add owner first and last name to `WalletData` - -### Fixed - -- Add missing returns in fluent setter methods - -## [3.0.0] - 2021-10-18 - -_Updates the API integration to use IXOPAY's Transaction V3 JSON based API._ - -### Changed - -- **Breaking:** move `CardData`, `IbanData`, `WalletData`, `ChargebackData` and `ChargebackReversalData` to a new namespace -- Rename attributes from old API to new API -- Deprecate old getter and setter functions - -### Added - -- Add customer profiles -- Add `payByLink` - -## [2.5.4] - 2020-06-25 - -### Added - -- Add `transactionIndicator` to register transactions - -## [2.5.3] - 2020-04-20 - -### Changed - -- Send SDK version in request headers - -### Added - -- Add `scheduleMerchantMetadata` to callback results -- Add `merchantMetaData` to scheduler data and result - -## [2.5.2] - 2019-12-03 - -### Added - -- Set custom `curl` request headers and options - -## [2.5.1] - 2019-12-03 - -### Removed - -- Remove `FILTER_FLAG_SCHEME_REQUIRED` and `FILTER_FLAG_HOST_REQUIRED` flags if PHP version is newer than 7.3 - -## [2.5.0] - 2019-08-07 - -### Changed - -- Move the package to the IXOPAY organization - -## [2.4.4] - 2019-05-02 - -### Added - -- Add `CARDONFILE_MERCHANT` transaction indicator - -## [2.4.3] - 2019-04-09 - -### Changed - -- Support PHP 5.6 - -## [2.4.2] - 2019-04-08 - -### Added - -- Add wallet data to callbacks - -## [2.4.1] - 2018-12-18 - -### Fixed - -- Fix wrong variable usage - -## [2.4.0] - 2018-12-06 - -### Added - -- Add customer data -- Add status API - -## [2.3.1] - 2018-10-05 - -### Fixed - -- Fix XML parsing - -## [2.3.0] - 2018-10-05 - -### Added - -- Add customer data to callbacks and result objects - -## [2.2.0] - 2018-06-13 - -### Added - -- Add scheduler API -- Add `merchantMetaData` to transactions and callbacks - -## [2.1.13] - 2018-04-04 - -### Added - -- Add reference to previous transactions for payout transactions - -## [2.1.12] - 2018-03-26 - -### Added - -- Add `ChargebackReversalData` -- Add callback type `CHARGEBACK-REVERSAL` - -## [2.1.11] - 2017-11-24 - -### Added - -- Add `transactionIndicator` to `Debit` for use with recurring credit card or card-on-file transactions - -## [2.1.10] - 2017-11-15 - -### Added - -- Add 3D Secure error code - -## [2.1.9] - 2017-11-07 - -### Added - -- Add `callbackUrl` for `Refund` requests - -## [2.1.8] - 2017-10-31 - -### Fixed - -- Fix callback validation - -## [2.1.7] - 2017-10-30 - -### Added - -- Add `callbackUrl` for `Payout` requests - -## [2.1.6] - 2017-06-22 - -_Re-publish to packagist._ - -## [2.1.5] - 2017-06-22 - -### Changed - -- parse `mandateDate` to DateTime -- parse `ibanData` - -## [2.1.4] - 2017-06-20 - -### Added - -- add IBAN information to return data -- add examples for callback & debit - -## [2.1.3] - 2017-05-03 - -### Changed - -- Allow to set XML namespace - -## [2.1.2] - 2017-03-13 - -### Changed - -- Remove requirement to use XML namespaces - -## [2.1.1] - 2017-03-08 - -_Re-publish to packagist._ - -## [2.1.0] - 2017-03-03 - -### Added - -- Support payout transactions - -## [2.0.2] - 2017-02-10 - -### Added - -- Add fields `mandateId` and `mandateDate` to `Customer` - -## [2.0.1] - 2017-02-08 - -### Added - -- Add error codes for IBAN invalid, BIC invalid and customer data invalid - -## [2.0.0] - 2017-02-03 - -### Changed - -- Support PHP 7.x -- **Breaking:** Rename `Void` to `VoidTransaction` - -## [1.1.3] - 2017-02-10 - -### Added - -- Add fields `mandateId` and `mandateDate` to `Customer` - -## [1.1.2] - 2017-02-08 - -_Re-publish to packagist._ - -## [1.1.1] - 2017-02-08 - -_Re-publish to packagist._ - -## [1.1.0] - 2017-02-08 - -_Re-publish to packagist._ - -## [1.0.20] - 2017-02-08 - -### Fixed - -- Renames for PHP 7.x compatibility - -## [1.0.19] - 2017-02-08 - -### Changed - -- Allow gateway authorization header - -## [1.0.18] - 2016-02-08 - -### Changed - -- Rename service to `Gateway` - -### Added - -- Add timeout exception -- Add error codes for transaction cancelled - -## [1.0.17] - 2016-08-30 - -### Added - -- Add error codes for pickup card, lost card and stolen card - -## [1.0.16] - 2016-08-18 - -### Added - - -- Add error codes for transaction cancelled and risk-check block - - -## [1.0.15] - 2016-04-11 - -### Added - -- Add missing fluent setter in customer - -### Fixed - -- Remove private repositories in public library -- Remove prefer source flag - -## [1.0.14] - 2016-02-04 - -### Added - -- Add phone data - -## [1.0.13] - 2016-01-14 - -### Changed - -- Extend `AbstractTransactionWithReference` in `Preauthorize` - -### Added - -- Add setter for hashed password - -## [1.0.12] - 2015-12-21 - -### Fixed - -- Handle empty redirect type - -## [1.0.11] - 2015-12-18 - -### Added - -- Add redirect type - -## [1.0.10] - 2015-12-02 - -### Added - -- Add offsite URLs to register call -- Add billing first and last name -- Add purchased id - -## [1.0.9] - 2015-10-20 - -### Added - -- Add customer extra data -- Add error codes for chargeback reverted -- Add error codes for payment dispute -- Add `toArray()` to return data - -## [1.0.8] - 2015-10-07 - -### Fixed - -- sort order - -## [1.0.7] - 2015-10-07 - -### Changed - -- Deprecate test mode -- Customer extends data - -### Added - -- Add customer gender - -## [1.0.6] - 2015-09-25 - -### Added - -- Add `toArray()`to callback and transaction results - -## [1.0.5] - 2015-09-25 - -### Fixed - -- Capture requires `Amountable` interface - -## [1.0.4] - 2015-09-25 - -_Re-publish to packagist._ - -## [1.0.3] - 2015-09-22 - -### Fixed - -- Add dependency `psr/log` - -## [1.0.2] - 2015-09-22 - -### Added - -- Add client logging - -### Fixed - -- Generate pre-authorize without reference node -- Fix amount formatting - -## [1.0.1] - 2015-09-15 - -### Added - -- Add email verified flag -- Add license and requirements - -## [1.0.0] - 2015-09-09 - -_Initial release._ - -[3.8.0]: https://github.com/ixopay/php-ixopay/releases/tag/v3.8.0 -[3.7.0]: https://github.com/ixopay/php-ixopay/releases/tag/v3.7.0 -[3.6.0]: https://github.com/ixopay/php-ixopay/releases/tag/v3.6.0 -[3.5.0]: https://github.com/ixopay/php-ixopay/releases/tag/v3.5.0 -[3.4.0]: https://github.com/ixopay/php-ixopay/releases/tag/v3.4.0 -[3.3.1]: https://github.com/ixopay/php-ixopay/releases/tag/v3.3.1 -[3.3.0]: https://github.com/ixopay/php-ixopay/releases/tag/v3.3.0 -[3.2.0]: https://github.com/ixopay/php-ixopay/releases/tag/v3.2.0 -[3.1.0]: https://github.com/ixopay/php-ixopay/releases/tag/v3.1.0 -[3.0.6]: https://github.com/ixopay/php-ixopay/releases/tag/v3.0.6 -[3.0.5]: https://github.com/ixopay/php-ixopay/releases/tag/v3.0.5 -[3.0.4]: https://github.com/ixopay/php-ixopay/releases/tag/v3.0.4 -[3.0.3]: https://github.com/ixopay/php-ixopay/releases/tag/v3.0.3 -[3.0.2]: https://github.com/ixopay/php-ixopay/releases/tag/v3.0.2 -[3.0.1]: https://github.com/ixopay/php-ixopay/releases/tag/v3.0.1 -[3.0.0]: https://github.com/ixopay/php-ixopay/releases/tag/v3.0.0 -[2.5.4]: https://github.com/ixopay/php-ixopay/releases/tag/v2.5.4 -[2.5.3]: https://github.com/ixopay/php-ixopay/releases/tag/v2.5.3 -[2.5.2]: https://github.com/ixopay/php-ixopay/releases/tag/v2.5.2 -[2.5.1]: https://github.com/ixopay/php-ixopay/releases/tag/v2.5.1 -[2.5.0]: https://github.com/ixopay/php-ixopay/releases/tag/v2.5 -[2.4.4]: https://github.com/ixopay/php-ixopay/releases/tag/v2.4.4 -[2.4.3]: https://github.com/ixopay/php-ixopay/releases/tag/v2.4.3 -[2.4.2]: https://github.com/ixopay/php-ixopay/releases/tag/v2.4.2 -[2.4.1]: https://github.com/ixopay/php-ixopay/releases/tag/v2.4.1 -[2.4.0]: https://github.com/ixopay/php-ixopay/releases/tag/v2.4 -[2.3.1]: https://github.com/ixopay/php-ixopay/releases/tag/v2.3.1 -[2.3.0]: https://github.com/ixopay/php-ixopay/releases/tag/v2.3 -[2.2.0]: https://github.com/ixopay/php-ixopay/releases/tag/v2.2 -[2.1.13]: https://github.com/ixopay/php-ixopay/releases/tag/v2.1.13 -[2.1.12]: https://github.com/ixopay/php-ixopay/releases/tag/v2.1.12 -[2.1.11]: https://github.com/ixopay/php-ixopay/releases/tag/v2.1.11 -[2.1.10]: https://github.com/ixopay/php-ixopay/releases/tag/v2.1.10 -[2.1.9]: https://github.com/ixopay/php-ixopay/releases/tag/v2.1.9 -[2.1.8]: https://github.com/ixopay/php-ixopay/releases/tag/v2.1.8 -[2.1.7]: https://github.com/ixopay/php-ixopay/releases/tag/v2.1.7 -[2.1.6]: https://github.com/ixopay/php-ixopay/releases/tag/v2.1.6 -[2.1.5]: https://github.com/ixopay/php-ixopay/compare/v2.1.4...v2.1.5 -[2.1.4]: https://github.com/ixopay/php-ixopay/releases/tag/v2.1.4 -[2.1.3]: https://github.com/ixopay/php-ixopay/releases/tag/v2.1.3 -[2.1.2]: https://github.com/ixopay/php-ixopay/releases/tag/v2.1.2 -[2.1.1]: https://github.com/ixopay/php-ixopay/releases/tag/v2.1.1 -[2.1.0]: https://github.com/ixopay/php-ixopay/releases/tag/v2.1.0 -[2.0.2]: https://github.com/ixopay/php-ixopay/compare/v2.0.1...v2.0.2 -[2.0.1]: https://github.com/ixopay/php-ixopay/compare/v2.0.0...v2.0.1 -[2.0.0]: https://github.com/ixopay/php-ixopay/releases/tag/v2.0.0 -[1.1.3]: https://github.com/ixopay/php-ixopay/compare/v1.1.2...v1.1.3 -[1.1.2]: https://github.com/ixopay/php-ixopay/compare/v1.1.1...v1.1.2 -[1.1.1]: https://github.com/ixopay/php-ixopay/compare/v1.1.0...v1.1.1 -[1.1.0]: https://github.com/ixopay/php-ixopay/compare/v1.0.20...v1.1.0 -[1.0.20]: https://github.com/ixopay/php-ixopay/compare/v1.0.19...v1.0.20 -[1.0.19]: https://github.com/ixopay/php-ixopay/compare/v1.0.18...v1.0.19 -[1.0.18]: https://github.com/ixopay/php-ixopay/compare/v1.0.17...v1.0.18 -[1.0.17]: https://github.com/ixopay/php-ixopay/compare/v1.0.16...v1.0.17 -[1.0.16]: https://github.com/ixopay/php-ixopay/compare/v1.0.15...v1.0.16 -[1.0.15]: https://github.com/ixopay/php-ixopay/releases/tag/v1.0.15 -[1.0.14]: https://github.com/ixopay/php-ixopay/compare/v1.0.13...v1.0.14 -[1.0.13]: https://github.com/ixopay/php-ixopay/compare/v1.0.12...v1.0.13 -[1.0.12]: https://github.com/ixopay/php-ixopay/compare/v1.0.11...v1.0.12 -[1.0.11]: https://github.com/ixopay/php-ixopay/compare/v1.0.10...v1.0.11 -[1.0.10]: https://github.com/ixopay/php-ixopay/compare/v1.0.9...v1.0.10 -[1.0.9]: https://github.com/ixopay/php-ixopay/compare/v1.0.8...v1.0.9 -[1.0.8]: https://github.com/ixopay/php-ixopay/compare/v1.0.7...v1.0.8 -[1.0.7]: https://github.com/ixopay/php-ixopay/compare/v1.0.6...v1.0.7 -[1.0.6]: https://github.com/ixopay/php-ixopay/compare/v1.0.5...v1.0.6 -[1.0.5]: https://github.com/ixopay/php-ixopay/compare/v1.0.4...v1.0.5 -[1.0.4]: https://github.com/ixopay/php-ixopay/compare/v1.0.3...v1.0.4 -[1.0.3]: https://github.com/ixopay/php-ixopay/compare/v1.0.2...v1.0.3 -[1.0.2]: https://github.com/ixopay/php-ixopay/compare/v1.0.1...v1.0.2 -[1.0.1]: https://github.com/ixopay/php-ixopay/compare/v1.0.0...v1.0.1 -[1.0.0]: https://github.com/ixopay/php-ixopay/releases/tag/v1.0.0 diff --git a/LICENSE.md b/LICENSE.md index b3bff10..53c9383 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,7 @@ The MIT License (MIT) ===================== -Copyright © 2023 IXOLIT GmbH +Copyright © 2025 IXOPAY GmbH Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/README.md b/README.md index e365bb3..2a8bf14 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,8 @@ provides convenient access to the [IXOPAY REST APIs][ixopay-docs-api]. ### Requirements -- PHP 5.6 or newer -- Installed [Composer][composer] +- PHP v8.1 or newer +- [Composer][composer] ### Composer @@ -78,9 +78,6 @@ use Ixopay\Client\Data\Customer; use Ixopay\Client\Transaction\Debit; use Ixopay\Client\Transaction\Result; -// Include the autoloader (if not already done via Composer autoloader) -require_once('path/to/initClientAutoload.php'); - // Instantiate the "Ixopay\Client\Client" with your credentials $api_user = "your_username"; $api_password = "your_username"; @@ -95,6 +92,8 @@ Once you instantiated a [client with credentials](#setting-up-credentials), you can use the instance to make transaction API calls. ```php +=5.6", + "php": ">=v8.1", "ext-curl": "*", - "psr/log": "*" + "ext-dom": "*", + "ext-json": "*", + "psr/log": "^1.0.0 || ^2.0.0 || ^3.0.0" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpstan/phpstan": "^2.0" + }, + "scripts": { + "phpstan": [ + "./vendor/bin/phpstan analyze -l 3 -- src examples" + ], + "parallel-lint": [ + "vendor/bin/parallel-lint --colors --blame ." + ] }, "autoload": { "psr-4": { "Ixopay\\Client\\": "src/" } }, - "scripts": { + "config": { + "preferred-install": "dist", + "sort-packages": true }, "minimum-stability": "dev", "prefer-stable": true diff --git a/examples/callback.php b/examples/callback.php index 898d29f..8a89557 100644 --- a/examples/callback.php +++ b/examples/callback.php @@ -1,7 +1,7 @@ getMerchantTransactionId(); $gatewayTransactionId = $callbackResult->getUuid(); +$status = $callbackResult->getResult(); if ($status === Result::RESULT_OK) { @@ -46,4 +47,4 @@ // confirm callback with body "OK" echo "OK"; -die; \ No newline at end of file +die; diff --git a/examples/customerprofile.php b/examples/customerprofile.php index e7e06f1..151eca1 100644 --- a/examples/customerprofile.php +++ b/examples/customerprofile.php @@ -1,7 +1,6 @@ getAdapterMessage() // $result->getAdapterCode() -} \ No newline at end of file +} diff --git a/examples/options.php b/examples/options.php index 88bf3d1..1bf1f85 100644 --- a/examples/options.php +++ b/examples/options.php @@ -1,7 +1,6 @@ getOptions() } else{ // $result->getErrorMessage() -} \ No newline at end of file +} diff --git a/examples/schedule.php b/examples/schedule.php index 5b8ea24..d6773b7 100644 --- a/examples/schedule.php +++ b/examples/schedule.php @@ -1,7 +1,6 @@ cancelSchedule($scheduleId); // handle result accordingly -*/ \ No newline at end of file +*/ diff --git a/examples/status.php b/examples/status.php index a5ecea1..8dc12e4 100644 --- a/examples/status.php +++ b/examples/status.php @@ -1,7 +1,6 @@ getErrorMessage(); // $result->getErrorCode(); -} \ No newline at end of file +} diff --git a/src/Client.php b/src/Client.php index 74be8a0..2bbc697 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1178,7 +1178,7 @@ public function deleteCustomerProfileByProfileGuid($profileGuid) { * @return DeleteProfileResponse|ErrorResponse * @throws ClientException * @throws Http\Exception\ClientException - * @throws TimeoutException# + * @throws TimeoutException * @throws RateLimitException * @throws GeneralErrorException */ @@ -1484,17 +1484,11 @@ private function hashPassword($password) { */ public static function setApiUrl($url) { if (empty($url)) { - throw new InvalidValueException('The URL to the IxoPay Gateway can not be empty!'); + throw new InvalidValueException('The URL to the IXOPAY Gateway can not be empty!'); } - if (PHP_MAJOR_VERSION < 7 || (PHP_MAJOR_VERSION === 7 && PHP_MINOR_VERSION < 3)) { - if (!\filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED)) { - throw new InvalidValueException('The URL to the IxoPay Gateway should be a valid URL!'); - } - } else { - if (!\filter_var($url, FILTER_VALIDATE_URL)) { - throw new InvalidValueException('The URL to the IxoPay Gateway should be a valid URL!'); - } + if (!\filter_var($url, FILTER_VALIDATE_URL)) { + throw new InvalidValueException('The URL to the IXOPAY Gateway should be a valid URL!'); } static::$gatewayUrl = $url; diff --git a/src/CustomerProfile/CustomerData.php b/src/CustomerProfile/CustomerData.php index e83c809..5a34e2b 100644 --- a/src/CustomerProfile/CustomerData.php +++ b/src/CustomerProfile/CustomerData.php @@ -9,7 +9,7 @@ * * @package Ixopay\Client\CustomerProfile * - * @property string firstName + * @property string $firstName * @property string $lastName * @property \DateTime $birthDate * @property string $gender @@ -43,5 +43,4 @@ public function setBirthDate($birthDate) { } $this->birthDate = $birthDate; } - -} \ No newline at end of file +} diff --git a/src/Data/CreditCardCustomer.php b/src/Data/CreditCardCustomer.php index fdbd8af..3ab660f 100644 --- a/src/Data/CreditCardCustomer.php +++ b/src/Data/CreditCardCustomer.php @@ -167,7 +167,7 @@ public function getStartYear() { /** * @deprecated - * @param int $cvv + * @param string $cvv * * @return $this */ diff --git a/src/Data/Result/CreditcardData.php b/src/Data/Result/CreditcardData.php index 9df8d31..d94d4f0 100644 --- a/src/Data/Result/CreditcardData.php +++ b/src/Data/Result/CreditcardData.php @@ -251,7 +251,9 @@ public function getFirstSixDigits() { * @return $this */ public function setFirstSixDigits($firstSixDigits) { - return $this->setBinDigits($firstSixDigits); + $this->setBinDigits($firstSixDigits); + + return $this; } /** @@ -450,16 +452,38 @@ public function setSchemeTransactionIdentifier($schemeTransactionIdentifier) * @return array */ public function toArray() { - $resultData = array(); - - foreach ($this as $field => $value) { - $resultData[$field] = $value; + $resultData = []; + + $fields = [ + 'binBank', + 'binBrand', + 'binCountry', + 'binDigits', + 'binLevel', + 'binType', + 'cardHolder', + 'country', + 'eci', + 'expiryMonth', + 'expiryYear', + 'fingerprint', + 'firstName', + // 'firstSixDigits', + 'lastFourDigits', + 'lastName', + 'schemeTransactionIdentifier', + 'threeDSecure', + 'type', + ]; + + foreach ($fields as $field) { + $resultData[$field] = $this->{$field}; } + // Property $firstSixDigits was removed because of the implementation of // binDigits. For backwards compatibility this will be set directly. $resultData['firstSixDigits'] = $this->getFirstSixDigits(); return $resultData; } - } diff --git a/src/Data/Result/IbanData.php b/src/Data/Result/IbanData.php index 25f2885..34fc2ee 100644 --- a/src/Data/Result/IbanData.php +++ b/src/Data/Result/IbanData.php @@ -108,12 +108,12 @@ public function setCountry($country) { * @return array */ public function toArray() { - return array( + return [ 'accountOwner' => $this->getAccountOwner(), 'iban' => $this->getIban(), 'bic' => $this->getBic(), 'bankName' => $this->getBankName(), 'country' => $this->getCountry() - ); + ]; } -} \ No newline at end of file +} diff --git a/src/Data/RiskCheckData.php b/src/Data/RiskCheckData.php index 3f4dc80..a7d6b4c 100644 --- a/src/Data/RiskCheckData.php +++ b/src/Data/RiskCheckData.php @@ -7,15 +7,24 @@ /** * Class RiskCheckData * - * - * @property string riskCheckResult - * @property int riskScore - * @property boolean threeDSecureRequired - * - * * @package Ixopay\Client\Data */ -class RiskCheckData extends DataObject { +class RiskCheckData extends DataObject +{ + /** + * @var string + */ + protected $riskCheckResult; + + /** + * @var int + */ + protected $riskScore; + + /** + * @var bool + */ + protected $threeDSecureRequired; /** * @return string @@ -62,4 +71,4 @@ public function setThreeDSecureRequired($threeDSecureRequired) { -} \ No newline at end of file +} diff --git a/src/Data/ThreeDSecureData.php b/src/Data/ThreeDSecureData.php index 25f752a..fcfa7b7 100644 --- a/src/Data/ThreeDSecureData.php +++ b/src/Data/ThreeDSecureData.php @@ -73,16 +73,16 @@ class ThreeDSecureData extends DataObject /** @var \DateTime */ protected $shippingAddressFirstUsage; - /** @var int */ + /** @var null|int */ protected $transactionActivityDay; - /** @var int */ + /** @var int|null */ protected $transactionActivityYear; - /** @var int */ + /** @var int|null */ protected $addCardAttemptsDay; - /** @var int */ + /** @var int|null */ protected $purchaseCountSixMonths; /** @var string */ @@ -689,7 +689,7 @@ public function setShippingAddressFirstUsage($shippingAddressFirstUsage) } /** - * @return string + * @return int|null */ public function getTransactionActivityDay() { @@ -697,7 +697,7 @@ public function getTransactionActivityDay() } /** - * @param string $transactionActivityDay + * @param int|null $transactionActivityDay * * @return ThreeDSecureData */ @@ -708,7 +708,7 @@ public function setTransactionActivityDay($transactionActivityDay) } /** - * @return string + * @return int|null */ public function getTransactionActivityYear() { @@ -716,7 +716,7 @@ public function getTransactionActivityYear() } /** - * @param string $transactionActivityYear + * @param int|null $transactionActivityYear * * @return ThreeDSecureData */ @@ -727,7 +727,7 @@ public function setTransactionActivityYear($transactionActivityYear) } /** - * @return string + * @return int|null */ public function getAddCardAttemptsDay() { @@ -735,7 +735,7 @@ public function getAddCardAttemptsDay() } /** - * @param string $addCardAttemptsDay + * @param int|null $addCardAttemptsDay * * @return ThreeDSecureData */ @@ -746,7 +746,7 @@ public function setAddCardAttemptsDay($addCardAttemptsDay) } /** - * @return string + * @return int|null */ public function getPurchaseCountSixMonths() { @@ -754,7 +754,7 @@ public function getPurchaseCountSixMonths() } /** - * @param string $purchaseCountSixMonths + * @param int|null $purchaseCountSixMonths * * @return ThreeDSecureData */ diff --git a/src/Dispute/DisputeResult.php b/src/Dispute/DisputeResult.php index 19cb2f8..8b339f1 100644 --- a/src/Dispute/DisputeResult.php +++ b/src/Dispute/DisputeResult.php @@ -2,6 +2,8 @@ namespace Ixopay\Client\Dispute; +use Ixopay\Client\Transaction\Error; + class DisputeResult { /** diff --git a/src/Http/CurlClient.php b/src/Http/CurlClient.php index e6aec47..d9e815c 100644 --- a/src/Http/CurlClient.php +++ b/src/Http/CurlClient.php @@ -2,6 +2,7 @@ namespace Ixopay\Client\Http; +use CurlHandle; use Ixopay\Client\Client; use Ixopay\Client\Http\Exception\ClientException; @@ -17,7 +18,7 @@ class CurlClient implements ClientInterface { const METHOD_PUT = 'put'; /** - * @var resource + * @var CurlHandle */ private $handle; @@ -134,15 +135,6 @@ public function setCustomCurlOptions(array $customOptions){ return $this; } - /** - * - */ - public function __destruct() { - if (is_resource($this->handle)) { - curl_close($this->handle); - } - } - /** * Execute the request and return the response * @@ -171,9 +163,7 @@ public function send($method, $url, array $headers = []) { $allHeaders[] = 'X-SDK-PlatformVersion: ' . phpversion(); } - if (!empty($allHeaders)) { - $this->setOption(CURLOPT_HTTPHEADER, $allHeaders); - } + $this->setOption(CURLOPT_HTTPHEADER, $allHeaders); if($this->customOptions){ $this->setOptionArray($this->customOptions); diff --git a/src/Http/CurlExec.php b/src/Http/CurlExec.php index 3477efb..c857d87 100644 --- a/src/Http/CurlExec.php +++ b/src/Http/CurlExec.php @@ -3,6 +3,8 @@ namespace Ixopay\Client\Http; +use CurlHandle; + /** * Class CurlExec * @@ -11,7 +13,7 @@ class CurlExec { /** - * @var resource + * @var CurlHandle */ private $handle; @@ -26,21 +28,20 @@ class CurlExec { private $headers = array(); /** - * @var string + * @var ?string */ private $body; /** - * @param resource $handle + * @param CurlHandle $handle */ public function __construct($handle) { $this->handle = $handle; - curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, array($this, 'readHeaders')); $this->reset(); } /** - * @param resource $handle + * @param CurlHandle $handle * * @return CurlExec */ @@ -48,17 +49,6 @@ public static function getInstance($handle) { return new self($handle); } - /** - * @param resource $curl - * @param string $headerLine - * - * @return int - */ - private function readHeaders($curl, $headerLine) { - $this->headerString .= $headerLine; - return strlen($headerLine); - } - /** * @return $this */ @@ -125,4 +115,4 @@ public function getHeaders() { return $this->headers; } -} \ No newline at end of file +} diff --git a/src/Json/DataObject.php b/src/Json/DataObject.php index a83888a..c5100a0 100644 --- a/src/Json/DataObject.php +++ b/src/Json/DataObject.php @@ -76,41 +76,27 @@ public function __toString() { return json_encode($this->_data) ?: ''; } - - /** - * @param string $offset - * @return bool - */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return array_key_exists($offset, $this->_data); } - /** - * @param string $offset - * @return mixed|null - */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->__get($offset); } - /** - * @param string $offset - * @param mixed $value - */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { - return $this->__set($offset, $value); + $this->__set($offset, $value); } - /** - * @param string $offset - */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { $this->__unset($offset); } - /** - * @return array - */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->_data; } diff --git a/src/Json/JsonGenerator.php b/src/Json/JsonGenerator.php index 8ccfdcc..fc7478d 100644 --- a/src/Json/JsonGenerator.php +++ b/src/Json/JsonGenerator.php @@ -395,9 +395,10 @@ protected function createPayout($transaction, $language){ * * @param $items * - * @return array + * @return array|null */ - protected function createItems($items){ + protected function createItems($items) + { if(!$items){ return null; @@ -428,10 +429,10 @@ protected function createItems($items){ * * @param $transactionSplits * - * @return array + * @return array|null */ - protected function createSplits($transactionSplits){ - + protected function createSplits($transactionSplits) + { if(!$transactionSplits){ return null; } diff --git a/src/Json/JsonParser.php b/src/Json/JsonParser.php index 0e50f3d..4e9f774 100644 --- a/src/Json/JsonParser.php +++ b/src/Json/JsonParser.php @@ -552,7 +552,7 @@ protected function parseCustomerProfileData($data){ * @param $key * @param null $default * - * @return null + * @return mixed */ protected function arrGet($arr, $key, $default=null){ if(isset($arr[$key])){ diff --git a/src/Schedule/ScheduleData.php b/src/Schedule/ScheduleData.php index 347a0c5..dd4033a 100644 --- a/src/Schedule/ScheduleData.php +++ b/src/Schedule/ScheduleData.php @@ -197,8 +197,7 @@ public function getStartDateTimeFormatted($format = null) { } /** - * @param \DateTime|string - * + * @param \DateTime|string $startDateTime * @return ScheduleData * @throws \Exception */ @@ -219,7 +218,7 @@ public function getContinueDateTime() { } /** - * @param string|null + * @param string|null $format * @return string|null */ public function getContinueDateTimeFormatted($format = null) { @@ -227,7 +226,7 @@ public function getContinueDateTimeFormatted($format = null) { } /** - * @param null|\DateTime + * @param null|\DateTime $continueDateTime * * @return ScheduleData */ diff --git a/src/StatusApi/StatusRequestData.php b/src/StatusApi/StatusRequestData.php index 3cded0d..c28c5bd 100644 --- a/src/StatusApi/StatusRequestData.php +++ b/src/StatusApi/StatusRequestData.php @@ -23,7 +23,7 @@ class StatusRequestData { /** * the referenceId received by the transaction response * - * @var string + * @var ?string */ protected $uuid; @@ -114,4 +114,4 @@ public function validate() { } } -} \ No newline at end of file +} diff --git a/src/StatusApi/StatusResult.php b/src/StatusApi/StatusResult.php index 4ca0f49..1e6db68 100644 --- a/src/StatusApi/StatusResult.php +++ b/src/StatusApi/StatusResult.php @@ -124,9 +124,9 @@ class StatusResult { protected $errors = array(); /** - * @var ChargebackData + * @var ?ChargebackData */ - protected $chargebackData = array(); + protected $chargebackData = null; /** * for your internal use @@ -529,9 +529,9 @@ public function getChargebackData() { } /** - * @param ChargebackData $chargebackData + * @param ?ChargebackData $chargebackData */ - public function setChargebackData(ChargebackData $chargebackData) { + public function setChargebackData(?ChargebackData $chargebackData) { $this->chargebackData = $chargebackData; } diff --git a/src/Transaction/Base/AddToCustomerProfileInterface.php b/src/Transaction/Base/AddToCustomerProfileInterface.php index 7bdf5ae..cd8accc 100644 --- a/src/Transaction/Base/AddToCustomerProfileInterface.php +++ b/src/Transaction/Base/AddToCustomerProfileInterface.php @@ -17,10 +17,10 @@ interface AddToCustomerProfileInterface { public function getCustomerProfileData(); /** - * @param CustomerProfileData $customerProfileData + * @param ?CustomerProfileData $customerProfileData */ - public function setCustomerProfileData(CustomerProfileData $customerProfileData = null); - + public function setCustomerProfileData(?CustomerProfileData $customerProfileData = null); + /** * @param bool $addToCustomerProfile */ @@ -50,7 +50,7 @@ public function setCustomerProfileIdentification($identification); * @return string */ public function getCustomerProfileIdentification(); - + /** * @return bool */ @@ -60,4 +60,4 @@ public function getMarkAsPreferred(); * @param bool $markAsPreferred */ public function setMarkAsPreferred($markAsPreferred); -} \ No newline at end of file +} diff --git a/src/Transaction/Base/AddToCustomerProfileTrait.php b/src/Transaction/Base/AddToCustomerProfileTrait.php index 1bc5ed7..36ccfe3 100644 --- a/src/Transaction/Base/AddToCustomerProfileTrait.php +++ b/src/Transaction/Base/AddToCustomerProfileTrait.php @@ -19,7 +19,7 @@ trait AddToCustomerProfileTrait { protected $addToCustomerProfile = false; /** - * @var CustomerProfileData + * @var CustomerProfileData|null */ protected $customerProfileData; @@ -31,12 +31,14 @@ public function getCustomerProfileData() { } /** - * @param CustomerProfileData|null $customerProfileData + * @param ?CustomerProfileData $customerProfileData * * @return $this */ - public function setCustomerProfileData(CustomerProfileData $customerProfileData = null) { + public function setCustomerProfileData(?CustomerProfileData $customerProfileData = null) + { $this->customerProfileData = $customerProfileData; + return $this; } @@ -133,4 +135,4 @@ public function setMarkAsPreferred($markAsPreferred) { } return $this; } -} \ No newline at end of file +} diff --git a/src/Transaction/Error.php b/src/Transaction/Error.php index 7436d9f..c041425 100644 --- a/src/Transaction/Error.php +++ b/src/Transaction/Error.php @@ -205,4 +205,4 @@ public function setAdapterMessage($adapterMessage) { $this->adapterMessage = $adapterMessage; } -} \ No newline at end of file +} diff --git a/src/Transaction/IncrementalAuthorization.php b/src/Transaction/IncrementalAuthorization.php index f950b5d..99e6fff 100644 --- a/src/Transaction/IncrementalAuthorization.php +++ b/src/Transaction/IncrementalAuthorization.php @@ -30,11 +30,4 @@ class IncrementalAuthorization extends AbstractTransactionWithReference use ItemsTrait; use IndicatorTrait; use LevelTwoAndThreeDataTrait; - - /** - * @return string - */ - public function getTransactionMethod() { - return self::TRANSACTION_METHOD_INCREMENTAL_AUTHORIZATION; - } } diff --git a/src/Transaction/Result.php b/src/Transaction/Result.php index e545a78..e2a007c 100644 --- a/src/Transaction/Result.php +++ b/src/Transaction/Result.php @@ -351,14 +351,14 @@ public function getExtraData() { /** * tells you how to proceed with the transaction * - * @return int + * @return string */ public function getReturnType() { return $this->returnType; } /** - * @param int $returnType + * @param string $returnType * * @return $this */ diff --git a/src/Xml/Parser.php b/src/Xml/Parser.php index 7915ee9..43bda3f 100644 --- a/src/Xml/Parser.php +++ b/src/Xml/Parser.php @@ -417,7 +417,7 @@ protected function parseReturnType(\DOMNode $node) { /** * @param \DOMNode $node - * @return string + * @return ?string */ protected function parseRedirectType(\DOMNode $node) { if ($node && $node->attributes) { diff --git a/src/Xml/XmlGenerator.php b/src/Xml/XmlGenerator.php index ffed5ab..1f52fd8 100644 --- a/src/Xml/XmlGenerator.php +++ b/src/Xml/XmlGenerator.php @@ -103,10 +103,13 @@ public function generateTransaction($method, AbstractTransaction $transaction, $ $node = $this->generatePayoutNode($transaction, $method); break; default: - throw new NotSupportedException(\sprintf( + $className = get_class($transaction); + $e = sprintf( 'Transaction Type %s is not supported', - \substr(\get_class($transaction), \strrpos('\\') + 1) - )); + substr($className, strrpos($className, '\\') + 1), + ); + + throw new NotSupportedException($e); } } @@ -347,15 +350,15 @@ protected function appendAddToCustomerProfileNode(\DOMNode $parentNode, AddToCus if ($transaction->getMarkAsPreferred()) { $this->_appendTextNode($profileNode, 'markAsPreferred', 'true'); } - + $parentNode->appendChild($profileNode); - + } elseif ($transaction->getCustomerProfileIdentification()) { $this->_appendTextNode($profileNode, 'customerIdentification', $transaction->getCustomerProfileIdentification()); if ($transaction->getMarkAsPreferred()) { $this->_appendTextNode($profileNode, 'markAsPreferred', 'true'); } - + $parentNode->appendChild($profileNode); } @@ -400,7 +403,7 @@ protected function appendOffsiteNodes(\DOMNode $parentNode, OffsiteInterface $tr protected function appendAmountableNodes(\DOMNode $parentNode, AmountableInterface $transaction) { $this->verifyAmountType($transaction->getAmount(), 'amount'); $this->verifyCurrencyType($transaction->getCurrency(), 'currency'); - + $this->_appendTextNode($parentNode, 'amount', number_format($transaction->getAmount(), 2, '.', '')); $this->_appendTextNode($parentNode, 'currency', $transaction->getCurrency()); } @@ -792,7 +795,7 @@ private function verifyFutureDateTime($startDateTime, $elementName) { throw new TypeException('Value of '.$elementName.' must be a Date/Time object in future'); } } - + /** * @param \DOMNode $parentNode * @param string $nodeName