From 1e14bb1bcad8a565de3de05a8c06540bced5d949 Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Fri, 24 Jul 2020 13:25:06 +0200 Subject: [PATCH] Release Version 1.2.8.0 (#201) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [change] (PHPLIB-209) Add traceId to transactions and payment. * [Change] (PHPLIB-209) Fix several style issues. * [change] (PHPLIB-209) Add traceId tests. * [change] (PHPLIB-209) Update unit tests for traceId. * [change] (PHPLIB-209) Update changelog and version. * [change] (PHPLIB-209) Update CHANGELOG.md * [change] (PHPLIB-209) Fix tests. * Update src/Heidelpay.php Co-Authored-By: David Owusu <33735090+Ryouzanpaku@users.noreply.github.com> * Merge remote-tracking branch 'remotes/github/develop' into bugfix/PHPLIB-309/renaming-cc-holder-to-cardHolder (#171) * [bugfix] (PHPLIB-309) Rename Cards holder to cardHolder. * [change] (PHPLIB-209) Fix tests add update version and CHANGELOG.md * [change] (PHPLIB-309) Update test. * [change] (PHPLIB-309) Update unit test. * [change] (PHPLIB-309) Add unit tests to verify deprecated getter/setter. * [change] (PHPLIB-309) Add integration test to verify deprecated getter/setter. Co-authored-by: sixer1182 * [change] (PHPLIB-318) Refactor tests to fit latest API changes. (#176) Co-authored-by: sixer1182 * [change] (PHPLIB-300) Add description. (#172) Co-authored-by: sixer1182 * [change] (PHPLIB-307) Add email field to PayPal example. (#173) Co-authored-by: sixer1182 * change/PHPLIB-187/add-geolocation-to-card (#174) * [bugfix] (PHPLIB-309) Rename Cards holder to cardHolder. * [change] (PHPLIB-209) Fix tests add update version and CHANGELOG.md * [change] (PHPLIB-309) Update test. * [change] (PHPLIB-309) Update unit test. * [refactor] (PHPLIB-187) Geolocation: Move geolocation to trait. * [refactor] (PHPLIB-187) Geolocation: Add geolocation to card class. * [change] (PHPLIB-187) Fix styles. * [change] (PHPLIB-187) Update CHANGELOG.md * [change] (PHPLIB-187) Remove dead "code" * [change] (PHPLIB-187) Fix examples: Fix ids due to api changes. * [change] (PHPLIB-187) Fix examples: Fix ids due to api changes. Co-authored-by: sixer1182 * change/PHPLIB-304/update-webhook-support (#175) * [bugfix] (PHPLIB-309) Rename Cards holder to cardHolder. * [change] (PHPLIB-209) Fix tests add update version and CHANGELOG.md * [change] (PHPLIB-309) Update test. * [change] (PHPLIB-309) Update unit test. * [change] (PHPLIB-304) Update webhook events. * [change] (PHPLIB-304) Fix tests: Fix ids due to api changes. Co-authored-by: sixer1182 * change/PHPLIB-323/Update-errorcodes (#177) * [change] (PHPLIB-323) Update respons codes due to API changes. * [change] (PHPLIB-323) Update CHANGELOG.md * [change] (PHPLIB-323) Update respons codes due to API changes. * [change] (PHPLIB-323) Update respons codes due to API changes. Co-authored-by: sixer1182 * bugfix/PHPLIB-319/auth-has-empty-cancel-obj-when-payment-is-cancelled (#178) * [change] (PHPLIB-318) Refactor tests to fit latest API changes. * [change] (PHPLIB-323) Update respons codes due to API changes. * [change] (PHPLIB-323) Update CHANGELOG.md * [change] (PHPLIB-323) Update respons codes due to API changes. * [change] (PHPLIB-323) Update respons codes due to API changes. * [change] (PHPLIB-319) Do not add cancellation to authorization if it fails. * [refactor] (PHPLIB-319) Replace type hinting. * [refactor] (PHPLIB-319) Avoid adding the cancellation object twice. * [refactor] (PHPLIB-319) Update CHANGELOG.md * [refactor] (PHPLIB-319) Fix unit test. * [refactor] (PHPLIB-319) Fix CHANGELOG.md Co-authored-by: sixer1182 * [change] (PHPLIB-336) Mask auth header in debug log. (#180) Co-authored-by: sixer1182 * bugfix/PHPLIB-330/fix-errors-related-to-tls-certs (#182) * [bugfix] (PHPLIB-330) Add local certificate to travis config. * [bugfix] (PHPLIB-330) Add local certificate to travis config. * [bugfix] (PHPLIB-330) Add local certificate to travis config. * [bugfix] (PHPLIB-330) Add local certificate to travis config. * [bugfix] (PHPLIB-330) Add curl error text to log. * [bugfix] (PHPLIB-330) Add curl error text to log. * [change] (PHPLIB-336) Mask auth header in debug log. * [change] (PHPLIB-336) Switch to composer update for integration test. * Revert "[change] (PHPLIB-336) Switch to composer update for integration test." This reverts commit dbe61bf7 * [change] (PHPLIB-330) debugging: disable peer and host verification * [change] (PHPLIB-330) debugging: enable peer verification * [change] (PHPLIB-330) debugging: disable peer verification and enable host common name is set. * [change] (PHPLIB-330) debugging: disable peer verification and enable host common name verfication. * [change] (PHPLIB-330) debugging: enable verify ssl status * [change] (PHPLIB-330) debugging: enable verify ssl status * [change] (PHPLIB-330) debugging: enable curl verbos output * [change] (PHPLIB-330) debugging: add env var for curl verbosity. * [change] (PHPLIB-330) debugging: add env var for curl verbosity. * [change] (PHPLIB-330) debugging: add env var for curl verbosity. * [change] (PHPLIB-330) debugging: add date to output. * [change] (PHPLIB-330) debugging: add date to output. * [change] (PHPLIB-330) debugging: add date to output. * [change] (PHPLIB-330) debugging: add date to output. * [change] (PHPLIB-330) debugging: set linux distribution to default * [change] (PHPLIB-330) remove linux distribution from travis config to enable using the current default. * [change] (PHPLIB-330) update CHANGELOG.md * [change] (PHPLIB-330) Update PHP Unit config. * [change] (PHPLIB-330) Update CHANGELOG.md * [change] (PHPLIB-330) Fix typo in field id. Co-authored-by: sixer1182 * Merge remote-tracking branch 'remotes/github/develop' into change/PHPLIB-326/debug-output-nach-fehlgeschlagenem-test (#183) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. Co-authored-by: sixer1182 * change/PHPLIB-333/remove-default-key-pair-from-examples (#184) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. * [change] (PHPLIB-333) Remove default key pair from examples. * [change] (PHPLIB-333) Update version since the changes are quite intence. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) Fix key validation. * [change] (PHPLIB-333) Move general key-check to index. Co-authored-by: sixer1182 * change/PHPLIB-334/remove-default-keypair-from-tests (#185) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. * [change] (PHPLIB-333) Remove default key pair from examples. * [change] (PHPLIB-333) Update version since the changes are quite intence. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) Fix key validation. * [change] (PHPLIB-333) Move general key-check to index. * [change] (PHPLIB-334) Remove default keys from tests and refactor tests. * [change] (PHPLIB-334) Tests: Extend unit test for fetching the keys from env vars. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Refactor tests due to removal of default keys. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Update recurring test to comply to latest api changes. * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update CHANGELOG.md * [refactor] (PHPLIB-334) Fix style issues. Co-authored-by: sixer1182 * change/PHPLIB-317/refactor-due-to-min-php-version (#186) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. * [change] (PHPLIB-333) Remove default key pair from examples. * [change] (PHPLIB-333) Update version since the changes are quite intence. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) Fix key validation. * [change] (PHPLIB-333) Move general key-check to index. * [change] (PHPLIB-334) Remove default keys from tests and refactor tests. * [change] (PHPLIB-334) Tests: Extend unit test for fetching the keys from env vars. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Refactor tests due to removal of default keys. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Update recurring test to comply to latest api changes. * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update CHANGELOG.md * [refactor] (PHPLIB-317) Adapt style and features to PHP version 7.1. * Add return type hints. * Fix some minor issues. * Add missing exception annotations. * Remove unnecessary comments from tests. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Refactor code. * Replace deprecated methods. * Add some noinspection rules. * Fixed some minor issues. * [refactor] (PHPLIB-317) Remove debug code. * [change] (PHPLIB-317) Tests remove throws annotations. * [change] (PHPLIB-317) Apply change due to review comment. Co-authored-by: sixer1182 * PHPLIB-313/change/examples_always_create_heidelpay_instance_to_show_sandbox_banner (#187) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. * [change] (PHPLIB-333) Remove default key pair from examples. * [change] (PHPLIB-333) Update version since the changes are quite intence. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) Fix key validation. * [change] (PHPLIB-333) Move general key-check to index. * [change] (PHPLIB-334) Remove default keys from tests and refactor tests. * [change] (PHPLIB-334) Tests: Extend unit test for fetching the keys from env vars. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Refactor tests due to removal of default keys. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Update recurring test to comply to latest api changes. * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update CHANGELOG.md * [refactor] (PHPLIB-317) Adapt style and features to PHP version 7.1. * Add return type hints. * Fix some minor issues. * Add missing exception annotations. * Remove unnecessary comments from tests. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Refactor code. * Replace deprecated methods. * Add some noinspection rules. * Fixed some minor issues. * [refactor] (PHPLIB-317) Remove debug code. * [refactor] (PHPLIB-334) Fix style issues. * [change] (PHPLIB-313) Examples/PrePayment: Create heidelpay object to make sure the sandbox banner is visible. * [change] (PHPLIB-313) Examples/PrePayment: Create heidelpay object to make sure the sandbox banner is visible. * [change] (PHPLIB-313) Update due to codacy issues. * [change] (PHPLIB-313) Tests: Fix unit tests. * [change] (PHPLIB-313) Add missing throws annotations. * [change] (PHPLIB-313) Add missing throws annotations. Co-authored-by: sixer1182 * Added the possibility to add custom css to the payment page * PHPLIB-340/change/update-workflow-in-examples (#188) * [change] (PHPLIB-340) Examples: Update describing comments in examples. * [change] (PHPLIB-340) Tests: Add accessor to create and return heidelpayObject if necessary. * [change] (PHPLIB-340) Add method to get the initial transaction object from a payment. * [change] (PHPLIB-340) Examples: Refactor Alipay ReturnController.php to incorporate all possible cases of payment result handling. * [change] (PHPLIB-340) Examples: Refactor Failure.php * [change] (PHPLIB-340) Fix support email address in README.md * [change] (PHPLIB-340) Fix support contact data in README.md * [change] (PHPLIB-340) Fix support contact data in README.md * [change] (PHPLIB-340) Examples: Refactor examples to use generic return controller (with exceptions). * [change] (PHPLIB-340) Examples: Update. * [change] (PHPLIB-340) Examples: Update workflow and templates. * [change] (PHPLIB-340) Examples: Update workflow. * [change] (PHPLIB-340) Examples: Update workflow. * [change] (PHPLIB-340) Add PrePayment to invoice types to handle its workflow correctly. * [change] (PHPLIB-340) Update CHANGELOG.md * [change] (PHPLIB-340) Update comments. * [change] (PHPLIB-340) Update comments. * [change] (PHPLIB-340) Cleanup. * [change] (PHPLIB-340) Prepayment is handled explicitly in examples and not as invoice type. * [change] (PHPLIB-340) Examples: Show additional payment information on success page of invoice/prepayment. * Update examples/ReturnController.php Co-authored-by: Florian Evertz <10667564+xBlack-Shadow@users.noreply.github.com> Co-authored-by: sixer1182 Co-authored-by: Florian Evertz <10667564+xBlack-Shadow@users.noreply.github.com> * Merge remote-tracking branch 'remotes/github/develop' into PHPLIB-345/change/release-and-merge-external-pr (#191) * [change] (PHPLIB-345) Paypage: Add css property and tests. * [change] (PHPLIB-345) Paypage: Fix style. * [change] (PHPLIB-345) Fix CHANGELOG.md Co-authored-by: sixer1182 * Merge remote-tracking branch 'remotes/github/develop' into PHPLIB-345/change/release-and-merge-external-pr (#193) * [change] (PHPLIB-345) Paypage: Add css property and tests. * [change] (PHPLIB-345) Paypage: Fix style. * [change] (PHPLIB-345) Fix CHANGELOG.md Co-authored-by: sixer1182 * PHPLIB-345/change/release-and-merge-external-pr (#195) * Release 1.2.7.2 (#179) * [change] (PHPLIB-209) Add traceId to transactions and payment. * [Change] (PHPLIB-209) Fix several style issues. * [change] (PHPLIB-209) Add traceId tests. * [change] (PHPLIB-209) Update unit tests for traceId. * [change] (PHPLIB-209) Update changelog and version. * [change] (PHPLIB-209) Update CHANGELOG.md * [change] (PHPLIB-209) Fix tests. * Update src/Heidelpay.php Co-Authored-By: David Owusu <33735090+Ryouzanpaku@users.noreply.github.com> * Merge remote-tracking branch 'remotes/github/develop' into bugfix/PHPLIB-309/renaming-cc-holder-to-cardHolder (#171) * [bugfix] (PHPLIB-309) Rename Cards holder to cardHolder. * [change] (PHPLIB-209) Fix tests add update version and CHANGELOG.md * [change] (PHPLIB-309) Update test. * [change] (PHPLIB-309) Update unit test. * [change] (PHPLIB-309) Add unit tests to verify deprecated getter/setter. * [change] (PHPLIB-309) Add integration test to verify deprecated getter/setter. Co-authored-by: sixer1182 * [change] (PHPLIB-318) Refactor tests to fit latest API changes. (#176) Co-authored-by: sixer1182 * [change] (PHPLIB-300) Add description. (#172) Co-authored-by: sixer1182 * [change] (PHPLIB-307) Add email field to PayPal example. (#173) Co-authored-by: sixer1182 * change/PHPLIB-187/add-geolocation-to-card (#174) * [bugfix] (PHPLIB-309) Rename Cards holder to cardHolder. * [change] (PHPLIB-209) Fix tests add update version and CHANGELOG.md * [change] (PHPLIB-309) Update test. * [change] (PHPLIB-309) Update unit test. * [refactor] (PHPLIB-187) Geolocation: Move geolocation to trait. * [refactor] (PHPLIB-187) Geolocation: Add geolocation to card class. * [change] (PHPLIB-187) Fix styles. * [change] (PHPLIB-187) Update CHANGELOG.md * [change] (PHPLIB-187) Remove dead "code" * [change] (PHPLIB-187) Fix examples: Fix ids due to api changes. * [change] (PHPLIB-187) Fix examples: Fix ids due to api changes. Co-authored-by: sixer1182 * change/PHPLIB-304/update-webhook-support (#175) * [bugfix] (PHPLIB-309) Rename Cards holder to cardHolder. * [change] (PHPLIB-209) Fix tests add update version and CHANGELOG.md * [change] (PHPLIB-309) Update test. * [change] (PHPLIB-309) Update unit test. * [change] (PHPLIB-304) Update webhook events. * [change] (PHPLIB-304) Fix tests: Fix ids due to api changes. Co-authored-by: sixer1182 * change/PHPLIB-323/Update-errorcodes (#177) * [change] (PHPLIB-323) Update respons codes due to API changes. * [change] (PHPLIB-323) Update CHANGELOG.md * [change] (PHPLIB-323) Update respons codes due to API changes. * [change] (PHPLIB-323) Update respons codes due to API changes. Co-authored-by: sixer1182 * bugfix/PHPLIB-319/auth-has-empty-cancel-obj-when-payment-is-cancelled (#178) * [change] (PHPLIB-318) Refactor tests to fit latest API changes. * [change] (PHPLIB-323) Update respons codes due to API changes. * [change] (PHPLIB-323) Update CHANGELOG.md * [change] (PHPLIB-323) Update respons codes due to API changes. * [change] (PHPLIB-323) Update respons codes due to API changes. * [change] (PHPLIB-319) Do not add cancellation to authorization if it fails. * [refactor] (PHPLIB-319) Replace type hinting. * [refactor] (PHPLIB-319) Avoid adding the cancellation object twice. * [refactor] (PHPLIB-319) Update CHANGELOG.md * [refactor] (PHPLIB-319) Fix unit test. * [refactor] (PHPLIB-319) Fix CHANGELOG.md Co-authored-by: sixer1182 Co-authored-by: sixer1182 Co-authored-by: David Owusu <33735090+Ryouzanpaku@users.noreply.github.com> * [change] (PHPLIB-345) Paypage: Add css property and tests. * [change] (PHPLIB-345) Paypage: Fix style. * [change] (PHPLIB-345) Fix CHANGELOG.md * [change] (PHPLIB-209) Update CHANGELOG.md * Merge remote-tracking branch 'remotes/github/develop' into bugfix/PHPLIB-309/renaming-cc-holder-to-cardHolder (#171) * [bugfix] (PHPLIB-309) Rename Cards holder to cardHolder. * [change] (PHPLIB-209) Fix tests add update version and CHANGELOG.md * [change] (PHPLIB-309) Update test. * [change] (PHPLIB-309) Update unit test. * [change] (PHPLIB-309) Add unit tests to verify deprecated getter/setter. * [change] (PHPLIB-309) Add integration test to verify deprecated getter/setter. Co-authored-by: sixer1182 * [change] (PHPLIB-300) Add description. (#172) Co-authored-by: sixer1182 * [change] (PHPLIB-336) Mask auth header in debug log. (#180) Co-authored-by: sixer1182 * bugfix/PHPLIB-330/fix-errors-related-to-tls-certs (#182) * [bugfix] (PHPLIB-330) Add local certificate to travis config. * [bugfix] (PHPLIB-330) Add local certificate to travis config. * [bugfix] (PHPLIB-330) Add local certificate to travis config. * [bugfix] (PHPLIB-330) Add local certificate to travis config. * [bugfix] (PHPLIB-330) Add curl error text to log. * [bugfix] (PHPLIB-330) Add curl error text to log. * [change] (PHPLIB-336) Mask auth header in debug log. * [change] (PHPLIB-336) Switch to composer update for integration test. * Revert "[change] (PHPLIB-336) Switch to composer update for integration test." This reverts commit dbe61bf7 * [change] (PHPLIB-330) debugging: disable peer and host verification * [change] (PHPLIB-330) debugging: enable peer verification * [change] (PHPLIB-330) debugging: disable peer verification and enable host common name is set. * [change] (PHPLIB-330) debugging: disable peer verification and enable host common name verfication. * [change] (PHPLIB-330) debugging: enable verify ssl status * [change] (PHPLIB-330) debugging: enable verify ssl status * [change] (PHPLIB-330) debugging: enable curl verbos output * [change] (PHPLIB-330) debugging: add env var for curl verbosity. * [change] (PHPLIB-330) debugging: add env var for curl verbosity. * [change] (PHPLIB-330) debugging: add env var for curl verbosity. * [change] (PHPLIB-330) debugging: add date to output. * [change] (PHPLIB-330) debugging: add date to output. * [change] (PHPLIB-330) debugging: add date to output. * [change] (PHPLIB-330) debugging: add date to output. * [change] (PHPLIB-330) debugging: set linux distribution to default * [change] (PHPLIB-330) remove linux distribution from travis config to enable using the current default. * [change] (PHPLIB-330) update CHANGELOG.md * [change] (PHPLIB-330) Update PHP Unit config. * [change] (PHPLIB-330) Update CHANGELOG.md * [change] (PHPLIB-330) Fix typo in field id. Co-authored-by: sixer1182 * Merge remote-tracking branch 'remotes/github/develop' into change/PHPLIB-326/debug-output-nach-fehlgeschlagenem-test (#183) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. Co-authored-by: sixer1182 * change/PHPLIB-333/remove-default-key-pair-from-examples (#184) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. * [change] (PHPLIB-333) Remove default key pair from examples. * [change] (PHPLIB-333) Update version since the changes are quite intence. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) Fix key validation. * [change] (PHPLIB-333) Move general key-check to index. Co-authored-by: sixer1182 * change/PHPLIB-334/remove-default-keypair-from-tests (#185) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. * [change] (PHPLIB-333) Remove default key pair from examples. * [change] (PHPLIB-333) Update version since the changes are quite intence. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) Fix key validation. * [change] (PHPLIB-333) Move general key-check to index. * [change] (PHPLIB-334) Remove default keys from tests and refactor tests. * [change] (PHPLIB-334) Tests: Extend unit test for fetching the keys from env vars. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Refactor tests due to removal of default keys. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Update recurring test to comply to latest api changes. * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update CHANGELOG.md * [refactor] (PHPLIB-334) Fix style issues. Co-authored-by: sixer1182 * change/PHPLIB-317/refactor-due-to-min-php-version (#186) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. * [change] (PHPLIB-333) Remove default key pair from examples. * [change] (PHPLIB-333) Update version since the changes are quite intence. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) Fix key validation. * [change] (PHPLIB-333) Move general key-check to index. * [change] (PHPLIB-334) Remove default keys from tests and refactor tests. * [change] (PHPLIB-334) Tests: Extend unit test for fetching the keys from env vars. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Refactor tests due to removal of default keys. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Update recurring test to comply to latest api changes. * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update CHANGELOG.md * [refactor] (PHPLIB-317) Adapt style and features to PHP version 7.1. * Add return type hints. * Fix some minor issues. * Add missing exception annotations. * Remove unnecessary comments from tests. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Refactor code. * Replace deprecated methods. * Add some noinspection rules. * Fixed some minor issues. * [refactor] (PHPLIB-317) Remove debug code. * [change] (PHPLIB-317) Tests remove throws annotations. * [change] (PHPLIB-317) Apply change due to review comment. Co-authored-by: sixer1182 * PHPLIB-313/change/examples_always_create_heidelpay_instance_to_show_sandbox_banner (#187) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. * [change] (PHPLIB-333) Remove default key pair from examples. * [change] (PHPLIB-333) Update version since the changes are quite intence. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) Fix key validation. * [change] (PHPLIB-333) Move general key-check to index. * [change] (PHPLIB-334) Remove default keys from tests and refactor tests. * [change] (PHPLIB-334) Tests: Extend unit test for fetching the keys from env vars. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Refactor tests due to removal of default keys. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Update recurring test to comply to latest api changes. * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update CHANGELOG.md * [refactor] (PHPLIB-317) Adapt style and features to PHP version 7.1. * Add return type hints. * Fix some minor issues. * Add missing exception annotations. * Remove unnecessary comments from tests. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Refactor code. * Replace deprecated methods. * Add some noinspection rules. * Fixed some minor issues. * [refactor] (PHPLIB-317) Remove debug code. * [refactor] (PHPLIB-334) Fix style issues. * [change] (PHPLIB-313) Examples/PrePayment: Create heidelpay object to make sure the sandbox banner is visible. * [change] (PHPLIB-313) Examples/PrePayment: Create heidelpay object to make sure the sandbox banner is visible. * [change] (PHPLIB-313) Update due to codacy issues. * [change] (PHPLIB-313) Tests: Fix unit tests. * [change] (PHPLIB-313) Add missing throws annotations. * [change] (PHPLIB-313) Add missing throws annotations. Co-authored-by: sixer1182 * PHPLIB-340/change/update-workflow-in-examples (#188) * [change] (PHPLIB-340) Examples: Update describing comments in examples. * [change] (PHPLIB-340) Tests: Add accessor to create and return heidelpayObject if necessary. * [change] (PHPLIB-340) Add method to get the initial transaction object from a payment. * [change] (PHPLIB-340) Examples: Refactor Alipay ReturnController.php to incorporate all possible cases of payment result handling. * [change] (PHPLIB-340) Examples: Refactor Failure.php * [change] (PHPLIB-340) Fix support email address in README.md * [change] (PHPLIB-340) Fix support contact data in README.md * [change] (PHPLIB-340) Fix support contact data in README.md * [change] (PHPLIB-340) Examples: Refactor examples to use generic return controller (with exceptions). * [change] (PHPLIB-340) Examples: Update. * [change] (PHPLIB-340) Examples: Update workflow and templates. * [change] (PHPLIB-340) Examples: Update workflow. * [change] (PHPLIB-340) Examples: Update workflow. * [change] (PHPLIB-340) Add PrePayment to invoice types to handle its workflow correctly. * [change] (PHPLIB-340) Update CHANGELOG.md * [change] (PHPLIB-340) Update comments. * [change] (PHPLIB-340) Update comments. * [change] (PHPLIB-340) Cleanup. * [change] (PHPLIB-340) Prepayment is handled explicitly in examples and not as invoice type. * [change] (PHPLIB-340) Examples: Show additional payment information on success page of invoice/prepayment. * Update examples/ReturnController.php Co-authored-by: Florian Evertz <10667564+xBlack-Shadow@users.noreply.github.com> Co-authored-by: sixer1182 Co-authored-by: Florian Evertz <10667564+xBlack-Shadow@users.noreply.github.com> * [change] (PHPLIB-345) Paypage: Add css property and tests. * Added the possibility to add custom css to the payment page * [change] (PHPLIB-345) Paypage: Fix style. * [change] (PHPLIB-345) Fix CHANGELOG.md Co-authored-by: heidelpay Co-authored-by: sixer1182 Co-authored-by: David Owusu <33735090+Ryouzanpaku@users.noreply.github.com> Co-authored-by: Florian Evertz <10667564+xBlack-Shadow@users.noreply.github.com> Co-authored-by: “Baris * Revert "PHPLIB-345/change/release-and-merge-external-pr (#195)" (#196) This reverts commit fc991ed5f7c8a0f30a89620fa2bbf90f8a248702. * Revert "Merge remote-tracking branch 'remotes/github/develop' into PHPLIB-345/change/release-and-merge-external-pr (#193)" (#197) This reverts commit 69e87d647d2f0f7bdd37ec99285300206941fe88. * Revert "Merge remote-tracking branch 'remotes/github/develop' into PHPLIB-345/change/release-and-merge-external-pr (#191)" (#198) This reverts commit b07063384fd0b0daecbab793e7f1c02fc295183b. * Revert "Added the possibility to add custom css to the payment page" (#199) * [change] (PHPLIB-209) Update CHANGELOG.md * [change] (PHPLIB-336) Mask auth header in debug log. (#180) Co-authored-by: sixer1182 * bugfix/PHPLIB-330/fix-errors-related-to-tls-certs (#182) * [bugfix] (PHPLIB-330) Add local certificate to travis config. * [bugfix] (PHPLIB-330) Add local certificate to travis config. * [bugfix] (PHPLIB-330) Add local certificate to travis config. * [bugfix] (PHPLIB-330) Add local certificate to travis config. * [bugfix] (PHPLIB-330) Add curl error text to log. * [bugfix] (PHPLIB-330) Add curl error text to log. * [change] (PHPLIB-336) Mask auth header in debug log. * [change] (PHPLIB-336) Switch to composer update for integration test. * Revert "[change] (PHPLIB-336) Switch to composer update for integration test." This reverts commit dbe61bf7 * [change] (PHPLIB-330) debugging: disable peer and host verification * [change] (PHPLIB-330) debugging: enable peer verification * [change] (PHPLIB-330) debugging: disable peer verification and enable host common name is set. * [change] (PHPLIB-330) debugging: disable peer verification and enable host common name verfication. * [change] (PHPLIB-330) debugging: enable verify ssl status * [change] (PHPLIB-330) debugging: enable verify ssl status * [change] (PHPLIB-330) debugging: enable curl verbos output * [change] (PHPLIB-330) debugging: add env var for curl verbosity. * [change] (PHPLIB-330) debugging: add env var for curl verbosity. * [change] (PHPLIB-330) debugging: add env var for curl verbosity. * [change] (PHPLIB-330) debugging: add date to output. * [change] (PHPLIB-330) debugging: add date to output. * [change] (PHPLIB-330) debugging: add date to output. * [change] (PHPLIB-330) debugging: add date to output. * [change] (PHPLIB-330) debugging: set linux distribution to default * [change] (PHPLIB-330) remove linux distribution from travis config to enable using the current default. * [change] (PHPLIB-330) update CHANGELOG.md * [change] (PHPLIB-330) Update PHP Unit config. * [change] (PHPLIB-330) Update CHANGELOG.md * [change] (PHPLIB-330) Fix typo in field id. Co-authored-by: sixer1182 * Merge remote-tracking branch 'remotes/github/develop' into change/PHPLIB-326/debug-output-nach-fehlgeschlagenem-test (#183) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. Co-authored-by: sixer1182 * change/PHPLIB-333/remove-default-key-pair-from-examples (#184) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. * [change] (PHPLIB-333) Remove default key pair from examples. * [change] (PHPLIB-333) Update version since the changes are quite intence. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) Fix key validation. * [change] (PHPLIB-333) Move general key-check to index. Co-authored-by: sixer1182 * change/PHPLIB-334/remove-default-keypair-from-tests (#185) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. * [change] (PHPLIB-333) Remove default key pair from examples. * [change] (PHPLIB-333) Update version since the changes are quite intence. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) Fix key validation. * [change] (PHPLIB-333) Move general key-check to index. * [change] (PHPLIB-334) Remove default keys from tests and refactor tests. * [change] (PHPLIB-334) Tests: Extend unit test for fetching the keys from env vars. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Refactor tests due to removal of default keys. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Update recurring test to comply to latest api changes. * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update CHANGELOG.md * [refactor] (PHPLIB-334) Fix style issues. Co-authored-by: sixer1182 * change/PHPLIB-317/refactor-due-to-min-php-version (#186) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. * [change] (PHPLIB-333) Remove default key pair from examples. * [change] (PHPLIB-333) Update version since the changes are quite intence. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) Fix key validation. * [change] (PHPLIB-333) Move general key-check to index. * [change] (PHPLIB-334) Remove default keys from tests and refactor tests. * [change] (PHPLIB-334) Tests: Extend unit test for fetching the keys from env vars. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Refactor tests due to removal of default keys. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Update recurring test to comply to latest api changes. * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update CHANGELOG.md * [refactor] (PHPLIB-317) Adapt style and features to PHP version 7.1. * Add return type hints. * Fix some minor issues. * Add missing exception annotations. * Remove unnecessary comments from tests. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Refactor code. * Replace deprecated methods. * Add some noinspection rules. * Fixed some minor issues. * [refactor] (PHPLIB-317) Remove debug code. * [change] (PHPLIB-317) Tests remove throws annotations. * [change] (PHPLIB-317) Apply change due to review comment. Co-authored-by: sixer1182 * PHPLIB-313/change/examples_always_create_heidelpay_instance_to_show_sandbox_banner (#187) * [change] (PHPLIB-326) Enable test output for failed tests even when verbose test logging is disabled. * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Replace environment variable for test log output and set default to false (no output). * [change] (PHPLIB-326) Update CHANGELOG.md. * [change] (PHPLIB-326) Fix style issues. * [change] (PHPLIB-326) Add new line before and after log dump. * [change] (PHPLIB-326) Fix version in deprecation notice. * [change] (PHPLIB-333) Remove default key pair from examples. * [change] (PHPLIB-333) Update version since the changes are quite intence. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) small change,. * [change] (PHPLIB-333) Fix key validation. * [change] (PHPLIB-333) Move general key-check to index. * [change] (PHPLIB-334) Remove default keys from tests and refactor tests. * [change] (PHPLIB-334) Tests: Extend unit test for fetching the keys from env vars. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Refactor tests due to removal of default keys. * [change] (PHPLIB-334) Tests: Changed EnvironmentService call to static method. * [change] (PHPLIB-334) Tests: Update recurring test to comply to latest api changes. * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update README.md * [change] (PHPLIB-334) Update CHANGELOG.md * [refactor] (PHPLIB-317) Adapt style and features to PHP version 7.1. * Add return type hints. * Fix some minor issues. * Add missing exception annotations. * Remove unnecessary comments from tests. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Update CHANGELOG.md and replace abandoned codacy/coverage package. * [refactor] (PHPLIB-317) Refactor code. * Replace deprecated methods. * Add some noinspection rules. * Fixed some minor issues. * [refactor] (PHPLIB-317) Remove debug code. * [refactor] (PHPLIB-334) Fix style issues. * [change] (PHPLIB-313) Examples/PrePayment: Create heidelpay object to make sure the sandbox banner is visible. * [change] (PHPLIB-313) Examples/PrePayment: Create heidelpay object to make sure the sandbox banner is visible. * [change] (PHPLIB-313) Update due to codacy issues. * [change] (PHPLIB-313) Tests: Fix unit tests. * [change] (PHPLIB-313) Add missing throws annotations. * [change] (PHPLIB-313) Add missing throws annotations. Co-authored-by: sixer1182 * PHPLIB-340/change/update-workflow-in-examples (#188) * [change] (PHPLIB-340) Examples: Update describing comments in examples. * [change] (PHPLIB-340) Tests: Add accessor to create and return heidelpayObject if necessary. * [change] (PHPLIB-340) Add method to get the initial transaction object from a payment. * [change] (PHPLIB-340) Examples: Refactor Alipay ReturnController.php to incorporate all possible cases of payment result handling. * [change] (PHPLIB-340) Examples: Refactor Failure.php * [change] (PHPLIB-340) Fix support email address in README.md * [change] (PHPLIB-340) Fix support contact data in README.md * [change] (PHPLIB-340) Fix support contact data in README.md * [change] (PHPLIB-340) Examples: Refactor examples to use generic return controller (with exceptions). * [change] (PHPLIB-340) Examples: Update. * [change] (PHPLIB-340) Examples: Update workflow and templates. * [change] (PHPLIB-340) Examples: Update workflow. * [change] (PHPLIB-340) Examples: Update workflow. * [change] (PHPLIB-340) Add PrePayment to invoice types to handle its workflow correctly. * [change] (PHPLIB-340) Update CHANGELOG.md * [change] (PHPLIB-340) Update comments. * [change] (PHPLIB-340) Update comments. * [change] (PHPLIB-340) Cleanup. * [change] (PHPLIB-340) Prepayment is handled explicitly in examples and not as invoice type. * [change] (PHPLIB-340) Examples: Show additional payment information on success page of invoice/prepayment. * Update examples/ReturnController.php Co-authored-by: Florian Evertz <10667564+xBlack-Shadow@users.noreply.github.com> Co-authored-by: sixer1182 Co-authored-by: Florian Evertz <10667564+xBlack-Shadow@users.noreply.github.com> * Added the possibility to add custom css to the payment page * Merge remote-tracking branch 'remotes/github/develop' into PHPLIB-345/change/release-and-merge-external-pr (#191) * [change] (PHPLIB-345) Paypage: Add css property and tests. * [change] (PHPLIB-345) Paypage: Fix style. * [change] (PHPLIB-345) Fix CHANGELOG.md Co-authored-by: sixer1182 * Revert "Merge remote-tracking branch 'remotes/github/develop' into PHPLIB-345/change/release-and-merge-external-pr (#191)" (#198) This reverts commit b07063384fd0b0daecbab793e7f1c02fc295183b. * Revert "Added the possibility to add custom css to the payment page" (#199) * Revert "Revert "Added the possibility to add custom css to the payment page" (#199)" This reverts commit de1e8074 * Revert "Revert "Merge remote-tracking branch 'remotes/github/develop' into PHPLIB-345/change/release-and-merge-external-pr (#191)" (#198)" This reverts commit 9cb52ca2 Co-authored-by: sixer1182 Co-authored-by: David Owusu <33735090+Ryouzanpaku@users.noreply.github.com> Co-authored-by: “Baris Co-authored-by: Florian Evertz <10667564+xBlack-Shadow@users.noreply.github.com> Co-authored-by: heidelpay --- .travis.yml | 3 +- CHANGELOG.md | 31 ++ README.md | 12 +- composer.json | 3 +- examples/Alipay/Constants.php | 1 - examples/Alipay/ReturnController.php | 96 ----- examples/Card/Constants.php | 1 - examples/Card/ReturnController.php | 101 ----- examples/CardRecurring/Constants.php | 2 +- examples/CardRecurring/Controller.php | 2 +- examples/Constants.php | 1 + examples/EPSCharge/Constants.php | 1 - examples/EPSCharge/ReturnController.php | 96 ----- examples/EmbeddedPayPage/Constants.php | 1 - examples/EmbeddedPayPage/ReturnController.php | 118 ----- examples/EmbeddedPayPage/index.php | 5 + examples/ExampleDebugHandler.php | 4 +- examples/Failure.php | 4 +- examples/FlexiPayDirect/Constants.php | 1 - examples/FlexiPayDirect/ReturnController.php | 100 ----- examples/Giropay/Constants.php | 1 - examples/Giropay/ReturnController.php | 96 ----- examples/HostedPayPage/Constants.php | 1 - examples/HostedPayPage/index.php | 7 + examples/IDeal/Constants.php | 1 - examples/IDeal/ReturnController.php | 96 ----- examples/Invoice/Controller.php | 41 +- examples/Invoice/index.php | 9 +- examples/InvoiceFactoring/Controller.php | 46 +- examples/InvoiceFactoring/index.php | 8 +- examples/InvoiceGuaranteed/Controller.php | 46 +- examples/PayPal/Constants.php | 1 - examples/PayPal/ReturnController.php | 100 ----- examples/PayPalRecurring/Constants.php | 1 - examples/PayPalRecurring/ReturnController.php | 77 ---- examples/Pending.php | 7 +- examples/Prepayment/Controller.php | 40 +- examples/Prepayment/index.php | 9 +- examples/Przelewy24/Constants.php | 1 - examples/Przelewy24/ReturnController.php | 96 ----- .../{HostedPayPage => }/ReturnController.php | 97 +++-- .../SepaDirectDebitGuaranteed/Controller.php | 24 +- examples/Sofort/Constants.php | 1 - examples/Sofort/ReturnController.php | 100 ----- examples/Success.php | 19 +- examples/Webhooks/fetchAll.php | 11 - examples/Webhooks/index.php | 11 - examples/Webhooks/removeAll.php | 13 +- examples/Wechatpay/Constants.php | 1 - examples/Wechatpay/ReturnController.php | 96 ----- examples/_enableExamples.php | 7 +- examples/index.php | 29 +- phpunit.xml | 2 - src/Adapter/CurlAdapter.php | 23 +- src/Adapter/HttpAdapterInterface.php | 18 +- src/Constants/ApiResponseCodes.php | 97 +++-- src/Constants/BasketItemTypes.php | 10 +- src/Constants/CancelReasonCodes.php | 8 +- .../CompanyCommercialSectorItems.php | 84 ++-- src/Constants/CompanyRegistrationTypes.php | 4 +- src/Constants/IdStrings.php | 58 +-- src/Constants/PaymentState.php | 24 +- src/Constants/Salutations.php | 6 +- src/Constants/TransactionTypes.php | 12 +- src/Constants/WebhookEvents.php | 60 +-- src/Exceptions/HeidelpayApiException.php | 4 +- src/Heidelpay.php | 53 +-- src/Interfaces/CancelServiceInterface.php | 2 +- src/Interfaces/ResourceServiceInterface.php | 4 +- src/Resources/AbstractHeidelpayResource.php | 15 +- src/Resources/Basket.php | 6 +- src/Resources/Customer.php | 22 +- src/Resources/EmbeddedResources/Address.php | 12 +- src/Resources/EmbeddedResources/Amount.php | 2 +- .../EmbeddedResources/BasketItem.php | 10 +- .../EmbeddedResources/CardDetails.php | 14 +- .../EmbeddedResources/CompanyInfo.php | 6 +- .../EmbeddedResources/GeoLocation.php | 4 +- src/Resources/EmbeddedResources/Message.php | 2 +- src/Resources/InstalmentPlan.php | 32 +- src/Resources/InstalmentPlans.php | 4 +- src/Resources/Keypair.php | 18 +- src/Resources/Metadata.php | 6 +- src/Resources/Payment.php | 61 +-- .../PaymentTypes/BasePaymentType.php | 4 + src/Resources/PaymentTypes/Card.php | 14 +- src/Resources/PaymentTypes/EPS.php | 2 +- .../PaymentTypes/HirePurchaseDirectDebit.php | 6 +- src/Resources/PaymentTypes/Ideal.php | 2 +- src/Resources/PaymentTypes/Paypage.php | 62 ++- src/Resources/PaymentTypes/Paypal.php | 2 +- .../PaymentTypes/SepaDirectDebit.php | 6 +- .../SepaDirectDebitGuaranteed.php | 6 +- src/Resources/Recurring.php | 2 +- .../AbstractTransactionType.php | 10 +- .../TransactionTypes/Authorization.php | 18 +- .../TransactionTypes/Cancellation.php | 10 +- src/Resources/TransactionTypes/Charge.php | 22 +- src/Resources/TransactionTypes/Payout.php | 8 +- src/Resources/TransactionTypes/Shipment.php | 2 +- src/Resources/Webhook.php | 4 +- src/Resources/Webhooks.php | 4 +- src/Services/CancelService.php | 7 +- src/Services/EnvironmentService.php | 89 ++-- src/Services/HttpService.php | 15 +- src/Services/IdService.php | 9 +- src/Services/PaymentService.php | 2 +- src/Services/ResourceService.php | 10 +- src/Services/ValueService.php | 14 + src/Services/WebhookService.php | 6 +- src/Traits/HasCancellations.php | 2 +- src/Traits/HasDate.php | 2 +- src/Traits/HasInvoiceId.php | 2 +- src/Traits/HasOrderId.php | 2 +- src/Traits/HasTraceId.php | 2 +- src/Traits/HasUniqueAndShortId.php | 4 +- src/Traits/IsInvoiceType.php | 6 + test/BaseIntegrationTest.php | 60 +++ test/BasePaymentTest.php | 99 ++--- test/Fixtures/CustomerFixtureTrait.php | 2 + test/TestDebugHandler.php | 32 +- test/bootstrap.php | 2 + test/integration/BasketTest.php | 50 +-- test/integration/CustomerTest.php | 113 +---- test/integration/DummyResource.php | 2 + test/integration/ExceptionTest.php | 12 +- test/integration/KeypairTest.php | 25 +- test/integration/PaymentCancelTest.php | 117 +---- test/integration/PaymentTest.php | 60 +-- test/integration/PaymentTypes/AlipayTest.php | 18 +- test/integration/PaymentTypes/CardTest.php | 122 ++---- test/integration/PaymentTypes/EPSTest.php | 27 +- test/integration/PaymentTypes/GiropayTest.php | 29 +- .../HirePurchaseDirectDebitTest.php | 51 +-- test/integration/PaymentTypes/IdealTest.php | 25 +- .../PaymentTypes/InvoiceFactoringTest.php | 73 +--- .../PaymentTypes/InvoiceGuaranteedTest.php | 37 +- test/integration/PaymentTypes/InvoiceTest.php | 42 +- test/integration/PaymentTypes/PISTest.php | 18 +- test/integration/PaymentTypes/PaypageTest.php | 64 +-- test/integration/PaymentTypes/PaypalTest.php | 24 +- .../PaymentTypes/PrepaymentTest.php | 28 +- .../PaymentTypes/Przelewy24Test.php | 25 +- .../SepaDirectDebitGuaranteedTest.php | 30 +- .../PaymentTypes/SepaDirectDebitTest.php | 38 +- test/integration/PaymentTypes/SofortTest.php | 18 +- .../PaymentTypes/WechatpayTest.php | 22 +- test/integration/RecurringPaymentTest.php | 50 +-- test/integration/SetMetadataTest.php | 32 +- .../TransactionTypes/AuthorizationTest.php | 45 +- .../CancelAfterAuthorizationTest.php | 33 +- .../CancelAfterChargeTest.php | 36 +- .../TransactionTypes/CancelTest.php | 43 +- .../ChargeAfterAuthorizationTest.php | 23 +- .../TransactionTypes/ChargeTest.php | 33 +- .../TransactionTypes/PayoutTest.php | 40 +- .../TransactionTypes/ShipmentTest.php | 28 +- test/integration/WebhookTest.php | 62 +-- test/script/travis_before_install.sh | 7 +- test/script/travis_install.sh | 1 - test/script/travis_script.sh | 1 + test/unit/Constants/PaymentStateTest.php | 18 +- test/unit/DummyResource.php | 2 + .../Exceptions/HeidelpayApiExceptionTest.php | 11 +- test/unit/HeidelpayTest.php | 48 +-- .../AbstractHeidelpayResourceTest.php | 75 +--- test/unit/Resources/BasketTest.php | 35 +- test/unit/Resources/CustomerFactoryTest.php | 15 +- test/unit/Resources/CustomerTest.php | 51 +-- .../unit/Resources/DummyHeidelpayResource.php | 2 + .../EmbeddedResources/AmountTest.php | 9 +- .../EmbeddedResources/BasketItemTest.php | 9 +- .../EmbeddedResources/GeoLocationTest.php | 9 +- test/unit/Resources/InstalmentPlanTest.php | 21 +- test/unit/Resources/KeypairTest.php | 18 +- test/unit/Resources/MetadataTest.php | 21 +- test/unit/Resources/PaymentTest.php | 408 ++++++------------ test/unit/Resources/PaymentTypes/CardTest.php | 67 +-- test/unit/Resources/PaymentTypes/EPSTest.php | 7 +- .../HirePurchaseDirectDebitTest.php | 25 +- .../unit/Resources/PaymentTypes/IdealTest.php | 7 +- .../Resources/PaymentTypes/PayPageTest.php | 74 ++-- .../Resources/PaymentTypes/PayPalTest.php | 7 +- .../SepaDirectDebitGuaranteedTest.php | 10 +- .../PaymentTypes/SepaDirectDebitTest.php | 10 +- test/unit/Resources/RecurringTest.php | 9 +- .../AbstractTransactionTypeTest.php | 39 +- .../TransactionTypes/AuthorizationTest.php | 45 +- .../TransactionTypes/CancellationTest.php | 17 +- .../Resources/TransactionTypes/ChargeTest.php | 39 +- .../TransactionTypes/DummyTransactionType.php | 2 + .../Resources/TransactionTypes/PayoutTest.php | 23 +- .../TransactionTypes/ShipmentTest.php | 13 +- test/unit/Resources/WebhookTest.php | 11 +- test/unit/Resources/WebhooksTest.php | 34 +- test/unit/Services/CancelServiceTest.php | 104 +---- test/unit/Services/DummyAdapter.php | 10 +- test/unit/Services/DummyDebugHandler.php | 4 +- test/unit/Services/EnvironmentServiceTest.php | 196 +++++++++ test/unit/Services/HttpServiceTest.php | 83 ++-- test/unit/Services/PaymentServiceTest.php | 124 ++---- .../unit/Services/ResourceNameServiceTest.php | 9 +- test/unit/Services/ResourceServiceTest.php | 336 +++++---------- test/unit/Services/WebhooksServiceTest.php | 95 ++-- test/unit/Traits/CanAuthorizeTest.php | 15 +- .../Traits/CanAuthorizeWithCustomerTest.php | 15 +- test/unit/Traits/CanDirectChargeTest.php | 15 +- .../CanDirectChargeWithCustomerTest.php | 15 +- test/unit/Traits/CanPayoutTest.php | 15 +- .../unit/Traits/CanPayoutWithCustomerTest.php | 15 +- test/unit/Traits/CanRecurTest.php | 24 +- test/unit/Traits/HasCancellationsTest.php | 21 +- test/unit/Traits/HasInvoiceIdTest.php | 7 +- test/unit/Traits/HasPaymentStateTest.php | 7 +- test/unit/Traits/TraitDummyCanRecur.php | 4 +- .../Traits/TraitDummyCanRecurNonResource.php | 2 + ...itDummyHasCancellationsHasPaymentState.php | 2 + test/unit/Traits/TraitDummyHasInvoiceId.php | 2 + .../TraitDummyWithCustomerWithParentIF.php | 5 +- .../TraitDummyWithCustomerWithoutParentIF.php | 2 + .../TraitDummyWithoutCustomerWithParentIF.php | 5 +- ...aitDummyWithoutCustomerWithoutParentIF.php | 2 + .../Validators/PrivateKeyValidatorTest.php | 9 +- .../Validators/PublicKeyValidatorTest.php | 9 +- 224 files changed, 2203 insertions(+), 4554 deletions(-) delete mode 100755 examples/Alipay/ReturnController.php delete mode 100644 examples/Card/ReturnController.php delete mode 100755 examples/EPSCharge/ReturnController.php delete mode 100644 examples/EmbeddedPayPage/ReturnController.php delete mode 100644 examples/FlexiPayDirect/ReturnController.php delete mode 100644 examples/Giropay/ReturnController.php delete mode 100644 examples/IDeal/ReturnController.php delete mode 100755 examples/PayPal/ReturnController.php delete mode 100644 examples/PayPalRecurring/ReturnController.php delete mode 100644 examples/Przelewy24/ReturnController.php rename examples/{HostedPayPage => }/ReturnController.php (52%) delete mode 100644 examples/Sofort/ReturnController.php delete mode 100755 examples/Wechatpay/ReturnController.php create mode 100644 test/BaseIntegrationTest.php create mode 100644 test/unit/Services/EnvironmentServiceTest.php diff --git a/.travis.yml b/.travis.yml index f2316349..43dd5b33 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: php -dist: trusty matrix: fast_finish: true include: @@ -39,4 +38,4 @@ install: script: - ./test/script/travis_script.sh after_success: - - php vendor/bin/codacycoverage clover build/coverage/xml + - bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l PHP -r build/coverage/xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 10309e24..47e97511 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,33 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.2.8.0][1.2.8.0] + +### Add +* Curl error string to debug log. +* Environment variable to enable/disable verbose curl output. +* Method to get the initial transaction from a payment. +* Parameter `css` to `Paypage` to enable custom styling. Special thanks to github user [bleenders](https://github.com/bleenders). + +### Change +* Mask auth header in debug log. +* Refactor test logging. +* Replace test environment variable. +* Apply minor changes. +* Refactor tests due to disabled default keypair. +* Refactor all files to reflect PHP 7.1 standards. +* Replace `codacy/coverage` with `codacy/codacy-coverage-reporter`. +* Update examples. + +### Fix +* Change TravisCI config to use default linux distribution in VM to fix certificate errors during integration tests. +* Remove invalid PHPUnit config parameters. + +### Remove +* Disabled key pair from examples and tests. +* Remove deprecated method `authorizeWithPayment`. +* Remove return value from `deleteCustomer` method. + ## [1.2.7.2][1.2.7.2] ### Fix @@ -21,6 +48,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a * Added geolocation to Card resource. * Payout webhook events. +### Changed +* Fixed some minor issues. + ## [1.2.7.1][1.2.7.1] ### Added @@ -413,3 +443,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [1.2.7.0]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.6.0..1.2.7.0 [1.2.7.1]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.7.0..1.2.7.1 [1.2.7.2]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.7.1..1.2.7.2 +[1.2.8.0]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.7.2..1.2.8.0 diff --git a/README.md b/README.md index 229fec7c..fc529d4a 100755 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ Please refer to the following documentation for installation instructions and us * [API Documentation](https://docs.heidelpay.com/docs/introduction) * [PHP SDK Documentation](https://docs.heidelpay.com/docs/php-sdk) -* [How to use the examples](https://docs.heidelpay.com/v1.0/docs/php-sdk#section-using-the-example-implementations) -* [Debugging](https://docs.heidelpay.com/v1.0/docs/php-sdk#section-debugging) +* [How to use the examples](https://docs.heidelpay.com/docs/example-implementations) +* [Debugging](https://docs.heidelpay.com/docs/logging-and-debugging) ## Supported payment types * Card (credit card and debit card) + Recurring @@ -45,13 +45,13 @@ Please refer to the following documentation for installation instructions and us For any issues or questions please get in touch with our support team. ### Web page -[https://dev.heidelpay.com/](https://dev.heidelpay.com/) +[https://docs.heidelpay.com/](https://docs.heidelpay.com/) ### Email -support@heidelpay.com +[support@heidelpay.com](mailto:support@heidelpay.com) ### Phone -+49 (0)6221/6471-100 +[+49 (0)6221/6471-100](tel:+49-62216471-100) ### Twitter -@devHeidelpay \ No newline at end of file +[@devHeidelpay](https://twitter.com/devHeidelpay) \ No newline at end of file diff --git a/composer.json b/composer.json index ae925171..6e5287ce 100755 --- a/composer.json +++ b/composer.json @@ -14,8 +14,7 @@ "ext-json": "*" }, "require-dev": { - "phpunit/phpunit": ">6.5 <8.0", - "codacy/coverage": "^1.4", + "phpunit/phpunit": ">6.5 <9.0", "friendsofphp/php-cs-fixer": "^2.0" }, "suggest": { diff --git a/examples/Alipay/Constants.php b/examples/Alipay/Constants.php index de175dba..50cb21b1 100755 --- a/examples/Alipay/Constants.php +++ b/examples/Alipay/Constants.php @@ -27,4 +27,3 @@ define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'Alipay'); define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php'); -define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php'); diff --git a/examples/Alipay/ReturnController.php b/examples/Alipay/ReturnController.php deleted file mode 100755 index f0849f47..00000000 --- a/examples/Alipay/ReturnController.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * @package heidelpayPHP\examples - */ - -/** Require the constants of this example */ -require_once __DIR__ . '/Constants.php'; - -/** @noinspection PhpIncludeInspection */ -/** Require the composer autoloader file */ -require_once __DIR__ . '/../../../../autoload.php'; - -use heidelpayPHP\examples\ExampleDebugHandler; -use heidelpayPHP\Exceptions\HeidelpayApiException; -use heidelpayPHP\Heidelpay; - -$clientMessage = 'Something went wrong. Please try again later.'; -$merchantMessage = 'Something went wrong. Please try again later.'; - -function redirect($url, $merchantMessage = '', $clientMessage = '') -{ - $_SESSION['merchantMessage'] = $merchantMessage; - $_SESSION['clientMessage'] = $clientMessage; - header('Location: ' . $url); - die(); -} - -session_start(); - -// Retrieve the paymentId you remembered within the Controller -if (!isset($_SESSION['PaymentId'])) { - redirect(FAILURE_URL, 'The payment id is missing.', $clientMessage); -} -$paymentId = $_SESSION['PaymentId']; - -// Catch API errors, write the message to your log and show the ClientMessage to the client. -try { - // Create a heidelpay object using your private key and register a debug handler if you want to. - $heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY); - $heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Redirect to success if the payment has been successfully completed. - $payment = $heidelpay->fetchPayment($paymentId); - - if ($payment->isCompleted()) { - // The payment process has been successful. - // You can create the order and show a success page. - redirect(SUCCESS_URL); - } elseif ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // Check the result message of the charge to find out what went wrong. - $charge = $payment->getChargeByIndex(0); - $merchantMessage = $charge->getMessage()->getCustomer(); -} catch (HeidelpayApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); - diff --git a/examples/Card/Constants.php b/examples/Card/Constants.php index 1c771888..22b43203 100644 --- a/examples/Card/Constants.php +++ b/examples/Card/Constants.php @@ -27,4 +27,3 @@ define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'Card'); define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php'); -define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php'); diff --git a/examples/Card/ReturnController.php b/examples/Card/ReturnController.php deleted file mode 100644 index b9d8643e..00000000 --- a/examples/Card/ReturnController.php +++ /dev/null @@ -1,101 +0,0 @@ - - * - * @package heidelpayPHP\examples - */ - -/** Require the constants of this example */ -require_once __DIR__ . '/Constants.php'; - -/** @noinspection PhpIncludeInspection */ -/** Require the composer autoloader file */ -require_once __DIR__ . '/../../../../autoload.php'; - -use heidelpayPHP\examples\ExampleDebugHandler; -use heidelpayPHP\Exceptions\HeidelpayApiException; -use heidelpayPHP\Heidelpay; -use heidelpayPHP\Resources\TransactionTypes\Authorization; - -session_start(); - -$clientMessage = 'Something went wrong. Please try again later.'; -$merchantMessage = 'Something went wrong. Please try again later.'; - -function redirect($url, $merchantMessage = '', $clientMessage = '') -{ - $_SESSION['merchantMessage'] = $merchantMessage; - $_SESSION['clientMessage'] = $clientMessage; - header('Location: ' . $url); - die(); -} - -// Retrieve the paymentId you remembered within the Controller -if (!isset($_SESSION['PaymentId'])) { - redirect(FAILURE_URL, 'The payment id is missing.', $clientMessage); -} -$paymentId = $_SESSION['PaymentId']; - -// Catch API errors, write the message to your log and show the ClientMessage to the client. -try { - // Create a heidelpay object using your private key and register a debug handler if you want to. - $heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY); - $heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Redirect to success if the payment has been successfully completed or is still in handled. - $payment = $heidelpay->fetchPayment($paymentId); - - if ($payment->isCompleted()) { - // The payment process has been successful. - // You can create the order and show a success page. - redirect(SUCCESS_URL); - } elseif ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // Check the result message of the transaction to find out what went wrong. - $transaction = $payment->getAuthorization(); - if ($transaction instanceof Authorization) { - $merchantMessage = $transaction->getMessage()->getCustomer(); - } else { - $transaction = $payment->getChargeByIndex(0); - $merchantMessage = $transaction->getMessage()->getCustomer(); - } -} catch (HeidelpayApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/CardRecurring/Constants.php b/examples/CardRecurring/Constants.php index a19a0395..fc93783c 100644 --- a/examples/CardRecurring/Constants.php +++ b/examples/CardRecurring/Constants.php @@ -27,4 +27,4 @@ define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'CardRecurring'); define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php'); -define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php'); +define('MY_RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php'); diff --git a/examples/CardRecurring/Controller.php b/examples/CardRecurring/Controller.php index 33fde55a..22ac3324 100644 --- a/examples/CardRecurring/Controller.php +++ b/examples/CardRecurring/Controller.php @@ -61,7 +61,7 @@ function redirect($url, $merchantMessage = '', $clientMessage = '') $heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY); $heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - $recurring = $heidelpay->activateRecurringPayment($paymentTypeId, RETURN_CONTROLLER_URL); + $recurring = $heidelpay->activateRecurringPayment($paymentTypeId, MY_RETURN_CONTROLLER_URL); // You'll need to remember the paymentId for later in the ReturnController (in case of 3ds) $_SESSION['PaymentTypeId'] = $paymentTypeId; diff --git a/examples/Constants.php b/examples/Constants.php index c9e201d5..6130f0bc 100755 --- a/examples/Constants.php +++ b/examples/Constants.php @@ -32,3 +32,4 @@ define('SUCCESS_URL', EXAMPLE_BASE_FOLDER . 'Success.php'); define('PENDING_URL', EXAMPLE_BASE_FOLDER . 'Pending.php'); define('FAILURE_URL', EXAMPLE_BASE_FOLDER . 'Failure.php'); +define('RETURN_CONTROLLER_URL', EXAMPLE_BASE_FOLDER . 'ReturnController.php'); diff --git a/examples/EPSCharge/Constants.php b/examples/EPSCharge/Constants.php index c14c7ed3..c443135a 100755 --- a/examples/EPSCharge/Constants.php +++ b/examples/EPSCharge/Constants.php @@ -27,4 +27,3 @@ define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'EPSCharge'); define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php'); -define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php'); diff --git a/examples/EPSCharge/ReturnController.php b/examples/EPSCharge/ReturnController.php deleted file mode 100755 index 281ed67d..00000000 --- a/examples/EPSCharge/ReturnController.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * @package heidelpayPHP\examples - */ - -/** Require the constants of this example */ -require_once __DIR__ . '/Constants.php'; - -/** @noinspection PhpIncludeInspection */ -/** Require the composer autoloader file */ -require_once __DIR__ . '/../../../../autoload.php'; - -use heidelpayPHP\examples\ExampleDebugHandler; -use heidelpayPHP\Exceptions\HeidelpayApiException; -use heidelpayPHP\Heidelpay; - -$clientMessage = 'Something went wrong. Please try again later.'; -$merchantMessage = 'Something went wrong. Please try again later.'; - -function redirect($url, $merchantMessage = '', $clientMessage = '') -{ - $_SESSION['merchantMessage'] = $merchantMessage; - $_SESSION['clientMessage'] = $clientMessage; - header('Location: ' . $url); - die(); -} - -session_start(); - -// Retrieve the paymentId you remembered within the Controller -if (!isset($_SESSION['PaymentId'])) { - redirect(FAILURE_URL, 'The payment id is missing.', $clientMessage); -} -$paymentId = $_SESSION['PaymentId']; - -// Catch API errors, write the message to your log and show the ClientMessage to the client. -try { - // Create a heidelpay object using your private key and register a debug handler if you want to. - $heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY); - $heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Redirect to success if the payment has been successfully completed. - $payment = $heidelpay->fetchPayment($paymentId); - - if ($payment->isCompleted()) { - // The payment process has been successful. - // You can create the order and show a success page. - redirect(SUCCESS_URL); - } elseif ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // Check the result message of the charge to find out what went wrong. - $charge = $payment->getChargeByIndex(0); - $merchantMessage = $charge->getMessage()->getCustomer(); -} catch (HeidelpayApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); - diff --git a/examples/EmbeddedPayPage/Constants.php b/examples/EmbeddedPayPage/Constants.php index 0c9971ad..2041f20b 100644 --- a/examples/EmbeddedPayPage/Constants.php +++ b/examples/EmbeddedPayPage/Constants.php @@ -27,4 +27,3 @@ define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'EmbeddedPayPage'); define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php'); -define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php'); diff --git a/examples/EmbeddedPayPage/ReturnController.php b/examples/EmbeddedPayPage/ReturnController.php deleted file mode 100644 index 0b629e77..00000000 --- a/examples/EmbeddedPayPage/ReturnController.php +++ /dev/null @@ -1,118 +0,0 @@ - - * - * @package heidelpayPHP\examples - */ - -/** Require the constants of this example */ -require_once __DIR__ . '/Constants.php'; - -/** @noinspection PhpIncludeInspection */ -/** Require the composer autoloader file */ -require_once __DIR__ . '/../../../../autoload.php'; - -use heidelpayPHP\examples\ExampleDebugHandler; -use heidelpayPHP\Exceptions\HeidelpayApiException; -use heidelpayPHP\Heidelpay; -use heidelpayPHP\Resources\AbstractHeidelpayResource; -use heidelpayPHP\Resources\Payment; -use heidelpayPHP\Resources\TransactionTypes\Authorization; -use heidelpayPHP\Resources\TransactionTypes\Charge; - -session_start(); - -$clientMessage = 'Something went wrong. Please try again later.'; -$merchantMessage = 'Something went wrong. Please try again later.'; - -function redirect($url, $merchantMessage = '', $clientMessage = '') -{ - $_SESSION['merchantMessage'] = $merchantMessage; - $_SESSION['clientMessage'] = $clientMessage; - header('Location: ' . $url); - die(); -} - -/** - * @param Payment $payment - * @return AbstractHeidelpayResource|Authorization|Charge|null - * @throws HeidelpayApiException - * @throws RuntimeException - */ -function getTransaction(Payment $payment) -{ - $transaction = $payment->getAuthorization(); - if (!$transaction instanceof Authorization) { - $transaction = $payment->getChargeByIndex(0); - } - return $transaction; -} - -// Retrieve the paymentId you remembered within the Controller -if (!isset($_SESSION['PaymentId'])) { - redirect(FAILURE_URL, 'The payment id is missing.', $clientMessage); -} -$paymentId = $_SESSION['PaymentId']; - -// Catch API errors, write the message to your log and show the ClientMessage to the client. -try { - // Create a heidelpay object using your private key and register a debug handler if you want to. - $heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY); - $heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Redirect to success if the payment has been successfully completed or is still in handled. - $payment = $heidelpay->fetchPayment($paymentId); - - // You'll need to remember the shortId to show it on the success or failure page - $transaction = getTransaction($payment); - $_SESSION['ShortId'] = $transaction->getShortId(); - - if ($payment->isCompleted()) { - // The payment process has been successful. - // You can create the order and show a success page. - redirect(SUCCESS_URL); - } elseif ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // For better debugging log the error message in your error log - $merchantMessage = $transaction->getMessage()->getCustomer(); - -} catch (HeidelpayApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/EmbeddedPayPage/index.php b/examples/EmbeddedPayPage/index.php index 3a7e8477..6a98dbb9 100644 --- a/examples/EmbeddedPayPage/index.php +++ b/examples/EmbeddedPayPage/index.php @@ -27,6 +27,7 @@ require_once __DIR__ . '/Constants.php'; /** @noinspection PhpIncludeInspection */ + /** Require the composer autoloader file */ require_once __DIR__ . '/../../../../autoload.php'; ?> @@ -76,6 +77,10 @@ diff --git a/examples/IDeal/Constants.php b/examples/IDeal/Constants.php index 3b19c11a..9964e3fa 100644 --- a/examples/IDeal/Constants.php +++ b/examples/IDeal/Constants.php @@ -27,4 +27,3 @@ define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'IDeal'); define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php'); -define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php'); diff --git a/examples/IDeal/ReturnController.php b/examples/IDeal/ReturnController.php deleted file mode 100644 index 062617b6..00000000 --- a/examples/IDeal/ReturnController.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * @package heidelpayPHP\examples - */ - -/** Require the constants of this example */ -require_once __DIR__ . '/Constants.php'; - -/** @noinspection PhpIncludeInspection */ -/** Require the composer autoloader file */ -require_once __DIR__ . '/../../../../autoload.php'; - -use heidelpayPHP\examples\ExampleDebugHandler; -use heidelpayPHP\Exceptions\HeidelpayApiException; -use heidelpayPHP\Heidelpay; - -$clientMessage = 'Something went wrong. Please try again later.'; -$merchantMessage = 'Something went wrong. Please try again later.'; - -function redirect($url, $merchantMessage = '', $clientMessage = '') -{ - $_SESSION['merchantMessage'] = $merchantMessage; - $_SESSION['clientMessage'] = $clientMessage; - header('Location: ' . $url); - die(); -} - -session_start(); - -// Retrieve the paymentId you remembered within the Controller -if (!isset($_SESSION['PaymentId'])) { - redirect(FAILURE_URL, 'The payment id is missing.', $clientMessage); -} -$paymentId = $_SESSION['PaymentId']; - -// Catch API errors, write the message to your log and show the ClientMessage to the client. -try { - // Create a heidelpay object using your private key and register a debug handler if you want to. - $heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY); - $heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Redirect to success if the payment has been successfully completed. - $payment = $heidelpay->fetchPayment($paymentId); - - if ($payment->isCompleted()) { - // The payment process has been successful. - // You can create the order and show a success page. - redirect(SUCCESS_URL); - } elseif ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // Check the result message of the charge to find out what went wrong. - $charge = $payment->getChargeByIndex(0); - $merchantMessage = $charge->getMessage()->getCustomer(); -} catch (HeidelpayApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); - diff --git a/examples/Invoice/Controller.php b/examples/Invoice/Controller.php index 10cb17cb..40892654 100644 --- a/examples/Invoice/Controller.php +++ b/examples/Invoice/Controller.php @@ -67,28 +67,27 @@ function redirect($url, $merchantMessage = '', $clientMessage = '') // You'll need to remember the shortId to show it on the success or failure page $_SESSION['ShortId'] = $transaction->getShortId(); + $_SESSION['PaymentId'] = $transaction->getPaymentId(); + $_SESSION['additionalPaymentInformation'] = + sprintf( + "Please transfer the amount of %f %s to the following account:

" + . "Holder: %s
" + . "IBAN: %s
" + . "BIC: %s

" + . "Please use only this identification number as the descriptor:
" + . "%s", + $transaction->getAmount(), + $transaction->getCurrency(), + $transaction->getHolder(), + $transaction->getIban(), + $transaction->getBic(), + $transaction->getDescriptor() + ); + + + // To avoid redundant code this example redirects to the general ReturnController which contains the code example to handle payment results. + redirect(RETURN_CONTROLLER_URL); - // Redirect to the success or failure page depending on the state of the transaction - $payment = $transaction->getPayment(); - - if ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); } catch (HeidelpayApiException $e) { $merchantMessage = $e->getMerchantMessage(); $clientMessage = $e->getClientMessage(); diff --git a/examples/Invoice/index.php b/examples/Invoice/index.php index 0b266c72..2efb0463 100644 --- a/examples/Invoice/index.php +++ b/examples/Invoice/index.php @@ -39,10 +39,9 @@ Heidelpay UI Examples - + @@ -51,5 +50,11 @@ + diff --git a/examples/InvoiceFactoring/Controller.php b/examples/InvoiceFactoring/Controller.php index 5ef89181..006216a7 100755 --- a/examples/InvoiceFactoring/Controller.php +++ b/examples/InvoiceFactoring/Controller.php @@ -83,36 +83,32 @@ function redirect($url, $merchantMessage = '', $clientMessage = '') // You'll need to remember the shortId to show it on the success or failure page $_SESSION['ShortId'] = $transaction->getShortId(); + $_SESSION['PaymentId'] = $transaction->getPaymentId(); + $_SESSION['additionalPaymentInformation'] = + sprintf( + "Please transfer the amount of %f %s to the following account:

" + . "Holder: %s
" + . "IBAN: %s
" + . "BIC: %s

" + . "Please use only this identification number as the descriptor:
" + . "%s", + $transaction->getAmount(), + $transaction->getCurrency(), + $transaction->getHolder(), + $transaction->getIban(), + $transaction->getBic(), + $transaction->getDescriptor() + ); + + // To avoid redundant code this example redirects to the general ReturnController which contains the code example to handle payment results. + redirect(RETURN_CONTROLLER_URL); - // Redirect to the success or failure page depending on the state of the transaction - $payment = $transaction->getPayment(); - - if ($payment->isCompleted()) { - // The payment process has been successful. - // You can create the order and show a success page. - redirect(SUCCESS_URL); - } elseif ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); } catch (HeidelpayApiException $e) { $merchantMessage = $e->getMerchantMessage(); $clientMessage = $e->getClientMessage(); } catch (RuntimeException $e) { $merchantMessage = $e->getMessage(); } +// Write the merchant message to your log. +// Show the client message to the customer (it is localized). redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/InvoiceFactoring/index.php b/examples/InvoiceFactoring/index.php index 9fa317ad..2ac6b916 100755 --- a/examples/InvoiceFactoring/index.php +++ b/examples/InvoiceFactoring/index.php @@ -39,8 +39,6 @@ Heidelpay UI Examples - @@ -52,5 +50,11 @@ + diff --git a/examples/InvoiceGuaranteed/Controller.php b/examples/InvoiceGuaranteed/Controller.php index 49e04fce..2585cd23 100755 --- a/examples/InvoiceGuaranteed/Controller.php +++ b/examples/InvoiceGuaranteed/Controller.php @@ -74,36 +74,32 @@ function redirect($url, $merchantMessage = '', $clientMessage = '') // You'll need to remember the shortId to show it on the success or failure page $_SESSION['ShortId'] = $transaction->getShortId(); + $_SESSION['PaymentId'] = $transaction->getPaymentId(); + $_SESSION['additionalPaymentInformation'] = + sprintf( + "Please transfer the amount of %f %s to the following account:

" + . "Holder: %s
" + . "IBAN: %s
" + . "BIC: %s

" + . "Please use only this identification number as the descriptor:
" + . "%s", + $transaction->getAmount(), + $transaction->getCurrency(), + $transaction->getHolder(), + $transaction->getIban(), + $transaction->getBic(), + $transaction->getDescriptor() + ); + + // To avoid redundant code this example redirects to the general ReturnController which contains the code example to handle payment results. + redirect(RETURN_CONTROLLER_URL); - // Redirect to the success or failure page depending on the state of the transaction - $payment = $transaction->getPayment(); - - if ($payment->isCompleted()) { - // The payment process has been successful. - // You can create the order and show a success page. - redirect(SUCCESS_URL); - } elseif ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); } catch (HeidelpayApiException $e) { $merchantMessage = $e->getMerchantMessage(); $clientMessage = $e->getClientMessage(); } catch (RuntimeException $e) { $merchantMessage = $e->getMessage(); } +// Write the merchant message to your log. +// Show the client message to the customer (it is localized). redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/PayPal/Constants.php b/examples/PayPal/Constants.php index 888622dd..5c20ff53 100755 --- a/examples/PayPal/Constants.php +++ b/examples/PayPal/Constants.php @@ -27,4 +27,3 @@ define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'PayPal'); define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php'); -define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php'); diff --git a/examples/PayPal/ReturnController.php b/examples/PayPal/ReturnController.php deleted file mode 100755 index 9d27c94b..00000000 --- a/examples/PayPal/ReturnController.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * @package heidelpayPHP\examples - */ - -/** Require the constants of this example */ -require_once __DIR__ . '/Constants.php'; - -/** @noinspection PhpIncludeInspection */ -/** Require the composer autoloader file */ -require_once __DIR__ . '/../../../../autoload.php'; - -use heidelpayPHP\examples\ExampleDebugHandler; -use heidelpayPHP\Exceptions\HeidelpayApiException; -use heidelpayPHP\Heidelpay; -use heidelpayPHP\Resources\TransactionTypes\Authorization; - -$clientMessage = 'Something went wrong. Please try again later.'; -$merchantMessage = 'Something went wrong. Please try again later.'; - -function redirect($url, $merchantMessage = '', $clientMessage = '') -{ - $_SESSION['merchantMessage'] = $merchantMessage; - $_SESSION['clientMessage'] = $clientMessage; - header('Location: ' . $url); - die(); -} - -session_start(); - -// Retrieve the paymentId you remembered within the Controller -if (!isset($_SESSION['PaymentId'])) { - redirect(FAILURE_URL, 'The payment id is missing.', $clientMessage); -} -$paymentId = $_SESSION['PaymentId']; - -// Catch API errors, write the message to your log and show the ClientMessage to the client. -try { - // Create a heidelpay object using your private key and register a debug handler if you want to. - $heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY); - $heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Redirect to success if the payment has been successfully completed. - $payment = $heidelpay->fetchPayment($paymentId); - - if ($payment->isCompleted()) { - // The payment process has been successful. - // You can create the order and show a success page. - redirect(SUCCESS_URL); - } elseif ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // Check the result message of the transaction to find out what went wrong. - $transaction = $payment->getAuthorization(); - if (!$transaction instanceof Authorization) { - $transaction = $payment->getChargeByIndex(0); - } - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (HeidelpayApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); - diff --git a/examples/PayPalRecurring/Constants.php b/examples/PayPalRecurring/Constants.php index 5a4a9e3d..db8e0af5 100644 --- a/examples/PayPalRecurring/Constants.php +++ b/examples/PayPalRecurring/Constants.php @@ -27,4 +27,3 @@ define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'PayPalRecurring'); define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php'); -define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php'); diff --git a/examples/PayPalRecurring/ReturnController.php b/examples/PayPalRecurring/ReturnController.php deleted file mode 100644 index 212260a6..00000000 --- a/examples/PayPalRecurring/ReturnController.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * @package heidelpayPHP\examples - */ - -/** Require the constants of this example */ -require_once __DIR__ . '/Constants.php'; - -/** @noinspection PhpIncludeInspection */ -/** Require the composer autoloader file */ -require_once __DIR__ . '/../../../../autoload.php'; - -use heidelpayPHP\examples\ExampleDebugHandler; -use heidelpayPHP\Exceptions\HeidelpayApiException; -use heidelpayPHP\Heidelpay; -use heidelpayPHP\Resources\PaymentTypes\Paypal; - -session_start(); - -$clientMessage = 'Something went wrong. Please try again later.'; -$merchantMessage = 'Something went wrong. Please try again later.'; - -function redirect($url, $merchantMessage = '', $clientMessage = '') -{ - $_SESSION['merchantMessage'] = $merchantMessage; - $_SESSION['clientMessage'] = $clientMessage; - header('Location: ' . $url); - die(); -} - -// Retrieve the paymentId you remembered within the Controller -if (!isset($_SESSION['PaymentTypeId'])) { - redirect(FAILURE_URL, 'The payment type id is missing.', $clientMessage); -} -$paymentTypeId = $_SESSION['PaymentTypeId']; - -// Catch API errors, write the message to your log and show the ClientMessage to the client. -try { - // Create a heidelpay object using your private key and register a debug handler if you want to. - $heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY); - $heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Redirect to success if the payment has been successfully completed or is still in handled. - $paymentType = $heidelpay->fetchPaymentType($paymentTypeId); - - if ($paymentType instanceof Paypal && $paymentType->isRecurring()) { - redirect(SUCCESS_URL); - } -} catch (HeidelpayApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} - -redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/Pending.php b/examples/Pending.php index f7f0e1b0..4581e23a 100644 --- a/examples/Pending.php +++ b/examples/Pending.php @@ -31,14 +31,13 @@

Pending

- The payment transaction has been completed, however the payment is pending.
- In some cases (e. g. authorization transaction or invoice payments) this is normal.
- In other cases the status of the payment is not definite at the moment.
+ The payment transaction has been completed, however it has the state pending.
+ The status of the payment is not definite at the moment.
You can create the Order in your shop but should set its status to pending payment.

Please use the webhook feature to be informed about later changes of the payment. - You should ship only if the payment changes to completed. + You should ship only if the status changes to success. Please look for ShortId ' . $_SESSION['ShortId'] . ' in hIP (heidelpay Intelligence Platform) to see the transaction.

'; diff --git a/examples/Prepayment/Controller.php b/examples/Prepayment/Controller.php index 293f6531..4ac68f55 100644 --- a/examples/Prepayment/Controller.php +++ b/examples/Prepayment/Controller.php @@ -67,28 +67,26 @@ function redirect($url, $merchantMessage = '', $clientMessage = '') // You'll need to remember the shortId to show it on the success or failure page $_SESSION['ShortId'] = $transaction->getShortId(); + $_SESSION['PaymentId'] = $transaction->getPaymentId(); + $_SESSION['additionalPaymentInformation'] = + sprintf( + "Please transfer the amount of %f %s to the following account:

" + . "Holder: %s
" + . "IBAN: %s
" + . "BIC: %s

" + . "Please use only this identification number as the descriptor:
" + . "%s", + $transaction->getAmount(), + $transaction->getCurrency(), + $transaction->getHolder(), + $transaction->getIban(), + $transaction->getBic(), + $transaction->getDescriptor() + ); + + // To avoid redundant code this example redirects to the general ReturnController which contains the code example to handle payment results. + redirect(RETURN_CONTROLLER_URL); - // Redirect to the success or failure page depending on the state of the transaction - $payment = $transaction->getPayment(); - - if ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); } catch (HeidelpayApiException $e) { $merchantMessage = $e->getMerchantMessage(); $clientMessage = $e->getClientMessage(); diff --git a/examples/Prepayment/index.php b/examples/Prepayment/index.php index 3ed893b5..0c5e7e81 100644 --- a/examples/Prepayment/index.php +++ b/examples/Prepayment/index.php @@ -39,10 +39,9 @@ Heidelpay UI Examples - + @@ -51,5 +50,11 @@ + diff --git a/examples/Przelewy24/Constants.php b/examples/Przelewy24/Constants.php index c4f4ba51..bf700d89 100644 --- a/examples/Przelewy24/Constants.php +++ b/examples/Przelewy24/Constants.php @@ -27,4 +27,3 @@ define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'Przelewy24'); define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php'); -define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php'); diff --git a/examples/Przelewy24/ReturnController.php b/examples/Przelewy24/ReturnController.php deleted file mode 100644 index fef5b3b5..00000000 --- a/examples/Przelewy24/ReturnController.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * @package heidelpayPHP/examples - */ - -/** Require the constants of this example */ -require_once __DIR__ . '/Constants.php'; - -/** @noinspection PhpIncludeInspection */ -/** Require the composer autoloader file */ -require_once __DIR__ . '/../../../../autoload.php'; - -use heidelpayPHP\examples\ExampleDebugHandler; -use heidelpayPHP\Exceptions\HeidelpayApiException; -use heidelpayPHP\Heidelpay; - -$clientMessage = 'Something went wrong. Please try again later.'; -$merchantMessage = 'Something went wrong. Please try again later.'; - -function redirect($url, $merchantMessage = '', $clientMessage = '') -{ - $_SESSION['merchantMessage'] = $merchantMessage; - $_SESSION['clientMessage'] = $clientMessage; - header('Location: ' . $url); - die(); -} - -session_start(); - -// Retrieve the paymentId you remembered within the Controller -if (!isset($_SESSION['PaymentId'])) { - redirect(FAILURE_URL, 'The payment id is missing.', $clientMessage); -} -$paymentId = $_SESSION['PaymentId']; - -// Catch API errors, write the message to your log and show the ClientMessage to the client. -try { - // Create a heidelpay object using your private key and register a debug handler if you want to. - $heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY); - $heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Redirect to success if the payment has been successfully completed. - $payment = $heidelpay->fetchPayment($paymentId); - - if ($payment->isCompleted()) { - // The payment process has been successful. - // You can create the order and show a success page. - redirect(SUCCESS_URL); - } elseif ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // Check the result message of the charge to find out what went wrong. - $charge = $payment->getChargeByIndex(0); - $merchantMessage = $charge->getMessage()->getCustomer(); -} catch (HeidelpayApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); - diff --git a/examples/HostedPayPage/ReturnController.php b/examples/ReturnController.php similarity index 52% rename from examples/HostedPayPage/ReturnController.php rename to examples/ReturnController.php index 462b8840..99621602 100644 --- a/examples/HostedPayPage/ReturnController.php +++ b/examples/ReturnController.php @@ -1,7 +1,10 @@ getAuthorization(); - if (!$transaction instanceof Authorization) { - $transaction = $payment->getChargeByIndex(0); - } - return $transaction; -} +session_start(); // Retrieve the paymentId you remembered within the Controller if (!isset($_SESSION['PaymentId'])) { @@ -80,45 +66,64 @@ function getTransaction(Payment $payment) $heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY); $heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - // Redirect to success if the payment has been successfully completed or is still in handled. - $payment = $heidelpay->fetchPayment($paymentId); - - // You'll need to remember the shortId to show it on the success or failure page - $transaction = getTransaction($payment); - - if ($transaction instanceof AbstractTransactionType) { - $_SESSION['ShortId'] = $transaction->getShortId(); - } + // Redirect to success if the payment has been successfully completed. + $payment = $heidelpay->fetchPayment($paymentId); + $transaction = $payment->getInitialTransaction(); if ($payment->isCompleted()) { // The payment process has been successful. - // You can create the order and show a success page. + // You show the success page. + // Goods can be shipped. redirect(SUCCESS_URL); } elseif ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); + if ($transaction->isSuccess()) { + if ($transaction instanceof Authorization) { + // Payment is ready to be captured. + // Goods can be shipped later AFTER charge. + } else { + // Payment is not done yet (e.g. Prepayment) + // Goods can be shipped later after incoming payment (event). + } + + // In any case: + // * You can show the success page. + // * You can set order status to pending payment + redirect(SUCCESS_URL); + } elseif ($transaction->isPending()) { + + // The initial transaction of invoice types will not change to success but stay pending. + $paymentType = $payment->getPaymentType(); + if ($paymentType instanceof Prepayment || $paymentType->isInvoiceType()) { + // Awaiting payment by the customer. + // Goods can be shipped immediately except for Prepayment type. + redirect(SUCCESS_URL); + } + + // In cases of a redirect to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for + // the payment to update it's status after redirect into shop. + // In this case the payment and the transaction are pending at first and change to cancel or success later. + + // Use the webhooks feature to stay informed about changes of payment and transaction (e.g. cancel, success) + // then you can handle the states as shown above in transaction->isSuccess() branch. + redirect(PENDING_URL); + } } // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. + // In this case do not create the order or cancel it if you already did. + // Redirect to an error page in your shop and show a message if you want. + // Check the result message of the initial transaction to find out what went wrong. if ($transaction instanceof AbstractTransactionType) { // For better debugging log the error message in your error log - $merchantMessage = $transaction->getMessage()->getCustomer(); + $merchantMessage = $transaction->getMessage()->getMerchant(); + $clientMessage = $transaction->getMessage()->getCustomer(); } - } catch (HeidelpayApiException $e) { $merchantMessage = $e->getMerchantMessage(); $clientMessage = $e->getClientMessage(); } catch (RuntimeException $e) { $merchantMessage = $e->getMessage(); } +// Write the merchant message to your log. +// Show the client message to the customer (it is localized). redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/SepaDirectDebitGuaranteed/Controller.php b/examples/SepaDirectDebitGuaranteed/Controller.php index a2752c28..13318816 100755 --- a/examples/SepaDirectDebitGuaranteed/Controller.php +++ b/examples/SepaDirectDebitGuaranteed/Controller.php @@ -77,29 +77,11 @@ function redirect($url, $merchantMessage = '', $clientMessage = '') // Redirect to the success or failure depending on the state of the transaction $payment = $transaction->getPayment(); + $_SESSION['PaymentId'] = $transaction->getPaymentId(); - if ($payment->isCompleted()) { - // The payment process has been successful. - // You can create the order and show a success page. - redirect(SUCCESS_URL); - } elseif ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. + // To avoid redundant code this example redirects to the general ReturnController which contains the code example to handle payment results. + redirect(RETURN_CONTROLLER_URL); - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // Check the result message of the transaction to find out what went wrong. - $merchantMessage = $transaction->getMessage()->getCustomer(); } catch (HeidelpayApiException $e) { $merchantMessage = $e->getMerchantMessage(); $clientMessage = $e->getClientMessage(); diff --git a/examples/Sofort/Constants.php b/examples/Sofort/Constants.php index 8785ae8d..46a0d83a 100644 --- a/examples/Sofort/Constants.php +++ b/examples/Sofort/Constants.php @@ -27,4 +27,3 @@ define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'Sofort'); define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php'); -define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php'); diff --git a/examples/Sofort/ReturnController.php b/examples/Sofort/ReturnController.php deleted file mode 100644 index f35102ef..00000000 --- a/examples/Sofort/ReturnController.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * @package heidelpayPHP\examples - */ - -/** Require the constants of this example */ -require_once __DIR__ . '/Constants.php'; - -/** @noinspection PhpIncludeInspection */ -/** Require the composer autoloader file */ -require_once __DIR__ . '/../../../../autoload.php'; - -use heidelpayPHP\examples\ExampleDebugHandler; -use heidelpayPHP\Exceptions\HeidelpayApiException; -use heidelpayPHP\Heidelpay; -use heidelpayPHP\Resources\TransactionTypes\Charge; - -$clientMessage = 'Something went wrong. Please try again later.'; -$merchantMessage = 'Something went wrong. Please try again later.'; - -function redirect($url, $merchantMessage = '', $clientMessage = '') -{ - $_SESSION['merchantMessage'] = $merchantMessage; - $_SESSION['clientMessage'] = $clientMessage; - header('Location: ' . $url); - die(); -} - -session_start(); - -// Retrieve the paymentId you remembered within the Controller -if (!isset($_SESSION['PaymentId'])) { - redirect(FAILURE_URL, 'The payment id is missing.', $clientMessage); -} -$paymentId = $_SESSION['PaymentId']; - -// Catch API errors, write the message to your log and show the ClientMessage to the client. -try { - // Create a heidelpay object using your private key and register a debug handler if you want to. - $heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY); - $heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Redirect to success if the payment has been successfully completed. - $payment = $heidelpay->fetchPayment($paymentId); - - if ($payment->isCompleted()) { - // The payment process has been successful. - // You can create the order and show a success page. - redirect(SUCCESS_URL); - } elseif ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // Check the result message of the transaction to find out what went wrong. - $transaction = $payment->getChargeByIndex(0); - if (!$transaction instanceof Charge) { - $transaction = $payment->getChargeByIndex(0); - } - $merchantMessage = $transaction->getMessage()->getCustomer(); -} catch (HeidelpayApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); - diff --git a/examples/Success.php b/examples/Success.php index 22125534..08eaec9f 100755 --- a/examples/Success.php +++ b/examples/Success.php @@ -31,14 +31,19 @@

Success

- The payment has been successfully completed. + The order has been successfully placed. + Please look for ShortId ' . $_SESSION['ShortId'] . ' in hIP (heidelpay Intelligence Platform) to see the transaction.

'; - } - if (isset($_SESSION['PaymentId']) && !empty($_SESSION['PaymentId'])) { - echo '

The PaymentId of your transaction is \'' . $_SESSION['PaymentId'] . '\'.

'; - } + if (isset($_SESSION['additionalPaymentInformation'])) { + echo $_SESSION['additionalPaymentInformation']; + } + + if (isset($_SESSION['ShortId']) && !empty($_SESSION['ShortId'])) { + echo '

Please look for ShortId ' . $_SESSION['ShortId'] . ' in hIP (heidelpay Intelligence Platform) to see the transaction.

'; + } + if (isset($_SESSION['PaymentId']) && !empty($_SESSION['PaymentId'])) { + echo '

The PaymentId of your transaction is \'' . $_SESSION['PaymentId'] . '\'.

'; + } ?>

start again

diff --git a/examples/Webhooks/fetchAll.php b/examples/Webhooks/fetchAll.php index 9acb25ab..d4b40593 100644 --- a/examples/Webhooks/fetchAll.php +++ b/examples/Webhooks/fetchAll.php @@ -78,17 +78,6 @@ function printInfo($title, $text) setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); diff --git a/examples/Webhooks/index.php b/examples/Webhooks/index.php index c8e5dacf..57eb1058 100755 --- a/examples/Webhooks/index.php +++ b/examples/Webhooks/index.php @@ -85,17 +85,6 @@ function printInfo($title, $text) setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); diff --git a/examples/Webhooks/removeAll.php b/examples/Webhooks/removeAll.php index caf440f8..b5fc59a3 100755 --- a/examples/Webhooks/removeAll.php +++ b/examples/Webhooks/removeAll.php @@ -83,24 +83,13 @@ function printInfo($title, $text) setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); $heidelpay->deleteAllWebhooks(); printSuccess( - 'De-registered all existing events for this private key', + 'De-registered all existing events for the given private key', 'Unsubscribed all events registered for the private key: "' . HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY . '".' ); diff --git a/examples/Wechatpay/Constants.php b/examples/Wechatpay/Constants.php index 807c63e9..48d2c5bf 100755 --- a/examples/Wechatpay/Constants.php +++ b/examples/Wechatpay/Constants.php @@ -27,4 +27,3 @@ define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'Wechatpay'); define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php'); -define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php'); diff --git a/examples/Wechatpay/ReturnController.php b/examples/Wechatpay/ReturnController.php deleted file mode 100755 index a50c0073..00000000 --- a/examples/Wechatpay/ReturnController.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * @package heidelpayPHP\examples - */ - -/** Require the constants of this example */ -require_once __DIR__ . '/Constants.php'; - -/** @noinspection PhpIncludeInspection */ -/** Require the composer autoloader file */ -require_once __DIR__ . '/../../../../autoload.php'; - -use heidelpayPHP\examples\ExampleDebugHandler; -use heidelpayPHP\Exceptions\HeidelpayApiException; -use heidelpayPHP\Heidelpay; - -$clientMessage = 'Something went wrong. Please try again later.'; -$merchantMessage = 'Something went wrong. Please try again later.'; - -function redirect($url, $merchantMessage = '', $clientMessage = '') -{ - $_SESSION['merchantMessage'] = $merchantMessage; - $_SESSION['clientMessage'] = $clientMessage; - header('Location: ' . $url); - die(); -} - -session_start(); - -// Retrieve the paymentId you remembered within the Controller -if (!isset($_SESSION['PaymentId'])) { - redirect(FAILURE_URL, 'The payment id is missing.', $clientMessage); -} -$paymentId = $_SESSION['PaymentId']; - -// Catch API errors, write the message to your log and show the ClientMessage to the client. -try { - // Create a heidelpay object using your private key and register a debug handler if you want to. - $heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY); - $heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); - - // Redirect to success if the payment has been successfully completed. - $payment = $heidelpay->fetchPayment($paymentId); - - if ($payment->isCompleted()) { - // The payment process has been successful. - // You can create the order and show a success page. - redirect(SUCCESS_URL); - } elseif ($payment->isPending()) { - // In case of authorization this is normal since you will later charge the payment. - // You can create the order with status pending payment and show a success page to the customer if you want. - - // In cases of redirection to an external service (e.g. 3D secure, PayPal, etc) it sometimes takes time for - // the payment to update it's status. In this case it might be pending at first and change to cancel or success later. - // Use the webhooks feature to stay informed about changes of the payment (e.g. cancel, success) - // then you can cancel the order later or mark it paid as soon as the event is triggered. - - // In any case, the payment is not done when the payment is pending and you should ship until it changes to success. - redirect(PENDING_URL); - } - // If the payment is neither success nor pending something went wrong. - // In this case do not create the order. - // Redirect to an error page in your shop and show an message if you want. - - // Check the result message of the charge to find out what went wrong. - $charge = $payment->getChargeByIndex(0); - $merchantMessage = $charge->getMessage()->getCustomer(); -} catch (HeidelpayApiException $e) { - $merchantMessage = $e->getMerchantMessage(); - $clientMessage = $e->getClientMessage(); -} catch (RuntimeException $e) { - $merchantMessage = $e->getMessage(); -} -redirect(FAILURE_URL, $merchantMessage, $clientMessage); - diff --git a/examples/_enableExamples.php b/examples/_enableExamples.php index e4c5a4cd..efd206e1 100755 --- a/examples/_enableExamples.php +++ b/examples/_enableExamples.php @@ -34,9 +34,6 @@ /* Please enter the path from root directory to the example folder */ define('HEIDELPAY_PHP_PAYMENT_API_FOLDER', '/vendor/heidelpay/heidelpay-php/examples/'); -define('DEFAULT_PRIVATE_KEY', 's-priv-2a102ZMq3gV4I3zJ888J7RR6u75oqK3n'); -define('DEFAULT_PUBLIC_KEY', 's-pub-2a10ifVINFAjpQJ9qW8jBe5OJPBx6Gxa'); - /* Please provide your own sandbox-keypair here. */ -define('HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY', DEFAULT_PRIVATE_KEY); -define('HEIDELPAY_PHP_PAYMENT_API_PUBLIC_KEY', DEFAULT_PUBLIC_KEY); +define('HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY', 's-priv-***'); +define('HEIDELPAY_PHP_PAYMENT_API_PUBLIC_KEY', 's-pub-***'); diff --git a/examples/index.php b/examples/index.php index 6fbe211a..fddfad0f 100755 --- a/examples/index.php +++ b/examples/index.php @@ -23,12 +23,23 @@ * @package heidelpayPHP\examples */ +use heidelpayPHP\Validators\PrivateKeyValidator; +use heidelpayPHP\Validators\PublicKeyValidator; + /** Require the constants of this example */ require_once __DIR__ . '/Constants.php'; /** @noinspection PhpIncludeInspection */ /** Require the composer autoloader file */ require_once __DIR__ . '/../../../autoload.php'; + +function printMessage($type, $title, $text) +{ + echo '
'. + '
' . $title . '
'. + '

' . nl2br($text) . '

'. + '
'; +} ?> @@ -57,6 +68,22 @@ Choose the Payment Type you want to evaluate ... + + support@heidelpay.com' + ); + } + ?> +
@@ -250,7 +277,7 @@
-
+
Try
diff --git a/phpunit.xml b/phpunit.xml index cc401a35..d0d58a86 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -8,8 +8,6 @@ convertWarningsToExceptions="false" processIsolation="false" stopOnFailure="false" - strict="true" - syntaxCheck="false" verbose="true"> diff --git a/src/Adapter/CurlAdapter.php b/src/Adapter/CurlAdapter.php index 4ed982d5..5460f5c1 100755 --- a/src/Adapter/CurlAdapter.php +++ b/src/Adapter/CurlAdapter.php @@ -51,9 +51,10 @@ public function __construct() /** * {@inheritDoc} */ - public function init($url, $payload = null, $httpMethod = HttpAdapterInterface::REQUEST_GET) + public function init($url, $payload = null, $httpMethod = HttpAdapterInterface::REQUEST_GET): void { $timeout = EnvironmentService::getTimeout(); + $curlVerbose = EnvironmentService::isCurlVerbose(); $this->request = curl_init($url); $this->setOption(CURLOPT_HEADER, 0); @@ -65,7 +66,8 @@ public function init($url, $payload = null, $httpMethod = HttpAdapterInterface:: $this->setOption(CURLOPT_RETURNTRANSFER, 1); $this->setOption(CURLOPT_SSL_VERIFYPEER, 1); $this->setOption(CURLOPT_SSL_VERIFYHOST, 2); - $this->setOption(CURLOPT_SSLVERSION, 6); // CURL_SSLVERSION_TLSv1_2 + $this->setOption(CURLOPT_VERBOSE, $curlVerbose); + $this->setOption(CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); if (in_array($httpMethod, [HttpAdapterInterface::REQUEST_POST, HttpAdapterInterface::REQUEST_PUT], true)) { $this->setOption(CURLOPT_POSTFIELDS, $payload); @@ -75,12 +77,13 @@ public function init($url, $payload = null, $httpMethod = HttpAdapterInterface:: /** * {@inheritDoc} */ - public function execute() + public function execute(): ?string { $response = curl_exec($this->request); - $error = curl_errno($this->request); + $error = curl_error($this->request); + $errorNo = curl_errno($this->request); - switch ($error) { + switch ($errorNo) { case 0: return $response; break; @@ -88,7 +91,7 @@ public function execute() $errorMessage = 'Timeout: The Payment API seems to be not available at the moment!'; break; default: - $errorMessage = 'An error occurred sending the request (curl_errno: '. $error . ').'; + $errorMessage = $error . ' (curl_errno: '. $errorNo . ').'; break; } throw new HeidelpayApiException($errorMessage); @@ -105,7 +108,7 @@ public function getResponseCode(): string /** * {@inheritDoc} */ - public function close() + public function close(): void { curl_close($this->request); } @@ -113,7 +116,7 @@ public function close() /** * {@inheritDoc} */ - public function setHeaders(array $headers) + public function setHeaders(array $headers): void { array_walk($headers, static function (&$value, $key) { $value = $key . ': ' . $value; @@ -125,7 +128,7 @@ public function setHeaders(array $headers) /** * {@inheritDoc} */ - public function setUserAgent($userAgent) + public function setUserAgent($userAgent): void { $this->setOption(CURLOPT_USERAGENT, Heidelpay::SDK_TYPE); } @@ -136,7 +139,7 @@ public function setUserAgent($userAgent) * @param $name * @param $value */ - private function setOption($name, $value) + private function setOption($name, $value): void { curl_setopt($this->request, $name, $value); } diff --git a/src/Adapter/HttpAdapterInterface.php b/src/Adapter/HttpAdapterInterface.php index 35cba149..3fa96efa 100755 --- a/src/Adapter/HttpAdapterInterface.php +++ b/src/Adapter/HttpAdapterInterface.php @@ -28,10 +28,10 @@ interface HttpAdapterInterface { - const REQUEST_POST = 'POST'; - const REQUEST_DELETE = 'DELETE'; - const REQUEST_PUT = 'PUT'; - const REQUEST_GET = 'GET'; + public const REQUEST_POST = 'POST'; + public const REQUEST_DELETE = 'DELETE'; + public const REQUEST_PUT = 'PUT'; + public const REQUEST_GET = 'GET'; /** * Initializes the request. @@ -40,7 +40,7 @@ interface HttpAdapterInterface * @param string $payload Json encoded payload string. * @param string $httpMethod The Http method to perform. */ - public function init($url, $payload = null, $httpMethod = HttpAdapterInterface::REQUEST_GET); + public function init($url, $payload = null, $httpMethod = HttpAdapterInterface::REQUEST_GET): void; /** * Executes the request and returns the response. @@ -49,7 +49,7 @@ public function init($url, $payload = null, $httpMethod = HttpAdapterInterface:: * * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. */ - public function execute(); + public function execute(): ?string; /** * Returns the Http code of the response. @@ -61,7 +61,7 @@ public function getResponseCode(): string; /** * Closes the connection of the request. */ - public function close(); + public function close(): void; /** * Sets the headers for the request. @@ -69,12 +69,12 @@ public function close(); * * @param array $headers */ - public function setHeaders(array $headers); + public function setHeaders(array $headers): void; /** * Sets the user Agent. * * @param $userAgent */ - public function setUserAgent($userAgent); + public function setUserAgent($userAgent): void; } diff --git a/src/Constants/ApiResponseCodes.php b/src/Constants/ApiResponseCodes.php index e494fef7..3453f20d 100755 --- a/src/Constants/ApiResponseCodes.php +++ b/src/Constants/ApiResponseCodes.php @@ -27,75 +27,74 @@ class ApiResponseCodes { // Status codes - const API_SUCCESS_REQUEST_PROCESSED_IN_TEST_MODE = 'API.000.100.112'; - const API_SUCCESS_CHARGED_AMOUNT_HIGHER_THAN_EXPECTED = 'API.100.550.340'; - const API_SUCCESS_CHARGED_AMOUNT_LOWER_THAN_EXPECTED = 'API.100.550.341'; + public const API_SUCCESS_REQUEST_PROCESSED_IN_TEST_MODE = 'API.000.100.112'; + public const API_SUCCESS_CHARGED_AMOUNT_HIGHER_THAN_EXPECTED = 'API.100.550.340'; + public const API_SUCCESS_CHARGED_AMOUNT_LOWER_THAN_EXPECTED = 'API.100.550.341'; - const CORE_TRANSACTION_PENDING = 'COR.000.200.000'; + public const CORE_TRANSACTION_PENDING = 'COR.000.200.000'; // Errors codes - const API_ERROR_GENERAL = 'API.000.000.999'; - const API_ERROR_PAYMENT_NOT_FOUND = 'API.310.100.003'; - const API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED = 'API.320.000.004'; - const API_ERROR_TRANSACTION_CHARGE_NOT_ALLOWED = 'API.330.000.004'; - const API_ERROR_TRANSACTION_CANCEL_NOT_ALLOWED = 'API.340.000.004'; - const API_ERROR_TRANSACTION_SHIP_NOT_ALLOWED = 'API.360.000.004'; - const API_ERROR_SHIPPING_REQUIRES_INVOICE_ID = 'API.360.100.025'; - const API_ERROR_CUSTOMER_ID_REQUIRED = 'API.320.100.008'; - const API_ERROR_ORDER_ID_ALREADY_IN_USE = 'API.320.200.138'; - const API_ERROR_RESOURCE_DOES_NOT_BELONG_TO_MERCHANT = 'API.320.200.145'; - const API_ERROR_CHARGED_AMOUNT_HIGHER_THAN_EXPECTED = 'API.330.100.007'; - const API_ERROR_IVF_REQUIRES_CUSTOMER = 'API.330.100.008'; - const API_ERROR_IVF_REQUIRES_BASKET = 'API.330.100.023'; - const API_ERROR_ADDRESSES_DO_NOT_MATCH = 'API.330.100.106'; - const API_ERROR_CURRENCY_IS_NOT_SUPPORTED = 'API.330.100.202'; + public const API_ERROR_GENERAL = 'API.000.000.999'; + public const API_ERROR_PAYMENT_NOT_FOUND = 'API.310.100.003'; + public const API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED = 'API.320.000.004'; + public const API_ERROR_TRANSACTION_CHARGE_NOT_ALLOWED = 'API.330.000.004'; + public const API_ERROR_TRANSACTION_CANCEL_NOT_ALLOWED = 'API.340.000.004'; + public const API_ERROR_TRANSACTION_SHIP_NOT_ALLOWED = 'API.360.000.004'; + public const API_ERROR_SHIPPING_REQUIRES_INVOICE_ID = 'API.360.100.025'; + public const API_ERROR_CUSTOMER_ID_REQUIRED = 'API.320.100.008'; + public const API_ERROR_ORDER_ID_ALREADY_IN_USE = 'API.320.200.138'; + public const API_ERROR_RESOURCE_DOES_NOT_BELONG_TO_MERCHANT = 'API.320.200.145'; + public const API_ERROR_CHARGED_AMOUNT_HIGHER_THAN_EXPECTED = 'API.330.100.007'; + public const API_ERROR_IVF_REQUIRES_CUSTOMER = 'API.330.100.008'; + public const API_ERROR_IVF_REQUIRES_BASKET = 'API.330.100.023'; + public const API_ERROR_ADDRESSES_DO_NOT_MATCH = 'API.330.100.106'; + public const API_ERROR_CURRENCY_IS_NOT_SUPPORTED = 'API.330.100.202'; /** * API_ERROR_AUTHORIZE_ALREADY_CANCELLED * * @deprecated since 1.2.3.0 * @see ApiResponseCodes::API_ERROR_ALREADY_CANCELLED */ - const API_ERROR_AUTHORIZE_ALREADY_CANCELLED = 'API.340.100.014'; - const API_ERROR_ALREADY_CANCELLED = 'API.340.100.014'; + public const API_ERROR_AUTHORIZE_ALREADY_CANCELLED = 'API.340.100.014'; + public const API_ERROR_ALREADY_CANCELLED = 'API.340.100.014'; /** * API_ERROR_CHARGE_ALREADY_CHARGED_BACK * * @deprecated since 1.2.3.0 * @see ApiResponseCodes::API_ERROR_ALREADY_CHARGED_BACK */ - const API_ERROR_CHARGE_ALREADY_CHARGED_BACK = 'API.340.100.015'; - const API_ERROR_ALREADY_CHARGED_BACK = 'API.340.100.015'; - const API_ERROR_ALREADY_CHARGED = 'API.340.100.018'; - const API_ERROR_CANCEL_REASON_CODE_IS_MISSING = 'API.340.100.024'; - const API_ERROR_AMOUNT_IS_MISSING = 'API.340.200.130'; - const API_ERROR_CUSTOMER_DOES_NOT_EXIST = 'API.410.100.100'; - const API_ERROR_CUSTOMER_ID_ALREADY_EXISTS = 'API.410.200.010'; - const API_ERROR_ADDRESS_NAME_TO_LONG = 'API.410.200.031'; - const API_ERROR_CUSTOMER_CAN_NOT_BE_FOUND = 'API.500.100.100'; - const API_ERROR_REQUEST_DATA_IS_INVALID = 'API.500.300.999'; - const API_ERROR_RECURRING_PAYMENT_NOT_SUPPORTED = 'API.500.550.004'; - const API_ERROR_WEBHOOK_EVENT_ALREADY_REGISTERED = 'API.510.310.009'; - const API_ERROR_WEBHOOK_CAN_NOT_BE_FOUND = 'API.510.310.008'; - const API_ERROR_BASKET_ITEM_IMAGE_INVALID_URL = 'API.600.630.004'; + public const API_ERROR_CHARGE_ALREADY_CHARGED_BACK = 'API.340.100.015'; + public const API_ERROR_ALREADY_CHARGED_BACK = 'API.340.100.015'; + public const API_ERROR_ALREADY_CHARGED = 'API.340.100.018'; + public const API_ERROR_CANCEL_REASON_CODE_IS_MISSING = 'API.340.100.024'; + public const API_ERROR_AMOUNT_IS_MISSING = 'API.340.200.130'; + public const API_ERROR_CUSTOMER_DOES_NOT_EXIST = 'API.410.100.100'; + public const API_ERROR_CUSTOMER_ID_ALREADY_EXISTS = 'API.410.200.010'; + public const API_ERROR_ADDRESS_NAME_TO_LONG = 'API.410.200.031'; + public const API_ERROR_CUSTOMER_CAN_NOT_BE_FOUND = 'API.500.100.100'; + public const API_ERROR_REQUEST_DATA_IS_INVALID = 'API.500.300.999'; + public const API_ERROR_RECURRING_PAYMENT_NOT_SUPPORTED = 'API.500.550.004'; + public const API_ERROR_WEBHOOK_EVENT_ALREADY_REGISTERED = 'API.510.310.009'; + public const API_ERROR_WEBHOOK_CAN_NOT_BE_FOUND = 'API.510.310.008'; + public const API_ERROR_BASKET_ITEM_IMAGE_INVALID_URL = 'API.600.630.004'; /** * API_ERROR_BASKET_ITEM_IMAGE_INVALID_EXTENSION * * @deprecated since 1.2.5.0 Will be removed in next major version. */ - const API_ERROR_BASKET_ITEM_IMAGE_INVALID_EXTENSION = 'API.600.630.005'; - const API_ERROR_ACTIVATE_RECURRING_VIA_TRANSACTION = 'API.640.550.005'; - const API_ERROR_RECURRING_ALREADY_ACTIVE = 'API.640.550.006'; - const API_ERROR_INVALID_KEY = 'API.710.000.002'; - const API_ERROR_INSUFFICIENT_PERMISSION = 'API.710.000.005'; - const API_ERROR_WRONG_AUTHENTICATION_METHOD = 'API.710.000.007'; - const API_ERROR_FIELD_IS_MISSING = 'API.710.200.100'; + public const API_ERROR_BASKET_ITEM_IMAGE_INVALID_EXTENSION = 'API.600.630.005'; + public const API_ERROR_RECURRING_ALREADY_ACTIVE = 'API.640.550.006'; + public const API_ERROR_INVALID_KEY = 'API.710.000.002'; + public const API_ERROR_INSUFFICIENT_PERMISSION = 'API.710.000.005'; + public const API_ERROR_WRONG_AUTHENTICATION_METHOD = 'API.710.000.007'; + public const API_ERROR_FIELD_IS_MISSING = 'API.710.200.100'; - const CORE_ERROR_INVALID_OR_MISSING_LOGIN = 'COR.100.300.600'; - const CORE_ERROR_INSURANCE_ALREADY_ACTIVATED = 'COR.700.400.800'; + public const CORE_ERROR_INVALID_OR_MISSING_LOGIN = 'COR.100.300.600'; + public const CORE_ERROR_INSURANCE_ALREADY_ACTIVATED = 'COR.700.400.800'; - const SDM_ERROR_CURRENT_INSURANCE_EVENT = 'SDM.CURRENT_INSURANCE_EVENT'; - const SDM_ERROR_LIMIT_EXCEEDED = 'SDM.LIMIT_EXCEEDED'; - const SDM_ERROR_NEGATIVE_TRAIT_FOUND = 'SDM.NEGATIVE_TRAIT_FOUND'; - const SDM_ERROR_INCREASED_RISK = 'SDM.INCREASED_RISK'; - const SDM_ERROR_DATA_FORMAT_ERROR = 'SDM.DATA_FORMAT_ERROR'; + public const SDM_ERROR_CURRENT_INSURANCE_EVENT = 'SDM.CURRENT_INSURANCE_EVENT'; + public const SDM_ERROR_LIMIT_EXCEEDED = 'SDM.LIMIT_EXCEEDED'; + public const SDM_ERROR_NEGATIVE_TRAIT_FOUND = 'SDM.NEGATIVE_TRAIT_FOUND'; + public const SDM_ERROR_INCREASED_RISK = 'SDM.INCREASED_RISK'; + public const SDM_ERROR_DATA_FORMAT_ERROR = 'SDM.DATA_FORMAT_ERROR'; } diff --git a/src/Constants/BasketItemTypes.php b/src/Constants/BasketItemTypes.php index 60ec2b20..919e6ce9 100644 --- a/src/Constants/BasketItemTypes.php +++ b/src/Constants/BasketItemTypes.php @@ -26,10 +26,10 @@ class BasketItemTypes { - const GOODS = 'goods'; - const SHIPMENT = 'shipment'; - const VOUCHER = 'voucher'; - const DIGITAL = 'digital'; + public const GOODS = 'goods'; + public const SHIPMENT = 'shipment'; + public const VOUCHER = 'voucher'; + public const DIGITAL = 'digital'; - const ARRAY = [self::GOODS, self::SHIPMENT, self::DIGITAL, self::VOUCHER]; + public const ARRAY = [self::GOODS, self::SHIPMENT, self::DIGITAL, self::VOUCHER]; } diff --git a/src/Constants/CancelReasonCodes.php b/src/Constants/CancelReasonCodes.php index 7aa80db1..845f5c9d 100755 --- a/src/Constants/CancelReasonCodes.php +++ b/src/Constants/CancelReasonCodes.php @@ -26,11 +26,11 @@ class CancelReasonCodes { - const REASON_CODE_CANCEL = 'CANCEL'; - const REASON_CODE_RETURN = 'RETURN'; - const REASON_CODE_CREDIT = 'CREDIT'; + public const REASON_CODE_CANCEL = 'CANCEL'; + public const REASON_CODE_RETURN = 'RETURN'; + public const REASON_CODE_CREDIT = 'CREDIT'; - const REASON_CODE_ARRAY = [ + public const REASON_CODE_ARRAY = [ self::REASON_CODE_CANCEL, self::REASON_CODE_RETURN, self::REASON_CODE_CREDIT diff --git a/src/Constants/CompanyCommercialSectorItems.php b/src/Constants/CompanyCommercialSectorItems.php index 3660b955..aa209865 100644 --- a/src/Constants/CompanyCommercialSectorItems.php +++ b/src/Constants/CompanyCommercialSectorItems.php @@ -26,49 +26,49 @@ class CompanyCommercialSectorItems { - const OTHER = 'OTHER'; - const WHOLESALE_TRADE_EXCEPT_VEHICLE_TRADE = 'WHOLESALE_TRADE_EXCEPT_VEHICLE_TRADE'; - const RETAIL_TRADE_EXCEPT_VEHICLE_TRADE = 'RETAIL_TRADE_EXCEPT_VEHICLE_TRADE'; - const WATER_TRANSPORT = 'WATER_TRANSPORT'; - const AIR_TRANSPORT = 'AIR_TRANSPORT'; - const WAREHOUSING_AND_SUPPORT_ACTIVITIES_FOR_TRANSPORTATION = 'WAREHOUSING_AND_SUPPORT_ACTIVITIES_FOR_TRANSPORTATION'; - const POSTAL_AND_COURIER_ACTIVITIES = 'POSTAL_AND_COURIER_ACTIVITIES'; - const ACCOMMODATION = 'ACCOMMODATION'; - const FOOD_AND_BEVERAGE_SERVICE_ACTIVITIES = 'FOOD_AND_BEVERAGE_SERVICE_ACTIVITIES'; - const MOTION_PICTURE_PRODUCTION_AND_SIMILAR_ACTIVITIES = 'MOTION_PICTURE_PRODUCTION_AND_SIMILAR_ACTIVITIES'; - const TELECOMMUNICATIONS = 'TELECOMMUNICATIONS'; - const COMPUTER_PROGRAMMING_CONSULTANCY_AND_RELATED_ACTIVITIES = 'COMPUTER_PROGRAMMING_CONSULTANCY_AND_RELATED_ACTIVITIES'; - const INFORMATION_SERVICE_ACTIVITIES = 'INFORMATION_SERVICE_ACTIVITIES'; - const RENTAL_AND_LEASING_ACTIVITIES = 'RENTAL_AND_LEASING_ACTIVITIES'; - const TRAVEL_AGENCY_AND_RELATED_ACTIVITIES = 'TRAVEL_AGENCY_AND_RELATED_ACTIVITIES'; - const SERVICES_TO_BUILDINGS_AND_LANDSCAPE_ACTIVITIES = 'SERVICES_TO_BUILDINGS_AND_LANDSCAPE_ACTIVITIES'; - const LIBRARIES_AND_SIMILAR_CULTURAL_ACTIVITIES = 'LIBRARIES_AND_SIMILAR_CULTURAL_ACTIVITIES'; - const SPORTS_ACTIVITIES_AND_AMUSEMENT_AND_RECREATION_ACTIVITIES = 'SPORTS_ACTIVITIES_AND_AMUSEMENT_AND_RECREATION_ACTIVITIES'; - const OTHER_PERSONAL_SERVICE_ACTIVITIES = 'OTHER_PERSONAL_SERVICE_ACTIVITIES'; - const NON_RESIDENTIAL_REAL_ESTATE_ACTIVITIES = 'NON_RESIDENTIAL_REAL_ESTATE_ACTIVITIES'; - const MANAGEMENT_CONSULTANCY_ACTIVITIES = 'MANAGEMENT_CONSULTANCY_ACTIVITIES'; - const ELECTRICITY_GAS_AND_STEAM_SUPPLY = 'ELECTRICITY_GAS_AND_STEAM_SUPPLY'; - const WATER_COLLECTION_TREATMENT_AND_SUPPLY = 'WATER_COLLECTION_TREATMENT_AND_SUPPLY'; - const SEWERAGE = 'SEWERAGE'; - const MANUFACTURE_OF_FOOD_PRODUCTS = 'MANUFACTURE_OF_FOOD_PRODUCTS'; - const MANUFACTURE_OF_BEVERAGES = 'MANUFACTURE_OF_BEVERAGES'; - const MANUFACTURE_OF_TEXTILES = 'MANUFACTURE_OF_TEXTILES'; - const OTHERS_COMMERCIAL_SECTORS = 'OTHERS_COMMERCIAL_SECTORS'; - const MANUFACTURE_OF_WEARING_APPAREL = 'MANUFACTURE_OF_WEARING_APPAREL'; - const MANUFACTURE_OF_LEATHER_AND_RELATED_PRODUCTS = 'MANUFACTURE_OF_LEATHER_AND_RELATED_PRODUCTS'; - const MANUFACTURE_OF_PHARMACEUTICAL_PRODUCTS = 'MANUFACTURE_OF_PHARMACEUTICAL_PRODUCTS'; - const REPAIR_AND_INSTALLATION_OF_MACHINERY_AND_EQUIPMENT = 'REPAIR_AND_INSTALLATION_OF_MACHINERY_AND_EQUIPMENT'; - const TRADE_AND_REPAIR_OF_MOTOR_VEHICLES = 'TRADE_AND_REPAIR_OF_MOTOR_VEHICLES'; - const PUBLISHING_ACTIVITIES = 'PUBLISHING_ACTIVITIES'; - const REPAIR_OF_COMPUTERS_AND_GOODS = 'REPAIR_OF_COMPUTERS_AND_GOODS'; - const PRINTING_AND_REPRODUCTION_OF_RECORDED_MEDIA = 'PRINTING_AND_REPRODUCTION_OF_RECORDED_MEDIA'; - const MANUFACTURE_OF_FURNITURE = 'MANUFACTURE_OF_FURNITURE'; - const OTHER_MANUFACTURING = 'OTHER_MANUFACTURING'; - const ADVERTISING_AND_MARKET_RESEARCH = 'ADVERTISING_AND_MARKET_RESEARCH'; - const OTHER_PROFESSIONAL_SCIENTIFIC_AND_TECHNICAL_ACTIVITIES = 'OTHER_PROFESSIONAL_SCIENTIFIC_AND_TECHNICAL_ACTIVITIES'; - const ARTS_ENTERTAINMENT_AND_RECREATION = 'ARTS_ENTERTAINMENT_AND_RECREATION'; + public const OTHER = 'OTHER'; + public const WHOLESALE_TRADE_EXCEPT_VEHICLE_TRADE = 'WHOLESALE_TRADE_EXCEPT_VEHICLE_TRADE'; + public const RETAIL_TRADE_EXCEPT_VEHICLE_TRADE = 'RETAIL_TRADE_EXCEPT_VEHICLE_TRADE'; + public const WATER_TRANSPORT = 'WATER_TRANSPORT'; + public const AIR_TRANSPORT = 'AIR_TRANSPORT'; + public const WAREHOUSING_AND_SUPPORT_ACTIVITIES_FOR_TRANSPORTATION = 'WAREHOUSING_AND_SUPPORT_ACTIVITIES_FOR_TRANSPORTATION'; + public const POSTAL_AND_COURIER_ACTIVITIES = 'POSTAL_AND_COURIER_ACTIVITIES'; + public const ACCOMMODATION = 'ACCOMMODATION'; + public const FOOD_AND_BEVERAGE_SERVICE_ACTIVITIES = 'FOOD_AND_BEVERAGE_SERVICE_ACTIVITIES'; + public const MOTION_PICTURE_PRODUCTION_AND_SIMILAR_ACTIVITIES = 'MOTION_PICTURE_PRODUCTION_AND_SIMILAR_ACTIVITIES'; + public const TELECOMMUNICATIONS = 'TELECOMMUNICATIONS'; + public const COMPUTER_PROGRAMMING_CONSULTANCY_AND_RELATED_ACTIVITIES = 'COMPUTER_PROGRAMMING_CONSULTANCY_AND_RELATED_ACTIVITIES'; + public const INFORMATION_SERVICE_ACTIVITIES = 'INFORMATION_SERVICE_ACTIVITIES'; + public const RENTAL_AND_LEASING_ACTIVITIES = 'RENTAL_AND_LEASING_ACTIVITIES'; + public const TRAVEL_AGENCY_AND_RELATED_ACTIVITIES = 'TRAVEL_AGENCY_AND_RELATED_ACTIVITIES'; + public const SERVICES_TO_BUILDINGS_AND_LANDSCAPE_ACTIVITIES = 'SERVICES_TO_BUILDINGS_AND_LANDSCAPE_ACTIVITIES'; + public const LIBRARIES_AND_SIMILAR_CULTURAL_ACTIVITIES = 'LIBRARIES_AND_SIMILAR_CULTURAL_ACTIVITIES'; + public const SPORTS_ACTIVITIES_AND_AMUSEMENT_AND_RECREATION_ACTIVITIES = 'SPORTS_ACTIVITIES_AND_AMUSEMENT_AND_RECREATION_ACTIVITIES'; + public const OTHER_PERSONAL_SERVICE_ACTIVITIES = 'OTHER_PERSONAL_SERVICE_ACTIVITIES'; + public const NON_RESIDENTIAL_REAL_ESTATE_ACTIVITIES = 'NON_RESIDENTIAL_REAL_ESTATE_ACTIVITIES'; + public const MANAGEMENT_CONSULTANCY_ACTIVITIES = 'MANAGEMENT_CONSULTANCY_ACTIVITIES'; + public const ELECTRICITY_GAS_AND_STEAM_SUPPLY = 'ELECTRICITY_GAS_AND_STEAM_SUPPLY'; + public const WATER_COLLECTION_TREATMENT_AND_SUPPLY = 'WATER_COLLECTION_TREATMENT_AND_SUPPLY'; + public const SEWERAGE = 'SEWERAGE'; + public const MANUFACTURE_OF_FOOD_PRODUCTS = 'MANUFACTURE_OF_FOOD_PRODUCTS'; + public const MANUFACTURE_OF_BEVERAGES = 'MANUFACTURE_OF_BEVERAGES'; + public const MANUFACTURE_OF_TEXTILES = 'MANUFACTURE_OF_TEXTILES'; + public const OTHERS_COMMERCIAL_SECTORS = 'OTHERS_COMMERCIAL_SECTORS'; + public const MANUFACTURE_OF_WEARING_APPAREL = 'MANUFACTURE_OF_WEARING_APPAREL'; + public const MANUFACTURE_OF_LEATHER_AND_RELATED_PRODUCTS = 'MANUFACTURE_OF_LEATHER_AND_RELATED_PRODUCTS'; + public const MANUFACTURE_OF_PHARMACEUTICAL_PRODUCTS = 'MANUFACTURE_OF_PHARMACEUTICAL_PRODUCTS'; + public const REPAIR_AND_INSTALLATION_OF_MACHINERY_AND_EQUIPMENT = 'REPAIR_AND_INSTALLATION_OF_MACHINERY_AND_EQUIPMENT'; + public const TRADE_AND_REPAIR_OF_MOTOR_VEHICLES = 'TRADE_AND_REPAIR_OF_MOTOR_VEHICLES'; + public const PUBLISHING_ACTIVITIES = 'PUBLISHING_ACTIVITIES'; + public const REPAIR_OF_COMPUTERS_AND_GOODS = 'REPAIR_OF_COMPUTERS_AND_GOODS'; + public const PRINTING_AND_REPRODUCTION_OF_RECORDED_MEDIA = 'PRINTING_AND_REPRODUCTION_OF_RECORDED_MEDIA'; + public const MANUFACTURE_OF_FURNITURE = 'MANUFACTURE_OF_FURNITURE'; + public const OTHER_MANUFACTURING = 'OTHER_MANUFACTURING'; + public const ADVERTISING_AND_MARKET_RESEARCH = 'ADVERTISING_AND_MARKET_RESEARCH'; + public const OTHER_PROFESSIONAL_SCIENTIFIC_AND_TECHNICAL_ACTIVITIES = 'OTHER_PROFESSIONAL_SCIENTIFIC_AND_TECHNICAL_ACTIVITIES'; + public const ARTS_ENTERTAINMENT_AND_RECREATION = 'ARTS_ENTERTAINMENT_AND_RECREATION'; - const COMMERCIAL_SECTOR_ARRAY = [ + public const COMMERCIAL_SECTOR_ARRAY = [ self::OTHER, self::WHOLESALE_TRADE_EXCEPT_VEHICLE_TRADE, self::RETAIL_TRADE_EXCEPT_VEHICLE_TRADE, diff --git a/src/Constants/CompanyRegistrationTypes.php b/src/Constants/CompanyRegistrationTypes.php index c3026e92..b5810952 100644 --- a/src/Constants/CompanyRegistrationTypes.php +++ b/src/Constants/CompanyRegistrationTypes.php @@ -26,6 +26,6 @@ class CompanyRegistrationTypes { - const REGISTRATION_TYPE_REGISTERED = 'registered'; - const REGISTRATION_TYPE_NOT_REGISTERED = 'not_registered'; + public const REGISTRATION_TYPE_REGISTERED = 'registered'; + public const REGISTRATION_TYPE_NOT_REGISTERED = 'not_registered'; } diff --git a/src/Constants/IdStrings.php b/src/Constants/IdStrings.php index 0530f832..2a2db26d 100755 --- a/src/Constants/IdStrings.php +++ b/src/Constants/IdStrings.php @@ -27,40 +27,40 @@ class IdStrings { // Transactions - const CHARGE = 'chg'; - const AUTHORIZE = 'aut'; - const CANCEL = 'cnl'; - const SHIPMENT = 'shp'; - const PAYOUT = 'out'; + public const CHARGE = 'chg'; + public const AUTHORIZE = 'aut'; + public const CANCEL = 'cnl'; + public const SHIPMENT = 'shp'; + public const PAYOUT = 'out'; // Payment Types - const CARD = 'crd'; - const GIROPAY = 'gro'; - const IDEAL = 'idl'; - const INVOICE = 'ivc'; - const INVOICE_GUARANTEED = 'ivg'; - const PAYPAL = 'ppl'; - const PREPAYMENT = 'ppy'; - const PRZELEWY24 = 'p24'; - const SEPA_DIRECT_DEBIT_GUARANTEED = 'ddg'; - const SEPA_DIRECT_DEBIT = 'sdd'; - const SOFORT = 'sft'; - const PIS = 'pis'; - const EPS = 'eps'; - const ALIPAY = 'ali'; - const WECHATPAY = 'wcp'; - const INVOICE_FACTORING = 'ivf'; - const HIRE_PURCHASE_DIRECT_DEBIT = 'hdd'; - const PAYMENT_PAGE = 'ppg'; + public const CARD = 'crd'; + public const GIROPAY = 'gro'; + public const IDEAL = 'idl'; + public const INVOICE = 'ivc'; + public const INVOICE_GUARANTEED = 'ivg'; + public const PAYPAL = 'ppl'; + public const PREPAYMENT = 'ppy'; + public const PRZELEWY24 = 'p24'; + public const SEPA_DIRECT_DEBIT_GUARANTEED = 'ddg'; + public const SEPA_DIRECT_DEBIT = 'sdd'; + public const SOFORT = 'sft'; + public const PIS = 'pis'; + public const EPS = 'eps'; + public const ALIPAY = 'ali'; + public const WECHATPAY = 'wcp'; + public const INVOICE_FACTORING = 'ivf'; + public const HIRE_PURCHASE_DIRECT_DEBIT = 'hdd'; + public const PAYMENT_PAGE = 'ppg'; // Resources - const BASKET = 'bsk'; - const WEBHOOK = 'whk'; - const PAYMENT = 'pay'; - const CUSTOMER = 'cst'; - const METADATA = 'mtd'; + public const BASKET = 'bsk'; + public const WEBHOOK = 'whk'; + public const PAYMENT = 'pay'; + public const CUSTOMER = 'cst'; + public const METADATA = 'mtd'; - const PAYMENT_TYPES = [ + public const PAYMENT_TYPES = [ self::CARD, self::GIROPAY, self::IDEAL, diff --git a/src/Constants/PaymentState.php b/src/Constants/PaymentState.php index 208eb1c4..a9a1ca2c 100755 --- a/src/Constants/PaymentState.php +++ b/src/Constants/PaymentState.php @@ -28,19 +28,19 @@ class PaymentState { - const STATE_PENDING = 0; - const STATE_COMPLETED = 1; - const STATE_CANCELED = 2; - const STATE_PARTLY = 3; - const STATE_PAYMENT_REVIEW = 4; - const STATE_CHARGEBACK = 5; + public const STATE_PENDING = 0; + public const STATE_COMPLETED = 1; + public const STATE_CANCELED = 2; + public const STATE_PARTLY = 3; + public const STATE_PAYMENT_REVIEW = 4; + public const STATE_CHARGEBACK = 5; - const STATE_NAME_PENDING = 'pending'; - const STATE_NAME_COMPLETED = 'completed'; - const STATE_NAME_CANCELED = 'canceled'; - const STATE_NAME_PARTLY = 'partly'; - const STATE_NAME_PAYMENT_REVIEW = 'payment review'; - const STATE_NAME_CHARGEBACK = 'chargeback'; + public const STATE_NAME_PENDING = 'pending'; + public const STATE_NAME_COMPLETED = 'completed'; + public const STATE_NAME_CANCELED = 'canceled'; + public const STATE_NAME_PARTLY = 'partly'; + public const STATE_NAME_PAYMENT_REVIEW = 'payment review'; + public const STATE_NAME_CHARGEBACK = 'chargeback'; /** * Returns the name of the state with the given code. diff --git a/src/Constants/Salutations.php b/src/Constants/Salutations.php index ac30098c..10173850 100755 --- a/src/Constants/Salutations.php +++ b/src/Constants/Salutations.php @@ -26,7 +26,7 @@ class Salutations { - const MR = 'mr'; - const MRS = 'mrs'; - const UNKNOWN = 'unknown'; + public const MR = 'mr'; + public const MRS = 'mrs'; + public const UNKNOWN = 'unknown'; } diff --git a/src/Constants/TransactionTypes.php b/src/Constants/TransactionTypes.php index 21460400..ef952b2a 100755 --- a/src/Constants/TransactionTypes.php +++ b/src/Constants/TransactionTypes.php @@ -26,10 +26,10 @@ class TransactionTypes { - const AUTHORIZATION = 'authorize'; - const CHARGE = 'charge'; - const REVERSAL = 'cancel-authorize'; - const REFUND = 'cancel-charge'; - const SHIPMENT = 'shipment'; - const PAYOUT = 'payout'; + public const AUTHORIZATION = 'authorize'; + public const CHARGE = 'charge'; + public const REVERSAL = 'cancel-authorize'; + public const REFUND = 'cancel-charge'; + public const SHIPMENT = 'shipment'; + public const PAYOUT = 'payout'; } diff --git a/src/Constants/WebhookEvents.php b/src/Constants/WebhookEvents.php index 7679e9fa..3d4d4694 100755 --- a/src/Constants/WebhookEvents.php +++ b/src/Constants/WebhookEvents.php @@ -27,53 +27,53 @@ class WebhookEvents { // all events - const ALL = 'all'; + public const ALL = 'all'; // authorize events - const AUTHORIZE = 'authorize'; - const AUTHORIZE_SUCCEEDED = 'authorize.succeeded'; - const AUTHORIZE_FAILED = 'authorize.failed'; - const AUTHORIZE_PENDING = 'authorize.pending'; - const AUTHORIZE_EXPIRED = 'authorize.expired'; - const AUTHORIZE_CANCELED = 'authorize.canceled'; + public const AUTHORIZE = 'authorize'; + public const AUTHORIZE_SUCCEEDED = 'authorize.succeeded'; + public const AUTHORIZE_FAILED = 'authorize.failed'; + public const AUTHORIZE_PENDING = 'authorize.pending'; + public const AUTHORIZE_EXPIRED = 'authorize.expired'; + public const AUTHORIZE_CANCELED = 'authorize.canceled'; // charge events - const CHARGE = 'charge'; - const CHARGE_SUCCEEDED = 'charge.succeeded'; - const CHARGE_FAILED = 'charge.failed'; - const CHARGE_PENDING = 'charge.pending'; - const CHARGE_EXPIRED = 'charge.expired'; - const CHARGE_CANCELED = 'charge.canceled'; + public const CHARGE = 'charge'; + public const CHARGE_SUCCEEDED = 'charge.succeeded'; + public const CHARGE_FAILED = 'charge.failed'; + public const CHARGE_PENDING = 'charge.pending'; + public const CHARGE_EXPIRED = 'charge.expired'; + public const CHARGE_CANCELED = 'charge.canceled'; // chargeback events - const CHARGEBACK = 'chargeback'; + public const CHARGEBACK = 'chargeback'; // payout events - const PAYOUT = 'payout'; - const PAYOUT_SUCCEEDED = 'payout.succeeded'; - const PAYOUT_FAILED = 'payout.failed'; + public const PAYOUT = 'payout'; + public const PAYOUT_SUCCEEDED = 'payout.succeeded'; + public const PAYOUT_FAILED = 'payout.failed'; // types events - const TYPES = 'types'; + public const TYPES = 'types'; // customer events - const CUSTOMER = 'customer'; - const CUSTOMER_CREATED = 'customer.created'; - const CUSTOMER_DELETED = 'customer.deleted'; - const CUSTOMER_UPDATED = 'customer.updated'; + public const CUSTOMER = 'customer'; + public const CUSTOMER_CREATED = 'customer.created'; + public const CUSTOMER_DELETED = 'customer.deleted'; + public const CUSTOMER_UPDATED = 'customer.updated'; // payment events - const PAYMENT_PENDING = 'payment.pending'; - const PAYMENT_COMPLETED = 'payment.completed'; - const PAYMENT_CANCELED = 'payment.canceled'; - const PAYMENT_PARTLY = 'payment.partly'; - const PAYMENT_PAYMENT_REVIEW = 'payment.payment_review'; - const PAYMENT_CHARGEBACK = 'payment.chargeback'; + public const PAYMENT_PENDING = 'payment.pending'; + public const PAYMENT_COMPLETED = 'payment.completed'; + public const PAYMENT_CANCELED = 'payment.canceled'; + public const PAYMENT_PARTLY = 'payment.partly'; + public const PAYMENT_PAYMENT_REVIEW = 'payment.payment_review'; + public const PAYMENT_CHARGEBACK = 'payment.chargeback'; // shipment events - const SHIPMENT = 'shipment'; + public const SHIPMENT = 'shipment'; - const ALLOWED_WEBHOOKS = [ + public const ALLOWED_WEBHOOKS = [ self::ALL, self::AUTHORIZE, self::AUTHORIZE_SUCCEEDED, diff --git a/src/Exceptions/HeidelpayApiException.php b/src/Exceptions/HeidelpayApiException.php index e730afa7..22defeea 100755 --- a/src/Exceptions/HeidelpayApiException.php +++ b/src/Exceptions/HeidelpayApiException.php @@ -28,8 +28,8 @@ class HeidelpayApiException extends Exception { - const MESSAGE = 'The payment api returned an error!'; - const CLIENT_MESSAGE = 'The payment api returned an error!'; + public const MESSAGE = 'The payment api returned an error!'; + public const CLIENT_MESSAGE = 'The payment api returned an error!'; /** @var string $clientMessage */ protected $clientMessage; diff --git a/src/Heidelpay.php b/src/Heidelpay.php index 4912ba81..805f1cbf 100755 --- a/src/Heidelpay.php +++ b/src/Heidelpay.php @@ -44,7 +44,6 @@ use heidelpayPHP\Resources\PaymentTypes\BasePaymentType; use heidelpayPHP\Resources\PaymentTypes\Paypage; use heidelpayPHP\Resources\Recurring; -use heidelpayPHP\Resources\TransactionTypes\AbstractTransactionType; use heidelpayPHP\Resources\TransactionTypes\Authorization; use heidelpayPHP\Resources\TransactionTypes\Cancellation; use heidelpayPHP\Resources\TransactionTypes\Charge; @@ -61,10 +60,10 @@ class Heidelpay implements HeidelpayParentInterface, PaymentServiceInterface, ResourceServiceInterface, WebhookServiceInterface, CancelServiceInterface { - const BASE_URL = 'api.heidelpay.com'; - const API_VERSION = 'v1'; - const SDK_TYPE = 'heidelpayPHP'; - const SDK_VERSION = '1.2.7.2'; + public const BASE_URL = 'api.heidelpay.com'; + public const API_VERSION = 'v1'; + public const SDK_TYPE = 'heidelpayPHP'; + public const SDK_VERSION = '1.2.8.0'; /** @var string $key */ private $key; @@ -152,7 +151,7 @@ public function setKey($key): Heidelpay * @return string|null The locale of the customer. * Refer to the documentation under https://docs.heidelpay.com for a list of supported values. */ - public function getLocale() + public function getLocale(): ?string { return $this->locale; } @@ -275,7 +274,7 @@ public function setDebugMode(bool $debugMode): Heidelpay /** * @return DebugHandlerInterface|null */ - public function getDebugHandler() + public function getDebugHandler(): ?DebugHandlerInterface { return $this->debugHandler; } @@ -539,7 +538,7 @@ public function updateCustomer(Customer $customer): Customer /** * {@inheritDoc} */ - public function deleteCustomer($customer) + public function deleteCustomer($customer): void { $this->resourceService->deleteCustomer($customer); } @@ -683,7 +682,7 @@ public function fetchAllWebhooks(): array /** * {@inheritDoc} */ - public function deleteAllWebhooks() + public function deleteAllWebhooks(): void { $this->webhookService->deleteAllWebhooks(); } @@ -743,38 +742,6 @@ public function authorize( ); } - /** - * Performs an Authorization transaction using a Payment object and returns the resulting Authorization resource. - * - * @param float $amount The amount to authorize. - * @param string $currency The currency of the amount. - * @param Payment $payment The Payment object to create the Authorization for. - * @param string $returnUrl The URL used to return to the shop if the process requires leaving it. - * @param Customer|string|null $customer The Customer object or the id of the customer resource to reference. - * @param string|null $orderId A custom order id which can be set by the merchant. - * @param Metadata|null $metadata The Metadata object containing custom information for the payment. - * @param Basket|null $basket The Basket object corresponding to the payment. - * The Basket object will be created automatically if it does not exist - * yet (i.e. has no id). - * - * @return AbstractTransactionType The resulting object of the Authorization resource. - * - * @deprecated since 1.2.6.0 - */ - public function authorizeWithPayment( - $amount, - $currency, - Payment $payment, - $returnUrl = null, - $customer = null, - $orderId = null, - $metadata = null, - $basket = null - ): AbstractTransactionType { - return $this->paymentService - ->authorizeWithPayment($amount, $currency, $payment, $returnUrl, $customer, $orderId, $metadata, $basket); - } - // // @@ -878,7 +845,7 @@ public function cancelPayment( /** * {@inheritDoc} */ - public function cancelPaymentAuthorization($payment, float $amount = null) + public function cancelPaymentAuthorization($payment, float $amount = null): ?Cancellation { return $this->cancelService->cancelPaymentAuthorization($payment, $amount); } @@ -1019,7 +986,7 @@ public function fetchDirectDebitInstalmentPlans( * * @param $message */ - public function debugLog($message) + public function debugLog($message): void { if ($this->isDebugMode()) { $debugHandler = $this->getDebugHandler(); diff --git a/src/Interfaces/CancelServiceInterface.php b/src/Interfaces/CancelServiceInterface.php index c53ad89f..b0c729a5 100644 --- a/src/Interfaces/CancelServiceInterface.php +++ b/src/Interfaces/CancelServiceInterface.php @@ -144,5 +144,5 @@ public function cancelPayment( * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is a error while using the SDK. */ - public function cancelPaymentAuthorization($payment, float $amount = null); + public function cancelPaymentAuthorization($payment, float $amount = null): ?Cancellation; } diff --git a/src/Interfaces/ResourceServiceInterface.php b/src/Interfaces/ResourceServiceInterface.php index c368a683..09814024 100644 --- a/src/Interfaces/ResourceServiceInterface.php +++ b/src/Interfaces/ResourceServiceInterface.php @@ -271,12 +271,10 @@ public function updateCustomer(Customer $customer): Customer; * * @param Customer|string $customer The customer to be deleted. Can be the customer object or its id. * - * @return Customer|null The customer object if there was a failure deleting it or null if the deletion succeeded. - * * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function deleteCustomer($customer); + public function deleteCustomer($customer): void; /** * Fetch an authorization object by its payment object or id. diff --git a/src/Resources/AbstractHeidelpayResource.php b/src/Resources/AbstractHeidelpayResource.php index fb5af5b2..3aca6cb9 100755 --- a/src/Resources/AbstractHeidelpayResource.php +++ b/src/Resources/AbstractHeidelpayResource.php @@ -76,7 +76,7 @@ public static function getResourceName(): string * * @return string|null */ - public function getId() + public function getId(): ?string { return $this->id; } @@ -121,7 +121,7 @@ public function getParentResource(): HeidelpayParentInterface /** * @return DateTime|null */ - public function getFetchedAt() + public function getFetchedAt(): ?DateTime { return $this->fetchedAt; } @@ -239,7 +239,7 @@ public function getUri($appendId = true): string * @param $object * @param stdClass $response */ - private static function updateValues($object, stdClass $response) + private static function updateValues($object, stdClass $response): void { foreach ($response as $key => $value) { // set empty string to null (workaround) @@ -307,7 +307,7 @@ protected function getResource(AbstractHeidelpayResource $resource): AbstractHei * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - protected function fetchResource(AbstractHeidelpayResource $resource) + protected function fetchResource(AbstractHeidelpayResource $resource): void { $this->getResourceService()->fetchResource($resource); } @@ -443,7 +443,7 @@ private static function propertyShouldBeSkipped($property, $value): bool * @param $key * @param $value */ - private static function setItemProperty($item, $key, $value) + private static function setItemProperty($item, $key, $value): void { $setter = 'set' . ucfirst($key); if (!is_callable([$item, $setter])) { @@ -486,8 +486,9 @@ protected function getResourcePath(): string * * @param stdClass $response * @param string $method + * @noinspection PhpUnusedParameterInspection */ - public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET) + public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET): void { self::updateValues($this, $response); @@ -509,7 +510,7 @@ public function handleResponse(stdClass $response, $method = HttpAdapterInterfac * * @return string|null */ - public function getExternalId() + public function getExternalId(): ?string { return null; } diff --git a/src/Resources/Basket.php b/src/Resources/Basket.php index b96c41ba..5d33e89e 100755 --- a/src/Resources/Basket.php +++ b/src/Resources/Basket.php @@ -185,7 +185,7 @@ public function getItemCount(): int /** * @return string|null */ - public function getNote() + public function getNote(): ?string { return $this->note; } @@ -265,7 +265,7 @@ public function addBasketItem(BasketItem $basketItem): Basket * * @return BasketItem|null */ - public function getBasketItemByIndex($index) + public function getBasketItemByIndex($index): ?BasketItem { return $this->basketItems[$index] ?? null; } @@ -315,7 +315,7 @@ protected function getResourcePath(): string /** * {@inheritDoc} */ - public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET) + public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET): void { parent::handleResponse($response, $method); diff --git a/src/Resources/Customer.php b/src/Resources/Customer.php index a62b6aec..b3557650 100755 --- a/src/Resources/Customer.php +++ b/src/Resources/Customer.php @@ -96,7 +96,7 @@ public function __construct(string $firstname = null, string $lastname = null) /** * @return string|null */ - public function getFirstname() + public function getFirstname(): ?string { return $this->firstname; } @@ -115,7 +115,7 @@ public function setFirstname($firstname): Customer /** * @return string|null */ - public function getLastname() + public function getLastname(): ?string { return $this->lastname; } @@ -154,7 +154,7 @@ public function setSalutation($salutation): Customer /** * @return string|null */ - public function getBirthDate() + public function getBirthDate(): ?string { return $this->birthDate; } @@ -173,7 +173,7 @@ public function setBirthDate($birthday): Customer /** * @return string|null */ - public function getCompany() + public function getCompany(): ?string { return $this->company; } @@ -192,7 +192,7 @@ public function setCompany($company): Customer /** * @return string|null */ - public function getEmail() + public function getEmail(): ?string { return $this->email; } @@ -211,7 +211,7 @@ public function setEmail($email): Customer /** * @return string|null */ - public function getPhone() + public function getPhone(): ?string { return $this->phone; } @@ -230,7 +230,7 @@ public function setPhone($phone): Customer /** * @return string|null */ - public function getMobile() + public function getMobile(): ?string { return $this->mobile; } @@ -287,7 +287,7 @@ public function setShippingAddress(Address $shippingAddress): Customer /** * @return string|null */ - public function getCustomerId() + public function getCustomerId(): ?string { return $this->customerId; } @@ -306,7 +306,7 @@ public function setCustomerId($customerId): Customer /** * @return CompanyInfo|null */ - public function getCompanyInfo() + public function getCompanyInfo(): ?CompanyInfo { return $this->companyInfo; } @@ -341,7 +341,7 @@ protected function getResourcePath(): string /** * {@inheritDoc} */ - public function getExternalId() + public function getExternalId(): ?string { return $this->getCustomerId(); } @@ -349,7 +349,7 @@ public function getExternalId() /** * {@inheritDoc} */ - public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET) + public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET): void { if (isset($response->companyInfo) && $this->companyInfo === null) { $this->companyInfo = new CompanyInfo(); diff --git a/src/Resources/EmbeddedResources/Address.php b/src/Resources/EmbeddedResources/Address.php index cf88d362..39e0c05b 100755 --- a/src/Resources/EmbeddedResources/Address.php +++ b/src/Resources/EmbeddedResources/Address.php @@ -51,7 +51,7 @@ class Address extends AbstractHeidelpayResource /** * @return string|null */ - public function getName() + public function getName(): ?string { return $this->name; } @@ -70,7 +70,7 @@ public function setName($name): Address /** * @return string|null */ - public function getStreet() + public function getStreet(): ?string { return $this->street; } @@ -89,7 +89,7 @@ public function setStreet($street): Address /** * @return string|null */ - public function getState() + public function getState(): ?string { return $this->state; } @@ -108,7 +108,7 @@ public function setState($state): Address /** * @return string|null */ - public function getZip() + public function getZip(): ?string { return $this->zip; } @@ -127,7 +127,7 @@ public function setZip($zip): Address /** * @return string|null */ - public function getCity() + public function getCity(): ?string { return $this->city; } @@ -146,7 +146,7 @@ public function setCity($city): Address /** * @return string|null */ - public function getCountry() + public function getCountry(): ?string { return $this->country; } diff --git a/src/Resources/EmbeddedResources/Amount.php b/src/Resources/EmbeddedResources/Amount.php index 559dfbc7..7ea8338d 100755 --- a/src/Resources/EmbeddedResources/Amount.php +++ b/src/Resources/EmbeddedResources/Amount.php @@ -117,7 +117,7 @@ protected function setRemaining(float $remaining): self /** * @return string|null */ - public function getCurrency() + public function getCurrency(): ?string { return $this->currency; } diff --git a/src/Resources/EmbeddedResources/BasketItem.php b/src/Resources/EmbeddedResources/BasketItem.php index d3d9b583..4ef82c50 100755 --- a/src/Resources/EmbeddedResources/BasketItem.php +++ b/src/Resources/EmbeddedResources/BasketItem.php @@ -92,7 +92,7 @@ public function __construct( /** * @return string|null */ - public function getBasketItemReferenceId() + public function getBasketItemReferenceId(): ?string { return $this->basketItemReferenceId; } @@ -244,7 +244,7 @@ public function setAmountNet(float $amountNet): BasketItem /** * @return string|null */ - public function getUnit() + public function getUnit(): ?string { return $this->unit; } @@ -282,7 +282,7 @@ public function setTitle(string $title): BasketItem /** * @return string|null */ - public function getImageUrl() + public function getImageUrl(): ?string { return $this->imageUrl; } @@ -301,7 +301,7 @@ public function setImageUrl($imageUrl): BasketItem /** * @return string|null */ - public function getSubTitle() + public function getSubTitle(): ?string { return $this->subTitle; } @@ -320,7 +320,7 @@ public function setSubTitle($subTitle): BasketItem /** * @return string|null */ - public function getType() + public function getType(): ?string { return $this->type; } diff --git a/src/Resources/EmbeddedResources/CardDetails.php b/src/Resources/EmbeddedResources/CardDetails.php index 8b6a80e3..74fa18dc 100644 --- a/src/Resources/EmbeddedResources/CardDetails.php +++ b/src/Resources/EmbeddedResources/CardDetails.php @@ -54,7 +54,7 @@ class CardDetails extends AbstractHeidelpayResource /** * @return string|null */ - public function getCardType() + public function getCardType(): ?string { return $this->cardType; } @@ -73,7 +73,7 @@ protected function setCardType($cardType): CardDetails /** * @return string|null */ - public function getAccount() + public function getAccount(): ?string { return $this->account; } @@ -92,7 +92,7 @@ protected function setAccount($account): CardDetails /** * @return string|null */ - public function getCountryIsoA2() + public function getCountryIsoA2(): ?string { return $this->countryIsoA2; } @@ -111,7 +111,7 @@ protected function setCountryIsoA2($countryIsoA2): CardDetails /** * @return string|null */ - public function getCountryName() + public function getCountryName(): ?string { return $this->countryName; } @@ -130,7 +130,7 @@ protected function setCountryName($countryName): CardDetails /** * @return string|null */ - public function getIssuerName() + public function getIssuerName(): ?string { return $this->issuerName; } @@ -149,7 +149,7 @@ protected function setIssuerName($issuerName): CardDetails /** * @return string|null */ - public function getIssuerUrl() + public function getIssuerUrl(): ?string { return $this->issuerUrl; } @@ -168,7 +168,7 @@ protected function setIssuerUrl($issuerUrl): CardDetails /** * @return string|null */ - public function getIssuerPhoneNumber() + public function getIssuerPhoneNumber(): ?string { return $this->issuerPhoneNumber; } diff --git a/src/Resources/EmbeddedResources/CompanyInfo.php b/src/Resources/EmbeddedResources/CompanyInfo.php index f5dd3018..e4c71b2e 100644 --- a/src/Resources/EmbeddedResources/CompanyInfo.php +++ b/src/Resources/EmbeddedResources/CompanyInfo.php @@ -47,7 +47,7 @@ class CompanyInfo extends AbstractHeidelpayResource /** * @return string|null */ - public function getRegistrationType() + public function getRegistrationType(): ?string { return $this->registrationType; } @@ -66,7 +66,7 @@ public function setRegistrationType($registrationType): CompanyInfo /** * @return string|null */ - public function getCommercialRegisterNumber() + public function getCommercialRegisterNumber(): ?string { return $this->commercialRegisterNumber; } @@ -86,7 +86,7 @@ public function setCommercialRegisterNumber($commercialRegisterNumber): CompanyI /** * @return string|null */ - public function getFunction() + public function getFunction(): ?string { return $this->function; } diff --git a/src/Resources/EmbeddedResources/GeoLocation.php b/src/Resources/EmbeddedResources/GeoLocation.php index 1eca406b..5ce7db82 100644 --- a/src/Resources/EmbeddedResources/GeoLocation.php +++ b/src/Resources/EmbeddedResources/GeoLocation.php @@ -39,7 +39,7 @@ class GeoLocation extends AbstractHeidelpayResource /** * @return string|null */ - public function getClientIp() + public function getClientIp(): ?string { return $this->clientIp; } @@ -58,7 +58,7 @@ protected function setClientIp($clientIp): GeoLocation /** * @return string|null */ - public function getCountryCode() + public function getCountryCode(): ?string { return $this->countryCode; } diff --git a/src/Resources/EmbeddedResources/Message.php b/src/Resources/EmbeddedResources/Message.php index 2909a5dd..337f273e 100755 --- a/src/Resources/EmbeddedResources/Message.php +++ b/src/Resources/EmbeddedResources/Message.php @@ -80,7 +80,7 @@ protected function setCustomer(string $customer): Message /** * @return string|null */ - public function getMerchant() + public function getMerchant(): ?string { return $this->merchant; } diff --git a/src/Resources/InstalmentPlan.php b/src/Resources/InstalmentPlan.php index 5468342e..ceba213a 100644 --- a/src/Resources/InstalmentPlan.php +++ b/src/Resources/InstalmentPlan.php @@ -123,7 +123,7 @@ public function __construct( /** * @return string|null */ - public function getOrderDate() + public function getOrderDate(): ?string { return $this->orderDate; } @@ -142,7 +142,7 @@ public function setOrderDate($orderDate): self /** * @return int|null */ - public function getNumberOfRates() + public function getNumberOfRates(): ?int { return $this->numberOfRates; } @@ -161,7 +161,7 @@ public function setNumberOfRates($numberOfRates): self /** * @return string|null */ - public function getDayOfPurchase() + public function getDayOfPurchase(): ?string { return $this->dayOfPurchase; } @@ -180,7 +180,7 @@ public function setDayOfPurchase($dayOfPurchase): self /** * @return float|null */ - public function getTotalPurchaseAmount() + public function getTotalPurchaseAmount(): ?float { return $this->totalPurchaseAmount; } @@ -199,7 +199,7 @@ public function setTotalPurchaseAmount($totalPurchaseAmount): self /** * @return float|null */ - public function getTotalInterestAmount() + public function getTotalInterestAmount(): ?float { return $this->totalInterestAmount; } @@ -218,7 +218,7 @@ public function setTotalInterestAmount($totalInterestAmount): self /** * @return float|null */ - public function getTotalAmount() + public function getTotalAmount(): ?float { return $this->totalAmount; } @@ -237,7 +237,7 @@ public function setTotalAmount($totalAmount): self /** * @return float|null */ - public function getEffectiveInterestRate() + public function getEffectiveInterestRate(): ?float { return $this->effectiveInterestRate; } @@ -256,7 +256,7 @@ public function setEffectiveInterestRate($effectiveInterestRate): self /** * @return float|null */ - public function getNominalInterestRate() + public function getNominalInterestRate(): ?float { return $this->nominalInterestRate; } @@ -275,7 +275,7 @@ public function setNominalInterestRate($nominalInterestRate): self /** * @return float|null */ - public function getFeeFirstRate() + public function getFeeFirstRate(): ?float { return $this->feeFirstRate; } @@ -294,7 +294,7 @@ public function setFeeFirstRate($feeFirstRate): self /** * @return float|null */ - public function getFeePerRate() + public function getFeePerRate(): ?float { return $this->feePerRate; } @@ -313,7 +313,7 @@ public function setFeePerRate($feePerRate): self /** * @return float|null */ - public function getMonthlyRate() + public function getMonthlyRate(): ?float { return $this->monthlyRate; } @@ -332,7 +332,7 @@ public function setMonthlyRate($monthlyRate): self /** * @return float|null */ - public function getLastRate() + public function getLastRate(): ?float { return $this->lastRate; } @@ -351,7 +351,7 @@ public function setLastRate($lastRate): self /** * @return string|null */ - public function getInvoiceDate() + public function getInvoiceDate(): ?string { return $this->invoiceDate; } @@ -370,7 +370,7 @@ public function setInvoiceDate($invoiceDate): InstalmentPlan /** * @return string|null */ - public function getInvoiceDueDate() + public function getInvoiceDueDate(): ?string { return $this->invoiceDueDate; } @@ -390,7 +390,7 @@ public function setInvoiceDueDate($invoiceDueDate): InstalmentPlan /** * @return stdClass[]|null */ - public function getInstallmentRates() + public function getInstallmentRates(): ?array { return $this->installmentRates; } @@ -426,7 +426,7 @@ public function getTransactionParams(): array /** * {@inheritDoc} */ - public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET) + public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET): void { parent::handleResponse($response, $method); diff --git a/src/Resources/InstalmentPlans.php b/src/Resources/InstalmentPlans.php index 70cc8b2e..ffff8e90 100644 --- a/src/Resources/InstalmentPlans.php +++ b/src/Resources/InstalmentPlans.php @@ -148,7 +148,7 @@ protected function setPlans(array $plans): InstalmentPlans /** * @return string|null */ - public function getOrderDate() + public function getOrderDate(): ?string { return $this->orderDate; } @@ -211,7 +211,7 @@ public function getResourcePath(): string /** * {@inheritDoc} */ - public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET) + public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET): void { parent::handleResponse($response, $method); diff --git a/src/Resources/Keypair.php b/src/Resources/Keypair.php index 5914ac96..4c2a3835 100755 --- a/src/Resources/Keypair.php +++ b/src/Resources/Keypair.php @@ -69,7 +69,7 @@ class Keypair extends AbstractHeidelpayResource /** * @return string|null */ - public function getPublicKey() + public function getPublicKey(): ?string { return $this->publicKey; } @@ -77,7 +77,7 @@ public function getPublicKey() /** * @param string $publicKey */ - protected function setPublicKey(string $publicKey) + protected function setPublicKey(string $publicKey): void { $this->publicKey = $publicKey; } @@ -85,7 +85,7 @@ protected function setPublicKey(string $publicKey) /** * @return string|null */ - public function getPrivateKey() + public function getPrivateKey(): ?string { return $this->privateKey; } @@ -93,7 +93,7 @@ public function getPrivateKey() /** * @param string $privateKey */ - protected function setPrivateKey(string $privateKey) + protected function setPrivateKey(string $privateKey): void { $this->privateKey = $privateKey; } @@ -109,7 +109,7 @@ public function getPaymentTypes(): array /** * @param array $paymentTypes */ - protected function setPaymentTypes(array $paymentTypes) + protected function setPaymentTypes(array $paymentTypes): void { $this->paymentTypes = $paymentTypes; } @@ -125,7 +125,7 @@ public function getAvailablePaymentTypes(): array /** * @param array $paymentTypes */ - protected function setAvailablePaymentTypes(array $paymentTypes) + protected function setAvailablePaymentTypes(array $paymentTypes): void { $this->setPaymentTypes($paymentTypes); } @@ -230,7 +230,7 @@ public function setDetailed(bool $detailed): Keypair * * @return bool|null */ - public function isCof() + public function isCof(): ?bool { return $this->cof; } @@ -249,7 +249,7 @@ protected function setCof(bool $cof): Keypair /** * @return bool|null */ - public function isValidateBasket() + public function isValidateBasket(): ?bool { return $this->validateBasket; } @@ -272,7 +272,7 @@ protected function setValidateBasket($validateBasket): Keypair /** * @inheritDoc */ - public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET) + public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET): void { parent::handleResponse($response, $method); diff --git a/src/Resources/Metadata.php b/src/Resources/Metadata.php index 32bdbc2c..32d42e66 100755 --- a/src/Resources/Metadata.php +++ b/src/Resources/Metadata.php @@ -42,7 +42,7 @@ class Metadata extends AbstractHeidelpayResource /** * @return string|null */ - public function getShopType() + public function getShopType(): ?string { return $this->shopType; } @@ -61,7 +61,7 @@ public function setShopType(string $shopType): Metadata /** * @return string|null */ - public function getShopVersion() + public function getShopVersion(): ?string { return $this->shopVersion; } @@ -124,7 +124,7 @@ public function expose() * Add custom properties (i. e. properties without setter) to the metadata array. * {@inheritDoc} */ - public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET) + public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET): void { parent::handleResponse($response, $method); diff --git a/src/Resources/Payment.php b/src/Resources/Payment.php index b2ec0b92..1a2330cd 100755 --- a/src/Resources/Payment.php +++ b/src/Resources/Payment.php @@ -30,10 +30,10 @@ use heidelpayPHP\Constants\IdStrings; use heidelpayPHP\Constants\TransactionTypes; use heidelpayPHP\Exceptions\HeidelpayApiException; -use heidelpayPHP\Heidelpay; use heidelpayPHP\Resources\EmbeddedResources\Amount; use heidelpayPHP\Resources\PaymentTypes\BasePaymentType; use heidelpayPHP\Resources\PaymentTypes\Paypage; +use heidelpayPHP\Resources\TransactionTypes\AbstractTransactionType; use heidelpayPHP\Resources\TransactionTypes\Authorization; use heidelpayPHP\Resources\TransactionTypes\Cancellation; use heidelpayPHP\Resources\TransactionTypes\Charge; @@ -105,7 +105,7 @@ public function __construct($parent = null) * * @return string|null */ - public function getRedirectUrl() + public function getRedirectUrl(): ?string { return $this->redirectUrl; } @@ -233,7 +233,7 @@ public function addCharge(Charge $charge): self * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function getCharge($chargeId, $lazy = false) + public function getCharge($chargeId, $lazy = false): ?Charge { /** @var Charge $charge */ foreach ($this->charges as $charge) { @@ -291,7 +291,6 @@ public function setCustomer($customer): Payment return $this; } - /** @var Heidelpay $heidelpay */ $heidelpay = $this->getHeidelpayObject(); /** @var Customer $customerObject */ @@ -315,7 +314,7 @@ public function setCustomer($customer): Payment * * @return Customer|null The Customer object referenced by this Payment or null if no Customer could be found. */ - public function getCustomer() + public function getCustomer(): ?Customer { return $this->customer; } @@ -325,7 +324,7 @@ public function getCustomer() * * @return BasePaymentType|null The PaymentType referenced by this Payment. */ - public function getPaymentType() + public function getPaymentType(): ?BasePaymentType { return $this->paymentType; } @@ -347,7 +346,6 @@ public function setPaymentType($paymentType): Payment return $this; } - /** @var Heidelpay $heidelpay */ $heidelpay = $this->getHeidelpayObject(); /** @var BasePaymentType $paymentTypeObject */ @@ -367,7 +365,7 @@ public function setPaymentType($paymentType): Payment /** * @return Metadata|null */ - public function getMetadata() + public function getMetadata(): ?Metadata { return $this->metadata; } @@ -387,7 +385,6 @@ public function setMetadata($metadata): Payment } $this->metadata = $metadata; - /** @var Heidelpay $heidelpay */ $heidelpay = $this->getHeidelpayObject(); if ($this->metadata->getId() === null) { $heidelpay->getResourceService()->createResource($this->metadata->setParentResource($heidelpay)); @@ -399,7 +396,7 @@ public function setMetadata($metadata): Payment /** * @return Basket|null */ - public function getBasket() + public function getBasket(): ?Basket { return $this->basket; } @@ -422,7 +419,6 @@ public function setBasket($basket): Payment return $this; } - /** @var Heidelpay $heidelpay */ $heidelpay = $this->getHeidelpayObject(); if ($this->basket->getId() === null) { $heidelpay->getResourceService()->createResource($this->basket->setParentResource($heidelpay)); @@ -447,7 +443,7 @@ public function setBasket($basket): Payment * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function getCancellation($cancellationId, $lazy = false) + public function getCancellation($cancellationId, $lazy = false): ?Cancellation { /** @var Cancellation $cancellation */ foreach ($this->getCancellations() as $cancellation) { @@ -520,7 +516,7 @@ public function getShipments(): array * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function getShipment($shipmentId, $lazy = false) + public function getShipment($shipmentId, $lazy = false): ?Shipment { /** @var Shipment $shipment */ foreach ($this->getShipments() as $shipment) { @@ -570,6 +566,21 @@ public function getCurrency(): string return $this->amount->getCurrency(); } + /** + * Returns the initial transaction (Authorize or Charge) of the payment. + * + * @param bool $lazy + * + * @return AbstractTransactionType|null + * + * @throws HeidelpayApiException + * @throws RuntimeException + */ + public function getInitialTransaction($lazy = false): ?AbstractTransactionType + { + return $this->getAuthorization($lazy) ?? $this->getChargeByIndex(0, $lazy); + } + /** * Sets the currency string of the amounts of this Payment. * @@ -601,7 +612,7 @@ protected function getResourcePath(): string * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET) + public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET): void { parent::handleResponse($response, $method); @@ -621,7 +632,7 @@ public function handleResponse(stdClass $response, $method = HttpAdapterInterfac /** * {@inheritDoc} */ - public function getExternalId() + public function getExternalId(): ?string { return $this->getOrderId(); } @@ -646,7 +657,7 @@ public function getExternalId() * @deprecated since 1.2.3.0 * @see Payment::cancelAmount() */ - public function cancel($amount = null, $reason = CancelReasonCodes::REASON_CODE_CANCEL) + public function cancel($amount = null, $reason = CancelReasonCodes::REASON_CODE_CANCEL): ?Cancellation { $cancellations = $this->cancelAmount($amount, $reason); @@ -752,7 +763,7 @@ public function cancelAuthorization($amount = null): array * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function cancelAuthorizationAmount(float $amount = null) + public function cancelAuthorizationAmount(float $amount = null): ?Cancellation { return $this->getHeidelpayObject()->cancelPaymentAuthorization($this, $amount); } @@ -799,7 +810,7 @@ public function ship($invoiceId = null, $orderId = null) * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - private function updateResponseTransactions(array $transactions = []) + private function updateResponseTransactions(array $transactions = []): void { if (empty($transactions)) { return; @@ -840,7 +851,7 @@ private function updateResponseTransactions(array $transactions = []) * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - private function updateResponseResources($resources) + private function updateResponseResources($resources): void { if (isset($resources->paymentId)) { $this->setId($resources->paymentId); @@ -882,7 +893,7 @@ private function updateResponseResources($resources) * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - private function updateAuthorizationTransaction($transaction) + private function updateAuthorizationTransaction($transaction): void { $transactionId = IdService::getResourceIdFromUrl($transaction->url, IdStrings::AUTHORIZE); $authorization = $this->getAuthorization(true); @@ -902,7 +913,7 @@ private function updateAuthorizationTransaction($transaction) * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - private function updateChargeTransaction($transaction) + private function updateChargeTransaction($transaction): void { $transactionId = IdService::getResourceIdFromUrl($transaction->url, IdStrings::CHARGE); $charge = $this->getCharge($transactionId, true); @@ -922,7 +933,7 @@ private function updateChargeTransaction($transaction) * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - private function updateReversalTransaction($transaction) + private function updateReversalTransaction($transaction): void { $transactionId = IdService::getResourceIdFromUrl($transaction->url, IdStrings::CANCEL); $authorization = $this->getAuthorization(true); @@ -947,7 +958,7 @@ private function updateReversalTransaction($transaction) * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - private function updateRefundTransaction($transaction) + private function updateRefundTransaction($transaction): void { $refundId = IdService::getResourceIdFromUrl($transaction->url, IdStrings::CANCEL); $chargeId = IdService::getResourceIdFromUrl($transaction->url, IdStrings::CHARGE); @@ -974,7 +985,7 @@ private function updateRefundTransaction($transaction) * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - private function updateShipmentTransaction($transaction) + private function updateShipmentTransaction($transaction): void { $shipmentId = IdService::getResourceIdFromUrl($transaction->url, IdStrings::SHIPMENT); $shipment = $this->getShipment($shipmentId, true); @@ -994,7 +1005,7 @@ private function updateShipmentTransaction($transaction) * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - private function updatePayoutTransaction($transaction) + private function updatePayoutTransaction($transaction): void { $payoutId = IdService::getResourceIdFromUrl($transaction->url, IdStrings::PAYOUT); $payout = $this->getPayout(true); diff --git a/src/Resources/PaymentTypes/BasePaymentType.php b/src/Resources/PaymentTypes/BasePaymentType.php index a5ecec47..58ad8be3 100755 --- a/src/Resources/PaymentTypes/BasePaymentType.php +++ b/src/Resources/PaymentTypes/BasePaymentType.php @@ -30,6 +30,10 @@ abstract class BasePaymentType extends AbstractHeidelpayResource { /** * Return true for invoice types. + * This enables you to handle the invoice workflow correctly. + * Special to these payment types is that the initial charge transaction never changes from pending to success. + * And that shipment is done before payment is complete. + * Pending state of initial transaction can be viewed as successful and can be handled as such. * * @return bool */ diff --git a/src/Resources/PaymentTypes/Card.php b/src/Resources/PaymentTypes/Card.php index 5710b97f..dd98cebb 100755 --- a/src/Resources/PaymentTypes/Card.php +++ b/src/Resources/PaymentTypes/Card.php @@ -102,7 +102,7 @@ public function setNumber($pan): Card /** * @return string|null */ - public function getExpiryDate() + public function getExpiryDate(): ?string { return $this->expiryDate; } @@ -133,7 +133,7 @@ public function setExpiryDate($expiryDate): Card /** * @return string|null */ - public function getCvc() + public function getCvc(): ?string { return $this->cvc; } @@ -152,7 +152,7 @@ public function setCvc($cvc): Card /** * @return string|null */ - public function getCardHolder() + public function getCardHolder(): ?string { return $this->cardHolder; } @@ -173,7 +173,7 @@ public function setCardHolder($cardHolder): Card * * @deprecated since 1.2.7.2 */ - public function getHolder() + public function getHolder(): ?string { return $this->getCardHolder(); } @@ -193,7 +193,7 @@ public function setHolder($cardHolder): Card /** * @return bool|null */ - public function get3ds() + public function get3ds(): ?bool { return $this->card3ds; } @@ -234,7 +234,7 @@ protected function setBrand(string $brand): Card /** * @return CardDetails|null */ - public function getCardDetails() + public function getCardDetails(): ?CardDetails { return $this->cardDetails; } @@ -261,7 +261,7 @@ public function expose() /** * {@inheritDoc} */ - public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET) + public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET): void { parent::handleResponse($response, $method); diff --git a/src/Resources/PaymentTypes/EPS.php b/src/Resources/PaymentTypes/EPS.php index 9a7fc411..035d7988 100755 --- a/src/Resources/PaymentTypes/EPS.php +++ b/src/Resources/PaymentTypes/EPS.php @@ -38,7 +38,7 @@ class EPS extends BasePaymentType /** * @return string|null */ - public function getBic() + public function getBic(): ?string { return $this->bic; } diff --git a/src/Resources/PaymentTypes/HirePurchaseDirectDebit.php b/src/Resources/PaymentTypes/HirePurchaseDirectDebit.php index bb462909..65818262 100755 --- a/src/Resources/PaymentTypes/HirePurchaseDirectDebit.php +++ b/src/Resources/PaymentTypes/HirePurchaseDirectDebit.php @@ -80,7 +80,7 @@ public function selectInstalmentPlan($plan): self /** * @return string|null */ - public function getIban() + public function getIban(): ?string { return $this->iban; } @@ -99,7 +99,7 @@ public function setIban($iban): self /** * @return string|null */ - public function getBic() + public function getBic(): ?string { return $this->bic; } @@ -118,7 +118,7 @@ public function setBic($bic): self /** * @return string|null */ - public function getAccountHolder() + public function getAccountHolder(): ?string { return $this->accountHolder; } diff --git a/src/Resources/PaymentTypes/Ideal.php b/src/Resources/PaymentTypes/Ideal.php index 14838f56..f916482b 100755 --- a/src/Resources/PaymentTypes/Ideal.php +++ b/src/Resources/PaymentTypes/Ideal.php @@ -38,7 +38,7 @@ class Ideal extends BasePaymentType /** * @return string|null */ - public function getBic() + public function getBic(): ?string { return $this->bic; } diff --git a/src/Resources/PaymentTypes/Paypage.php b/src/Resources/PaymentTypes/Paypage.php index b728d887..1de955c4 100644 --- a/src/Resources/PaymentTypes/Paypage.php +++ b/src/Resources/PaymentTypes/Paypage.php @@ -99,6 +99,9 @@ class Paypage extends BasePaymentType /** @var bool $card3ds */ protected $card3ds; + /** @var array|null $css */ + protected $css; + /** * Paypage constructor. * @@ -175,7 +178,7 @@ public function setReturnUrl(string $returnUrl): Paypage /** * @return string|null */ - public function getLogoImage() + public function getLogoImage(): ?string { return $this->logoImage; } @@ -194,7 +197,7 @@ public function setLogoImage($logoImage): Paypage /** * @return string|null */ - public function getFullPageImage() + public function getFullPageImage(): ?string { return $this->fullPageImage; } @@ -213,7 +216,7 @@ public function setFullPageImage($fullPageImage): Paypage /** * @return string|null */ - public function getShopName() + public function getShopName(): ?string { return $this->shopName; } @@ -232,7 +235,7 @@ public function setShopName($shopName): Paypage /** * @return string|null */ - public function getShopDescription() + public function getShopDescription(): ?string { return $this->shopDescription; } @@ -251,7 +254,7 @@ public function setShopDescription($shopDescription): Paypage /** * @return string|null */ - public function getTagline() + public function getTagline(): ?string { return $this->tagline; } @@ -270,7 +273,7 @@ public function setTagline($tagline): Paypage /** * @return string|null */ - public function getTermsAndConditionUrl() + public function getTermsAndConditionUrl(): ?string { return $this->termsAndConditionUrl; } @@ -289,7 +292,7 @@ public function setTermsAndConditionUrl($termsAndConditionUrl): Paypage /** * @return string|null */ - public function getPrivacyPolicyUrl() + public function getPrivacyPolicyUrl(): ?string { return $this->privacyPolicyUrl; } @@ -308,7 +311,7 @@ public function setPrivacyPolicyUrl($privacyPolicyUrl): Paypage /** * @return string|null */ - public function getImprintUrl() + public function getImprintUrl(): ?string { return $this->imprintUrl; } @@ -327,7 +330,7 @@ public function setImprintUrl($imprintUrl): Paypage /** * @return string|null */ - public function getHelpUrl() + public function getHelpUrl(): ?string { return $this->helpUrl; } @@ -346,7 +349,7 @@ public function setHelpUrl($helpUrl): Paypage /** * @return string|null */ - public function getContactUrl() + public function getContactUrl(): ?string { return $this->contactUrl; } @@ -387,7 +390,7 @@ public function setAction(String $action): Paypage /** * @return Payment|null */ - public function getPayment() + public function getPayment(): ?Payment { return $this->payment; } @@ -406,7 +409,7 @@ public function setPayment(Payment $payment): Paypage /** * @return Basket|null */ - public function getBasket() + public function getBasket(): ?Basket { if (!$this->payment instanceof Payment) { return null; @@ -417,7 +420,7 @@ public function getBasket() /** * @return Customer|null */ - public function getCustomer() + public function getCustomer(): ?Customer { if (!$this->payment instanceof Payment) { return null; @@ -428,7 +431,7 @@ public function getCustomer() /** * @return Metadata|null */ - public function getMetadata() + public function getMetadata(): ?Metadata { if (!$this->payment instanceof Payment) { return null; @@ -439,7 +442,7 @@ public function getMetadata() /** * @return string|null */ - public function getRedirectUrl() + public function getRedirectUrl(): ?string { $payment = $this->getPayment(); if ($payment instanceof Payment) { @@ -470,7 +473,7 @@ public function setRedirectUrl(string $redirectUrl): Paypage * * @return null|string The Id of the payment object or null if nothing is found. */ - public function getPaymentId() + public function getPaymentId(): ?string { if ($this->payment instanceof Payment) { return $this->payment->getId(); @@ -520,7 +523,7 @@ public function addExcludeType(string $excludeType): Paypage /** * @return bool|null */ - public function isCard3ds() + public function isCard3ds(): ?bool { return $this->card3ds; } @@ -536,6 +539,25 @@ public function setCard3ds($card3ds): Paypage return $this; } + /** + * @return array|null + */ + public function getCss(): ?array + { + return $this->css; + } + + /** + * @param array|null $styles + * + * @return Paypage + */ + public function setCss($styles): Paypage + { + $this->css = empty($styles) ? null : $styles; + return $this; + } + /** * @param float|null $effectiveInterestRate * @@ -550,7 +572,7 @@ public function setEffectiveInterestRate(float $effectiveInterestRate): Paypage /** * @return float|null */ - public function getEffectiveInterestRate() + public function getEffectiveInterestRate(): ?float { return $this->getAdditionalAttribute('effectiveInterestRate'); } @@ -584,7 +606,7 @@ protected function getResourcePath(): string * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET) + public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET): void { if (isset($response->impressumUrl)) { $response->imprintUrl = $response->impressumUrl; @@ -641,7 +663,7 @@ public function getLinkedResources(): array * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - private function fetchPayment() + private function fetchPayment(): void { $payment = $this->getPayment(); if ($payment instanceof AbstractHeidelpayResource) { diff --git a/src/Resources/PaymentTypes/Paypal.php b/src/Resources/PaymentTypes/Paypal.php index aac16aba..b2d6a300 100755 --- a/src/Resources/PaymentTypes/Paypal.php +++ b/src/Resources/PaymentTypes/Paypal.php @@ -42,7 +42,7 @@ class Paypal extends BasePaymentType /** * @return string|null */ - public function getEmail() + public function getEmail(): ?string { return $this->email; } diff --git a/src/Resources/PaymentTypes/SepaDirectDebit.php b/src/Resources/PaymentTypes/SepaDirectDebit.php index 33b40783..218b99f9 100755 --- a/src/Resources/PaymentTypes/SepaDirectDebit.php +++ b/src/Resources/PaymentTypes/SepaDirectDebit.php @@ -56,7 +56,7 @@ public function __construct($iban) /** * @return string|null */ - public function getIban() + public function getIban(): ?string { return $this->iban; } @@ -75,7 +75,7 @@ public function setIban($iban): self /** * @return string|null */ - public function getBic() + public function getBic(): ?string { return $this->bic; } @@ -94,7 +94,7 @@ public function setBic($bic): self /** * @return string|null */ - public function getHolder() + public function getHolder(): ?string { return $this->holder; } diff --git a/src/Resources/PaymentTypes/SepaDirectDebitGuaranteed.php b/src/Resources/PaymentTypes/SepaDirectDebitGuaranteed.php index 5d99819d..3ae5b82f 100755 --- a/src/Resources/PaymentTypes/SepaDirectDebitGuaranteed.php +++ b/src/Resources/PaymentTypes/SepaDirectDebitGuaranteed.php @@ -56,7 +56,7 @@ public function __construct($iban) /** * @return string|null */ - public function getIban() + public function getIban(): ?string { return $this->iban; } @@ -75,7 +75,7 @@ public function setIban($iban): self /** * @return string|null */ - public function getBic() + public function getBic(): ?string { return $this->bic; } @@ -94,7 +94,7 @@ public function setBic($bic): self /** * @return string|null */ - public function getHolder() + public function getHolder(): ?string { return $this->holder; } diff --git a/src/Resources/Recurring.php b/src/Resources/Recurring.php index 413db441..94a3d1a5 100644 --- a/src/Resources/Recurring.php +++ b/src/Resources/Recurring.php @@ -98,7 +98,7 @@ public function setPaymentTypeId(string $paymentTypeId): Recurring /** * @return string|null */ - public function getRedirectUrl() + public function getRedirectUrl(): ?string { return $this->redirectUrl; } diff --git a/src/Resources/TransactionTypes/AbstractTransactionType.php b/src/Resources/TransactionTypes/AbstractTransactionType.php index 9112e277..edc27eca 100755 --- a/src/Resources/TransactionTypes/AbstractTransactionType.php +++ b/src/Resources/TransactionTypes/AbstractTransactionType.php @@ -61,7 +61,7 @@ abstract class AbstractTransactionType extends AbstractHeidelpayResource * * @return Payment|null */ - public function getPayment() + public function getPayment(): ?Payment { return $this->payment; } @@ -85,7 +85,7 @@ public function setPayment($payment): self * * @return null|string The Id of the payment object or null if nothing is found. */ - public function getPaymentId() + public function getPaymentId(): ?string { if ($this->payment instanceof Payment) { return $this->payment->getId(); @@ -99,7 +99,7 @@ public function getPaymentId() * * @return string|null */ - public function getRedirectUrl() + public function getRedirectUrl(): ?string { return $this->payment->getRedirectUrl(); } @@ -114,7 +114,7 @@ public function getRedirectUrl() * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET) + public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET): void { parent::handleResponse($response, $method); @@ -164,7 +164,7 @@ public function getLinkedResources(): array * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function fetchPayment() + public function fetchPayment(): void { $payment = $this->getPayment(); if ($payment instanceof AbstractHeidelpayResource) { diff --git a/src/Resources/TransactionTypes/Authorization.php b/src/Resources/TransactionTypes/Authorization.php index a4519630..ec2362de 100755 --- a/src/Resources/TransactionTypes/Authorization.php +++ b/src/Resources/TransactionTypes/Authorization.php @@ -78,7 +78,7 @@ public function __construct($amount = null, $currency = null, $returnUrl = null) /** * @return float|null */ - public function getAmount() + public function getAmount(): ?float { return $this->amount; } @@ -97,7 +97,7 @@ public function setAmount($amount): self /** * @return float|null */ - public function getCancelledAmount() + public function getCancelledAmount(): ?float { $amount = 0.0; foreach ($this->getCancellations() as $cancellation) { @@ -111,7 +111,7 @@ public function getCancelledAmount() /** * @return string|null */ - public function getCurrency() + public function getCurrency(): ?string { return $this->currency; } @@ -130,7 +130,7 @@ public function setCurrency($currency): self /** * @return string|null */ - public function getReturnUrl() + public function getReturnUrl(): ?string { return $this->returnUrl; } @@ -149,7 +149,7 @@ public function setReturnUrl($returnUrl): self /** * @return bool|null */ - public function isCard3ds() + public function isCard3ds(): ?bool { return $this->card3ds; } @@ -168,7 +168,7 @@ public function setCard3ds($card3ds): Authorization /** * @return string|null */ - public function getPaymentReference() + public function getPaymentReference(): ?string { return $this->paymentReference; } @@ -187,7 +187,7 @@ public function setPaymentReference($paymentReference): Authorization /** * @return string|null */ - public function getExternalOrderId() + public function getExternalOrderId(): ?string { return $this->externalOrderId; } @@ -208,7 +208,7 @@ protected function setExternalOrderId($externalOrderId): Authorization * * @return string|null */ - public function getZgReferenceId() + public function getZgReferenceId(): ?string { return $this->zgReferenceId; } @@ -229,7 +229,7 @@ protected function setZgReferenceId($zgReferenceId): Authorization /** * @return string|null */ - public function getPDFLink() + public function getPDFLink(): ?string { return $this->PDFLink; } diff --git a/src/Resources/TransactionTypes/Cancellation.php b/src/Resources/TransactionTypes/Cancellation.php index 790da78a..7da843e5 100755 --- a/src/Resources/TransactionTypes/Cancellation.php +++ b/src/Resources/TransactionTypes/Cancellation.php @@ -75,7 +75,7 @@ public function __construct($amount = null) * * @return float|null */ - public function getAmount() + public function getAmount(): ?float { return $this->amount; } @@ -98,7 +98,7 @@ public function setAmount($amount): Cancellation * * @return string|null */ - public function getReasonCode() + public function getReasonCode(): ?string { return $this->reasonCode; } @@ -121,7 +121,7 @@ public function setReasonCode($reasonCode): Cancellation /** * @return string|null */ - public function getPaymentReference() + public function getPaymentReference(): ?string { return $this->paymentReference; } @@ -143,7 +143,7 @@ public function setPaymentReference($paymentReference): Cancellation * * @return float|null */ - public function getAmountNet() + public function getAmountNet(): ?float { return $this->amountNet; } @@ -168,7 +168,7 @@ public function setAmountNet($amountNet): Cancellation * * @return float|null */ - public function getAmountVat() + public function getAmountVat(): ?float { return $this->amountVat; } diff --git a/src/Resources/TransactionTypes/Charge.php b/src/Resources/TransactionTypes/Charge.php index 3bd2ff06..ebf74d68 100755 --- a/src/Resources/TransactionTypes/Charge.php +++ b/src/Resources/TransactionTypes/Charge.php @@ -80,7 +80,7 @@ public function __construct($amount = null, $currency = null, $returnUrl = null) /** * @return float|null */ - public function getAmount() + public function getAmount(): ?float { return $this->amount; } @@ -99,7 +99,7 @@ public function setAmount($amount): self /** * @return float|null */ - public function getCancelledAmount() + public function getCancelledAmount(): ?float { $amount = 0.0; foreach ($this->getCancellations() as $cancellation) { @@ -113,7 +113,7 @@ public function getCancelledAmount() /** * @return float|null */ - public function getTotalAmount() + public function getTotalAmount(): ?float { return $this->getAmount() - $this->getCancelledAmount(); } @@ -121,7 +121,7 @@ public function getTotalAmount() /** * @return string|null */ - public function getCurrency() + public function getCurrency(): ?string { return $this->currency; } @@ -140,7 +140,7 @@ public function setCurrency($currency): self /** * @return string|null */ - public function getReturnUrl() + public function getReturnUrl(): ?string { return $this->returnUrl; } @@ -162,7 +162,7 @@ public function setReturnUrl($returnUrl): self * * @return string|null */ - public function getIban() + public function getIban(): ?string { return $this->iban; } @@ -184,7 +184,7 @@ protected function setIban(string $iban): self * * @return string|null */ - public function getBic() + public function getBic(): ?string { return $this->bic; } @@ -206,7 +206,7 @@ protected function setBic(string $bic): self * * @return string|null */ - public function getHolder() + public function getHolder(): ?string { return $this->holder; } @@ -228,7 +228,7 @@ protected function setHolder(string $holder): self * * @return string|null */ - public function getDescriptor() + public function getDescriptor(): ?string { return $this->descriptor; } @@ -247,7 +247,7 @@ protected function setDescriptor(string $descriptor): self /** * @return string|null */ - public function getPaymentReference() + public function getPaymentReference(): ?string { return $this->paymentReference; } @@ -266,7 +266,7 @@ public function setPaymentReference($referenceText): Charge /** * @return bool|null */ - public function isCard3ds() + public function isCard3ds(): ?bool { return $this->card3ds; } diff --git a/src/Resources/TransactionTypes/Payout.php b/src/Resources/TransactionTypes/Payout.php index ab4820d4..d09bc473 100644 --- a/src/Resources/TransactionTypes/Payout.php +++ b/src/Resources/TransactionTypes/Payout.php @@ -61,7 +61,7 @@ public function __construct($amount = null, $currency = null, $returnUrl = null) /** * @return float|null */ - public function getAmount() + public function getAmount(): ?float { return $this->amount; } @@ -80,7 +80,7 @@ public function setAmount($amount): self /** * @return string|null */ - public function getCurrency() + public function getCurrency(): ?string { return $this->currency; } @@ -99,7 +99,7 @@ public function setCurrency($currency): self /** * @return string|null */ - public function getReturnUrl() + public function getReturnUrl(): ?string { return $this->returnUrl; } @@ -118,7 +118,7 @@ public function setReturnUrl($returnUrl): Payout /** * @return string|null */ - public function getPaymentReference() + public function getPaymentReference(): ?string { return $this->paymentReference; } diff --git a/src/Resources/TransactionTypes/Shipment.php b/src/Resources/TransactionTypes/Shipment.php index d9d4d195..73b15dbd 100755 --- a/src/Resources/TransactionTypes/Shipment.php +++ b/src/Resources/TransactionTypes/Shipment.php @@ -38,7 +38,7 @@ class Shipment extends AbstractTransactionType /** * @return float|null */ - public function getAmount() + public function getAmount(): ?float { return $this->amount; } diff --git a/src/Resources/Webhook.php b/src/Resources/Webhook.php index 320814c0..e994aa68 100755 --- a/src/Resources/Webhook.php +++ b/src/Resources/Webhook.php @@ -49,7 +49,7 @@ public function __construct(string $url = '', string $event = '') /** * @return string|null */ - public function getUrl() + public function getUrl(): ?string { return $this->url; } @@ -68,7 +68,7 @@ public function setUrl(string $url): Webhook /** * @return string|null */ - public function getEvent() + public function getEvent(): ?string { return $this->event; } diff --git a/src/Resources/Webhooks.php b/src/Resources/Webhooks.php index 336163ae..b119df4f 100755 --- a/src/Resources/Webhooks.php +++ b/src/Resources/Webhooks.php @@ -113,7 +113,7 @@ public function getWebhookList(): array * * @throws RuntimeException */ - public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET) + public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET): void { parent::handleResponse($response, $method); @@ -135,7 +135,7 @@ public function handleResponse(stdClass $response, $method = HttpAdapterInterfac * * @throws RuntimeException */ - private function handleRegisteredWebhooks(array $responseArray = []) + private function handleRegisteredWebhooks(array $responseArray = []): void { $registeredWebhooks = []; diff --git a/src/Services/CancelService.php b/src/Services/CancelService.php index 3e6c2bf2..b3e9249f 100644 --- a/src/Services/CancelService.php +++ b/src/Services/CancelService.php @@ -35,6 +35,7 @@ use heidelpayPHP\Resources\TransactionTypes\Charge; use RuntimeException; use function in_array; +use function is_string; class CancelService implements CancelServiceInterface { @@ -209,7 +210,7 @@ public function cancelPayment( /** * {@inheritDoc} */ - public function cancelPaymentAuthorization($payment, float $amount = null) + public function cancelPaymentAuthorization($payment, float $amount = null): ?Cancellation { $cancellation = null; $completeCancel = $amount === null; @@ -300,7 +301,7 @@ public function cancelPaymentCharges( * * @throws HeidelpayApiException */ - private function isExceptionAllowed(HeidelpayApiException $exception) + private function isExceptionAllowed(HeidelpayApiException $exception): void { $allowedErrors = [ ApiResponseCodes::API_ERROR_ALREADY_CANCELLED, @@ -323,7 +324,7 @@ private function isExceptionAllowed(HeidelpayApiException $exception) * * @return float|null */ - private function updateCancelAmount($remainingToCancel, float $amount) + private function updateCancelAmount($remainingToCancel, float $amount): ?float { $cancelWholePayment = $remainingToCancel === null; if (!$cancelWholePayment) { diff --git a/src/Services/EnvironmentService.php b/src/Services/EnvironmentService.php index 8cd265f9..871b8fff 100755 --- a/src/Services/EnvironmentService.php +++ b/src/Services/EnvironmentService.php @@ -25,23 +25,45 @@ namespace heidelpayPHP\Services; use function in_array; +use function is_bool; class EnvironmentService { - const ENV_VAR_NAME_ENVIRONMENT = 'HEIDELPAY_MGW_ENV'; - const ENV_VAR_VALUE_STAGING_ENVIRONMENT = 'STG'; - const ENV_VAR_VALUE_DEVELOPMENT_ENVIRONMENT = 'DEV'; - const ENV_VAR_VALUE_PROD_ENVIRONMENT = 'PROD'; + private const ENV_VAR_NAME_ENVIRONMENT = 'HEIDELPAY_MGW_ENV'; + public const ENV_VAR_VALUE_STAGING_ENVIRONMENT = 'STG'; + public const ENV_VAR_VALUE_DEVELOPMENT_ENVIRONMENT = 'DEV'; + public const ENV_VAR_VALUE_PROD_ENVIRONMENT = 'PROD'; - const ENV_VAR_NAME_DISABLE_TEST_LOGGING = 'HEIDELPAY_MGW_DISABLE_TEST_LOGGING'; + /** @deprecated ENV_VAR_NAME_DISABLE_TEST_LOGGING since 1.2.7.3 replaced by ENV_VAR_NAME_VERBOSE_TEST_LOGGING */ + public const ENV_VAR_NAME_DISABLE_TEST_LOGGING = 'HEIDELPAY_MGW_DISABLE_TEST_LOGGING'; + public const ENV_VAR_NAME_VERBOSE_TEST_LOGGING = 'HEIDELPAY_MGW_VERBOSE_TEST_LOGGING'; - const ENV_VAR_TEST_PRIVATE_KEY = 'HEIDELPAY_MGW_TEST_PRIVATE_KEY'; - const ENV_VAR_TEST_PUBLIC_KEY = 'HEIDELPAY_MGW_TEST_PUBLIC_KEY'; - const DEFAULT_TEST_PRIVATE_KEY = 's-priv-2a102ZMq3gV4I3zJ888J7RR6u75oqK3n'; - const DEFAULT_TEST_PUBLIC_KEY = 's-pub-2a10ifVINFAjpQJ9qW8jBe5OJPBx6Gxa'; + public const ENV_VAR_TEST_PRIVATE_KEY = 'HEIDELPAY_MGW_TEST_PRIVATE_KEY'; + public const ENV_VAR_TEST_PUBLIC_KEY = 'HEIDELPAY_MGW_TEST_PUBLIC_KEY'; + public const ENV_VAR_TEST_PRIVATE_KEY_NON_3DS = 'HEIDELPAY_MGW_TEST_PRIVATE_KEY_NON_3DS'; + public const ENV_VAR_TEST_PUBLIC_KEY_NON_3DS = 'HEIDELPAY_MGW_TEST_PUBLIC_KEY_NON_3DS'; - const ENV_VAR_NAME_TIMEOUT = 'HEIDELPAY_MGW_TIMEOUT'; - const ENV_VAR_DEFAULT_TIMEOUT = 60; + private const ENV_VAR_NAME_TIMEOUT = 'HEIDELPAY_MGW_TIMEOUT'; + private const DEFAULT_TIMEOUT = 60; + + private const ENV_VAR_NAME_CURL_VERBOSE = 'HEIDELPAY_MGW_CURL_VERBOSE'; + + /** + * Returns the value of the given env var as bool. + * + * @param string $varName + * + * @return bool + */ + protected static function getBoolEnvValue(string $varName): bool + { + /** @noinspection ProperNullCoalescingOperatorUsageInspection */ + $envVar = $_SERVER[$varName] ?? false; + if (!is_bool($envVar)) { + $envVar = in_array(strtolower(stripslashes($envVar)), [true, 'true', '1'], true); + } + return $envVar; + } /** * Returns the MGW environment set via environment variable or PROD es default. @@ -50,7 +72,7 @@ class EnvironmentService */ public function getMgwEnvironment(): string { - return $_SERVER[self::ENV_VAR_NAME_ENVIRONMENT] ?? self::ENV_VAR_VALUE_PROD_ENVIRONMENT; + return stripslashes($_SERVER[self::ENV_VAR_NAME_ENVIRONMENT] ?? self::ENV_VAR_VALUE_PROD_ENVIRONMENT); } /** @@ -60,8 +82,10 @@ public function getMgwEnvironment(): string */ public static function isTestLoggingActive(): bool { - $testLoggingDisabled = strtolower($_SERVER[self::ENV_VAR_NAME_DISABLE_TEST_LOGGING] ?? 'false'); - return in_array($testLoggingDisabled, ['false', '0'], true); + if (isset($_SERVER[self::ENV_VAR_NAME_VERBOSE_TEST_LOGGING])) { + return self::getBoolEnvValue(self::ENV_VAR_NAME_VERBOSE_TEST_LOGGING); + } + return !self::getBoolEnvValue(self::ENV_VAR_NAME_DISABLE_TEST_LOGGING); } /** @@ -72,37 +96,50 @@ public static function isTestLoggingActive(): bool */ public static function getTimeout(): int { - $timeout = $_SERVER[self::ENV_VAR_NAME_TIMEOUT] ?? ''; - return is_numeric($timeout) ? (int)$timeout : self::ENV_VAR_DEFAULT_TIMEOUT; + $timeout = stripslashes($_SERVER[self::ENV_VAR_NAME_TIMEOUT] ?? ''); + return is_numeric($timeout) ? (int)$timeout : self::DEFAULT_TIMEOUT; + } + + /** + * Returns the curl verbose flag. + * + * @return bool + */ + public static function isCurlVerbose(): bool + { + $curlVerbose = strtolower(stripslashes($_SERVER[self::ENV_VAR_NAME_CURL_VERBOSE] ?? 'false')); + return in_array($curlVerbose, ['true', '1'], true); } /** * Returns the private key string set via environment variable. - * Returns the default key if the environment variable is not set. + * Returns the non 3ds version of the key if the non3ds flag is set. + * Returns an empty string if the environment variable is not set. * * @param bool $non3ds * * @return string */ - public function getTestPrivateKey($non3ds = false): string + public static function getTestPrivateKey($non3ds = false): string { - $variableName = self::ENV_VAR_TEST_PRIVATE_KEY . ($non3ds ? '_NON_3DS' : ''); - $key = $_SERVER[$variableName] ?? ''; - return empty($key) && !$non3ds ? self::DEFAULT_TEST_PRIVATE_KEY : $key; + $variableName = $non3ds ? self::ENV_VAR_TEST_PRIVATE_KEY_NON_3DS : self::ENV_VAR_TEST_PRIVATE_KEY; + $key = stripslashes($_SERVER[$variableName] ?? ''); + return empty($key) ? '' : $key; } /** * Returns the public key string set via environment variable. - * Returns the default key if the environment variable is not set. + * Returns the non 3ds version of the key if the non3ds flag is set. + * Returns an empty string if the environment variable is not set. * * @param bool $non3ds * * @return string */ - public function getTestPublicKey($non3ds = false): string + public static function getTestPublicKey($non3ds = false): string { - $variableName = self::ENV_VAR_TEST_PUBLIC_KEY . ($non3ds ? '_NON_3DS' : ''); - $key = $_SERVER[$variableName] ?? ''; - return empty($key) && !$non3ds ? self::DEFAULT_TEST_PUBLIC_KEY : $key; + $variableName = $non3ds ? self::ENV_VAR_TEST_PUBLIC_KEY_NON_3DS : self::ENV_VAR_TEST_PUBLIC_KEY; + $key = stripslashes($_SERVER[$variableName] ?? ''); + return empty($key) ? '' : $key; } } diff --git a/src/Services/HttpService.php b/src/Services/HttpService.php index 49f69e33..6a6dffd5 100755 --- a/src/Services/HttpService.php +++ b/src/Services/HttpService.php @@ -35,8 +35,8 @@ class HttpService { - const URL_PART_STAGING_ENVIRONMENT = 'stg'; - const URL_PART_DEVELOPMENT_ENVIRONMENT = 'dev'; + private const URL_PART_STAGING_ENVIRONMENT = 'stg'; + private const URL_PART_DEVELOPMENT_ENVIRONMENT = 'dev'; /** @var HttpAdapterInterface $httpAdapter */ private $httpAdapter; @@ -149,7 +149,7 @@ public function send( * * @throws RuntimeException */ - private function initRequest($uri, $payload, $httpMethod, $httpHeaders) + private function initRequest($uri, $payload, $httpMethod, $httpHeaders): void { $httpAdapter = $this->getAdapter(); $httpAdapter->init($uri, $payload, $httpMethod); @@ -166,7 +166,7 @@ private function initRequest($uri, $payload, $httpMethod, $httpHeaders) * * @throws HeidelpayApiException */ - private function handleErrors($responseCode, $response) + private function handleErrors($responseCode, $response): void { if ($response === null) { throw new HeidelpayApiException('The Request returned a null response!'); @@ -212,7 +212,12 @@ public function debugLog( $httpMethod, string $url, $response - ) { + ): void { + // mask auth string + $authHeader = explode(' ', $headers['Authorization']); + $authHeader[1] = ValueService::maskValue($authHeader[1]); + $headers['Authorization'] = implode(' ', $authHeader); + $heidelpayObj->debugLog($httpMethod . ': ' . $url); $writingOperations = [HttpAdapterInterface::REQUEST_POST, HttpAdapterInterface::REQUEST_PUT]; $heidelpayObj->debugLog('Headers: ' . json_encode($headers, JSON_UNESCAPED_SLASHES)); diff --git a/src/Services/IdService.php b/src/Services/IdService.php index d626d6c7..0e27692a 100755 --- a/src/Services/IdService.php +++ b/src/Services/IdService.php @@ -65,11 +65,11 @@ public static function getResourceIdFromUrl($url, $idString, $onlyLast = false): * * @return string|null */ - public static function getResourceIdOrNullFromUrl($url, $idString, $onlyLast = false) + public static function getResourceIdOrNullFromUrl($url, $idString, $onlyLast = false): ?string { try { return self::getResourceIdFromUrl($url, $idString, $onlyLast); - } catch (RuntimeException $e) { + } /** @noinspection BadExceptionsProcessingInspection */ catch (RuntimeException $e) { return null; } } @@ -79,7 +79,7 @@ public static function getResourceIdOrNullFromUrl($url, $idString, $onlyLast = f * * @return string|null */ - public static function getLastResourceIdFromUrlString($url) + public static function getLastResourceIdFromUrlString($url): ?string { return self::getResourceIdOrNullFromUrl($url, '([a-z]{3}|p24)', true); } @@ -89,9 +89,8 @@ public static function getLastResourceIdFromUrlString($url) * * @return string|null */ - public static function getResourceTypeFromIdString($typeId) + public static function getResourceTypeFromIdString($typeId): ?string { - $paymentType = null; $typeIdString = null; $typeIdParts = []; diff --git a/src/Services/PaymentService.php b/src/Services/PaymentService.php index cfe82a28..f37afc28 100755 --- a/src/Services/PaymentService.php +++ b/src/Services/PaymentService.php @@ -291,8 +291,8 @@ public function fetchDirectDebitInstalmentPlans( DateTime $orderDate = null ): InstalmentPlans { $hdd = (new HirePurchaseDirectDebit(null, null, null))->setParentResource($this->heidelpay); - /** @var InstalmentPlans $plans */ $plans = (new InstalmentPlans($amount, $currency, $effectiveInterest, $orderDate))->setParentResource($hdd); + /** @var InstalmentPlans $plans */ $plans = $this->heidelpay->getResourceService()->fetchResource($plans); return $plans; } diff --git a/src/Services/ResourceService.php b/src/Services/ResourceService.php index 59ac3032..dc92b130 100755 --- a/src/Services/ResourceService.php +++ b/src/Services/ResourceService.php @@ -275,7 +275,7 @@ public function updateResource(AbstractHeidelpayResource $resource): AbstractHei * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function deleteResource(AbstractHeidelpayResource &$resource) + public function deleteResource(AbstractHeidelpayResource &$resource): ?AbstractHeidelpayResource { $response = $this->send($resource, HttpAdapterInterface::REQUEST_DELETE); @@ -299,6 +299,7 @@ public function deleteResource(AbstractHeidelpayResource &$resource) * * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. + * @throws Exception */ public function fetchResource(AbstractHeidelpayResource $resource): AbstractHeidelpayResource { @@ -418,7 +419,6 @@ public function fetchPaymentByOrderId($orderId): Payment */ public function fetchKeypair($detailed = false): Keypair { - /** @var Keypair $keyPair */ $keyPair = (new Keypair())->setParentResource($this->heidelpay)->setDetailed($detailed); $this->fetchResource($keyPair); return $keyPair; @@ -500,7 +500,6 @@ public function updateBasket(Basket $basket): Basket */ public function createPaymentType(BasePaymentType $paymentType): BasePaymentType { - /** @var AbstractHeidelpayResource $paymentType */ $paymentType->setParentResource($this->heidelpay); $this->createResource($paymentType); return $paymentType; @@ -658,7 +657,7 @@ public function updateCustomer(Customer $customer): Customer /** * {@inheritDoc} */ - public function deleteCustomer($customer) + public function deleteCustomer($customer): void { $customerObject = $customer; @@ -667,7 +666,6 @@ public function deleteCustomer($customer) } $this->deleteResource($customerObject); - return $customerObject; } // @@ -679,7 +677,6 @@ public function deleteCustomer($customer) */ public function fetchAuthorization($payment): Authorization { - /** @var Payment $paymentObject */ $paymentObject = $this->fetchPayment($payment); /** @var Authorization $authorize */ $authorize = $paymentObject->getAuthorization(true); @@ -706,7 +703,6 @@ public function fetchCharge(Charge $charge): Charge */ public function fetchChargeById($payment, $chargeId): Charge { - /** @var Payment $paymentObject */ $paymentObject = $this->fetchPayment($payment); $charge = $paymentObject->getCharge($chargeId, true); diff --git a/src/Services/ValueService.php b/src/Services/ValueService.php index a0c4c9ad..03266335 100644 --- a/src/Services/ValueService.php +++ b/src/Services/ValueService.php @@ -25,6 +25,7 @@ namespace heidelpayPHP\Services; use function is_float; +use function strlen; class ValueService { @@ -40,4 +41,17 @@ public static function limitFloats($value) } return $value; } + + /** + * Mask a value. + * + * @param $value + * @param string $maskSymbol + * + * @return string + */ + public static function maskValue($value, $maskSymbol = '*'): string + { + return substr($value, 0, 6) . str_repeat($maskSymbol, strlen($value) - 10) . substr($value, -4); + } } diff --git a/src/Services/WebhookService.php b/src/Services/WebhookService.php index e5c838c8..85ebb8cc 100755 --- a/src/Services/WebhookService.php +++ b/src/Services/WebhookService.php @@ -156,9 +156,9 @@ public function deleteWebhook($webhook) */ public function fetchAllWebhooks(): array { - /** @var Webhooks $webhooks */ $webhooks = new Webhooks(); $webhooks->setParentResource($this->heidelpay); + /** @var Webhooks $webhooks */ $webhooks = $this->resourceService->fetchResource($webhooks); return $webhooks->getWebhookList(); @@ -167,7 +167,7 @@ public function fetchAllWebhooks(): array /** * {@inheritDoc} */ - public function deleteAllWebhooks() + public function deleteAllWebhooks(): void { $webhooks = new Webhooks(); $webhooks->setParentResource($this->heidelpay); @@ -179,9 +179,9 @@ public function deleteAllWebhooks() */ public function registerMultipleWebhooks(string $url, array $events): array { - /** @var Webhooks $webhooks */ $webhooks = new Webhooks($url, $events); $webhooks->setParentResource($this->heidelpay); + /** @var Webhooks $webhooks */ $webhooks = $this->resourceService->createResource($webhooks); return $webhooks->getWebhookList(); diff --git a/src/Traits/HasCancellations.php b/src/Traits/HasCancellations.php index 852bff5e..7b941f73 100755 --- a/src/Traits/HasCancellations.php +++ b/src/Traits/HasCancellations.php @@ -81,7 +81,7 @@ public function addCancellation(Cancellation $cancellation): self * * @return Cancellation|null The cancellation or null if none could be found. */ - public function getCancellation($cancellationId, $lazy = false) + public function getCancellation($cancellationId, $lazy = false): ?Cancellation { /** @var Cancellation $cancellation */ foreach ($this->cancellations as $cancellation) { diff --git a/src/Traits/HasDate.php b/src/Traits/HasDate.php index 41d72790..876c767c 100644 --- a/src/Traits/HasDate.php +++ b/src/Traits/HasDate.php @@ -39,7 +39,7 @@ trait HasDate * * @return string|null */ - public function getDate() + public function getDate(): ?string { $date = $this->date; return $date ? $date->format('Y-m-d H:i:s') : null; diff --git a/src/Traits/HasInvoiceId.php b/src/Traits/HasInvoiceId.php index 5cc10a7a..350d9883 100755 --- a/src/Traits/HasInvoiceId.php +++ b/src/Traits/HasInvoiceId.php @@ -34,7 +34,7 @@ trait HasInvoiceId /** * @return string|null */ - public function getInvoiceId() + public function getInvoiceId(): ?string { return $this->invoiceId; } diff --git a/src/Traits/HasOrderId.php b/src/Traits/HasOrderId.php index c2d3d568..8ab47444 100755 --- a/src/Traits/HasOrderId.php +++ b/src/Traits/HasOrderId.php @@ -34,7 +34,7 @@ trait HasOrderId /** * @return string|null */ - public function getOrderId() + public function getOrderId(): ?string { return $this->orderId; } diff --git a/src/Traits/HasTraceId.php b/src/Traits/HasTraceId.php index 8f4c56c3..f6d5a5a3 100644 --- a/src/Traits/HasTraceId.php +++ b/src/Traits/HasTraceId.php @@ -35,7 +35,7 @@ trait HasTraceId /** * @return string|null */ - public function getTraceId() + public function getTraceId(): ?string { return $this->traceId; } diff --git a/src/Traits/HasUniqueAndShortId.php b/src/Traits/HasUniqueAndShortId.php index f7956b08..7a777acd 100644 --- a/src/Traits/HasUniqueAndShortId.php +++ b/src/Traits/HasUniqueAndShortId.php @@ -37,7 +37,7 @@ trait HasUniqueAndShortId /** * @return string|null */ - public function getUniqueId() + public function getUniqueId(): ?string { return $this->uniqueId; } @@ -56,7 +56,7 @@ protected function setUniqueId(string $uniqueId): self /** * @return string|null */ - public function getShortId() + public function getShortId(): ?string { return $this->shortId; } diff --git a/src/Traits/IsInvoiceType.php b/src/Traits/IsInvoiceType.php index 3d67a0cf..5307054f 100644 --- a/src/Traits/IsInvoiceType.php +++ b/src/Traits/IsInvoiceType.php @@ -28,6 +28,12 @@ trait IsInvoiceType { /** * Return true for invoice types. + * This enables you to handle the invoice workflow correctly. + * Special to these payment types is that the initial charge transaction never changes from pending to success. + * And that shipment is done before payment is complete. + * Pending state of initial transaction can be viewed as successful and can be handled as such. + * + * @return bool */ public function isInvoiceType(): bool { diff --git a/test/BaseIntegrationTest.php b/test/BaseIntegrationTest.php new file mode 100644 index 00000000..6506bb8a --- /dev/null +++ b/test/BaseIntegrationTest.php @@ -0,0 +1,60 @@ + + * + * @package heidelpayPHP\test\integration + */ +namespace heidelpayPHP\test; + +use heidelpayPHP\Services\EnvironmentService; +use PHPUnit\Runner\BaseTestRunner; + +class BaseIntegrationTest extends BasePaymentTest +{ + /** + * {@inheritDoc} + */ + protected function setUp(): void + { + $this->getHeidelpayObject(EnvironmentService::getTestPrivateKey()); + } + + /** + * If verbose test output is disabled echo debug log when test did not pass. + * + * {@inheritDoc} + */ + protected function tearDown(): void + { + /** @var TestDebugHandler $debugHandler */ + $debugHandler = $this->heidelpay->getDebugHandler(); + + if ($this->getStatus() === BaseTestRunner::STATUS_PASSED) { + $debugHandler->clearTempLog(); + } else { + echo "\n"; + $debugHandler->dumpTempLog(); + echo "\n"; + } + } +} diff --git a/test/BasePaymentTest.php b/test/BasePaymentTest.php index 6ec5f2d7..f51d6ce7 100755 --- a/test/BasePaymentTest.php +++ b/test/BasePaymentTest.php @@ -1,6 +1,8 @@ getTestPrivateKey(); - $this->heidelpay = (new Heidelpay($privateKey))->setDebugHandler(new TestDebugHandler())->setDebugMode(true); - $this->childSetup(); + if (!$this->heidelpay instanceof Heidelpay) { + $this->heidelpay = (new Heidelpay($privateKey)) + ->setDebugHandler(new TestDebugHandler()) + ->setDebugMode(true); + } + return $this->heidelpay; } /** - * Override this in the child test class to perform custom setup tasks e.g. setting a different Key. + * {@inheritDoc} */ - protected function childSetup() + protected function setUp(): void { - // do nothing here + $this->getHeidelpayObject(); } // @@ -81,12 +86,10 @@ protected function childSetup() * This performs assertions to verify the tested value is an empty array. * * @param mixed $value - * - * @throws Exception */ - public function assertIsEmptyArray($value) + public function assertIsEmptyArray($value): void { - $this->assertInternalType('array', $value); + $this->assertIsArray($value); $this->assertEmpty($value); } @@ -96,8 +99,6 @@ public function assertIsEmptyArray($value) * @param float $expectedCharged * @param float $expectedTotal * @param float $expectedCanceled - * - * @throws Exception */ protected function assertAmounts( $payment, @@ -105,7 +106,7 @@ protected function assertAmounts( $expectedCharged, $expectedTotal, $expectedCanceled - ) { + ): void { $amount = $payment->getAmount(); $this->assertEquals($expectedRemaining, $amount->getRemaining(), 'The remaining amount does not match.'); $this->assertEquals($expectedCharged, $amount->getCharged(), 'The charged amount does not match.'); @@ -115,10 +116,8 @@ protected function assertAmounts( /** * @param mixed $transactionType - * - * @throws AssertionFailedError */ - public function assertTransactionResourceHasBeenCreated($transactionType) + public function assertTransactionResourceHasBeenCreated($transactionType): void { $this->assertNotNull($transactionType); $this->assertNotEmpty($transactionType->getId()); @@ -130,10 +129,8 @@ public function assertTransactionResourceHasBeenCreated($transactionType) * Asserts whether the given transaction was successful. * * @param AbstractTransactionType|Recurring $transaction - * - * @throws AssertionFailedError */ - protected function assertSuccess($transaction) + protected function assertSuccess($transaction): void { $this->assertTrue($transaction->isSuccess()); $this->assertFalse($transaction->isPending()); @@ -144,10 +141,8 @@ protected function assertSuccess($transaction) * Asserts whether the given transaction was a failure. * * @param AbstractTransactionType|Recurring $transaction - * - * @throws AssertionFailedError */ - protected function assertError($transaction) + protected function assertError($transaction): void { $this->assertFalse($transaction->isSuccess()); $this->assertFalse($transaction->isPending()); @@ -158,10 +153,8 @@ protected function assertError($transaction) * Asserts whether the given transaction is pending. * * @param AbstractTransactionType|Recurring $transaction - * - * @throws AssertionFailedError */ - protected function assertPending($transaction) + protected function assertPending($transaction): void { $this->assertFalse($transaction->isSuccess()); $this->assertTrue($transaction->isPending()); @@ -176,9 +169,6 @@ protected function assertPending($transaction) * Creates a Basket resource and returns it. * * @return Basket - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ public function createBasket(): Basket { @@ -196,28 +186,12 @@ public function createBasket(): Basket return $basket; } - /** - * Mask a credit card number. - * - * @param $number - * @param string $maskSymbol - * - * @return string - */ - protected function maskNumber($number, $maskSymbol = '*'): string - { - return substr($number, 0, 6) . str_repeat($maskSymbol, strlen($number) - 10) . substr($number, -4); - } - /** * Creates a Card object for tests. * * @param string $cardNumber * * @return Card - * - * @throws RuntimeException - * @throws \Exception */ protected function createCardObject(string $cardNumber = '5453010000059543'): Card { @@ -233,9 +207,6 @@ protected function createCardObject(string $cardNumber = '5453010000059543'): Ca * @param float $amount * * @return Authorization - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ public function createCardAuthorization($amount = 100.0): Authorization { @@ -248,9 +219,6 @@ public function createCardAuthorization($amount = 100.0): Authorization * Creates and returns an Authorization object with the API which can be used in test methods. * * @return Authorization - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ public function createPaypalAuthorization(): Authorization { @@ -266,9 +234,6 @@ public function createPaypalAuthorization(): Authorization * @param float $amount * * @return Charge - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ public function createCharge($amount = 100.0): Charge { @@ -290,8 +255,6 @@ public static function generateRandomId(): string * Returns the current date as string in the format Y-m-d. * * @return string - * - * @throws \Exception */ public function getTodaysDateString(): string { @@ -300,8 +263,6 @@ public function getTodaysDateString(): string /** * @return DateTime - * - * @throws \Exception */ public function getYesterdaysTimestamp(): DateTime { @@ -310,8 +271,6 @@ public function getYesterdaysTimestamp(): DateTime /** * @return DateTime - * - * @throws \Exception */ public function getTomorrowsTimestamp(): DateTime { @@ -320,8 +279,6 @@ public function getTomorrowsTimestamp(): DateTime /** * @return DateTime - * - * @throws \Exception */ public function getNextYearsTimestamp(): DateTime { diff --git a/test/Fixtures/CustomerFixtureTrait.php b/test/Fixtures/CustomerFixtureTrait.php index a16ffaf9..6ea32a4a 100755 --- a/test/Fixtures/CustomerFixtureTrait.php +++ b/test/Fixtures/CustomerFixtureTrait.php @@ -1,4 +1,6 @@ tempLog .= $logMessage; } } + + /** + * Clears the temp log. + */ + public function clearTempLog(): void + { + $this->tempLog = ''; + } + + /** + * Echos the contents of tempLog and clears it afterwards. + */ + public function dumpTempLog(): void + { + echo $this->tempLog; + $this->clearTempLog(); + } } diff --git a/test/bootstrap.php b/test/bootstrap.php index b50370bf..26c8d1ff 100755 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -1,4 +1,6 @@ setNote('This basket is creatable!'); @@ -109,12 +102,8 @@ public function maxBasketShouldBeCreatableAndFetchableWorkAround() * @param $expectException * @param $imageUrl * @param null $exceptionCode - * - * @throws AssertionFailedError - * @throws Exception - * @throws RuntimeException */ - public function basketItemWithInvalidUrlWillThrowAnError($expectException, $imageUrl, $exceptionCode = null) + public function basketItemWithInvalidUrlWillThrowAnError($expectException, $imageUrl, $exceptionCode = null): void { $basket = new Basket('b' . self::generateRandomId(), 123.4, 'EUR', []); $basketItem = (new BasketItem('myItem', 1234, 2345, 12))->setImageUrl($imageUrl); @@ -137,11 +126,8 @@ public function basketItemWithInvalidUrlWillThrowAnError($expectException, $imag * Verify the Basket can be updated. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function basketShouldBeUpdateable() + public function basketShouldBeUpdateable(): void { $orderId = 'o'. self::generateRandomId(); $basket = new Basket($orderId, 123.4, 'EUR', []); @@ -169,11 +155,8 @@ public function basketShouldBeUpdateable() * Verify basket can be passed to the payment on authorize. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function authorizeTransactionsShouldPassAlongTheBasketIdIfSet() + public function authorizeTransactionsShouldPassAlongTheBasketIdIfSet(): void { $orderId = 'o'. self::generateRandomId(); $basket = new Basket($orderId, 123.4, 'EUR', []); @@ -195,11 +178,8 @@ public function authorizeTransactionsShouldPassAlongTheBasketIdIfSet() * Verify basket can be passed to the payment on charge. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargeTransactionsShouldPassAlongTheBasketIdIfSet() + public function chargeTransactionsShouldPassAlongTheBasketIdIfSet(): void { $basket = $this->createBasket(); $this->assertNotEmpty($basket->getId()); @@ -218,11 +198,8 @@ public function chargeTransactionsShouldPassAlongTheBasketIdIfSet() * Verify basket will be created and passed to the payment on authorize if it does not exist yet. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function authorizeTransactionsShouldCreateBasketIfItDoesNotExistYet() + public function authorizeTransactionsShouldCreateBasketIfItDoesNotExistYet(): void { $orderId = 'o'. self::generateRandomId(); $basket = new Basket($orderId, 123.4, 'EUR', []); @@ -244,11 +221,8 @@ public function authorizeTransactionsShouldCreateBasketIfItDoesNotExistYet() * Verify basket will be created and passed to the payment on charge if it does not exist yet. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargeTransactionsShouldCreateBasketIfItDoesNotExistYet() + public function chargeTransactionsShouldCreateBasketIfItDoesNotExistYet(): void { $orderId = 'o'. self::generateRandomId(); $basket = new Basket($orderId, 123.4, 'EUR', []); diff --git a/test/integration/CustomerTest.php b/test/integration/CustomerTest.php index 6a514d0a..77912a7c 100755 --- a/test/integration/CustomerTest.php +++ b/test/integration/CustomerTest.php @@ -1,4 +1,6 @@ @@ -45,9 +45,6 @@ class CustomerTest extends BasePaymentTest * @test * * @return Customer - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ public function minCustomerCanBeCreatedAndFetched(): Customer { @@ -78,9 +75,6 @@ public function minCustomerCanBeCreatedAndFetched(): Customer * @test * * @return Customer - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ public function maxCustomerCanBeCreatedAndFetched(): Customer { @@ -89,7 +83,6 @@ public function maxCustomerCanBeCreatedAndFetched(): Customer $this->heidelpay->createCustomer($customer); $this->assertNotEmpty($customer->getId()); - /** @var Customer $fetchedCustomer */ $fetchedCustomer = $this->heidelpay->fetchCustomer($customer->getId()); $this->assertEquals($customer->expose(), $fetchedCustomer->expose()); @@ -98,25 +91,20 @@ public function maxCustomerCanBeCreatedAndFetched(): Customer /** * @param Customer $customer - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. * @depends maxCustomerCanBeCreatedAndFetched * @test */ - public function customerCanBeFetchedById(Customer $customer) + public function customerCanBeFetchedById(Customer $customer): void { $fetchedCustomer = $this->heidelpay->fetchCustomer($customer->getId()); $this->assertEquals($customer->getId(), $fetchedCustomer->getId()); } /** - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. * @depends maxCustomerCanBeCreatedAndFetched * @test */ - public function customerCanBeFetchedByCustomerId() + public function customerCanBeFetchedByCustomerId(): void { $customerId = 'c' . self::generateRandomId(); $customer = $this->getMaximumCustomer()->setCustomerId($customerId); @@ -128,13 +116,10 @@ public function customerCanBeFetchedByCustomerId() /** * @param Customer $customer - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. * @depends maxCustomerCanBeCreatedAndFetched * @test */ - public function customerCanBeFetchedByObject(Customer $customer) + public function customerCanBeFetchedByObject(Customer $customer): void { $customerToFetch = (new Customer())->setId($customer->getId()); $fetchedCustomer = $this->heidelpay->fetchCustomer($customerToFetch); @@ -143,13 +128,10 @@ public function customerCanBeFetchedByObject(Customer $customer) /** * @param Customer $customer - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. * @depends maxCustomerCanBeCreatedAndFetched * @test */ - public function customerCanBeFetchedByObjectWithData(Customer $customer) + public function customerCanBeFetchedByObjectWithData(Customer $customer): void { $customerToFetch = $this->getMinimalCustomer()->setId($customer->getId()); $this->assertNotEquals($customer->getFirstname(), $customerToFetch->getFirstname()); @@ -162,11 +144,8 @@ public function customerCanBeFetchedByObjectWithData(Customer $customer) * Customer can be referenced by payment. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function transactionShouldCreateAndReferenceCustomerIfItDoesNotExistYet() + public function transactionShouldCreateAndReferenceCustomerIfItDoesNotExistYet(): void { $customerId = 'c' . self::generateRandomId(); $customer = $this->getMaximumCustomerInclShippingAddress()->setCustomerId($customerId); @@ -175,7 +154,6 @@ public function transactionShouldCreateAndReferenceCustomerIfItDoesNotExistYet() $paypal = $this->heidelpay->createPaymentType(new Paypal()); $authorization = $paypal->authorize(12.0, 'EUR', self::RETURN_URL, $customer); - /** @var Payment $secPayment */ $secPayment = $this->heidelpay->fetchPayment($authorization->getPayment()->getId()); /** @var Customer $secCustomer */ @@ -188,11 +166,8 @@ public function transactionShouldCreateAndReferenceCustomerIfItDoesNotExistYet() * Customer can be referenced by payment. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function transactionShouldReferenceCustomerIfItExist() + public function transactionShouldReferenceCustomerIfItExist(): void { $customer = $this->getMaximumCustomer(); $this->heidelpay->createCustomer($customer); @@ -201,7 +176,6 @@ public function transactionShouldReferenceCustomerIfItExist() $paypal = $this->heidelpay->createPaymentType(new Paypal()); $authorization = $paypal->authorize(12.0, 'EUR', self::RETURN_URL, $customer); - /** @var Payment $secPayment */ $secPayment = $this->heidelpay->fetchPayment($authorization->getPayment()->getId()); /** @var Customer $secCustomer */ @@ -214,11 +188,8 @@ public function transactionShouldReferenceCustomerIfItExist() * Customer can be referenced by payment. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function transactionShouldReferenceCustomerIfItExistAndItsIdHasBeenPassed() + public function transactionShouldReferenceCustomerIfItExistAndItsIdHasBeenPassed(): void { $customer = $this->getMaximumCustomer(); $this->heidelpay->createCustomer($customer); @@ -227,7 +198,6 @@ public function transactionShouldReferenceCustomerIfItExistAndItsIdHasBeenPassed $paypal = $this->heidelpay->createPaymentType(new Paypal()); $authorization = $paypal->authorize(12.0, 'EUR', self::RETURN_URL, $customer->getId()); - /** @var Payment $secPayment */ $secPayment = $this->heidelpay->fetchPayment($authorization->getPayment()->getId()); /** @var Customer $secCustomer */ @@ -243,18 +213,14 @@ public function transactionShouldReferenceCustomerIfItExistAndItsIdHasBeenPassed * @test * * @param Customer $customer - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function customerShouldBeUpdatable(Customer $customer) + public function customerShouldBeUpdateable(Customer $customer): void { - $this->assertEquals($customer->getFirstname(), 'Peter'); + $this->assertEquals('Peter', $customer->getFirstname()); $customer->setFirstname('Not Peter'); $this->heidelpay->updateCustomer($customer); - $this->assertEquals($customer->getFirstname(), 'Not Peter'); + $this->assertEquals('Not Peter', $customer->getFirstname()); - /** @var Customer $fetchedCustomer */ $fetchedCustomer = $this->heidelpay->fetchCustomer($customer->getId()); $this->assertEquals($customer->getId(), $fetchedCustomer->getId()); $this->assertEquals('Not Peter', $fetchedCustomer->getFirstname()); @@ -267,11 +233,8 @@ public function customerShouldBeUpdatable(Customer $customer) * @test * * @param Customer $customer - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function customerShouldBeDeletableById(Customer $customer) + public function customerShouldBeDeletableById(Customer $customer): void { $this->assertNotNull($customer); $this->assertNotNull($customer->getId()); @@ -287,11 +250,8 @@ public function customerShouldBeDeletableById(Customer $customer) * Customer can be deleted. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function customerShouldBeDeletableByObject() + public function customerShouldBeDeletableByObject(): void { $customer = $this->heidelpay->createCustomer($this->getMaximumCustomer()); @@ -310,11 +270,8 @@ public function customerShouldBeDeletableByObject() * Verify an Exception is thrown if the customerId already exists. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function apiShouldReturnErrorIfCustomerAlreadyExists() + public function apiShouldReturnErrorIfCustomerAlreadyExists(): void { $customerId = str_replace(' ', '', microtime()); @@ -333,11 +290,8 @@ public function apiShouldReturnErrorIfCustomerAlreadyExists() * Verify a Customer is fetched and updated when its customerId already exist. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function customerShouldBeFetchedByCustomerIdAndUpdatedIfItAlreadyExists() + public function customerShouldBeFetchedByCustomerIdAndUpdatedIfItAlreadyExists(): void { $customerId = str_replace(' ', '', microtime()); @@ -346,7 +300,7 @@ public function customerShouldBeFetchedByCustomerIdAndUpdatedIfItAlreadyExists() $this->heidelpay->fetchCustomerByExtCustomerId($customerId); $this->assertTrue(false, 'Exception should be thrown here.'); } catch (HeidelpayApiException $e) { - $this->assertEquals($e->getCode(), ApiResponseCodes::API_ERROR_CUSTOMER_CAN_NOT_BE_FOUND); + $this->assertEquals(ApiResponseCodes::API_ERROR_CUSTOMER_CAN_NOT_BE_FOUND, $e->getCode()); $this->assertNotNull($e->getErrorId()); } @@ -368,11 +322,8 @@ public function customerShouldBeFetchedByCustomerIdAndUpdatedIfItAlreadyExists() * Verify customer address can take a name as long as both first and lastname concatenated. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function addressNameCanHoldFirstAndLastNameConcatenated() + public function addressNameCanHoldFirstAndLastNameConcatenated(): void { $customerId = 'c' . self::generateRandomId(); $customer = $this->getMaximumCustomerInclShippingAddress()->setCustomerId($customerId); @@ -398,19 +349,14 @@ public function addressNameCanHoldFirstAndLastNameConcatenated() * @test * * @return Customer - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ public function minNotRegisteredB2bCustomerCanBeCreatedAndFetched(): Customer { - /** @var Customer $customer */ $customer = $this->getMinimalNotRegisteredB2bCustomer(); $this->assertEmpty($customer->getId()); $this->heidelpay->createCustomer($customer); $this->assertNotEmpty($customer->getId()); - /** @var Customer $fetchedCustomer */ $fetchedCustomer = $this->heidelpay->fetchCustomer($customer->getId()); $exposeArray = $customer->expose(); $exposeArray['salutation'] = Salutations::UNKNOWN; @@ -423,19 +369,14 @@ public function minNotRegisteredB2bCustomerCanBeCreatedAndFetched(): Customer * Max not registered customer should be creatable. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function maxNotRegisteredB2bCustomerCanBeCreatedAndFetched() + public function maxNotRegisteredB2bCustomerCanBeCreatedAndFetched(): void { - /** @var Customer $customer */ $customer = $this->getMaximalNotRegisteredB2bCustomer(); $this->assertEmpty($customer->getId()); $this->heidelpay->createCustomer($customer); $this->assertNotEmpty($customer->getId()); - /** @var Customer $fetchedCustomer */ $fetchedCustomer = $this->heidelpay->fetchCustomer($customer->getId()); $this->assertEquals($customer->expose(), $fetchedCustomer->expose()); } @@ -450,19 +391,14 @@ public function maxNotRegisteredB2bCustomerCanBeCreatedAndFetched() * @test * * @return Customer - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ public function minRegisteredB2bCustomerCanBeCreatedAndFetched(): Customer { - /** @var Customer $customer */ $customer = $this->getMinimalRegisteredB2bCustomer(); $this->assertEmpty($customer->getId()); $this->heidelpay->createCustomer($customer); $this->assertNotEmpty($customer->getId()); - /** @var Customer $fetchedCustomer */ $fetchedCustomer = $this->heidelpay->fetchCustomer($customer->getId()); $exposeArray = $customer->expose(); $exposeArray['salutation'] = Salutations::UNKNOWN; @@ -475,19 +411,14 @@ public function minRegisteredB2bCustomerCanBeCreatedAndFetched(): Customer * Max registered customer should be creatable. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function maxRegisteredB2bCustomerCanBeCreatedAndFetched() + public function maxRegisteredB2bCustomerCanBeCreatedAndFetched(): void { - /** @var Customer $customer */ $customer = $this->getMaximalRegisteredB2bCustomer(); $this->assertEmpty($customer->getId()); $this->heidelpay->createCustomer($customer); $this->assertNotEmpty($customer->getId()); - /** @var Customer $fetchedCustomer */ $fetchedCustomer = $this->heidelpay->fetchCustomer($customer->getId()); $this->assertEquals($customer->expose(), $fetchedCustomer->expose()); } diff --git a/test/integration/DummyResource.php b/test/integration/DummyResource.php index 1847674f..038cdbac 100644 --- a/test/integration/DummyResource.php +++ b/test/integration/DummyResource.php @@ -1,4 +1,6 @@ heidelpay->createPaymentType(new Giropay()); $firstClientMessage = ''; diff --git a/test/integration/KeypairTest.php b/test/integration/KeypairTest.php index dcbda170..1ef92ea6 100644 --- a/test/integration/KeypairTest.php +++ b/test/integration/KeypairTest.php @@ -1,4 +1,6 @@ assertEquals($key, $heidelpay->getKey()); @@ -54,10 +53,8 @@ public function validKeysShouldBeExcepted($key) * @dataProvider invalidKeysDataProvider * * @param string $key - * - * @throws RuntimeException */ - public function invalidKeysShouldResultInException($key) + public function invalidKeysShouldResultInException($key): void { $this->expectException(RuntimeException::class); new Heidelpay($key); @@ -67,11 +64,8 @@ public function invalidKeysShouldResultInException($key) * Verify key pair config can be fetched. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function keypairShouldReturnExpectedValues() + public function keypairShouldReturnExpectedValues(): void { $keypair = $this->heidelpay->fetchKeypair(); $this->assertNotNull($keypair); @@ -85,11 +79,8 @@ public function keypairShouldReturnExpectedValues() * Verify key pair config can be fetched with details. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function keypairShouldBeFetchableWithDetails() + public function keypairShouldBeFetchableWithDetails(): void { $keypair = $this->heidelpay->fetchKeypair(true); $this->assertNotNull($keypair); diff --git a/test/integration/PaymentCancelTest.php b/test/integration/PaymentCancelTest.php index f052e359..8a6b3504 100644 --- a/test/integration/PaymentCancelTest.php +++ b/test/integration/PaymentCancelTest.php @@ -1,4 +1,6 @@ @@ -40,11 +38,8 @@ class PaymentCancelTest extends BasePaymentTest * Verify full cancel on cancelled authorize returns empty array. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function doubleCancelOnAuthorizeShouldReturnEmptyArray() + public function doubleCancelOnAuthorizeShouldReturnEmptyArray(): void { $authorization = $this->createCardAuthorization(); $payment = $this->heidelpay->fetchPayment($authorization->getPaymentId()); @@ -67,11 +62,8 @@ public function doubleCancelOnAuthorizeShouldReturnEmptyArray() * PHPLIB-228 - Case 1 + double cancel * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function cancelOnChargeAndDoubleCancel() + public function cancelOnChargeAndDoubleCancel(): void { $charge = $this->createCharge(123.44); $payment = $this->heidelpay->fetchPayment($charge->getPaymentId()); @@ -95,11 +87,8 @@ public function cancelOnChargeAndDoubleCancel() * PHPLIB-228 - Case 2 * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function fullCancelOnPaymentWithAuthorizeAndMultipleChargesShouldBePossible() + public function fullCancelOnPaymentWithAuthorizeAndMultipleChargesShouldBePossible(): void { $authorization = $this->createCardAuthorization(123.44); $payment = $this->heidelpay->fetchPayment($authorization->getPaymentId()); @@ -131,11 +120,8 @@ public function fullCancelOnPaymentWithAuthorizeAndMultipleChargesShouldBePossib * PHPLIB-228 - Case 3 * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function partialCancelAndFullCancelOnSingleCharge() + public function partialCancelAndFullCancelOnSingleCharge(): void { $charge = $this->createCharge(222.33); $payment = $this->heidelpay->fetchPayment($charge->getPaymentId()); @@ -161,13 +147,8 @@ public function partialCancelAndFullCancelOnSingleCharge() * * @param float $amount * @param int $numberCancels - * - * @throws AssertionFailedError - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function partialCancelOnMultipleChargedAuthorization($amount, $numberCancels) + public function partialCancelOnMultipleChargedAuthorization($amount, $numberCancels): void { $authorizeAmount = 123.44; $authorization = $this->createCardAuthorization($authorizeAmount); @@ -196,13 +177,8 @@ public function partialCancelOnMultipleChargedAuthorization($amount, $numberCanc * @dataProvider fullCancelDataProvider * * @param float $amount - * - * @throws AssertionFailedError - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function fullCancelOnAuthorize($amount) + public function fullCancelOnAuthorize($amount): void { $authorization = $this->createCardAuthorization(); $payment = $this->heidelpay->fetchPayment($authorization->getPaymentId()); @@ -219,11 +195,8 @@ public function fullCancelOnAuthorize($amount) * PHPLIB-228 - Case 7 * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function fullCancelOnPartCanceledAuthorize() + public function fullCancelOnPartCanceledAuthorize(): void { $authorization = $this->createCardAuthorization(); $payment = $this->heidelpay->fetchPayment($authorization->getPaymentId()); @@ -253,13 +226,8 @@ public function fullCancelOnPartCanceledAuthorize() * @dataProvider fullCancelDataProvider * * @param float $amount The amount to be cancelled. - * - * @throws AssertionFailedError - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function fullCancelOnFullyChargedAuthorize($amount) + public function fullCancelOnFullyChargedAuthorize($amount): void { $authorization = $this->createCardAuthorization(); $payment = $this->heidelpay->fetchPayment($authorization->getPaymentId()); @@ -284,13 +252,8 @@ public function fullCancelOnFullyChargedAuthorize($amount) * @dataProvider fullCancelDataProvider * * @param $amount - * - * @throws AssertionFailedError - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function fullCancelOnPartlyChargedAuthorizeShouldBePossible($amount) + public function fullCancelOnPartlyChargedAuthorizeShouldBePossible($amount): void { $authorization = $this->createCardAuthorization(); $payment = $this->heidelpay->fetchPayment($authorization->getPaymentId()); @@ -312,13 +275,8 @@ public function fullCancelOnPartlyChargedAuthorizeShouldBePossible($amount) * PHPLIB-228 - Case 10 * * @test - * - * @throws AssertionFailedError - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function partCancelOnUnchargedAuthorize() + public function partCancelOnUnchargedAuthorize(): void { $authorization = $this->createCardAuthorization(); $payment = $this->heidelpay->fetchPayment($authorization->getPaymentId()); @@ -335,13 +293,8 @@ public function partCancelOnUnchargedAuthorize() * PHPLIB-228 - Case 11 * * @test - * - * @throws AssertionFailedError - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function partCancelOnPartlyChargedAuthorizeWithAmountLtCharged() + public function partCancelOnPartlyChargedAuthorizeWithAmountLtCharged(): void { $authorization = $this->createCardAuthorization(); $payment = $this->heidelpay->fetchPayment($authorization->getPaymentId()); @@ -363,13 +316,8 @@ public function partCancelOnPartlyChargedAuthorizeWithAmountLtCharged() * PHPLIB-228 - Case 12 * * @test - * - * @throws AssertionFailedError - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function partCancelOnPartlyChargedAuthorizeWithAmountGtCharged() + public function partCancelOnPartlyChargedAuthorizeWithAmountGtCharged(): void { $authorization = $this->createCardAuthorization(); $payment = $this->heidelpay->fetchPayment($authorization->getPaymentId()); @@ -394,13 +342,8 @@ public function partCancelOnPartlyChargedAuthorizeWithAmountGtCharged() * @dataProvider fullCancelDataProvider * * @param float $amount - * - * @throws AssertionFailedError - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function fullCancelOnInitialInvoiceCharge($amount) + public function fullCancelOnInitialInvoiceCharge($amount): void { /** @var Invoice $invoice */ $invoice = $this->heidelpay->createPaymentType(new Invoice()); @@ -419,13 +362,8 @@ public function fullCancelOnInitialInvoiceCharge($amount) * PHPLIB-228 - Case 14 * * @test - * - * @throws AssertionFailedError - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function partCancelOnInitialInvoiceChargeShouldBePossible() + public function partCancelOnInitialInvoiceChargeShouldBePossible(): void { /** @var Invoice $invoice */ $invoice = $this->heidelpay->createPaymentType(new Invoice()); @@ -444,13 +382,8 @@ public function partCancelOnInitialInvoiceChargeShouldBePossible() * PHPLIB-228 - Case 15 * * @test - * - * @throws AssertionFailedError - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function cancelMoreThanWasCharged() + public function cancelMoreThanWasCharged(): void { $charge = $this->createCharge(50.0); $payment = $this->heidelpay->fetchPayment($charge->getPaymentId()); @@ -467,13 +400,8 @@ public function cancelMoreThanWasCharged() * PHPLIB-228 - Case 16 * * @test - * - * @throws AssertionFailedError - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function secondCancelExceedsRemainderOfPartlyCancelledCharge() + public function secondCancelExceedsRemainderOfPartlyCancelledCharge(): void { $authorization = $this->createCardAuthorization(); $payment = $this->heidelpay->fetchPayment($authorization->getPaymentId()); @@ -504,11 +432,8 @@ public function secondCancelExceedsRemainderOfPartlyCancelledCharge() * Verify cancellation with all parameters set. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function cancellationShouldWorkWithAllParametersSet() + public function cancellationShouldWorkWithAllParametersSet(): void { $authorization = $this->createCardAuthorization(119.0); $payment = $authorization->getPayment(); diff --git a/test/integration/PaymentTest.php b/test/integration/PaymentTest.php index 08948ab2..7abc2512 100755 --- a/test/integration/PaymentTest.php +++ b/test/integration/PaymentTest.php @@ -1,4 +1,6 @@ createCardAuthorization(); $payment = $authorization->getPayment(); @@ -88,11 +83,8 @@ public function fullChargeShouldBePossibleOnPaymentObject() * Verify payment can be fetched with charges. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function paymentShouldBeFetchableWithCharges() + public function paymentShouldBeFetchableWithCharges(): void { $authorize = $this->createCardAuthorization(); $payment = $authorize->getPayment(); @@ -118,11 +110,8 @@ public function paymentShouldBeFetchableWithCharges() * Verify partial charge after authorization. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function partialChargeAfterAuthorization() + public function partialChargeAfterAuthorization(): void { $authorization = $this->createCardAuthorization(); $fetchedPayment = $this->heidelpay->fetchPayment($authorization->getPayment()->getId()); @@ -136,11 +125,8 @@ public function partialChargeAfterAuthorization() * Verify authorization on payment. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function authorizationShouldBePossibleOnHeidelpayObject() + public function authorizationShouldBePossibleOnHeidelpayObject(): void { /** @var Paypal $paypal */ $paypal = $this->heidelpay->createPaymentType(new Paypal()); @@ -153,11 +139,8 @@ public function authorizationShouldBePossibleOnHeidelpayObject() * Verify heidelpay payment charge is possible using a paymentId. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function paymentChargeOnAuthorizeShouldBePossibleUsingPaymentId() + public function paymentChargeOnAuthorizeShouldBePossibleUsingPaymentId(): void { $card = $this->heidelpay->createPaymentType($this->createCardObject()); $authorization = $this->heidelpay->authorize(100.00, 'EUR', $card, 'http://heidelpay.com', null, null, null, null, false); @@ -170,11 +153,8 @@ public function paymentChargeOnAuthorizeShouldBePossibleUsingPaymentId() * Verify heidelpay payment charge is possible using a paymentId and optional ids. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function paymentChargeOnAuthorizeShouldTakeResourceIds() + public function paymentChargeOnAuthorizeShouldTakeResourceIds(): void { $card = $this->heidelpay->createPaymentType($this->createCardObject()); $authorization = $this->heidelpay->authorize(100.00, 'EUR', $card, 'http://heidelpay.com', null, null, null, null, false); @@ -187,11 +167,8 @@ public function paymentChargeOnAuthorizeShouldTakeResourceIds() * Verify heidelpay payment charge throws an error if the id does not belong to a payment. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargePaymentShouldThrowErrorOnNonPaymentId() + public function chargePaymentShouldThrowErrorOnNonPaymentId(): void { $this->expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_PAYMENT_NOT_FOUND); @@ -202,11 +179,8 @@ public function chargePaymentShouldThrowErrorOnNonPaymentId() * Verify a payment is fetched by orderId if the id is not set. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function paymentShouldBeFetchedByOrderIdIfIdIsNotSet() + public function paymentShouldBeFetchedByOrderIdIfIdIsNotSet(): void { $orderId = str_replace(' ', '', microtime()); $paypal = $this->heidelpay->createPaymentType(new Paypal()); @@ -222,11 +196,8 @@ public function paymentShouldBeFetchedByOrderIdIfIdIsNotSet() * Verify orderId does not need to be unique. * * @test - * - * @throws HeidelpayApiException - * @throws RuntimeException */ - public function shouldAllowNonUniqueOrderId() + public function shouldAllowNonUniqueOrderId(): void { $orderId = 'o' . self::generateRandomId(); @@ -248,11 +219,8 @@ public function shouldAllowNonUniqueOrderId() * Verify invoiceId does not need to be unique. * * @test - * - * @throws HeidelpayApiException - * @throws RuntimeException */ - public function shouldAllowNonUniqueInvoiceId() + public function shouldAllowNonUniqueInvoiceId(): void { $invoiceId = 'i' . self::generateRandomId(); diff --git a/test/integration/PaymentTypes/AlipayTest.php b/test/integration/PaymentTypes/AlipayTest.php index 0ac735a0..652dea36 100755 --- a/test/integration/PaymentTypes/AlipayTest.php +++ b/test/integration/PaymentTypes/AlipayTest.php @@ -1,4 +1,6 @@ expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED); diff --git a/test/integration/PaymentTypes/CardTest.php b/test/integration/PaymentTypes/CardTest.php index a42c5a49..df0f0d91 100755 --- a/test/integration/PaymentTypes/CardTest.php +++ b/test/integration/PaymentTypes/CardTest.php @@ -1,4 +1,6 @@ @@ -51,10 +50,6 @@ class CardTest extends BasePaymentTest * @param CardDetails $expectedCardDetails * * @return BasePaymentType - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ public function cardShouldBeCreatable(string $cardNumber, CardDetails $expectedCardDetails): BasePaymentType { @@ -84,11 +79,8 @@ public function cardShouldBeCreatable(string $cardNumber, CardDetails $expectedC * Verify card creation with 3ds flag set will provide the flag in transactions. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function cardWith3dsFlagShouldSetItAlsoInTransactions() + public function cardWith3dsFlagShouldSetItAlsoInTransactions(): void { $card = $this->createCardObject()->set3ds(false); /** @var Card $card */ @@ -103,17 +95,13 @@ public function cardWith3dsFlagShouldSetItAlsoInTransactions() * Verify that the card can perform an authorization with a card. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function cardCanPerformAuthorizationAndCreatesPayment() + public function cardCanPerformAuthorizationAndCreatesPayment(): void { - /** @var Card $card */ $card = $this->createCardObject(); + /** @var Card $card */ $card = $this->heidelpay->createPaymentType($card); - /** @var Authorization $authorization */ $authorization = $card->authorize(1.0, 'EUR', self::RETURN_URL); // verify authorization has been created @@ -137,20 +125,16 @@ public function cardCanPerformAuthorizationAndCreatesPayment() * Verify the card can perform charges and creates a payment object doing so. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function cardCanPerformChargeAndCreatesPaymentObject() + public function cardCanPerformChargeAndCreatesPaymentObject(): void { - /** @var Card $card */ $card = $this->createCardObject(); + /** @var Card $card */ $card = $this->heidelpay->createPaymentType($card); // card recurring is disabled by default $this->assertFalse($card->isRecurring()); - /** @var Charge $charge */ $charge = $card->charge(1.0, 'EUR', self::RETURN_URL, null, null, null, null, false); // card recurring is activated through charge transaction @@ -179,14 +163,11 @@ public function cardCanPerformChargeAndCreatesPaymentObject() * Verify that a card object can be fetched from the api using its id. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function cardCanBeFetched() + public function cardCanBeFetched(): void { - /** @var Card $card */ $card = $this->createCardObject(); + /** @var Card $card */ $card = $this->heidelpay->createPaymentType($card); $this->assertNotNull($card->getId()); $this->assertNotNull($card->getCardHolder()); @@ -194,7 +175,7 @@ public function cardCanBeFetched() /** @var Card $fetchedCard */ $fetchedCard = $this->heidelpay->fetchPaymentType($card->getId()); $this->assertNotNull($fetchedCard->getId()); - $this->assertEquals($this->maskNumber($card->getNumber()), $fetchedCard->getNumber()); + $this->assertEquals(ValueService::maskValue($card->getNumber()), $fetchedCard->getNumber()); $this->assertEquals($card->getExpiryDate(), $fetchedCard->getExpiryDate()); $this->assertEquals('***', $fetchedCard->getCvc()); $this->assertEquals($card->getCardHolder(), $fetchedCard->getCardHolder()); @@ -205,12 +186,9 @@ public function cardCanBeFetched() * * @test * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * * @deprecated since 1.2.7.2 */ - public function cardCanBeFetchedOld() + public function cardCanBeFetchedOld(): void { $card = $this->createCardObject(); $this->heidelpay->createPaymentType($card); @@ -220,7 +198,7 @@ public function cardCanBeFetchedOld() /** @var Card $fetchedCard */ $fetchedCard = $this->heidelpay->fetchPaymentType($card->getId()); $this->assertNotNull($fetchedCard->getId()); - $this->assertEquals($this->maskNumber($card->getNumber()), $fetchedCard->getNumber()); + $this->assertEquals(ValueService::maskValue($card->getNumber()), $fetchedCard->getNumber()); $this->assertEquals($card->getExpiryDate(), $fetchedCard->getExpiryDate()); $this->assertEquals('***', $fetchedCard->getCvc()); $this->assertEquals($card->getHolder(), $fetchedCard->getHolder()); @@ -230,25 +208,20 @@ public function cardCanBeFetchedOld() * Verify the card can charge the full amount of the authorization and the payment state is updated accordingly. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function fullChargeAfterAuthorize() + public function fullChargeAfterAuthorize(): void { - /** @var Card $card */ $card = $this->createCardObject(); + /** @var Card $card */ $card = $this->heidelpay->createPaymentType($card); - /** @var Authorization $authorization */ $authorization = $card->authorize(1.0, 'EUR', self::RETURN_URL, null, null, null, null, false); - $payment = $authorization->getPayment(); + $payment = $authorization->getPayment(); // pre-check to verify changes due to fullCharge call $this->assertAmounts($payment, 1.0, 0.0, 1.0, 0.0); $this->assertTrue($payment->isPending()); - /** @var Charge $charge */ $charge = $this->heidelpay->chargeAuthorization($payment->getId()); $paymentNew = $charge->getPayment(); @@ -261,14 +234,11 @@ public function fullChargeAfterAuthorize() * Verify the card can charge part of the authorized amount and the payment state is updated accordingly. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function partialChargeAfterAuthorization() + public function partialChargeAfterAuthorization(): void { - /** @var Card $card */ $card = $this->createCardObject(); + /** @var Card $card */ $card = $this->heidelpay->createPaymentType($card); $authorization = $this->heidelpay->authorize( 100.0, @@ -306,14 +276,11 @@ public function partialChargeAfterAuthorization() * Verify that an exception is thrown when trying to charge more than authorized. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function exceptionShouldBeThrownWhenChargingMoreThenAuthorized() + public function exceptionShouldBeThrownWhenChargingMoreThenAuthorized(): void { - /** @var Card $card */ $card = $this->createCardObject(); + /** @var Card $card */ $card = $this->heidelpay->createPaymentType($card); $authorization = $card->authorize(100.0000, 'EUR', self::RETURN_URL, null, null, null, null, false); $payment = $authorization->getPayment(); @@ -334,14 +301,11 @@ public function exceptionShouldBeThrownWhenChargingMoreThenAuthorized() * Verify the card payment can be charged until it is fully charged and the payment is updated accordingly. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function partialAndFullChargeAfterAuthorization() + public function partialAndFullChargeAfterAuthorization(): void { - /** @var Card $card */ $card = $this->createCardObject(); + /** @var Card $card */ $card = $this->heidelpay->createPaymentType($card); $authorization = $card->authorize(100.0000, 'EUR', self::RETURN_URL, null, null, null, null, false); $payment = $authorization->getPayment(); @@ -364,14 +328,11 @@ public function partialAndFullChargeAfterAuthorization() * Authorization can be fetched. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function authorizationShouldBeFetchable() + public function authorizationShouldBeFetchable(): void { - /** @var Card $card */ $card = $this->createCardObject(); + /** @var Card $card */ $card = $this->heidelpay->createPaymentType($card); $authorization = $card->authorize(100.0000, 'EUR', self::RETURN_URL); $payment = $authorization->getPayment(); @@ -382,14 +343,11 @@ public function authorizationShouldBeFetchable() /** * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function fullCancelAfterCharge() + public function fullCancelAfterCharge(): void { - /** @var Card $card */ $card = $this->createCardObject(); + /** @var Card $card */ $card = $this->heidelpay->createPaymentType($card); $charge = $card->charge(100.0, 'EUR', self::RETURN_URL, null, null, null, null, false); $payment = $charge->getPayment(); @@ -406,14 +364,11 @@ public function fullCancelAfterCharge() * Verify a card payment can be cancelled after being fully charged. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function fullCancelOnFullyChargedPayment() + public function fullCancelOnFullyChargedPayment(): void { - /** @var Card $card */ $card = $this->createCardObject(); + /** @var Card $card */ $card = $this->heidelpay->createPaymentType($card); $authorization = $card->authorize(100.0000, 'EUR', self::RETURN_URL, null, null, null, null, false); @@ -440,14 +395,11 @@ public function fullCancelOnFullyChargedPayment() * Full cancel on partly charged auth canceled charges. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function fullCancelOnPartlyPaidAuthWithCanceledCharges() + public function fullCancelOnPartlyPaidAuthWithCanceledCharges(): void { - /** @var Card $card */ $card = $this->createCardObject(); + /** @var Card $card */ $card = $this->heidelpay->createPaymentType($card); $authorization = $card->authorize(100.0000, 'EUR', self::RETURN_URL, null, null, null, null, false); @@ -472,11 +424,8 @@ public function fullCancelOnPartlyPaidAuthWithCanceledCharges() * Verify card charge can be canceled. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function cardChargeCanBeCanceled() + public function cardChargeCanBeCanceled(): void { /** @var Card $card */ $card = $this->heidelpay->createPaymentType($this->createCardObject()); @@ -491,11 +440,8 @@ public function cardChargeCanBeCanceled() * Verify card authorize can be canceled. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function cardAuthorizeCanBeCanceled() + public function cardAuthorizeCanBeCanceled(): void { /** @var Card $card */ $card = $this->heidelpay->createPaymentType($this->createCardObject()); diff --git a/test/integration/PaymentTypes/EPSTest.php b/test/integration/PaymentTypes/EPSTest.php index 217c7f06..e426cb23 100755 --- a/test/integration/PaymentTypes/EPSTest.php +++ b/test/integration/PaymentTypes/EPSTest.php @@ -1,4 +1,6 @@ expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED); @@ -87,11 +82,8 @@ public function epsShouldThrowExceptionOnAuthorize(EPS $eps) * @depends epsShouldBeCreatable * * @param EPS $eps - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function epsShouldBeChargeable(EPS $eps) + public function epsShouldBeChargeable(EPS $eps): void { $charge = $eps->charge(1.0, 'EUR', self::RETURN_URL); $this->assertNotNull($charge); @@ -111,11 +103,8 @@ public function epsShouldBeChargeable(EPS $eps) * @depends epsShouldBeCreatable * * @param EPS $eps - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function epsTypeCanBeFetched(EPS $eps) + public function epsTypeCanBeFetched(EPS $eps): void { $fetchedEPS = $this->heidelpay->fetchPaymentType($eps->getId()); $this->assertInstanceOf(EPS::class, $fetchedEPS); diff --git a/test/integration/PaymentTypes/GiropayTest.php b/test/integration/PaymentTypes/GiropayTest.php index 2d120c22..89d7cefd 100755 --- a/test/integration/PaymentTypes/GiropayTest.php +++ b/test/integration/PaymentTypes/GiropayTest.php @@ -1,4 +1,6 @@ heidelpay->createPaymentType($giropay); $this->assertInstanceOf(Giropay::class, $giropay); $this->assertNotNull($giropay->getId()); @@ -53,11 +51,8 @@ public function giroPayShouldBeCreatable() * Verify that an exception is thrown when giropay authorize is called. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function giroPayShouldThrowExceptionOnAuthorize() + public function giroPayShouldThrowExceptionOnAuthorize(): void { $this->expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED); @@ -70,11 +65,8 @@ public function giroPayShouldThrowExceptionOnAuthorize() * Verify that GiroPay is chargeable. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function giroPayShouldBeChargeable() + public function giroPayShouldBeChargeable(): void { /** @var Giropay $giropay */ $giropay = $this->heidelpay->createPaymentType(new Giropay()); @@ -91,11 +83,8 @@ public function giroPayShouldBeChargeable() * Verify a GiroPay object can be fetched from the api. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function giroPayCanBeFetched() + public function giroPayCanBeFetched(): void { $giropay = $this->heidelpay->createPaymentType(new Giropay()); $fetchedGiropay = $this->heidelpay->fetchPaymentType($giropay->getId()); diff --git a/test/integration/PaymentTypes/HirePurchaseDirectDebitTest.php b/test/integration/PaymentTypes/HirePurchaseDirectDebitTest.php index 74b4d971..5e24d3e9 100755 --- a/test/integration/PaymentTypes/HirePurchaseDirectDebitTest.php +++ b/test/integration/PaymentTypes/HirePurchaseDirectDebitTest.php @@ -1,4 +1,6 @@ heidelpay->fetchDirectDebitInstalmentPlans(119.0, 'EUR', 4.99); $this->assertGreaterThan(0, count($plans->getPlans())); @@ -61,7 +57,6 @@ public function instalmentPlanShouldBeSelectable() /** @var InstalmentPlan $selectedPlan */ $selectedPlan = $plans->getPlans()[1]; - /** @var HirePurchaseDirectDebit $hdd */ $hdd = new HirePurchaseDirectDebit($selectedPlan, 'DE46940594210000012345', 'Manuel Weißmann'); $this->heidelpay->createPaymentType($hdd); $this->assertArraySubset($selectedPlan->expose(), $hdd->expose()); @@ -88,13 +83,11 @@ public function instalmentPlanShouldBeSelectable() * @param $firstname * @param $lastname * @param $errorCode - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function hirePurchaseDirectDebitAuthorize($firstname, $lastname, $errorCode) + public function hirePurchaseDirectDebitAuthorize($firstname, $lastname, $errorCode): void { $hpPlans = $this->heidelpay->fetchDirectDebitInstalmentPlans(119.0, 'EUR', 4.99); + /** @var InstalmentPlan $selectedPlan */ $selectedPlan = $hpPlans->getPlans()[0]; $hdd = new HirePurchaseDirectDebit($selectedPlan, 'DE46940594210000012345', 'Manuel Weißmann'); $this->heidelpay->createPaymentType($hdd); @@ -121,12 +114,8 @@ public function hirePurchaseDirectDebitAuthorize($firstname, $lastname, $errorCo * Verify fetching instalment plans. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws Exception */ - public function instalmentPlanSelectionWithAllFieldsSet() + public function instalmentPlanSelectionWithAllFieldsSet(): void { $yesterday = $this->getYesterdaysTimestamp(); $plans = $this->heidelpay->fetchDirectDebitInstalmentPlans(119.0, 'EUR', 4.99, $yesterday); @@ -144,12 +133,8 @@ public function instalmentPlanSelectionWithAllFieldsSet() * Verify charge. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws Exception */ - public function verifyChargingAnInitializedHirePurchase() + public function verifyChargingAnInitializedHirePurchase(): void { $yesterday = $this->getYesterdaysTimestamp(); $plans = $this->heidelpay->fetchDirectDebitInstalmentPlans(119.0, 'EUR', 4.99, $yesterday); @@ -172,12 +157,8 @@ public function verifyChargingAnInitializedHirePurchase() * Verify charge and ship. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws Exception */ - public function verifyShippingAChargedHirePurchase() + public function verifyShippingAChargedHirePurchase(): void { $yesterday = $this->getYesterdaysTimestamp(); $plans = $this->heidelpay->fetchDirectDebitInstalmentPlans(119.0, 'EUR', 4.99, $yesterday); @@ -204,12 +185,8 @@ public function verifyShippingAChargedHirePurchase() * @test * * @depends verifyChargingAnInitializedHirePurchase - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws Exception */ - public function verifyChargeAndFullCancelAnInitializedHirePurchase() + public function verifyChargeAndFullCancelAnInitializedHirePurchase(): void { $yesterday = $this->getYesterdaysTimestamp(); $plans = $this->heidelpay->fetchDirectDebitInstalmentPlans(119.0, 'EUR', 4.99, $yesterday); @@ -233,12 +210,8 @@ public function verifyChargeAndFullCancelAnInitializedHirePurchase() * @test * * @depends verifyChargingAnInitializedHirePurchase - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws Exception */ - public function verifyPartlyCancelChargedHirePurchase() + public function verifyPartlyCancelChargedHirePurchase(): void { $yesterday = $this->getYesterdaysTimestamp(); $plans = $this->heidelpay->fetchDirectDebitInstalmentPlans(119.0, 'EUR', 4.99, $yesterday); diff --git a/test/integration/PaymentTypes/IdealTest.php b/test/integration/PaymentTypes/IdealTest.php index fcf3c38b..dcc498c8 100755 --- a/test/integration/PaymentTypes/IdealTest.php +++ b/test/integration/PaymentTypes/IdealTest.php @@ -1,4 +1,6 @@ expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED); @@ -78,11 +73,8 @@ public function idealShouldThrowExceptionOnAuthorize(Ideal $ideal) * @depends idealShouldBeCreatable * * @param Ideal $ideal - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function idealShouldBeChargeable(Ideal $ideal) + public function idealShouldBeChargeable(Ideal $ideal): void { $charge = $ideal->charge(1.0, 'EUR', self::RETURN_URL); $this->assertNotNull($charge); @@ -100,11 +92,8 @@ public function idealShouldBeChargeable(Ideal $ideal) * @depends idealShouldBeCreatable * * @param Ideal $ideal - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function idealTypeCanBeFetched(Ideal $ideal) + public function idealTypeCanBeFetched(Ideal $ideal): void { $fetchedIdeal = $this->heidelpay->fetchPaymentType($ideal->getId()); $this->assertInstanceOf(Ideal::class, $fetchedIdeal); diff --git a/test/integration/PaymentTypes/InvoiceFactoringTest.php b/test/integration/PaymentTypes/InvoiceFactoringTest.php index bbbbba16..67701c72 100755 --- a/test/integration/PaymentTypes/InvoiceFactoringTest.php +++ b/test/integration/PaymentTypes/InvoiceFactoringTest.php @@ -1,4 +1,6 @@ expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED); @@ -86,11 +79,8 @@ public function verifyInvoiceIsNotAuthorizable(InvoiceFactoring $invoice) * @depends invoiceFactoringTypeShouldBeCreatableAndFetchable * * @param InvoiceFactoring $invoiceFactoring - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function invoiceFactoringShouldRequiresCustomer(InvoiceFactoring $invoiceFactoring) + public function invoiceFactoringShouldRequiresCustomer(InvoiceFactoring $invoiceFactoring): void { $this->expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_IVF_REQUIRES_CUSTOMER); @@ -104,11 +94,8 @@ public function invoiceFactoringShouldRequiresCustomer(InvoiceFactoring $invoice * @depends invoiceFactoringTypeShouldBeCreatableAndFetchable * * @param InvoiceFactoring $invoiceFactoring - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function invoiceFactoringRequiresBasket(InvoiceFactoring $invoiceFactoring) + public function invoiceFactoringRequiresBasket(InvoiceFactoring $invoiceFactoring): void { $customer = $this->getMaximumCustomer(); $customer->setShippingAddress($customer->getBillingAddress()); @@ -128,10 +115,6 @@ public function invoiceFactoringRequiresBasket(InvoiceFactoring $invoiceFactorin * @param InvoiceFactoring $invoiceFactoring * * @return Charge - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws AssertionFailedError */ public function invoiceFactoringShouldBeChargeable(InvoiceFactoring $invoiceFactoring): Charge { @@ -154,12 +137,8 @@ public function invoiceFactoringShouldBeChargeable(InvoiceFactoring $invoiceFact * Verify Invoice Factoring is not shippable on heidelpay object. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws Exception */ - public function verifyInvoiceFactoringIsNotShippableWoInvoiceIdOnHeidelpayObject() + public function verifyInvoiceFactoringIsNotShippableWoInvoiceIdOnHeidelpayObject(): void { // create payment type /** @var InvoiceFactoring $invoiceFactoring */ @@ -183,12 +162,8 @@ public function verifyInvoiceFactoringIsNotShippableWoInvoiceIdOnHeidelpayObject * Verify Invoice Factoring is not shippable on payment object. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws Exception */ - public function verifyInvoiceFactoringIsNotShippableWoInvoiceIdOnPaymentObject() + public function verifyInvoiceFactoringIsNotShippableWoInvoiceIdOnPaymentObject(): void { // create payment type /** @var InvoiceFactoring $invoiceFactoring */ @@ -212,11 +187,8 @@ public function verifyInvoiceFactoringIsNotShippableWoInvoiceIdOnPaymentObject() * Verify Invoice Factoring shipment with invoice id on heidelpay object. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function verifyInvoiceFactoringShipmentWithInvoiceIdOnHeidelpayObject() + public function verifyInvoiceFactoringShipmentWithInvoiceIdOnHeidelpayObject(): void { // create payment type /** @var InvoiceFactoring $invoiceFactoring */ @@ -241,11 +213,8 @@ public function verifyInvoiceFactoringShipmentWithInvoiceIdOnHeidelpayObject() * Verify Invoice Factoring shipment with invoice id on payment object. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function verifyInvoiceFactoringShipmentWithInvoiceIdOnPaymentObject() + public function verifyInvoiceFactoringShipmentWithInvoiceIdOnPaymentObject(): void { // create payment type /** @var InvoiceFactoring $invoiceFactoring */ @@ -269,11 +238,8 @@ public function verifyInvoiceFactoringShipmentWithInvoiceIdOnPaymentObject() * Verify Invoice Factoring shipment with pre set invoice id * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function verifyInvoiceFactoringShipmentWithPreSetInvoiceId() + public function verifyInvoiceFactoringShipmentWithPreSetInvoiceId(): void { /** @var InvoiceFactoring $invoiceFactoring */ $invoiceFactoring = $this->heidelpay->createPaymentType(new InvoiceFactoring()); @@ -297,12 +263,9 @@ public function verifyInvoiceFactoringShipmentWithPreSetInvoiceId() * @test * * @param Charge $charge - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. * @depends invoiceFactoringShouldBeChargeable */ - public function verifyInvoiceChargeCanBeCanceled(Charge $charge) + public function verifyInvoiceChargeCanBeCanceled(Charge $charge): void { $cancellation = $charge->cancel($charge->getAmount(), CancelReasonCodes::REASON_CODE_CANCEL); $this->assertNotNull($cancellation); @@ -315,12 +278,9 @@ public function verifyInvoiceChargeCanBeCanceled(Charge $charge) * @test * * @param Charge $charge - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. * @depends invoiceFactoringShouldBeChargeable */ - public function verifyInvoiceChargeCanNotBeCancelledWoAmount(Charge $charge) + public function verifyInvoiceChargeCanNotBeCancelledWoAmount(Charge $charge): void { $this->expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_AMOUNT_IS_MISSING); @@ -333,12 +293,9 @@ public function verifyInvoiceChargeCanNotBeCancelledWoAmount(Charge $charge) * @test * * @param Charge $charge - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. * @depends invoiceFactoringShouldBeChargeable */ - public function verifyInvoiceChargeCanNotBeCancelledWoReasonCode(Charge $charge) + public function verifyInvoiceChargeCanNotBeCancelledWoReasonCode(Charge $charge): void { $this->expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_CANCEL_REASON_CODE_IS_MISSING); diff --git a/test/integration/PaymentTypes/InvoiceGuaranteedTest.php b/test/integration/PaymentTypes/InvoiceGuaranteedTest.php index 3108ae78..fcaedbd5 100755 --- a/test/integration/PaymentTypes/InvoiceGuaranteedTest.php +++ b/test/integration/PaymentTypes/InvoiceGuaranteedTest.php @@ -1,4 +1,6 @@ heidelpay->createPaymentType(new InvoiceGuaranteed()); @@ -52,11 +50,8 @@ public function invoiceGuaranteedTypeShouldBeCreatable() * Verify invoice guaranteed can be shipped. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function verifyInvoiceGuaranteedShipment() + public function verifyInvoiceGuaranteedShipment(): void { /** @var InvoiceGuaranteed $invoiceGuaranteed */ $invoiceGuaranteed = $this->heidelpay->createPaymentType(new InvoiceGuaranteed()); @@ -77,11 +72,8 @@ public function verifyInvoiceGuaranteedShipment() * Verify invoice guaranteed can be charged and cancelled. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function verifyInvoiceGuaranteedCanBeChargedAndCancelled() + public function verifyInvoiceGuaranteedCanBeChargedAndCancelled(): void { /** @var InvoiceGuaranteed $invoiceGuaranteed */ $invoiceGuaranteed = $this->heidelpay->createPaymentType(new InvoiceGuaranteed()); @@ -97,11 +89,8 @@ public function verifyInvoiceGuaranteedCanBeChargedAndCancelled() * Verify that an invoice guaranteed object can be fetched from the api. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function invoiceGuaranteedTypeCanBeFetched() + public function invoiceGuaranteedTypeCanBeFetched(): void { /** @var InvoiceGuaranteed $invoiceGuaranteed */ $invoiceGuaranteed = $this->heidelpay->createPaymentType(new InvoiceGuaranteed()); @@ -114,11 +103,8 @@ public function invoiceGuaranteedTypeCanBeFetched() * Verify ivg will throw error if addresses do not match. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function ivgShouldThrowErrorIfAddressesDoNotMatch() + public function ivgShouldThrowErrorIfAddressesDoNotMatch(): void { /** @var InvoiceGuaranteed $invoiceGuaranteed */ $invoiceGuaranteed = $this->heidelpay->createPaymentType(new InvoiceGuaranteed()); @@ -133,11 +119,8 @@ public function ivgShouldThrowErrorIfAddressesDoNotMatch() * Verify the invoiceId set during shipping overrides the previously set invoiceId. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function verifyInvoiceIdInShipmentWillOverrideTheOneFromCharge() + public function verifyInvoiceIdInShipmentWillOverrideTheOneFromCharge(): void { /** @var InvoiceGuaranteed $invoiceGuaranteed */ $invoiceGuaranteed = $this->heidelpay->createPaymentType(new InvoiceGuaranteed()); diff --git a/test/integration/PaymentTypes/InvoiceTest.php b/test/integration/PaymentTypes/InvoiceTest.php index a75a52ac..bf3170e6 100755 --- a/test/integration/PaymentTypes/InvoiceTest.php +++ b/test/integration/PaymentTypes/InvoiceTest.php @@ -1,4 +1,6 @@ heidelpay->createPaymentType(new Invoice()); @@ -52,11 +50,8 @@ public function invoiceTypeShouldBeCreatable() * Verify invoice is not authorizable. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function verifyInvoiceIsNotAuthorizable() + public function verifyInvoiceIsNotAuthorizable(): void { /** @var Invoice $invoice */ $invoice = $this->heidelpay->createPaymentType(new Invoice()); @@ -70,11 +65,8 @@ public function verifyInvoiceIsNotAuthorizable() * Verify invoice is chargeable. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function verifyInvoiceIsChargeable() + public function verifyInvoiceIsChargeable(): void { /** @var Invoice $invoice */ $invoice = $this->heidelpay->createPaymentType(new Invoice()); @@ -87,11 +79,8 @@ public function verifyInvoiceIsChargeable() * Verify invoice is not shippable. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function verifyInvoiceIsNotShippable() + public function verifyInvoiceIsNotShippable(): void { /** @var Invoice $invoice */ $invoice = $this->heidelpay->createPaymentType(new Invoice()); @@ -113,11 +102,8 @@ public function verifyInvoiceIsNotShippable() * Verify invoice charge can be canceled. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function verifyInvoiceChargeCanBeCanceled() + public function verifyInvoiceChargeCanBeCanceled(): void { /** @var Invoice $invoice */ $invoice = $this->heidelpay->createPaymentType(new Invoice()); @@ -133,11 +119,8 @@ public function verifyInvoiceChargeCanBeCanceled() * Verify invoice charge can be canceled. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function verifyInvoiceChargeCanBePartlyCanceled() + public function verifyInvoiceChargeCanBePartlyCanceled(): void { /** @var Invoice $invoice */ $invoice = $this->heidelpay->createPaymentType(new Invoice()); @@ -159,11 +142,8 @@ public function verifyInvoiceChargeCanBePartlyCanceled() * Verify that an invoice object can be fetched from the api. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function invoiceTypeCanBeFetched() + public function invoiceTypeCanBeFetched(): void { /** @var Invoice $invoice */ $invoice = $this->heidelpay->createPaymentType(new Invoice()); diff --git a/test/integration/PaymentTypes/PISTest.php b/test/integration/PaymentTypes/PISTest.php index 49a4c773..b896a0ac 100755 --- a/test/integration/PaymentTypes/PISTest.php +++ b/test/integration/PaymentTypes/PISTest.php @@ -1,4 +1,6 @@ expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED); diff --git a/test/integration/PaymentTypes/PaypageTest.php b/test/integration/PaymentTypes/PaypageTest.php index 0ca30dcb..6c40aca1 100644 --- a/test/integration/PaymentTypes/PaypageTest.php +++ b/test/integration/PaymentTypes/PaypageTest.php @@ -1,4 +1,6 @@ assertEmpty($paypage->getId()); @@ -56,12 +51,8 @@ public function minimalPaypageChargeShouldBeCreatableAndFetchable() * Verify the Paypage resource for charge can be created with all parameters. * * @test - * - * @throws AssertionFailedError - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function maximumPaypageChargeShouldBeCreatable() + public function maximumPaypageChargeShouldBeCreatable(): void { $orderId = 'o'. self::generateRandomId(); $basket = $this->createBasket(); @@ -81,7 +72,13 @@ public function maximumPaypageChargeShouldBeCreatable() ->setContactUrl('https://www.heidelpay.com/en/about-us/about-heidelpay/') ->setInvoiceId($invoiceId) ->setCard3ds(true) - ->setEffectiveInterestRate(4.99); + ->setEffectiveInterestRate(4.99) + ->setCss([ + 'shopDescription' => 'color: purple', + 'header' => 'background-color: red', + 'helpUrl' => 'color: blue', + 'contactUrl' => 'color: green', + ]); $this->assertEmpty($paypage->getId()); $paypage = $this->heidelpay->initPayPageCharge($paypage, $customer, $basket); $this->assertNotEmpty($paypage->getId()); @@ -96,12 +93,8 @@ public function maximumPaypageChargeShouldBeCreatable() * Verify the Paypage resource for authorize can be created with the mandatory parameters only. * * @test - * - * @throws AssertionFailedError - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function minimalPaypageAuthorizeShouldBeCreatableAndFetchable() + public function minimalPaypageAuthorizeShouldBeCreatableAndFetchable(): void { $paypage = new Paypage(100.0, 'EUR', self::RETURN_URL); $this->assertEmpty($paypage->getId()); @@ -113,12 +106,8 @@ public function minimalPaypageAuthorizeShouldBeCreatableAndFetchable() * Verify the Paypage resource for authorize can be created with all parameters. * * @test - * - * @throws AssertionFailedError - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function maximumPaypageAuthorizeShouldBeCreatable() + public function maximumPaypageAuthorizeShouldBeCreatable(): void { $orderId = 'o'. self::generateRandomId(); $basket = $this->createBasket(); @@ -138,16 +127,35 @@ public function maximumPaypageAuthorizeShouldBeCreatable() ->setContactUrl('https://www.heidelpay.com/en/about-us/about-heidelpay/') ->setInvoiceId($invoiceId) ->setCard3ds(true) - ->setEffectiveInterestRate(4.99); + ->setEffectiveInterestRate(4.99) + ->setCss([ + 'shopDescription' => 'color: purple', + 'header' => 'background-color: red', + 'helpUrl' => 'color: blue', + 'contactUrl' => 'color: green', + ]); $paypage->addExcludeType(Card::getResourceName()); $this->assertEmpty($paypage->getId()); $paypage = $this->heidelpay->initPayPageAuthorize($paypage, $customer, $basket); $this->assertNotEmpty($paypage->getId()); $this->assertEquals(4.99, $paypage->getEffectiveInterestRate()); - $this->assertArraySubset([Card::getResourceName()], $paypage->getExcludeTypes()); + $this->assertEquals([Card::getResourceName()], $paypage->getExcludeTypes()); $payment = $paypage->getPayment(); $this->assertInstanceOf(Payment::class, $payment); $this->assertNotNull($payment->getId()); $this->assertNotEmpty($paypage->getRedirectUrl()); } + + /** + * Validate paypage css can be set empty array. + * + * @test + */ + public function cssShouldAllowForEmptyArray(): void + { + $paypage = new Paypage(100.0, 'EUR', self::RETURN_URL); + $this->assertEmpty($paypage->getId()); + $paypage = $this->heidelpay->initPayPageAuthorize($paypage->setCss([])); + $this->assertNotEmpty($paypage->getId()); + } } diff --git a/test/integration/PaymentTypes/PaypalTest.php b/test/integration/PaymentTypes/PaypalTest.php index 54b32ba3..487926de 100755 --- a/test/integration/PaymentTypes/PaypalTest.php +++ b/test/integration/PaymentTypes/PaypalTest.php @@ -1,4 +1,6 @@ authorize(100.0, 'EUR', self::RETURN_URL); $this->assertNotNull($authorization); @@ -110,11 +101,8 @@ public function paypalShouldBeAuthorizable(Paypal $paypal) * @depends paypalShouldBeCreatableAndFetchable * * @param Paypal $paypal - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function paypalShouldBeChargeable(Paypal $paypal) + public function paypalShouldBeChargeable(Paypal $paypal): void { $charge = $paypal->charge(100.0, 'EUR', self::RETURN_URL); $this->assertNotNull($charge); diff --git a/test/integration/PaymentTypes/PrepaymentTest.php b/test/integration/PaymentTypes/PrepaymentTest.php index ca7924e1..d4ed5ce4 100755 --- a/test/integration/PaymentTypes/PrepaymentTest.php +++ b/test/integration/PaymentTypes/PrepaymentTest.php @@ -1,4 +1,6 @@ expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED); @@ -111,11 +103,8 @@ public function prepaymentTypeShouldNotBeAuthorizable(Prepayment $prepayment) * @depends prepaymentTypeShouldBeChargeable * * @param Charge $charge - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function prepaymentTypeShouldNotBeShippable(Charge $charge) + public function prepaymentTypeShouldNotBeShippable(Charge $charge): void { $this->expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_TRANSACTION_SHIP_NOT_ALLOWED); @@ -131,11 +120,8 @@ public function prepaymentTypeShouldNotBeShippable(Charge $charge) * @depends prepaymentShouldBeCreatableAndFetchable * * @param Prepayment $prepayment - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function prepaymentChargeCanBeCanceled(Prepayment $prepayment) + public function prepaymentChargeCanBeCanceled(Prepayment $prepayment): void { $charge = $prepayment->charge(100.0, 'EUR', self::RETURN_URL); $this->assertPending($charge); diff --git a/test/integration/PaymentTypes/Przelewy24Test.php b/test/integration/PaymentTypes/Przelewy24Test.php index fcc741f8..a4e4441f 100755 --- a/test/integration/PaymentTypes/Przelewy24Test.php +++ b/test/integration/PaymentTypes/Przelewy24Test.php @@ -1,4 +1,6 @@ charge(100.0, 'PLN', self::RETURN_URL); $this->assertNotNull($charge); @@ -88,11 +83,8 @@ public function przelewy24ShouldBeChargeable(Przelewy24 $przelewy24) * @depends przelewy24ShouldBeCreatableAndFetchable * * @param Przelewy24 $przelewy24 - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function przelewy24ShouldNotBeAuthorizable(Przelewy24 $przelewy24) + public function przelewy24ShouldNotBeAuthorizable(Przelewy24 $przelewy24): void { $this->expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED); @@ -108,11 +100,8 @@ public function przelewy24ShouldNotBeAuthorizable(Przelewy24 $przelewy24) * @dataProvider przelewy24CurrencyCodeProvider * * @param string $currencyCode - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function przelewy24ShouldThrowExceptionIfCurrencyIsNotSupported($currencyCode) + public function przelewy24ShouldThrowExceptionIfCurrencyIsNotSupported($currencyCode): void { /** @var Przelewy24 $przelewy24 */ $przelewy24 = $this->heidelpay->createPaymentType(new Przelewy24()); diff --git a/test/integration/PaymentTypes/SepaDirectDebitGuaranteedTest.php b/test/integration/PaymentTypes/SepaDirectDebitGuaranteedTest.php index 5da33d97..fd1f2e5b 100755 --- a/test/integration/PaymentTypes/SepaDirectDebitGuaranteedTest.php +++ b/test/integration/PaymentTypes/SepaDirectDebitGuaranteedTest.php @@ -1,4 +1,6 @@ expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED); @@ -102,11 +94,8 @@ public function directDebitGuaranteedShouldProhibitAuthorization(SepaDirectDebit * Verify direct debit guaranteed can be charged. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function directDebitGuaranteedShouldAllowCharge() + public function directDebitGuaranteedShouldAllowCharge(): void { $directDebitGuaranteed = (new SepaDirectDebitGuaranteed('DE89370400440532013000'))->setBic('COBADEFFXXX'); $this->heidelpay->createPaymentType($directDebitGuaranteed); @@ -120,11 +109,8 @@ public function directDebitGuaranteedShouldAllowCharge() * Verify ddg will throw error if addresses do not match. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function ddgShouldThrowErrorIfAddressesDoNotMatch() + public function ddgShouldThrowErrorIfAddressesDoNotMatch(): void { $directDebitGuaranteed = (new SepaDirectDebitGuaranteed('DE89370400440532013000'))->setBic('COBADEFFXXX'); $this->heidelpay->createPaymentType($directDebitGuaranteed); diff --git a/test/integration/PaymentTypes/SepaDirectDebitTest.php b/test/integration/PaymentTypes/SepaDirectDebitTest.php index 7f28a490..7cc5c576 100755 --- a/test/integration/PaymentTypes/SepaDirectDebitTest.php +++ b/test/integration/PaymentTypes/SepaDirectDebitTest.php @@ -1,4 +1,6 @@ setHolder('Max Mustermann')->setBic('COBADEFFXXX'); /** @var SepaDirectDebit $sdd */ @@ -79,14 +74,11 @@ public function sepaDirectDebitShouldBeCreatable() * Verify authorization is not allowed for sepa direct debit. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function authorizeShouldThrowException() + public function authorizeShouldThrowException(): void { - /** @var SepaDirectDebit $sdd */ $sdd = (new SepaDirectDebit('DE89370400440532013000'))->setHolder('Max Mustermann')->setBic('COBADEFFXXX'); + /** @var SepaDirectDebit $sdd */ $sdd = $this->heidelpay->createPaymentType($sdd); $this->expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED); @@ -96,14 +88,11 @@ public function authorizeShouldThrowException() /** * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function directDebitShouldBeChargeable() + public function directDebitShouldBeChargeable(): void { - /** @var SepaDirectDebit $sdd */ $sdd = (new SepaDirectDebit('DE89370400440532013000'))->setHolder('Max Mustermann')->setBic('COBADEFFXXX'); + /** @var SepaDirectDebit $sdd */ $sdd = $this->heidelpay->createPaymentType($sdd); $charge = $sdd->charge(100.0, 'EUR', self::RETURN_URL); $this->assertNotNull($charge); @@ -114,14 +103,11 @@ public function directDebitShouldBeChargeable() * Verify sdd charge is refundable. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function directDebitChargeShouldBeRefundable() + public function directDebitChargeShouldBeRefundable(): void { - /** @var SepaDirectDebit $sdd */ $sdd = (new SepaDirectDebit('DE89370400440532013000'))->setHolder('Max Mustermann')->setBic('COBADEFFXXX'); + /** @var SepaDirectDebit $sdd */ $sdd = $this->heidelpay->createPaymentType($sdd); $charge = $sdd->charge(100.0, 'EUR', self::RETURN_URL); diff --git a/test/integration/PaymentTypes/SofortTest.php b/test/integration/PaymentTypes/SofortTest.php index 33119789..d78312d6 100755 --- a/test/integration/PaymentTypes/SofortTest.php +++ b/test/integration/PaymentTypes/SofortTest.php @@ -1,4 +1,6 @@ expectException(HeidelpayApiException::class); $this->expectExceptionCode(ApiResponseCodes::API_ERROR_TRANSACTION_AUTHORIZE_NOT_ALLOWED); diff --git a/test/integration/PaymentTypes/WechatpayTest.php b/test/integration/PaymentTypes/WechatpayTest.php index fe73691b..d51c5b56 100755 --- a/test/integration/PaymentTypes/WechatpayTest.php +++ b/test/integration/PaymentTypes/WechatpayTest.php @@ -1,4 +1,6 @@ heidelpay->createPaymentType(new Wechatpay()); $this->assertInstanceOf(Wechatpay::class, $wechatpay); @@ -57,11 +55,8 @@ public function wechatpayShouldBeCreatableAndFetchable() * Verify wechatpay is chargeable. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function wechatpayShouldBeAbleToCharge() + public function wechatpayShouldBeAbleToCharge(): void { /** @var Wechatpay $wechatpay */ $wechatpay = $this->heidelpay->createPaymentType(new Wechatpay()); @@ -75,11 +70,8 @@ public function wechatpayShouldBeAbleToCharge() * Verify wechatpay is not authorizable. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function wechatpayShouldNotBeAuthorizable() + public function wechatpayShouldNotBeAuthorizable(): void { $wechatpay = $this->heidelpay->createPaymentType(new Wechatpay()); $this->expectException(HeidelpayApiException::class); diff --git a/test/integration/RecurringPaymentTest.php b/test/integration/RecurringPaymentTest.php index e1661996..4d7843c8 100644 --- a/test/integration/RecurringPaymentTest.php +++ b/test/integration/RecurringPaymentTest.php @@ -1,4 +1,6 @@ heidelpay->createPaymentType($this->createCardObject()->set3ds(true)); @@ -82,13 +76,10 @@ public function recurringForCardWith3dsShouldReturnAttributes() * Verify card without 3ds can activate recurring payments. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function recurringForCardWithout3dsShouldActivateRecurringAtOnce() + public function recurringForCardWithout3dsShouldActivateRecurringAtOnce(): void { - $privateKey = (new EnvironmentService())->getTestPrivateKey(true); + $privateKey = EnvironmentService::getTestPrivateKey(true); if (empty($privateKey)) { $this->markTestIncomplete('No non 3ds private key set'); } @@ -112,11 +103,8 @@ public function recurringForCardWithout3dsShouldActivateRecurringAtOnce() * Verify paypal can activate recurring payments. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function paypalShouldBeAbleToActivateRecurringPayments() + public function paypalShouldBeAbleToActivateRecurringPayments(): void { /** @var Paypal $paypal */ $paypal = $this->heidelpay->createPaymentType(new Paypal()); @@ -129,11 +117,8 @@ public function paypalShouldBeAbleToActivateRecurringPayments() * Verify sepa direct debit can activate recurring payments. * * @test - * - * @throws RuntimeException - * @throws HeidelpayApiException */ - public function sepaDirectDebitShouldBeAbleToActivateRecurringPayments() + public function sepaDirectDebitShouldBeAbleToActivateRecurringPayments(): void { /** @var SepaDirectDebit $dd */ $dd = $this->heidelpay->createPaymentType(new SepaDirectDebit('DE89370400440532013000')); @@ -151,17 +136,20 @@ public function sepaDirectDebitShouldBeAbleToActivateRecurringPayments() * Verify sepa direct debit guaranteed can activate recurring payments. * * @test - * - * @throws RuntimeException - * @throws HeidelpayApiException */ - public function sepaDirectDebitGuaranteedShouldBeAbleToActivateRecurringPayments() + public function sepaDirectDebitGuaranteedShouldBeAbleToActivateRecurringPayments(): void { /** @var SepaDirectDebitGuaranteed $ddg */ $ddg = $this->heidelpay->createPaymentType(new SepaDirectDebitGuaranteed('DE89370400440532013000')); + $this->assertFalse($ddg->isRecurring()); + $customer = $this->getMaximumCustomer(); + $customer->setShippingAddress($customer->getBillingAddress()); + $ddg->charge(10.0, 'EUR', self::RETURN_URL, $customer); + $ddg = $this->heidelpay->fetchPaymentType($ddg->getId()); + $this->assertTrue($ddg->isRecurring()); $this->expectException(HeidelpayApiException::class); - $this->expectExceptionCode(ApiResponseCodes::API_ERROR_ACTIVATE_RECURRING_VIA_TRANSACTION); - $ddg->activateRecurring('https://dev.heidelpay.com'); + $this->expectExceptionCode(ApiResponseCodes::API_ERROR_RECURRING_ALREADY_ACTIVE); + $this->heidelpay->activateRecurringPayment($ddg, self::RETURN_URL); } } diff --git a/test/integration/SetMetadataTest.php b/test/integration/SetMetadataTest.php index 6ac44123..4ba7d8b0 100755 --- a/test/integration/SetMetadataTest.php +++ b/test/integration/SetMetadataTest.php @@ -1,4 +1,6 @@ assertNull($metadata->getShopType()); @@ -71,11 +69,8 @@ public function metadataShouldBeCreatableAndFetchableWithTheApi() * Verify metadata will automatically created on authorize. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function authorizeShouldCreateMetadata() + public function authorizeShouldCreateMetadata(): void { $metadata = new Metadata(); $metadata->setShopType('Shopware'); @@ -93,11 +88,8 @@ public function authorizeShouldCreateMetadata() * Verify metadata will automatically created on charge. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargeShouldCreateMetadata() + public function chargeShouldCreateMetadata(): void { $metadata = new Metadata(); $metadata->setShopType('Shopware'); @@ -115,11 +107,8 @@ public function chargeShouldCreateMetadata() * Verify Metadata is fetched when payment is fetched. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function paymentShouldFetchMetadataResourceOnFetch() + public function paymentShouldFetchMetadataResourceOnFetch(): void { $metadata = (new Metadata())->addMetadata('key', 'value'); @@ -138,11 +127,8 @@ public function paymentShouldFetchMetadataResourceOnFetch() * Verify error is thrown when metadata is empty. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function emptyMetaDataShouldLeadToError() + public function emptyMetaDataShouldLeadToError(): void { $metadata = new Metadata(); $this->expectException(HeidelpayApiException::class); diff --git a/test/integration/TransactionTypes/AuthorizationTest.php b/test/integration/TransactionTypes/AuthorizationTest.php index ee5252c7..02284979 100644 --- a/test/integration/TransactionTypes/AuthorizationTest.php +++ b/test/integration/TransactionTypes/AuthorizationTest.php @@ -1,4 +1,6 @@ heidelpay->createPaymentType(new Paypal()); $authorize = $this->heidelpay->authorize(100.0, 'EUR', $paymentType->getId(), self::RETURN_URL); @@ -64,11 +60,8 @@ public function authorizeWithTypeId() * Verify heidelpay object can perform an authorization based on the paymentType object. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function authorizeWithType() + public function authorizeWithType(): void { $paymentType = $this->heidelpay->createPaymentType(new Paypal()); $authorize = $this->heidelpay->authorize(100.0, 'EUR', $paymentType, self::RETURN_URL); @@ -80,11 +73,8 @@ public function authorizeWithType() * Verify authorization produces Payment and Customer. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function authorizationProducesPaymentAndCustomer() + public function authorizationProducesPaymentAndCustomer(): void { $paymentType = $this->heidelpay->createPaymentType(new Paypal()); $customer = $this->getMinimalCustomer(); @@ -106,9 +96,6 @@ public function authorizationProducesPaymentAndCustomer() * @test * * @return Authorization - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ public function authorizationWithCustomerId(): Authorization { @@ -134,12 +121,8 @@ public function authorizationWithCustomerId(): Authorization * @test * * @param Authorization $authorization - * - * @throws HeidelpayApiException - * @throws Exception - * @throws RuntimeException */ - public function authorizationCanBeFetched(Authorization $authorization) + public function authorizationCanBeFetched(Authorization $authorization): void { $fetchedAuthorization = $this->heidelpay->fetchAuthorization($authorization->getPaymentId()); $this->assertEquals($authorization->expose(), $fetchedAuthorization->expose()); @@ -153,11 +136,8 @@ public function authorizationCanBeFetched(Authorization $authorization) * * @param BasePaymentType|AbstractHeidelpayResource $paymentType * @param string $expectedState The state the transaction is expected to be in. - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function authorizeHasExpectedStates(BasePaymentType $paymentType, $expectedState) + public function authorizeHasExpectedStates(BasePaymentType $paymentType, $expectedState): void { $paymentType = $this->heidelpay->createPaymentType($paymentType); $authorize = $this->heidelpay->authorize(100.0, 'EUR', $paymentType->getId(), self::RETURN_URL, null, null, null, null, false); @@ -170,11 +150,8 @@ public function authorizeHasExpectedStates(BasePaymentType $paymentType, $expect * Verify authorize accepts all parameters. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function authorizeShouldAcceptAllParameters() + public function authorizeShouldAcceptAllParameters(): void { /** @var Card $card */ $card = $this->heidelpay->createPaymentType($this->createCardObject()); @@ -220,8 +197,6 @@ public function authorizeShouldAcceptAllParameters() /** * @return array - * - * @throws RuntimeException */ public function authorizeHasExpectedStatesDP(): array { diff --git a/test/integration/TransactionTypes/CancelAfterAuthorizationTest.php b/test/integration/TransactionTypes/CancelAfterAuthorizationTest.php index 34e859cb..13fd8d08 100644 --- a/test/integration/TransactionTypes/CancelAfterAuthorizationTest.php +++ b/test/integration/TransactionTypes/CancelAfterAuthorizationTest.php @@ -1,4 +1,6 @@ heidelpay->createPaymentType($this->createCardObject()); $authorization = $this->heidelpay->authorize(100.0000, 'EUR', $card, self::RETURN_URL, null, null, null, null, false); @@ -66,11 +63,8 @@ public function fullCancelOnAuthorization() * Verify part cancel on an authorization. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function partCancelOnPayment() + public function partCancelOnPayment(): void { $card = $this->heidelpay->createPaymentType($this->createCardObject()); $authorization = $this->heidelpay->authorize(100.0000, 'EUR', $card, self::RETURN_URL, null, null, null, null, false); @@ -87,11 +81,8 @@ public function partCancelOnPayment() * Verify part cancel after authorization. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function partCancelOnAuthorize() + public function partCancelOnAuthorize(): void { $card = $this->heidelpay->createPaymentType($this->createCardObject()); $authorization = $this->heidelpay->authorize(100.0000, 'EUR', $card, self::RETURN_URL, null, null, null, null, false); @@ -112,11 +103,8 @@ public function partCancelOnAuthorize() * Verify a cancel can be fetched. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function anAuthorizationsFullReversalShallBeFetchable() + public function anAuthorizationsFullReversalShallBeFetchable(): void { $card = $this->heidelpay->createPaymentType($this->createCardObject()); $authorization = $this->heidelpay->authorize(100.0000, 'EUR', $card, self::RETURN_URL, null, null, null, null, false); @@ -150,11 +138,8 @@ public function anAuthorizationsFullReversalShallBeFetchable() * Verify cancels can be fetched. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function anAuthorizationsReversalsShouldBeFetchable() + public function anAuthorizationsReversalsShouldBeFetchable(): void { $card = $this->heidelpay->createPaymentType($this->createCardObject()); $authorization = $this->heidelpay->authorize(100.0000, 'EUR', $card, self::RETURN_URL, null, null, null, null, false); diff --git a/test/integration/TransactionTypes/CancelAfterChargeTest.php b/test/integration/TransactionTypes/CancelAfterChargeTest.php index a3041740..cabd3211 100644 --- a/test/integration/TransactionTypes/CancelAfterChargeTest.php +++ b/test/integration/TransactionTypes/CancelAfterChargeTest.php @@ -1,4 +1,6 @@ heidelpay->cancelCharge($charge); $this->assertNotNull($refund); @@ -80,11 +74,8 @@ public function chargeShouldBeFullyRefundable(Charge $charge) * Verify full refund of a charge. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargeShouldBeFullyRefundableWithId() + public function chargeShouldBeFullyRefundableWithId(): void { $paymentType = $this->heidelpay->createPaymentType(new SepaDirectDebit('DE89370400440532013000')); $charge = $this->heidelpay->charge(100.0000, 'EUR', $paymentType, self::RETURN_URL); @@ -98,11 +89,8 @@ public function chargeShouldBeFullyRefundableWithId() * Verify partial refund of a charge. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargeShouldBePartlyRefundableWithId() + public function chargeShouldBePartlyRefundableWithId(): void { $paymentType = $this->heidelpay->createPaymentType(new SepaDirectDebit('DE89370400440532013000')); $charge = $this->heidelpay->charge(100.0000, 'EUR', $paymentType, self::RETURN_URL); @@ -125,11 +113,8 @@ public function chargeShouldBePartlyRefundableWithId() * Verify partial refund of a charge. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargeShouldBePartlyRefundable() + public function chargeShouldBePartlyRefundable(): void { $paymentType = $this->heidelpay->createPaymentType(new SepaDirectDebit('DE89370400440532013000')); $charge = $this->heidelpay->charge(100.0000, 'EUR', $paymentType, self::RETURN_URL); @@ -152,11 +137,8 @@ public function chargeShouldBePartlyRefundable() * Verify payment reference can be set in cancel charge transaction aka refund. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function cancelShouldAcceptPaymentReferenceParameter() + public function cancelShouldAcceptPaymentReferenceParameter(): void { $paymentType = $this->heidelpay->createPaymentType(new SepaDirectDebit('DE89370400440532013000')); $charge = $this->heidelpay->charge(100.0000, 'EUR', $paymentType, self::RETURN_URL); diff --git a/test/integration/TransactionTypes/CancelTest.php b/test/integration/TransactionTypes/CancelTest.php index b44e0d68..06b95502 100644 --- a/test/integration/TransactionTypes/CancelTest.php +++ b/test/integration/TransactionTypes/CancelTest.php @@ -1,4 +1,6 @@ createCardAuthorization(); $cancel = $authorization->cancel(); @@ -51,11 +48,8 @@ public function reversalShouldBeFetchableViaHeidelpayObject() * Verify reversal is fetchable. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function reversalShouldBeFetchableViaPaymentObject() + public function reversalShouldBeFetchableViaPaymentObject(): void { $authorization = $this->createCardAuthorization(); $cancel = $authorization->cancel(); @@ -68,11 +62,8 @@ public function reversalShouldBeFetchableViaPaymentObject() * Verify refund is fetchable. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function refundShouldBeFetchableViaHeidelpayObject() + public function refundShouldBeFetchableViaHeidelpayObject(): void { $charge = $this->createCharge(); $cancel = $charge->cancel(); @@ -85,11 +76,8 @@ public function refundShouldBeFetchableViaHeidelpayObject() * Verify refund is fetchable. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function refundShouldBeFetchableViaPaymentObject() + public function refundShouldBeFetchableViaPaymentObject(): void { $charge = $this->createCharge(); $cancel = $charge->cancel(); @@ -102,11 +90,8 @@ public function refundShouldBeFetchableViaPaymentObject() * Verify reversal is fetchable via payment object. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function authorizationCancellationsShouldBeFetchableViaPaymentObject() + public function authorizationCancellationsShouldBeFetchableViaPaymentObject(): void { $authorization = $this->createCardAuthorization(); $reversal = $authorization->cancel(); @@ -121,11 +106,8 @@ public function authorizationCancellationsShouldBeFetchableViaPaymentObject() * Verify refund is fetchable via payment object. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargeCancellationsShouldBeFetchableViaPaymentObject() + public function chargeCancellationsShouldBeFetchableViaPaymentObject(): void { $charge = $this->createCharge(); $reversal = $charge->cancel(); @@ -140,11 +122,8 @@ public function chargeCancellationsShouldBeFetchableViaPaymentObject() * Verify transaction status. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function cancelStatusIsSetCorrectly() + public function cancelStatusIsSetCorrectly(): void { $charge = $this->createCharge(); $reversal = $charge->cancel(); diff --git a/test/integration/TransactionTypes/ChargeAfterAuthorizationTest.php b/test/integration/TransactionTypes/ChargeAfterAuthorizationTest.php index 98e94b8c..4b813e91 100644 --- a/test/integration/TransactionTypes/ChargeAfterAuthorizationTest.php +++ b/test/integration/TransactionTypes/ChargeAfterAuthorizationTest.php @@ -1,4 +1,6 @@ createCardAuthorization(); $payment = $authorization->getPayment(); @@ -57,11 +54,8 @@ public function authorizationShouldBeFullyChargeable() * Validate full charge after authorization. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function authorizationShouldBeFullyChargeableViaHeidelpayObject() + public function authorizationShouldBeFullyChargeableViaHeidelpayObject(): void { $authorization = $this->createCardAuthorization(); $payment = $authorization->getPayment(); @@ -80,11 +74,8 @@ public function authorizationShouldBeFullyChargeableViaHeidelpayObject() * Verify authorization is partly chargeable. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function authorizationShouldBePartlyChargeable() + public function authorizationShouldBePartlyChargeable(): void { $authorization = $this->createCardAuthorization(); $payment = $authorization->getPayment(); diff --git a/test/integration/TransactionTypes/ChargeTest.php b/test/integration/TransactionTypes/ChargeTest.php index 8e5c01bd..cb7b3b2f 100644 --- a/test/integration/TransactionTypes/ChargeTest.php +++ b/test/integration/TransactionTypes/ChargeTest.php @@ -1,4 +1,6 @@ heidelpay->createPaymentType(new SepaDirectDebit('DE89370400440532013000')); $charge = $this->heidelpay->charge(100.0, 'EUR', $paymentType->getId(), self::RETURN_URL); @@ -57,11 +54,8 @@ public function chargeShouldWorkWithTypeId() * Verify charging with payment type. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargeShouldWorkWithTypeObject() + public function chargeShouldWorkWithTypeObject(): void { $paymentType = $this->heidelpay->createPaymentType(new SepaDirectDebit('DE89370400440532013000')); $charge = $this->heidelpay->charge(100.0, 'EUR', $paymentType, self::RETURN_URL); @@ -75,11 +69,8 @@ public function chargeShouldWorkWithTypeObject() * Verify transaction status. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargeStatusIsSetCorrectly() + public function chargeStatusIsSetCorrectly(): void { $this->assertSuccess($this->createCharge()); } @@ -88,11 +79,8 @@ public function chargeStatusIsSetCorrectly() * Verify charge accepts all parameters. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargeShouldAcceptAllParameters() + public function chargeShouldAcceptAllParameters(): void { // prepare test data /** @var Card $paymentType */ @@ -137,11 +125,8 @@ public function chargeShouldAcceptAllParameters() * Verify charge accepts all parameters. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargeWithCustomerShouldAcceptAllParameters() + public function chargeWithCustomerShouldAcceptAllParameters(): void { // prepare test data /** @var InvoiceGuaranteed $ivg */ diff --git a/test/integration/TransactionTypes/PayoutTest.php b/test/integration/TransactionTypes/PayoutTest.php index 398a57c1..0fb7d22e 100644 --- a/test/integration/TransactionTypes/PayoutTest.php +++ b/test/integration/TransactionTypes/PayoutTest.php @@ -1,4 +1,6 @@ heidelpay->createPaymentType($this->createCardObject()); @@ -69,11 +65,8 @@ public function payoutCanBeCalledForCardType() * Verify payout can be performed for sepa direct debit payment type. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function payoutCanBeCalledForSepaDirectDebitType() + public function payoutCanBeCalledForSepaDirectDebitType(): void { $sepa = new SepaDirectDebit('DE89370400440532013000'); $this->heidelpay->createPaymentType($sepa); @@ -91,11 +84,8 @@ public function payoutCanBeCalledForSepaDirectDebitType() * Verify payout can be performed for sepa direct debit guaranteed payment type. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function payoutCanBeCalledForSepaDirectDebitGuaranteedType() + public function payoutCanBeCalledForSepaDirectDebitGuaranteedType(): void { $sepa = new SepaDirectDebitGuaranteed('DE89370400440532013000'); $this->heidelpay->createPaymentType($sepa); @@ -114,12 +104,8 @@ public function payoutCanBeCalledForSepaDirectDebitGuaranteedType() * Verify Payout transaction is fetched with Payment resource. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws Exception */ - public function payoutShouldBeFetchedWhenItsPaymentResourceIsFetched() + public function payoutShouldBeFetchedWhenItsPaymentResourceIsFetched(): void { /** @var Card $card */ $card = $this->heidelpay->createPaymentType($this->createCardObject()); @@ -136,11 +122,8 @@ public function payoutShouldBeFetchedWhenItsPaymentResourceIsFetched() * Verify Payout can be fetched via url. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function payoutShouldBeFetchableViaItsUrl() + public function payoutShouldBeFetchableViaItsUrl(): void { /** @var Card $card */ $card = $this->heidelpay->createPaymentType($this->createCardObject()); @@ -155,11 +138,8 @@ public function payoutShouldBeFetchableViaItsUrl() * Verify payout accepts all parameters. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function payoutShouldAcceptAllParameters() + public function payoutShouldAcceptAllParameters(): void { /** @var Card $card */ $card = $this->heidelpay->createPaymentType($this->createCardObject()); diff --git a/test/integration/TransactionTypes/ShipmentTest.php b/test/integration/TransactionTypes/ShipmentTest.php index b18d87b5..4809e62b 100644 --- a/test/integration/TransactionTypes/ShipmentTest.php +++ b/test/integration/TransactionTypes/ShipmentTest.php @@ -1,4 +1,6 @@ getMaximumCustomerInclShippingAddress()->setShippingAddress($this->getBillingAddress()); @@ -61,11 +58,8 @@ public function shipmentShouldBeCreatableAndFetchable() * Verify shipment transaction can be called on the payment object. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function shipmentCanBeCalledOnThePaymentObject() + public function shipmentCanBeCalledOnThePaymentObject(): void { $invoiceGuaranteed = new InvoiceGuaranteed(); $customer = $this->getMaximumCustomerInclShippingAddress()->setShippingAddress($this->getBillingAddress()); @@ -91,11 +85,8 @@ public function shipmentCanBeCalledOnThePaymentObject() * Verify shipment can be performed with payment object. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function shipmentShouldBePossibleWithPaymentObject() + public function shipmentShouldBePossibleWithPaymentObject(): void { $invoiceGuaranteed = new InvoiceGuaranteed(); $customer = $this->getMaximumCustomerInclShippingAddress()->setShippingAddress($this->getBillingAddress()); @@ -111,11 +102,8 @@ public function shipmentShouldBePossibleWithPaymentObject() * Verify transaction status. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function shipmentStatusIsSetCorrectly() + public function shipmentStatusIsSetCorrectly(): void { $invoiceGuaranteed = new InvoiceGuaranteed(); $customer = $this->getMaximumCustomerInclShippingAddress()->setShippingAddress($this->getBillingAddress()); diff --git a/test/integration/WebhookTest.php b/test/integration/WebhookTest.php index 9bf1cee7..92ba6f13 100755 --- a/test/integration/WebhookTest.php +++ b/test/integration/WebhookTest.php @@ -1,4 +1,6 @@ @@ -46,12 +46,8 @@ class WebhookTest extends BasePaymentTest * @dataProvider webhookResourceCanBeRegisteredAndFetchedDP * * @param string $event - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function webhookResourceCanBeRegisteredAndFetched($event) + public function webhookResourceCanBeRegisteredAndFetched($event): void { $url = $this->generateUniqueUrl(); $webhook = $this->heidelpay->createWebhook($url, $event); @@ -66,12 +62,8 @@ public function webhookResourceCanBeRegisteredAndFetched($event) * Verify Webhook url can be updated. * * @test - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function webhookUrlShouldBeUpdateable() + public function webhookUrlShouldBeUpdateable(): void { $url = $this->generateUniqueUrl(); $webhook = $this->heidelpay->createWebhook($url, WebhookEvents::ALL); @@ -90,12 +82,8 @@ public function webhookUrlShouldBeUpdateable() * Verify Webhook event can not be updated. * * @test - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function webhookEventShouldNotBeUpdateable() + public function webhookEventShouldNotBeUpdateable(): void { $webhook = $this->heidelpay->createWebhook($this->generateUniqueUrl(), WebhookEvents::ALL); $fetchedWebhook = $this->heidelpay->fetchWebhook($webhook->getId()); @@ -112,12 +100,8 @@ public function webhookEventShouldNotBeUpdateable() * Verify Webhook resource can be deleted. * * @test - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function webhookResourceShouldBeDeletable() + public function webhookResourceShouldBeDeletable(): void { $webhook = $this->heidelpay->createWebhook($this->generateUniqueUrl(), WebhookEvents::ALL); $fetchedWebhook = $this->heidelpay->fetchWebhook($webhook->getId()); @@ -134,12 +118,8 @@ public function webhookResourceShouldBeDeletable() * Verify webhook create will throw error when the event is already registered for the given URL. * * @test - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function webhookCreateShouldThrowErrorWhenEventIsAlreadyRegistered() + public function webhookCreateShouldThrowErrorWhenEventIsAlreadyRegistered(): void { $url = $this->generateUniqueUrl(); $this->heidelpay->createWebhook($url, WebhookEvents::ALL); @@ -157,12 +137,8 @@ public function webhookCreateShouldThrowErrorWhenEventIsAlreadyRegistered() * Verify fetching all registered webhooks will return an array of webhooks. * * @test - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function fetchWebhooksShouldReturnArrayOfRegisteredWebhooks() + public function fetchWebhooksShouldReturnArrayOfRegisteredWebhooks(): void { // --- Prepare --> remove all existing webhooks // start workaround - avoid error deleting non existing webhooks @@ -193,12 +169,8 @@ public function fetchWebhooksShouldReturnArrayOfRegisteredWebhooks() * @test * * @depends webhookResourceCanBeRegisteredAndFetched - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function allWebhooksShouldBeRemovableAtOnce() + public function allWebhooksShouldBeRemovableAtOnce(): void { // --- Verify webhooks have been registered --- $webhooks = $this->heidelpay->fetchAllWebhooks(); @@ -215,11 +187,8 @@ public function allWebhooksShouldBeRemovableAtOnce() * * @test * @depends allWebhooksShouldBeRemovableAtOnce - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function bulkSettingWebhookEventsShouldBePossible() + public function bulkSettingWebhookEventsShouldBePossible(): void { $webhookEvents = [WebhookEvents::AUTHORIZE, WebhookEvents::CHARGE, WebhookEvents::SHIPMENT]; $url = $this->generateUniqueUrl(); @@ -238,18 +207,15 @@ public function bulkSettingWebhookEventsShouldBePossible() // check whether all of the webhookEvents exist sort($webhookEvents); sort($registeredEvents); - $this->assertArraySubset($webhookEvents, $registeredEvents); + $this->assertEquals($webhookEvents, $registeredEvents); } /** * Verify setting one event with bulk setting. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function bulkSettingOnlyOneWebhookShouldBePossible() + public function bulkSettingOnlyOneWebhookShouldBePossible(): void { // remove all existing webhooks a avoid errors here $this->heidelpay->deleteAllWebhooks(); diff --git a/test/script/travis_before_install.sh b/test/script/travis_before_install.sh index 61a9e873..6466c42c 100755 --- a/test/script/travis_before_install.sh +++ b/test/script/travis_before_install.sh @@ -4,11 +4,16 @@ set -e trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR ## backup and disable xdebug +# shellcheck disable=SC2046 cp ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ~/.phpenv/versions/$(phpenv version-name)/xdebug.ini.bak +# shellcheck disable=SC2046 echo > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini phpenv rehash -# create directories for the tests +echo "openssl version" +openssl version + +## create directories for the tests mkdir -p build/logs composer self-update diff --git a/test/script/travis_install.sh b/test/script/travis_install.sh index f77c44e7..f93c1681 100755 --- a/test/script/travis_install.sh +++ b/test/script/travis_install.sh @@ -3,7 +3,6 @@ set -e trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR -PHPVER=$(phpenv version-name) INSTALL_COMMAND="composer install --no-interaction --prefer-dist" UPDATE_COMMAND="composer update --no-interaction --prefer-source" diff --git a/test/script/travis_script.sh b/test/script/travis_script.sh index 3170b704..74b6d3bc 100755 --- a/test/script/travis_script.sh +++ b/test/script/travis_script.sh @@ -7,6 +7,7 @@ trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit ./vendor/bin/php-cs-fixer fix --dry-run --diff --verbose ## enable xdebug again +# shellcheck disable=SC2046 mv ~/.phpenv/versions/$(phpenv version-name)/xdebug.ini.bak ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ## run the unit tests diff --git a/test/unit/Constants/PaymentStateTest.php b/test/unit/Constants/PaymentStateTest.php index 01f0c511..2cad6fb5 100755 --- a/test/unit/Constants/PaymentStateTest.php +++ b/test/unit/Constants/PaymentStateTest.php @@ -1,4 +1,6 @@ assertEquals($name, PaymentState::mapStateCodeToName($code)); } @@ -54,10 +54,8 @@ public function shouldMapCodeToName($code, $name) * * @param integer $code * @param string $name - * - * @throws RuntimeException */ - public function shouldMapNameToCode($name, $code) + public function shouldMapNameToCode($name, $code): void { $this->assertEquals($code, PaymentState::mapStateNameToCode($name)); } @@ -66,10 +64,8 @@ public function shouldMapNameToCode($name, $code) * This verifies that an exception is thrown when the code to map is unknown. * * @test - * - * @throws RuntimeException */ - public function mapCodeToNameShouldThrowAnExceptionIfTheCodeIsUnknown() + public function mapCodeToNameShouldThrowAnExceptionIfTheCodeIsUnknown(): void { $this->expectException(RuntimeException::class); @@ -80,10 +76,8 @@ public function mapCodeToNameShouldThrowAnExceptionIfTheCodeIsUnknown() * This verifies that an exception is thrown when the name to map is unknown. * * @test - * - * @throws RuntimeException */ - public function mapNameToCodeShouldThrowAnExceptionIfTheNameIsUnknown() + public function mapNameToCodeShouldThrowAnExceptionIfTheNameIsUnknown(): void { $this->expectException(RuntimeException::class); diff --git a/test/unit/DummyResource.php b/test/unit/DummyResource.php index e1e4d9e6..e5b069c8 100755 --- a/test/unit/DummyResource.php +++ b/test/unit/DummyResource.php @@ -1,4 +1,6 @@ assertEquals(HeidelpayApiException::CLIENT_MESSAGE, $exception->getClientMessage()); @@ -54,10 +53,8 @@ public function heidelpayApiExceptionShouldReturnDefaultDataWhenNoneIsSet() * * @param array $expected * @param array $testData - * - * @throws Exception */ - public function heidelpayApiExceptionShouldReturnTheGivenData(array $testData, array $expected) + public function heidelpayApiExceptionShouldReturnTheGivenData(array $testData, array $expected): void { $exception = new HeidelpayApiException($testData['message'], $testData['clientMessage'], $testData['code'], $testData['errorId']); $this->assertEquals($expected['message'], $exception->getMerchantMessage()); diff --git a/test/unit/HeidelpayTest.php b/test/unit/HeidelpayTest.php index fc864eaa..7e8cc5fa 100755 --- a/test/unit/HeidelpayTest.php +++ b/test/unit/HeidelpayTest.php @@ -1,5 +1,6 @@ -assertInstanceOf(ResourceService::class, $heidelpay->getResourceService()); - $this->assertInstanceOf(PaymentService::class, $heidelpay->getPaymentService()); + $paymentService = $heidelpay->getPaymentService(); + $this->assertInstanceOf(PaymentService::class, $paymentService); $this->assertInstanceOf(WebhookService::class, $heidelpay->getWebhookService()); - $this->assertSame($heidelpay, $heidelpay->getPaymentService()->getHeidelpay()); + /** @var PaymentService $paymentService */ + $this->assertSame($heidelpay, $paymentService->getHeidelpay()); $this->assertEquals('s-priv-1234', $heidelpay->getKey()); $this->assertEquals(null, $heidelpay->getLocale()); @@ -79,10 +77,8 @@ public function constructorShouldInitPropertiesProperly() * Verify getters and setters work properly. * * @test - * - * @throws RuntimeException */ - public function gettersAndSettersShouldWorkProperly() + public function gettersAndSettersShouldWorkProperly(): void { $heidelpay = new Heidelpay('s-priv-1234'); $heidelpay->setLocale('myLocale'); @@ -96,7 +92,6 @@ public function gettersAndSettersShouldWorkProperly() } $httpService = new HttpService(); - $this->assertInstanceOf(HttpService::class, $heidelpay->getHttpService()); $this->assertNotSame($httpService, $heidelpay->getHttpService()); $heidelpay->setHttpService($httpService); $this->assertSame($httpService, $heidelpay->getHttpService()); @@ -137,16 +132,13 @@ public function gettersAndSettersShouldWorkProperly() * @param array $heidelpayParams * @param string $serviceMethod * @param array $serviceParams - * - * @throws ReflectionException - * @throws RuntimeException */ public function heidelpayShouldForwardResourceActionCallsToTheResourceService( $heidelpayMethod, array $heidelpayParams, $serviceMethod, array $serviceParams - ) { + ): void { /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods([$serviceMethod])->getMock(); $resourceSrvMock->expects($this->once())->method($serviceMethod)->with(...$serviceParams); @@ -165,16 +157,13 @@ public function heidelpayShouldForwardResourceActionCallsToTheResourceService( * @param array $heidelpayParams * @param string $serviceMethod * @param array $serviceParams - * - * @throws ReflectionException - * @throws RuntimeException */ public function heidelpayShouldForwardPaymentActionCallsToThePaymentService( $heidelpayMethod, array $heidelpayParams, $serviceMethod, array $serviceParams - ) { + ): void { /** @var PaymentService|MockObject $paymentSrvMock */ $paymentSrvMock = $this->getMockBuilder(PaymentService::class)->disableOriginalConstructor()->setMethods([$serviceMethod])->getMock(); $paymentSrvMock->expects($this->once())->method($serviceMethod)->with(...$serviceParams); @@ -193,16 +182,13 @@ public function heidelpayShouldForwardPaymentActionCallsToThePaymentService( * @param array $heidelpayParams * @param string $serviceMethod * @param array $serviceParams - * - * @throws ReflectionException - * @throws RuntimeException */ public function heidelpayShouldForwardWebhookActionCallsToTheWebhookService( $heidelpayMethod, array $heidelpayParams, $serviceMethod, array $serviceParams - ) { + ): void { /** @var WebhookService|MockObject $webhookSrvMock */ $webhookSrvMock = $this->getMockBuilder(WebhookService::class)->disableOriginalConstructor()->setMethods([$serviceMethod])->getMock(); $webhookSrvMock->expects($this->once())->method($serviceMethod)->with(...$serviceParams); @@ -221,16 +207,13 @@ public function heidelpayShouldForwardWebhookActionCallsToTheWebhookService( * @param array $heidelpayParams * @param string $serviceMethod * @param array $serviceParams - * - * @throws ReflectionException - * @throws RuntimeException */ public function heidelpayShouldForwardCancelActionCallsToTheCancelService( $heidelpayMethod, array $heidelpayParams, $serviceMethod, array $serviceParams - ) { + ): void { /** @var CancelService|MockObject $cancelSrvMock */ $cancelSrvMock = $this->getMockBuilder(CancelService::class)->disableOriginalConstructor()->setMethods([$serviceMethod])->getMock(); $cancelSrvMock->expects($this->once())->method($serviceMethod)->with(...$serviceParams); @@ -245,9 +228,6 @@ public function heidelpayShouldForwardCancelActionCallsToTheCancelService( * Provide test data for heidelpayShouldForwardResourceActionCallsToTheResourceService. * * @return array - * - * @throws Exception - * @throws RuntimeException */ public static function resourceServiceDP(): array { @@ -312,8 +292,6 @@ public static function resourceServiceDP(): array * Provide test data for heidelpayShouldForwardPaymentActionCallsToThePaymentService. * * @return array - * - * @throws Exception */ public static function paymentServiceDP(): array { diff --git a/test/unit/Resources/AbstractHeidelpayResourceTest.php b/test/unit/Resources/AbstractHeidelpayResourceTest.php index 8962626f..37a9ea83 100755 --- a/test/unit/Resources/AbstractHeidelpayResourceTest.php +++ b/test/unit/Resources/AbstractHeidelpayResourceTest.php @@ -1,4 +1,6 @@ assertNull($customer->getId()); @@ -91,10 +87,8 @@ public function settersAndGettersShouldWork() * Verify getParentResource throws exception if it is not set. * * @test - * - * @throws RuntimeException */ - public function getParentResourceShouldThrowExceptionIfItIsNotSet() + public function getParentResourceShouldThrowExceptionIfItIsNotSet(): void { $customer = new Customer(); @@ -107,11 +101,8 @@ public function getParentResourceShouldThrowExceptionIfItIsNotSet() * Verify getHeidelpayObject calls getParentResource. * * @test - * - * @throws RuntimeException - * @throws ReflectionException */ - public function getHeidelpayObjectShouldCallGetParentResourceOnce() + public function getHeidelpayObjectShouldCallGetParentResourceOnce(): void { $customerMock = $this->getMockBuilder(Customer::class)->setMethods(['getParentResource'])->getMock(); $customerMock->expects($this->once())->method('getParentResource'); @@ -124,10 +115,8 @@ public function getHeidelpayObjectShouldCallGetParentResourceOnce() * Verify getter/setter of ParentResource and Heidelpay object. * * @test - * - * @throws RuntimeException */ - public function parentResourceAndHeidelpayGetterSetterShouldWork() + public function parentResourceAndHeidelpayGetterSetterShouldWork(): void { $heidelpayObj = new Heidelpay('s-priv-123'); $customer = new Customer(); @@ -140,11 +129,8 @@ public function parentResourceAndHeidelpayGetterSetterShouldWork() * Verify getUri will call parentResource. * * @test - * - * @throws RuntimeException - * @throws ReflectionException */ - public function getUriWillCallGetUriOnItsParentResource() + public function getUriWillCallGetUriOnItsParentResource(): void { $heidelpayMock = $this->getMockBuilder(Heidelpay::class) ->disableOriginalConstructor() @@ -166,11 +152,8 @@ public function getUriWillCallGetUriOnItsParentResource() * * @param AbstractHeidelpayResource $resource * @param string $resourcePath - * - * @throws ReflectionException - * @throws RuntimeException */ - public function getUriWillAddIdToTheUriIfItIsSetAndAppendIdIsSet(AbstractHeidelpayResource$resource, $resourcePath) + public function getUriWillAddIdToTheUriIfItIsSetAndAppendIdIsSet(AbstractHeidelpayResource$resource, $resourcePath): void { $heidelpayMock = $this->getMockBuilder(Heidelpay::class)->disableOriginalConstructor()->setMethods(['getUri'])->getMock(); $heidelpayMock->method('getUri')->willReturn('parent/resource/path/'); @@ -185,11 +168,8 @@ public function getUriWillAddIdToTheUriIfItIsSetAndAppendIdIsSet(AbstractHeidelp * Verify getUri with appendId == true will append the externalId if it is returned and the id is not set. * * @test - * - * @throws RuntimeException - * @throws ReflectionException */ - public function getUriWillAddExternalIdToTheUriIfTheIdIsNotSetButAppendIdIs() + public function getUriWillAddExternalIdToTheUriIfTheIdIsNotSetButAppendIdIs(): void { $heidelpayMock = $this->getMockBuilder(Heidelpay::class) ->disableOriginalConstructor() @@ -211,10 +191,8 @@ public function getUriWillAddExternalIdToTheUriIfTheIdIsNotSetButAppendIdIs() * Verify updateValues will update child objects. * * @test - * - * @throws Exception */ - public function updateValuesShouldUpdateChildObjects() + public function updateValuesShouldUpdateChildObjects(): void { $address = (new Address()) ->setState('DE-BW') @@ -234,7 +212,6 @@ public function updateValuesShouldUpdateChildObjects() $testResponse->billingAddress = json_decode($address->jsonSerialize(), false); $testResponse->companyInfo = json_decode($info->jsonSerialize(), false); - /** @var Customer $customer */ $customer = new Customer(); $customer->handleResponse($testResponse); @@ -257,15 +234,12 @@ public function updateValuesShouldUpdateChildObjects() * Verify updateValues will update resource fields with values from processing group in response. * * @test - * - * @throws Exception */ - public function updateValuesShouldUpdateValuesFromProcessingInTheActualObject() + public function updateValuesShouldUpdateValuesFromProcessingInTheActualObject(): void { $testResponse = new stdClass(); $testResponse->processing = (object)['customerId' => 'cst-id', 'firstname' => 'first', 'lastname' => 'last']; - /** @var Customer $customer */ $customer = CustomerFactory::createCustomer('firstName', 'lastName')->setCustomerId('customerId'); $this->assertEquals('customerId', $customer->getCustomerId()); $this->assertEquals('firstName', $customer->getFirstname()); @@ -281,10 +255,8 @@ public function updateValuesShouldUpdateValuesFromProcessingInTheActualObject() * Verify json_serialize translates a resource in valid json format and values are exposed correctly. * * @test - * - * @throws RuntimeException */ - public function jsonSerializeShouldTranslateResourceIntoJson() + public function jsonSerializeShouldTranslateResourceIntoJson(): void { $heidelpay = new Heidelpay('s-priv-123'); $address = (new Address()) @@ -324,10 +296,8 @@ public function jsonSerializeShouldTranslateResourceIntoJson() * Verify that empty values are not set on expose. * * @test - * - * @throws Exception */ - public function nullValuesShouldBeUnsetOnExpose() + public function nullValuesShouldBeUnsetOnExpose(): void { $customer = new Customer(); $customer->setEmail('my.email@test.com'); @@ -341,10 +311,8 @@ public function nullValuesShouldBeUnsetOnExpose() * Verify that ids of linked resources are added. * * @test - * - * @throws Exception */ - public function idsOfLinkedResourcesShouldBeAddedOnExpose() + public function idsOfLinkedResourcesShouldBeAddedOnExpose(): void { $customer = CustomerFactory::createCustomer('Max', ' Mustermann'); $customer->setId('MyTestId'); @@ -359,9 +327,8 @@ public function idsOfLinkedResourcesShouldBeAddedOnExpose() * Verify null is returned as externalId if the class does not implement the getter any. * * @test - * */ - public function getExternalIdShouldReturnNullIfItIsNotImplementedInTheExtendingClass() + public function getExternalIdShouldReturnNullIfItIsNotImplementedInTheExtendingClass(): void { $customer = CustomerFactory::createCustomer('Max', ' Mustermann'); $customer->setId('MyTestId'); @@ -374,10 +341,8 @@ public function getExternalIdShouldReturnNullIfItIsNotImplementedInTheExtendingC * The object and the transmitted value will be updated. * * @test - * - * @throws RuntimeException */ - public function moreThenFourDecimalPlaces() + public function moreThenFourDecimalPlaces(): void { // general $object = new DummyResource(); @@ -399,12 +364,8 @@ public function moreThenFourDecimalPlaces() * Verify additionalAttributes are set/get properly. * * @test - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function additionalAttributesShouldBeSettable() + public function additionalAttributesShouldBeSettable(): void { $paypage = new Paypage(123.4, 'EUR', self::RETURN_URL); @@ -429,8 +390,6 @@ public function additionalAttributesShouldBeSettable() * Data provider for getUriWillAddIdToTheUriIfItIsSetAndAppendIdIsSet. * * @return array - * - * @throws RuntimeException */ public function uriDataProvider(): array { diff --git a/test/unit/Resources/BasketTest.php b/test/unit/Resources/BasketTest.php index 3ee04815..63acbbb6 100755 --- a/test/unit/Resources/BasketTest.php +++ b/test/unit/Resources/BasketTest.php @@ -1,4 +1,6 @@ assertEquals(0, $basket->getAmountTotalGross()); @@ -79,7 +75,7 @@ public function gettersAndSettersShouldWorkProperly() $this->assertNotSame($basketItem2, $basket->getBasketItemByIndex(0)); $this->assertSame($basketItem2, $basket->getBasketItemByIndex(1)); - $this->assertArraySubset([$basketItem1, $basketItem2], $basket->getBasketItems()); + $this->assertEquals([$basketItem1, $basketItem2], $basket->getBasketItems()); $basket->setBasketItems([]); $this->assertEquals(0, $basket->getItemCount()); @@ -92,12 +88,8 @@ public function gettersAndSettersShouldWorkProperly() * Verify expose will call expose on all attached BasketItems. * * @test - * - * @throws Exception - * @throws ReflectionException - * @throws RuntimeException */ - public function exposeShouldCallExposeOnAllAttachedBasketItems() + public function exposeShouldCallExposeOnAllAttachedBasketItems(): void { $basketItemMock = $this->getMockBuilder(BasketItem::class)->setMethods(['expose'])->getMock(); $basketItemMock->expects($this->once())->method('expose')->willReturn('resultItem1'); @@ -107,18 +99,16 @@ public function exposeShouldCallExposeOnAllAttachedBasketItems() $basket = (new Basket())->setBasketItems([$basketItemMock, $basketItemMock2]); $basketItemsExposed = $basket->expose()['basketItems']; - self::assertContains('resultItem1', $basketItemsExposed); - self::assertContains('resultItem2', $basketItemsExposed); + $this->assertContains('resultItem1', $basketItemsExposed); + $this->assertContains('resultItem2', $basketItemsExposed); } /** * Verify handleResponse will create basket items for each basketitem in response. * * @test - * - * @throws Exception */ - public function handleResponseShouldCreateBasketItemObjectsForAllBasketItemsInResponse() + public function handleResponseShouldCreateBasketItemObjectsForAllBasketItemsInResponse(): void { $response = new stdClass(); $response->basketItems = []; @@ -139,11 +129,8 @@ public function handleResponseShouldCreateBasketItemObjectsForAllBasketItemsInRe * Verify BasketItemReferenceId is set automatically to the items index within the basket array if it is not set. * * @test - * - * @throws Exception - * @throws RuntimeException */ - public function referenceIdShouldBeAutomaticallySetToTheArrayIndexIfItIsNotSet() + public function referenceIdShouldBeAutomaticallySetToTheArrayIndexIfItIsNotSet(): void { $basketItem1 = new BasketItem(); $this->assertNull($basketItem1->getBasketItemReferenceId()); @@ -174,11 +161,9 @@ public function referenceIdShouldBeAutomaticallySetToTheArrayIndexIfItIsNotSet() * * @test * - * @throws Exception - * * @deprecated since 1.2.6.0 */ - public function amountTotalSetterGetterAccessAmountTotalGross() + public function amountTotalSetterGetterAccessAmountTotalGross(): void { $basket = new Basket(); $this->assertEquals($basket->getAmountTotalGross(), $basket->getAmountTotal()); diff --git a/test/unit/Resources/CustomerFactoryTest.php b/test/unit/Resources/CustomerFactoryTest.php index d8fb57ee..e83b6a8a 100644 --- a/test/unit/Resources/CustomerFactoryTest.php +++ b/test/unit/Resources/CustomerFactoryTest.php @@ -1,4 +1,6 @@ assertEquals('Max', $customer->getFirstname()); @@ -53,10 +52,8 @@ public function b2cCustomerIsCreatedAsExpected() * Verify that the factory creates the registered B2B customer object as desired. * * @test - * - * @throws Exception */ - public function registeredB2bCustomerIsCreatedAsExpected() + public function registeredB2bCustomerIsCreatedAsExpected(): void { $address = new Address(); @@ -80,10 +77,8 @@ public function registeredB2bCustomerIsCreatedAsExpected() * Verify that the factory creates the not registered B2B customer object as desired. * * @test - * - * @throws Exception */ - public function notRegisteredB2bCustomerIsCreatedAsExpected() + public function notRegisteredB2bCustomerIsCreatedAsExpected(): void { $address = new Address(); diff --git a/test/unit/Resources/CustomerTest.php b/test/unit/Resources/CustomerTest.php index de55dc3a..e1b8b005 100755 --- a/test/unit/Resources/CustomerTest.php +++ b/test/unit/Resources/CustomerTest.php @@ -1,4 +1,6 @@ assertNull($customer->getCustomerId()); @@ -77,8 +71,8 @@ public function settersAndGettersShouldWork() $customer->setLastname('Universum'); $this->assertEquals('Universum', $customer->getLastname()); - $customer->setBirthDate(new DateTime('1982-11-25')); - $this->assertEquals(new DateTime('1982-11-25'), $customer->getBirthDate()); + $customer->setBirthDate('1982-11-25'); + $this->assertEquals('1982-11-25', $customer->getBirthDate()); $customer->setPhone('1234567890'); $this->assertEquals('1234567890', $customer->getPhone()); @@ -97,10 +91,8 @@ public function settersAndGettersShouldWork() * Verify setter and getter of the billing address. * * @test - * - * @throws RuntimeException */ - public function settersAndGettersOfBillingAddressShouldWork() + public function settersAndGettersOfBillingAddressShouldWork(): void { $address = (new Address()) ->setState('billing_state') @@ -133,10 +125,8 @@ public function settersAndGettersOfBillingAddressShouldWork() * Verify setter and getter of the shipping address. * * @test - * - * @throws RuntimeException */ - public function settersAndGettersOfShippingAddressShouldWork() + public function settersAndGettersOfShippingAddressShouldWork(): void { $address = (new Address()) ->setState('shipping_state') @@ -169,10 +159,8 @@ public function settersAndGettersOfShippingAddressShouldWork() * Verify getters and setters of CompanyInfo * * @test - * - * @throws Exception */ - public function gettersAndSettersOfCompanyInfoShouldWork() + public function gettersAndSettersOfCompanyInfoShouldWork(): void { $companyInfo = new CompanyInfo(); $this->assertEquals(CompanyCommercialSectorItems::OTHER, $companyInfo->getCommercialSector()); @@ -205,12 +193,10 @@ public function gettersAndSettersOfCompanyInfoShouldWork() * * @dataProvider removeRestrictedSymbolsMethodShouldReturnTheCorrectValueDP * - * @throws Exception - * * @param mixed $value * @param mixed $expected */ - public function removeRestrictedSymbolsMethodShouldReturnTheCorrectValue($value, $expected) + public function removeRestrictedSymbolsMethodShouldReturnTheCorrectValue($value, $expected): void { $companyInfo = new CompanyInfo(); $this->assertNull($companyInfo->getFunction()); @@ -223,10 +209,8 @@ public function removeRestrictedSymbolsMethodShouldReturnTheCorrectValue($value, * Verify salutation only uses the given values. * * @test - * - * @throws Exception */ - public function salutationShouldOnlyTakeTheAllowedValues() + public function salutationShouldOnlyTakeTheAllowedValues(): void { $customer = new Customer(); $this->assertEquals(Salutations::UNKNOWN, $customer->getSalutation()); @@ -242,10 +226,8 @@ public function salutationShouldOnlyTakeTheAllowedValues() * Verify a Customer is fetched by customerId if the id is not set. * * @test - * - * @throws RuntimeException */ - public function customerShouldBeFetchedByCustomerIdIfIdIsNotSet() + public function customerShouldBeFetchedByCustomerIdIfIdIsNotSet(): void { $customerId = str_replace(' ', '', microtime()); $customer = (new Customer())->setParentResource(new Heidelpay('s-priv-123'))->setCustomerId($customerId); @@ -257,15 +239,12 @@ public function customerShouldBeFetchedByCustomerIdIfIdIsNotSet() * Verify fetchCustomerByExtCustomerId method will create a customer object set its customerId and call fetch with it. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchCustomerByOrderIdShouldCreateCustomerObjectWithCustomerIdAndCallFetch() + public function fetchCustomerByOrderIdShouldCreateCustomerObjectWithCustomerIdAndCallFetch(): void { $heidelpay = new Heidelpay('s-priv-1234'); $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchResource'])->setConstructorArgs([$heidelpay])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchResource') ->with($this->callback(static function ($customer) use ($heidelpay) { return $customer instanceof Customer && @@ -281,10 +260,8 @@ public function fetchCustomerByOrderIdShouldCreateCustomerObjectWithCustomerIdAn * Verify customer can be updated. * * @test - * - * @throws Exception */ - public function customerShouldBeUpdateable() + public function customerShouldBeUpdateable(): void { // when $customer = new Customer(); diff --git a/test/unit/Resources/DummyHeidelpayResource.php b/test/unit/Resources/DummyHeidelpayResource.php index 128a6d04..8db2da2b 100755 --- a/test/unit/Resources/DummyHeidelpayResource.php +++ b/test/unit/Resources/DummyHeidelpayResource.php @@ -1,4 +1,6 @@ assertNull($amount->getCurrency()); diff --git a/test/unit/Resources/EmbeddedResources/BasketItemTest.php b/test/unit/Resources/EmbeddedResources/BasketItemTest.php index 34907e6e..44af3d61 100755 --- a/test/unit/Resources/EmbeddedResources/BasketItemTest.php +++ b/test/unit/Resources/EmbeddedResources/BasketItemTest.php @@ -1,4 +1,6 @@ assertEquals(1, $basketItem->getQuantity()); diff --git a/test/unit/Resources/EmbeddedResources/GeoLocationTest.php b/test/unit/Resources/EmbeddedResources/GeoLocationTest.php index 91c56622..c00977ff 100644 --- a/test/unit/Resources/EmbeddedResources/GeoLocationTest.php +++ b/test/unit/Resources/EmbeddedResources/GeoLocationTest.php @@ -1,4 +1,6 @@ assertNull($geoLocation->getCountryCode()); diff --git a/test/unit/Resources/InstalmentPlanTest.php b/test/unit/Resources/InstalmentPlanTest.php index 9b093cef..456c60cc 100644 --- a/test/unit/Resources/InstalmentPlanTest.php +++ b/test/unit/Resources/InstalmentPlanTest.php @@ -1,4 +1,6 @@ assertEquals("plans?amount={$amount}¤cy={$currency}&effectiveInterest={$effectiveInterest}&orderDate=2019-11-13", $plans->getResourcePath()); @@ -56,11 +53,8 @@ public function verifyQueryString($amount, $currency, $effectiveInterest) * Verify getters and setters. * * @test - * - * @throws Exception - * @throws \Exception */ - public function gettersAndSettersShouldWorkAsExpected() + public function gettersAndSettersShouldWorkAsExpected(): void { // when $instalmentPlans = new InstalmentPlans(1.234, 'EUR', 23.45); @@ -100,10 +94,8 @@ public function gettersAndSettersShouldWorkAsExpected() * Verify plans can be retrieved. * * @test - * - * @throws Exception */ - public function plansShouldBeRetrievable() + public function plansShouldBeRetrievable(): void { // when $instalmentPlans = new InstalmentPlans(1.234, 'EUR', 23.45); @@ -120,7 +112,8 @@ public function plansShouldBeRetrievable() $this->assertCount(2, $plans); /** @var InstalmentPlan $plan1 */ - list($plan1, $plan2) = $plans; + /** @var InstalmentPlan $plan2 */ + [$plan1, $plan2] = $plans; $this->assertEquals('plan 1', $plan1->getOrderDate()); $this->assertEquals('plan 2', $plan2->getOrderDate()); } diff --git a/test/unit/Resources/KeypairTest.php b/test/unit/Resources/KeypairTest.php index e81f62b6..07a29d81 100755 --- a/test/unit/Resources/KeypairTest.php +++ b/test/unit/Resources/KeypairTest.php @@ -1,4 +1,6 @@ assertFalse($keypair->isDetailed()); @@ -65,10 +61,8 @@ public function gettersAndSettersWorkAsExpected() * Verify that a key pair can be updated on handle response. * * @test - * - * @throws RuntimeException */ - public function aKeypairShouldBeUpdatedThroughResponseHandling() + public function aKeypairShouldBeUpdatedThroughResponseHandling(): void { // when $keypair = new Keypair(); @@ -100,10 +94,8 @@ public function aKeypairShouldBeUpdatedThroughResponseHandling() * Verify that a key pair can be updated with details on handle response. * * @test - * - * @throws RuntimeException */ - public function aKeypairShouldBeUpdatedWithDetailsThroughResponseHandling() + public function aKeypairShouldBeUpdatedWithDetailsThroughResponseHandling(): void { $keypair = new Keypair(); diff --git a/test/unit/Resources/MetadataTest.php b/test/unit/Resources/MetadataTest.php index f6c0c6e2..585fae0e 100755 --- a/test/unit/Resources/MetadataTest.php +++ b/test/unit/Resources/MetadataTest.php @@ -1,4 +1,6 @@ addMetadata('myCustomData', 'Wow I can add custom information'); @@ -51,10 +50,8 @@ public function metaDataShouldAllowForCustomDataToBeSet() * Verify defined data can not be set. * * @test - * - * @throws Exception */ - public function metadataShouldNotAllowForMagicAccessToSdkAndShopData() + public function metadataShouldNotAllowForMagicAccessToSdkAndShopData(): void { $metaData = new Metadata(); $metaData->addMetadata('sdkType', 'sdkType'); @@ -73,10 +70,8 @@ public function metadataShouldNotAllowForMagicAccessToSdkAndShopData() * Verify expose contains all defined data. * * @test - * - * @throws Exception */ - public function exposeShouldGatherAllDefinedDataInTheAnArray() + public function exposeShouldGatherAllDefinedDataInTheAnArray(): void { $metaData = new Metadata(); $metaDataArray = (array)$metaData->expose(); @@ -99,10 +94,8 @@ public function exposeShouldGatherAllDefinedDataInTheAnArray() * Verify metadata can be updated. * * @test - * - * @throws Exception */ - public function handleResponseShouldUpdateMetadata() + public function handleResponseShouldUpdateMetadata(): void { $metaData = new Metadata(); $metaData->addMetadata('myData', 'This should be my Data'); diff --git a/test/unit/Resources/PaymentTest.php b/test/unit/Resources/PaymentTest.php index ab1ea16c..1d29ed9c 100755 --- a/test/unit/Resources/PaymentTest.php +++ b/test/unit/Resources/PaymentTest.php @@ -1,4 +1,6 @@ setParentResource(new Heidelpay('s-priv-1234')); @@ -86,12 +82,9 @@ public function gettersAndSettersShouldWorkProperly() /** * @test * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * * Todo: Workaround to be removed when API sends TraceID in processing-group */ - public function checkTraceIdWorkaround() + public function checkTraceIdWorkaround(): void { // initial check $payment = (new Payment())->setParentResource(new Heidelpay('s-priv-1234')); @@ -108,12 +101,8 @@ public function checkTraceIdWorkaround() * Verify getAuthorization should try to fetch resource if lazy loading is off and the authorization is not null. * * @test - * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function getAuthorizationShouldFetchAuthorizeIfNotLazyAndAuthIsNotNull() + public function getAuthorizationShouldFetchAuthorizeIfNotLazyAndAuthIsNotNull(): void { $payment = (new Payment())->setId('myPaymentId'); $authorization = new Authorization(); @@ -121,9 +110,10 @@ public function getAuthorizationShouldFetchAuthorizeIfNotLazyAndAuthIsNotNull() $resourceServiceMock = $this->getMockBuilder(ResourceService::class) ->disableOriginalConstructor()->setMethods(['getResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('getResource')->with($authorization); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); @@ -134,12 +124,8 @@ public function getAuthorizationShouldFetchAuthorizeIfNotLazyAndAuthIsNotNull() * Verify getAuthorization should try to fetch resource if lazy loading is off and the authorization is not null. * * @test - * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function getAuthorizationShouldNotFetchAuthorizeIfNotLazyAndAuthIsNull() + public function getAuthorizationShouldNotFetchAuthorizeIfNotLazyAndAuthIsNull(): void { $payment = (new Payment())->setId('myPaymentId'); @@ -147,7 +133,7 @@ public function getAuthorizationShouldNotFetchAuthorizeIfNotLazyAndAuthIsNull() ->disableOriginalConstructor()->setMethods(['getResource'])->getMock(); $resourceServiceMock->expects($this->never())->method('getResource'); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); @@ -158,11 +144,8 @@ public function getAuthorizationShouldNotFetchAuthorizeIfNotLazyAndAuthIsNull() * Verify Charge array is handled properly. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargesShouldBeHandledProperly() + public function chargesShouldBeHandledProperly(): void { $payment = new Payment(); $this->assertIsEmptyArray($payment->getCharges()); @@ -170,13 +153,13 @@ public function chargesShouldBeHandledProperly() $charge1 = (new Charge())->setId('firstCharge'); $charge2 = (new Charge())->setId('secondCharge'); - $subset[] = $charge1; + $chargeArray[] = $charge1; $payment->addCharge($charge1); - $this->assertArraySubset($subset, $payment->getCharges()); + $this->assertEquals($chargeArray, $payment->getCharges()); - $subset[] = $charge2; + $chargeArray[] = $charge2; $payment->addCharge($charge2); - $this->assertArraySubset($subset, $payment->getCharges()); + $this->assertEquals($chargeArray, $payment->getCharges()); $this->assertSame($charge2, $payment->getCharge('secondCharge', true)); $this->assertSame($charge1, $payment->getCharge('firstCharge', true)); @@ -189,12 +172,8 @@ public function chargesShouldBeHandledProperly() * Verify getChargeById will fetch the Charge if lazy loading is off and the charge exists. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function getChargeByIdShouldFetchChargeIfItExistsAndLazyLoadingIsOff() + public function getChargeByIdShouldFetchChargeIfItExistsAndLazyLoadingIsOff(): void { $payment = (new Payment())->setId('myPaymentId'); $charge1 = (new Charge())->setId('firstCharge'); @@ -209,7 +188,7 @@ public function getChargeByIdShouldFetchChargeIfItExistsAndLazyLoadingIsOff() ->method('getResource') ->withConsecutive([$charge1], [$charge2]); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); @@ -221,12 +200,8 @@ public function getChargeByIdShouldFetchChargeIfItExistsAndLazyLoadingIsOff() * Verify getCharge will fetch the Charge if lazy loading is off and the charge exists. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function getChargeShouldFetchChargeIfItExistsAndLazyLoadingIsOff() + public function getChargeShouldFetchChargeIfItExistsAndLazyLoadingIsOff(): void { $payment = (new Payment())->setId('myPaymentId'); $charge1 = (new Charge())->setId('firstCharge'); @@ -241,7 +216,7 @@ public function getChargeShouldFetchChargeIfItExistsAndLazyLoadingIsOff() ->method('getResource') ->withConsecutive([$charge1], [$charge2]); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); @@ -253,11 +228,8 @@ public function getChargeShouldFetchChargeIfItExistsAndLazyLoadingIsOff() * Verify getCharge and getChargeById will return null if the Charge does not exist. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function getChargeMethodsShouldReturnNullIfTheChargeIdUnknown() + public function getChargeMethodsShouldReturnNullIfTheChargeIdUnknown(): void { $payment = (new Payment())->setId('myPaymentId'); $charge1 = (new Charge())->setId('firstCharge'); @@ -278,21 +250,18 @@ public function getChargeMethodsShouldReturnNullIfTheChargeIdUnknown() * Verify getPayout should try to fetch resource if lazy loading is off and the authorization is not null. * * @test - * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function getPayoutShouldFetchPayoutIfNotLazyAndPayoutIsNotNull() + public function getPayoutShouldFetchPayoutIfNotLazyAndPayoutIsNotNull(): void { $payment = (new Payment())->setId('myPaymentId'); $payout = new Payout(); $payment->setPayout($payout); $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['getResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('getResource')->with($payout); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); @@ -303,19 +272,15 @@ public function getPayoutShouldFetchPayoutIfNotLazyAndPayoutIsNotNull() * Verify getPayout should try to fetch resource if lazy loading is off and the payout is not null. * * @test - * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function getPayoutShouldNotFetchPayoutIfNotLazyAndPayoutIsNull() + public function getPayoutShouldNotFetchPayoutIfNotLazyAndPayoutIsNull(): void { $payment = (new Payment())->setId('myPaymentId'); $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['getResource'])->getMock(); $resourceServiceMock->expects($this->never())->method('getResource'); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); @@ -326,11 +291,8 @@ public function getPayoutShouldNotFetchPayoutIfNotLazyAndPayoutIsNull() * Verify setCustomer does nothing if the passed customer is empty. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function setCustomerShouldDoNothingIfTheCustomerIsEmpty() + public function setCustomerShouldDoNothingIfTheCustomerIsEmpty(): void { $heidelpayObj = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpayObj); @@ -350,20 +312,17 @@ public function setCustomerShouldDoNothingIfTheCustomerIsEmpty() * Verify setCustomer will try to fetch the customer if it is passed as string (i. e. id). * * @test - * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function setCustomerShouldFetchCustomerIfItIsPassedAsIdString() + public function setCustomerShouldFetchCustomerIfItIsPassedAsIdString(): void { $payment = (new Payment())->setId('myPaymentId'); $resourceServiceMock = $this->getMockBuilder(ResourceService::class) ->disableOriginalConstructor()->setMethods(['fetchCustomer'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('fetchCustomer')->with('MyCustomerId'); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); @@ -374,21 +333,18 @@ public function setCustomerShouldFetchCustomerIfItIsPassedAsIdString() * Verify setCustomer will create the resource if it is passed as object without id. * * @test - * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function setCustomerShouldCreateCustomerIfItIsPassedAsObjectWithoutId() + public function setCustomerShouldCreateCustomerIfItIsPassedAsObjectWithoutId(): void { $payment = (new Payment())->setId('myPaymentId'); $customer = new Customer(); $resourceServiceMock = $this->getMockBuilder(ResourceService::class) ->disableOriginalConstructor()->setMethods(['createCustomer'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('createCustomer')->with($customer); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); @@ -399,11 +355,8 @@ public function setCustomerShouldCreateCustomerIfItIsPassedAsObjectWithoutId() * Verify setPaymentType will do nothing if the paymentType is empty. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function setPaymentTypeShouldDoNothingIfThePaymentTypeIsEmpty() + public function setPaymentTypeShouldDoNothingIfThePaymentTypeIsEmpty(): void { $heidelpayObj = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpayObj); @@ -423,20 +376,17 @@ public function setPaymentTypeShouldDoNothingIfThePaymentTypeIsEmpty() * Verify setPaymentType will try to fetch the payment type if it is passed as string (i. e. id). * * @test - * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function setPaymentTypeShouldFetchResourceIfItIsPassedAsIdString() + public function setPaymentTypeShouldFetchResourceIfItIsPassedAsIdString(): void { $payment = (new Payment())->setId('myPaymentId'); $resourceServiceMock = $this->getMockBuilder(ResourceService::class) ->disableOriginalConstructor()->setMethods(['fetchPaymentType'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('fetchPaymentType')->with('MyPaymentId'); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); @@ -447,21 +397,18 @@ public function setPaymentTypeShouldFetchResourceIfItIsPassedAsIdString() * Verify setCustomer will create the resource if it is passed as object without id. * * @test - * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function setPaymentTypeShouldCreateResourceIfItIsPassedAsObjectWithoutId() + public function setPaymentTypeShouldCreateResourceIfItIsPassedAsObjectWithoutId(): void { $payment = (new Payment())->setId('myPaymentId'); $paymentType = new Sofort(); $resourceServiceMock = $this->getMockBuilder(ResourceService::class) ->disableOriginalConstructor()->setMethods(['createPaymentType'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('createPaymentType')->with($paymentType); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); @@ -472,12 +419,8 @@ public function setPaymentTypeShouldCreateResourceIfItIsPassedAsObjectWithoutId( * Verify getCancellations will call getCancellations on all Charge and Authorization objects to fetch its refunds. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function getCancellationsShouldCollectAllCancellationsOfCorrespondingTransactions() + public function getCancellationsShouldCollectAllCancellationsOfCorrespondingTransactions(): void { $payment = new Payment(); $cancellation1 = (new Cancellation())->setId('cancellation1'); @@ -487,7 +430,7 @@ public function getCancellationsShouldCollectAllCancellationsOfCorrespondingTran $expectedCancellations = []; - $this->assertArraySubset($expectedCancellations, $payment->getCancellations()); + $this->assertEquals($expectedCancellations, $payment->getCancellations()); $authorize = $this->getMockBuilder(Authorization::class)->setMethods(['getCancellations'])->getMock(); $authorize->expects($this->exactly(4))->method('getCancellations')->willReturn([$cancellation1]); @@ -495,7 +438,7 @@ public function getCancellationsShouldCollectAllCancellationsOfCorrespondingTran /** @var Authorization $authorize */ $payment->setAuthorization($authorize); $expectedCancellations[] = $cancellation1; - $this->assertArraySubset($expectedCancellations, $payment->getCancellations()); + $this->assertEquals($expectedCancellations, $payment->getCancellations()); $charge1 = $this->getMockBuilder(Charge::class)->setMethods(['getCancellations'])->getMock(); $charge1->expects($this->exactly(3))->method('getCancellations')->willReturn([$cancellation2]); @@ -503,7 +446,7 @@ public function getCancellationsShouldCollectAllCancellationsOfCorrespondingTran /** @var Charge $charge1 */ $payment->addCharge($charge1); $expectedCancellations[] = $cancellation2; - $this->assertArraySubset($expectedCancellations, $payment->getCancellations()); + $this->assertEquals($expectedCancellations, $payment->getCancellations()); $charge2 = $this->getMockBuilder(Charge::class)->setMethods(['getCancellations'])->getMock(); $charge2->expects($this->exactly(2))->method('getCancellations')->willReturn([$cancellation3, $cancellation4]); @@ -512,26 +455,22 @@ public function getCancellationsShouldCollectAllCancellationsOfCorrespondingTran $payment->addCharge($charge2); $expectedCancellations[] = $cancellation3; $expectedCancellations[] = $cancellation4; - $this->assertArraySubset($expectedCancellations, $payment->getCancellations()); + $this->assertEquals($expectedCancellations, $payment->getCancellations()); $charge3 = $this->getMockBuilder(Charge::class)->setMethods(['getCancellations'])->getMock(); $charge3->expects($this->once())->method('getCancellations')->willReturn([]); /** @var Charge $charge3 */ $payment->addCharge($charge3); - $this->assertArraySubset($expectedCancellations, $payment->getCancellations()); + $this->assertEquals($expectedCancellations, $payment->getCancellations()); } /** * Verify getCancellation calls getCancellations and returns null if cancellation does not exist. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function getCancellationShouldCallGetCancellationsAndReturnNullIfNoCancellationExists() + public function getCancellationShouldCallGetCancellationsAndReturnNullIfNoCancellationExists(): void { $paymentMock = $this->getMockBuilder(Payment::class)->setMethods(['getCancellations'])->getMock(); $paymentMock->expects($this->once())->method('getCancellations')->willReturn([]); @@ -544,12 +483,8 @@ public function getCancellationShouldCallGetCancellationsAndReturnNullIfNoCancel * Verify getCancellation returns cancellation if it exists. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function getCancellationShouldReturnCancellationIfItExists() + public function getCancellationShouldReturnCancellationIfItExists(): void { $cancellation1 = (new Cancellation())->setId('cancellation1'); $cancellation2 = (new Cancellation())->setId('cancellation2'); @@ -567,12 +502,8 @@ public function getCancellationShouldReturnCancellationIfItExists() * Verify getCancellation fetches cancellation if it exists and lazy loading is false. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function getCancellationShouldReturnCancellationIfItExistsAndFetchItIfNotLazy() + public function getCancellationShouldReturnCancellationIfItExistsAndFetchItIfNotLazy(): void { $cancellation = (new Cancellation())->setId('cancellation123'); @@ -581,9 +512,10 @@ public function getCancellationShouldReturnCancellationIfItExistsAndFetchItIfNot $resourceServiceMock = $this->getMockBuilder(ResourceService::class) ->disableOriginalConstructor()->setMethods(['getResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('getResource')->with($cancellation); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); /** @var Payment $paymentMock */ @@ -597,11 +529,8 @@ public function getCancellationShouldReturnCancellationIfItExistsAndFetchItIfNot * Verify Shipments are handled properly. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function shipmentsShouldBeHandledProperly() + public function shipmentsShouldBeHandledProperly(): void { $payment = new Payment(); $this->assertIsEmptyArray($payment->getShipments()); @@ -609,13 +538,13 @@ public function shipmentsShouldBeHandledProperly() $shipment1 = (new Shipment())->setId('firstShipment'); $shipment2 = (new Shipment())->setId('secondShipment'); - $subset[] = $shipment1; + $shipArray[] = $shipment1; $payment->addShipment($shipment1); - $this->assertArraySubset($subset, $payment->getShipments()); + $this->assertEquals($shipArray, $payment->getShipments()); - $subset[] = $shipment2; + $shipArray[] = $shipment2; $payment->addShipment($shipment2); - $this->assertArraySubset($subset, $payment->getShipments()); + $this->assertEquals($shipArray, $payment->getShipments()); $this->assertSame($shipment2, $payment->getShipment('secondShipment', true)); $this->assertSame($shipment1, $payment->getShipment('firstShipment', true)); @@ -625,12 +554,8 @@ public function shipmentsShouldBeHandledProperly() * Verify getCancellation fetches cancellation if it exists and lazy loading is false. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function getShipmentByIdShouldReturnShipmentIfItExistsAndFetchItIfNotLazy() + public function getShipmentByIdShouldReturnShipmentIfItExistsAndFetchItIfNotLazy(): void { $shipment = (new Shipment())->setId('shipment123'); @@ -639,9 +564,10 @@ public function getShipmentByIdShouldReturnShipmentIfItExistsAndFetchItIfNotLazy $resourceServiceMock = $this->getMockBuilder(ResourceService::class) ->disableOriginalConstructor()->setMethods(['getResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('getResource')->with($shipment); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); /** @var Payment $paymentMock */ @@ -655,17 +581,13 @@ public function getShipmentByIdShouldReturnShipmentIfItExistsAndFetchItIfNotLazy * Verify the currency is fetched from the amount object. * * @test - * - * @throws Exception - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function getAndSetCurrencyShouldPropagateToTheAmountObject() + public function getAndSetCurrencyShouldPropagateToTheAmountObject(): void { /** @var Amount|MockObject $amountMock */ $amountMock = $this->getMockBuilder(Amount::class)->setMethods(['getCurrency', 'setCurrency'])->getMock(); $amountMock->expects($this->once())->method('getCurrency')->willReturn('MyTestGetCurrency'); + /** @noinspection PhpParamsInspection */ $amountMock->expects($this->once())->method('setCurrency')->with('MyTestSetCurrency'); $payment = (new Payment())->setAmount($amountMock); @@ -682,11 +604,8 @@ public function getAndSetCurrencyShouldPropagateToTheAmountObject() * @dataProvider stateDataProvider * * @param integer $state - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldUpdateStateId($state) + public function handleResponseShouldUpdateStateId($state): void { $payment = new Payment(); $this->assertEquals(PaymentState::STATE_PENDING, $payment->getState()); @@ -702,11 +621,8 @@ public function handleResponseShouldUpdateStateId($state) * Verify handleResponse updates payment id. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldUpdatePaymentId() + public function handleResponseShouldUpdatePaymentId(): void { $payment = (new Payment())->setId('MyPaymentId'); $this->assertEquals('MyPaymentId', $payment->getId()); @@ -722,20 +638,17 @@ public function handleResponseShouldUpdatePaymentId() * Verify handleResponse fetches Customer if it is not set. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function handleResponseShouldFetchCustomerIfItIsNotSet() + public function handleResponseShouldFetchCustomerIfItIsNotSet(): void { $payment = (new Payment())->setId('myPaymentId'); $resourceServiceMock = $this->getMockBuilder(ResourceService::class) ->disableOriginalConstructor()->setMethods(['fetchCustomer'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('fetchCustomer')->with('MyNewCustomerId'); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); @@ -751,21 +664,18 @@ public function handleResponseShouldFetchCustomerIfItIsNotSet() * Verify handleResponse updates customer if it set. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function handleResponseShouldFetchAndUpdateCustomerIfItIsAlreadySet() + public function handleResponseShouldFetchAndUpdateCustomerIfItIsAlreadySet(): void { $payment = (new Payment())->setId('myPaymentId'); $customer = (new Customer())->setId('customerId'); $resourceServiceMock = $this->getMockBuilder(ResourceService::class) ->disableOriginalConstructor()->setMethods(['getResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('getResource')->with($customer); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); $payment->setCustomer($customer); @@ -780,20 +690,17 @@ public function handleResponseShouldFetchAndUpdateCustomerIfItIsAlreadySet() * Verify handleResponse updates paymentType. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function handleResponseShouldFetchAndUpdatePaymentTypeIfTheIdIsSet() + public function handleResponseShouldFetchAndUpdatePaymentTypeIfTheIdIsSet(): void { $payment = (new Payment())->setId('myPaymentId'); $resourceServiceMock = $this->getMockBuilder(ResourceService::class) ->disableOriginalConstructor()->setMethods(['fetchPaymentType'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('fetchPaymentType')->with('PaymentTypeId'); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); @@ -807,16 +714,13 @@ public function handleResponseShouldFetchAndUpdatePaymentTypeIfTheIdIsSet() * Verify handleResponse updates metadata. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function handleResponseShouldFetchAndUpdateMetadataIfTheIdIsSet() + public function handleResponseShouldFetchAndUpdateMetadataIfTheIdIsSet(): void { $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['fetchMetadata'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('fetchMetadata')->with('MetadataId'); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment = (new Payment())->setId('myPaymentId')->setParentResource($heidelpayObj); @@ -830,17 +734,14 @@ public function handleResponseShouldFetchAndUpdateMetadataIfTheIdIsSet() * Verify handleResponse updates metadata. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function handleResponseShouldGetMetadataIfUnfetchedMetadataObjectWithIdIsGiven() + public function handleResponseShouldGetMetadataIfUnfetchedMetadataObjectWithIdIsGiven(): void { $metadata = (new Metadata())->setId('MetadataId'); $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['getResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('getResource')->with($metadata); - /** @var ResourceServiceInterface $resourceServiceMock */ + /** @var ResourceService $resourceServiceMock */ $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment = (new Payment())->setId('myPaymentId')->setParentResource($heidelpayObj)->setMetadata($metadata); @@ -854,11 +755,8 @@ public function handleResponseShouldGetMetadataIfUnfetchedMetadataObjectWithIdIs * Verify handleResponse does nothing if transactions is empty. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldUpdateChargeTransactions() + public function handleResponseShouldUpdateChargeTransactions(): void { $payment = (new Payment())->setId('MyPaymentId'); $this->assertIsEmptyArray($payment->getCharges()); @@ -880,11 +778,8 @@ public function handleResponseShouldUpdateChargeTransactions() * Verify handleResponse updates existing authorization from response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldUpdateAuthorizationFromResponse() + public function handleResponseShouldUpdateAuthorizationFromResponse(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -912,11 +807,8 @@ public function handleResponseShouldUpdateAuthorizationFromResponse() * Verify handleResponse adds authorization from response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldAddAuthorizationFromResponse() + public function handleResponseShouldAddAuthorizationFromResponse(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -943,11 +835,8 @@ public function handleResponseShouldAddAuthorizationFromResponse() * Verify handleResponse updates existing charge from response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldUpdateChargeFromResponseIfItExists() + public function handleResponseShouldUpdateChargeFromResponseIfItExists(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -977,11 +866,8 @@ public function handleResponseShouldUpdateChargeFromResponseIfItExists() * Verify handleResponse adds non existing charge from response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldAddChargeFromResponseIfItDoesNotExists() + public function handleResponseShouldAddChargeFromResponseIfItDoesNotExists(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -1010,11 +896,8 @@ public function handleResponseShouldAddChargeFromResponseIfItDoesNotExists() * Verify handleResponse updates existing reversals from response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldUpdateReversalFromResponseIfItExists() + public function handleResponseShouldUpdateReversalFromResponseIfItExists(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -1045,11 +928,8 @@ public function handleResponseShouldUpdateReversalFromResponseIfItExists() * Verify handleResponse adds non existing reversal from response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldAddReversalFromResponseIfItDoesNotExists() + public function handleResponseShouldAddReversalFromResponseIfItDoesNotExists(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -1081,11 +961,8 @@ public function handleResponseShouldAddReversalFromResponseIfItDoesNotExists() * Verify that handleResponse will throw an exception if the authorization to a reversal does not exist. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldThrowExceptionIfAnAuthorizeToAReversalDoesNotExist() + public function handleResponseShouldThrowExceptionIfAnAuthorizeToAReversalDoesNotExist(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -1107,11 +984,8 @@ public function handleResponseShouldThrowExceptionIfAnAuthorizeToAReversalDoesNo * Verify handleResponse updates existing refunds from response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldUpdateRefundsFromResponseIfItExists() + public function handleResponseShouldUpdateRefundsFromResponseIfItExists(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -1142,11 +1016,8 @@ public function handleResponseShouldUpdateRefundsFromResponseIfItExists() * Verify handleResponse adds non existing refund from response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldAddRefundFromResponseIfItDoesNotExists() + public function handleResponseShouldAddRefundFromResponseIfItDoesNotExists(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -1178,11 +1049,8 @@ public function handleResponseShouldAddRefundFromResponseIfItDoesNotExists() * Verify that handleResponse will throw an exception if the charge to a refund does not exist. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldThrowExceptionIfAChargeToARefundDoesNotExist() + public function handleResponseShouldThrowExceptionIfAChargeToARefundDoesNotExist(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -1204,11 +1072,8 @@ public function handleResponseShouldThrowExceptionIfAChargeToARefundDoesNotExist * Verify handleResponse updates existing shipment from response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldUpdateShipmentFromResponseIfItExists() + public function handleResponseShouldUpdateShipmentFromResponseIfItExists(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -1235,11 +1100,8 @@ public function handleResponseShouldUpdateShipmentFromResponseIfItExists() * Verify handleResponse adds non existing shipment from response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldAddShipmentFromResponseIfItDoesNotExists() + public function handleResponseShouldAddShipmentFromResponseIfItDoesNotExists(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -1265,11 +1127,8 @@ public function handleResponseShouldAddShipmentFromResponseIfItDoesNotExists() * Verify handleResponse updates existing payout from response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldUpdatePayoutFromResponseIfItExists() + public function handleResponseShouldUpdatePayoutFromResponseIfItExists(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -1296,11 +1155,8 @@ public function handleResponseShouldUpdatePayoutFromResponseIfItExists() * Verify handleResponse adds non existing refund from response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldAddPayoutFromResponseIfItDoesNotExists() + public function handleResponseShouldAddPayoutFromResponseIfItDoesNotExists(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('MyPaymentId'); @@ -1326,12 +1182,8 @@ public function handleResponseShouldAddPayoutFromResponseIfItDoesNotExists() * Verify charge will call chargePayment on heidelpay object. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function chargeMethodShouldPropagateToHeidelpayChargePaymentMethod() + public function chargeMethodShouldPropagateToHeidelpayChargePaymentMethod(): void { $payment = new Payment(); @@ -1354,12 +1206,8 @@ public function chargeMethodShouldPropagateToHeidelpayChargePaymentMethod() * Verify ship will call ship method on heidelpay object. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function shipMethodShouldPropagateToHeidelpayChargePaymentMethod() + public function shipMethodShouldPropagateToHeidelpayChargePaymentMethod(): void { $payment = new Payment(); @@ -1375,17 +1223,14 @@ public function shipMethodShouldPropagateToHeidelpayChargePaymentMethod() * Verify setMetadata will set parent resource and call create with metadata object. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function setMetaDataShouldSetParentResourceAndCreateMetaDataObject() + public function setMetaDataShouldSetParentResourceAndCreateMetaDataObject(): void { $metadata = (new Metadata())->addMetadata('myData', 'myValue'); /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['createResource'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource')->with($metadata); $heidelpay = (new Heidelpay('s-priv-1234'))->setResourceService($resourceSrvMock); @@ -1407,17 +1252,14 @@ public function setMetaDataShouldSetParentResourceAndCreateMetaDataObject() * Verify setMetadata will not set the metadata property if it is not of type metadata. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function metadataMustBeOfTypeMetadata() + public function metadataMustBeOfTypeMetadata(): void { $metadata = new Metadata(); /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['createResource'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource')->with($metadata); $heidelpay = (new Heidelpay('s-priv-1234'))->setResourceService($resourceSrvMock); @@ -1445,12 +1287,8 @@ public function metadataMustBeOfTypeMetadata() * Verify set Basket will call create if the given basket object does not exist yet. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function setBasketShouldCallCreateIfTheGivenBasketObjectDoesNotExistYet() + public function setBasketShouldCallCreateIfTheGivenBasketObjectDoesNotExistYet(): void { $heidelpay = new Heidelpay('s-priv-123'); @@ -1459,6 +1297,7 @@ public function setBasketShouldCallCreateIfTheGivenBasketObjectDoesNotExistYet() $heidelpay->setResourceService($resourceSrvMock); $basket = new Basket(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource')->with( $this->callback( static function ($object) use ($basket, $heidelpay) { @@ -1475,12 +1314,8 @@ static function ($object) use ($basket, $heidelpay) { * Verify setBasket won't call resource service when the basket is null. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function setBasketWontCallResourceServiceWhenBasketIsNull() + public function setBasketWontCallResourceServiceWhenBasketIsNull(): void { $heidelpay = new Heidelpay('s-priv-123'); @@ -1503,17 +1338,14 @@ public function setBasketWontCallResourceServiceWhenBasketIsNull() * Verify updateResponseResources will fetch the basketId in response if it is set. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function updateResponseResourcesShouldFetchBasketIdIfItIsSetInResponse() + public function updateResponseResourcesShouldFetchBasketIdIfItIsSetInResponse(): void { /** @var Heidelpay|MockObject $heidelpayMock */ $heidelpayMock = $this->getMockBuilder(Heidelpay::class)->disableOriginalConstructor()->setMethods(['fetchBasket'])->getMock(); $basket = new Basket(); + /** @noinspection PhpParamsInspection */ $heidelpayMock->expects($this->once())->method('fetchBasket')->with('myResourcesBasketId')->willReturn($basket); $payment = new Payment($heidelpayMock); @@ -1530,10 +1362,8 @@ public function updateResponseResourcesShouldFetchBasketIdIfItIsSetInResponse() * Verify a payment is fetched by orderId if the id is not set. * * @test - * - * @throws RuntimeException */ - public function paymentShouldBeFetchedByOrderIdIfIdIsNotSet() + public function paymentShouldBeFetchedByOrderIdIfIdIsNotSet(): void { $orderId = str_replace(' ', '', microtime()); $payment = (new Payment())->setOrderId($orderId)->setParentResource(new Heidelpay('s-priv-123')); @@ -1541,6 +1371,21 @@ public function paymentShouldBeFetchedByOrderIdIfIdIsNotSet() $this->assertEquals($orderId, end($lastElement)); } + /** + * Verify getInitialTransaction method returns the initial transaction. + * Autofetch is disabled due to missing transactionIds. + * + * @test + * @dataProvider initialTransactionDP + * + * @param AbstractTransactionType $expected + * @param Payment $payment + */ + public function initialTransactionShouldBeAuthIfExistsElseFirstCharge($expected, Payment $payment): void + { + $this->assertSame($expected, $payment->getInitialTransaction()); + } + // /** @@ -1560,5 +1405,20 @@ public function stateDataProvider(): array ]; } + /** + * Data provider to initialTransactionShouldBeAuthIfExistsElseFirstCharge + */ + public function initialTransactionDP(): array + { + $authorize = new Authorization(); + $charge = new Charge(); + + return [ + 'charge' => [$charge, (new Payment($this->getHeidelpayObject()))->addCharge($charge)], + 'authorize' => [$authorize, (new Payment($this->getHeidelpayObject()))->setAuthorization($authorize)], + 'authorize and charge' => [$authorize, (new Payment($this->getHeidelpayObject()))->addCharge($charge)->setAuthorization($authorize)] + ]; + } + // } diff --git a/test/unit/Resources/PaymentTypes/CardTest.php b/test/unit/Resources/PaymentTypes/CardTest.php index 1ca1ca8d..a6ceee0f 100755 --- a/test/unit/Resources/PaymentTypes/CardTest.php +++ b/test/unit/Resources/PaymentTypes/CardTest.php @@ -1,4 +1,6 @@ card = new Card($this->number, $this->expiryDate); } @@ -95,10 +92,8 @@ protected function setUp() * Verify the resource data is set properly. * * @test - * - * @throws RuntimeException */ - public function constructorShouldSetParameters() + public function constructorShouldSetParameters(): void { $number = '4111111111111111'; $expiryDate = '12/2030'; @@ -120,10 +115,8 @@ public function constructorShouldSetParameters() * * @param string $testData * @param string $expected - * - * @throws RuntimeException */ - public function expiryDateShouldBeExtendedToLongVersion($testData, $expected) + public function expiryDateShouldBeExtendedToLongVersion($testData, $expected): void { $this->card->setExpiryDate($testData); $this->assertEquals($expected, $this->card->getExpiryDate()); @@ -136,10 +129,8 @@ public function expiryDateShouldBeExtendedToLongVersion($testData, $expected) * @dataProvider invalidExpiryDateDataProvider * * @param string $testData - * - * @throws RuntimeException */ - public function yearOfExpiryDateShouldBeExtendedToLongVersion($testData) + public function yearOfExpiryDateShouldBeExtendedToLongVersion($testData): void { $this->expectException(RuntimeException::class); $this->card->setExpiryDate($testData); @@ -151,10 +142,8 @@ public function yearOfExpiryDateShouldBeExtendedToLongVersion($testData) * it afterwards by just setting the id. * * @test - * - * @throws RuntimeException */ - public function verifySettingExpiryDateNullChangesNothing() + public function verifySettingExpiryDateNullChangesNothing(): void { $card = new Card(null, null); $this->assertEquals(null, $card->getExpiryDate()); @@ -168,10 +157,8 @@ public function verifySettingExpiryDateNullChangesNothing() * Verify setting cvc. * * @test - * - * @throws Exception */ - public function verifyCvcCanBeSetAndChanged() + public function verifyCvcCanBeSetAndChanged(): void { $this->assertEquals(null, $this->card->getCvc()); $this->card->setCvc('123'); @@ -184,10 +171,8 @@ public function verifyCvcCanBeSetAndChanged() * Verify setting holder. * * @test - * - * @throws Exception */ - public function verifyHolderCanBeSetAndChanged() + public function verifyHolderCanBeSetAndChanged(): void { $this->assertEquals(null, $this->card->getCardHolder()); $this->card->setCardHolder('Julia Heideich'); @@ -201,11 +186,9 @@ public function verifyHolderCanBeSetAndChanged() * * @test * - * @throws Exception - * * @deprecated since 1.2.7.2 */ - public function verifyHolderCanBeSetAndChangedOld() + public function verifyHolderCanBeSetAndChangedOld(): void { $this->assertEquals(null, $this->card->getHolder()); $this->card->setHolder('Julia Heideich'); @@ -219,15 +202,12 @@ public function verifyHolderCanBeSetAndChangedOld() * * @test * - * @throws Exception - * @throws \PHPUnit\Framework\MockObject\RuntimeException - * @throws ReflectionException - * * @deprecated since 1.2.7.2 */ - public function verifyHolderSettersPropagate() + public function verifyHolderSettersPropagate(): void { $cardMock = $this->getMockBuilder(Card::class)->disableOriginalConstructor()->setMethods(['setCardHolder', 'getCardHolder'])->getMock(); + /** @noinspection PhpParamsInspection */ $cardMock->expects($this->once())->method('setCardHolder')->with('set my CardHolder'); $cardMock->expects($this->once())->method('getCardHolder')->willReturn('get my CardHolder'); @@ -240,11 +220,8 @@ public function verifyHolderSettersPropagate() * Verify card3ds flag. * * @test - * - * @throws AssertionFailedError - * @throws Exception */ - public function card3dsFlagShouldBeSettableInCardResource() + public function card3dsFlagShouldBeSettableInCardResource(): void { $this->assertNull($this->card->get3ds()); $this->assertArrayNotHasKey('3ds', $this->card->expose()); @@ -265,10 +242,8 @@ public function card3dsFlagShouldBeSettableInCardResource() * Verify setting brand. * * @test - * - * @throws Exception */ - public function verifyCardCanBeUpdated() + public function verifyCardCanBeUpdated(): void { $newGeoLocation = (object)['clientIp' => 'client ip', 'countryCode' => 'country code']; $newValues = (object)[ diff --git a/test/unit/Resources/PaymentTypes/EPSTest.php b/test/unit/Resources/PaymentTypes/EPSTest.php index 482ae1e7..86ef173a 100755 --- a/test/unit/Resources/PaymentTypes/EPSTest.php +++ b/test/unit/Resources/PaymentTypes/EPSTest.php @@ -1,4 +1,6 @@ assertNull($eps->getBic()); diff --git a/test/unit/Resources/PaymentTypes/HirePurchaseDirectDebitTest.php b/test/unit/Resources/PaymentTypes/HirePurchaseDirectDebitTest.php index c75a9279..1d8e6d15 100644 --- a/test/unit/Resources/PaymentTypes/HirePurchaseDirectDebitTest.php +++ b/test/unit/Resources/PaymentTypes/HirePurchaseDirectDebitTest.php @@ -1,4 +1,6 @@ assertEmpty($hdd->getTransactionParams()); @@ -170,12 +165,8 @@ public function getterAndSetterWorkAsExpected() * Verify handle response is called with the exposed data of the selected instalment plan. * * @test - * - * @throws Exception - * @throws RuntimeException - * @throws ReflectionException */ - public function selectedInstalmentPlanDataIsUsedToUpdateInstalmentPlanInformation() + public function selectedInstalmentPlanDataIsUsedToUpdateInstalmentPlanInformation(): void { /** @var HirePurchaseDirectDebit|MockObject $hddMock */ $hddMock = $this->getMockBuilder(HirePurchaseDirectDebit::class)->setMethods(['handleResponse'])->getMock(); @@ -186,6 +177,7 @@ public function selectedInstalmentPlanDataIsUsedToUpdateInstalmentPlanInformatio $exposedObject = (object)['data' => 'I am exposed']; $instalmentPlanMock->expects($this->once())->method('expose')->willReturn($exposedObject); + /** @noinspection PhpParamsInspection */ $hddMock->expects($this->once())->method('handleResponse')->with($exposedObject); $hddMock->selectInstalmentPlan($instalmentPlanMock); @@ -195,11 +187,8 @@ public function selectedInstalmentPlanDataIsUsedToUpdateInstalmentPlanInformatio * Verify instalment plan fetch can update instalment plan properties. * * @test - * - * @throws AssertionFailedError - * @throws Exception */ - public function instalmentPlanPropertiesShouldBeUpdateable() + public function instalmentPlanPropertiesShouldBeUpdateable(): void { $plan = new InstalmentPlan(); $this->assertEmpty($plan->getInstallmentRates()); @@ -212,6 +201,6 @@ public function instalmentPlanPropertiesShouldBeUpdateable() $planData = (object)['installmentRates' => $rates]; $plan->handleResponse($planData); - $this->assertArraySubset($rates, $plan->getInstallmentRates()); + $this->assertEquals($rates, $plan->getInstallmentRates()); } } diff --git a/test/unit/Resources/PaymentTypes/IdealTest.php b/test/unit/Resources/PaymentTypes/IdealTest.php index 45da68e5..0fedab28 100755 --- a/test/unit/Resources/PaymentTypes/IdealTest.php +++ b/test/unit/Resources/PaymentTypes/IdealTest.php @@ -1,4 +1,6 @@ assertNull($ideal->getBic()); diff --git a/test/unit/Resources/PaymentTypes/PayPageTest.php b/test/unit/Resources/PaymentTypes/PayPageTest.php index a23719d6..79647a12 100644 --- a/test/unit/Resources/PaymentTypes/PayPageTest.php +++ b/test/unit/Resources/PaymentTypes/PayPageTest.php @@ -1,4 +1,6 @@ assertNull($paypage->getShopDescription()); $this->assertNull($paypage->getShopName()); $this->assertNull($paypage->getTagline()); + $this->assertNull($paypage->getCss()); // link urls $this->assertNull($paypage->getContactUrl()); @@ -107,7 +103,13 @@ public function getterAndSetterWorkAsExpected() ->setPayment($payment) ->setRedirectUrl('https://redirect.url') ->addExcludeType(SepaDirectDebit::getResourceName()) - ->setCard3ds(true); + ->setCard3ds(true) + ->setCss([ + 'shopDescription' => 'color: purple', + 'header' => 'background-color: red', + 'helpUrl' => 'color: blue', + 'contactUrl' => 'color: green', + ]); // ----------- VERIFY test values ------------ $this->assertEquals(321.0, $paypage->getAmount()); @@ -126,6 +128,12 @@ public function getterAndSetterWorkAsExpected() $this->assertEquals('my shop description', $paypage->getShopDescription()); $this->assertEquals('my shop name', $paypage->getShopName()); $this->assertEquals('my shops tag line', $paypage->getTagline()); + $this->assertEquals([ + 'shopDescription' => 'color: purple', + 'header' => 'background-color: red', + 'helpUrl' => 'color: blue', + 'contactUrl' => 'color: green', + ], $paypage->getCss()); // link urls $this->assertEquals('my contact url', $paypage->getContactUrl()); @@ -135,9 +143,9 @@ public function getterAndSetterWorkAsExpected() $this->assertEquals('my tac url', $paypage->getTermsAndConditionUrl()); // other - $this->assertArraySubset([SepaDirectDebit::getResourceName()], $paypage->getExcludeTypes()); + $this->assertEquals([SepaDirectDebit::getResourceName()], $paypage->getExcludeTypes()); $paypage->setExcludeTypes([Card::getResourceName(), Giropay::getResourceName()]); - $this->assertArraySubset([Card::getResourceName(), Giropay::getResourceName()], $paypage->getExcludeTypes()); + $this->assertEquals([Card::getResourceName(), Giropay::getResourceName()], $paypage->getExcludeTypes()); $this->assertTrue($paypage->isCard3ds()); // SET test values 2 @@ -149,11 +157,8 @@ public function getterAndSetterWorkAsExpected() * Verify handling of response and property setters/getters. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function responseHandlingShouldWorkProperly() + public function responseHandlingShouldWorkProperly(): void { // when $paypage = new Paypage(123.4, 'EUR', 'https://docs.heidelpay.com'); @@ -175,6 +180,7 @@ public function responseHandlingShouldWorkProperly() $this->assertNull($paypage->getShopDescription()); $this->assertNull($paypage->getShopName()); $this->assertNull($paypage->getTagline()); + $this->assertNull($paypage->getCss()); $this->assertNull($paypage->getContactUrl()); $this->assertNull($paypage->getHelpUrl()); @@ -199,6 +205,7 @@ public function responseHandlingShouldWorkProperly() $response->imprintUrl = 'imprint url'; $response->privacyPolicyUrl = 'privacy policy url'; $response->termsAndConditionUrl = 'tac url'; + $response->css = ['my'=> 'styles']; $paypage->handleResponse($response); // then @@ -215,6 +222,7 @@ public function responseHandlingShouldWorkProperly() $this->assertEquals('shop description', $paypage->getShopDescription()); $this->assertEquals('shop name', $paypage->getShopName()); $this->assertEquals('tagline', $paypage->getTagline()); + $this->assertEquals(['my' => 'styles'], $paypage->getCss()); $this->assertEquals('contact url', $paypage->getContactUrl()); $this->assertEquals('help url', $paypage->getHelpUrl()); @@ -227,11 +235,8 @@ public function responseHandlingShouldWorkProperly() * Verify handling of payment object. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function paymentObjectShouldBeUpdatedProperly() + public function paymentObjectShouldBeUpdatedProperly(): void { // when $paypage = new Paypage(123.4, 'EUR', 'https://docs.heidelpay.com'); @@ -262,11 +267,8 @@ public function paymentObjectShouldBeUpdatedProperly() * Verify handling of response in case of special fields. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function responseHandlingShouldMapSpecialFieldsProperly() + public function responseHandlingShouldMapSpecialFieldsProperly(): void { // when $paypage = new Paypage(123.4, 'EUR', 'https://docs.heidelpay.com'); @@ -288,15 +290,11 @@ public function responseHandlingShouldMapSpecialFieldsProperly() * * @param string $method * @param mixed $fetchCallCount - * - *@throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function paymentShouldBeFetchedWhenItIsNoGetRequest($method, $fetchCallCount) + public function paymentShouldBeFetchedWhenItIsNoGetRequest($method, $fetchCallCount): void { // mock resource service to check whether fetch is called on it with the payment object. - /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ + /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['fetchResource'])->getMock(); // when @@ -305,6 +303,7 @@ public function paymentShouldBeFetchedWhenItIsNoGetRequest($method, $fetchCallCo $paypage->setPayment($payment)->setParentResource($payment); // should + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->exactly($fetchCallCount))->method('fetchResource')->with($payment); // when @@ -318,12 +317,8 @@ public function paymentShouldBeFetchedWhenItIsNoGetRequest($method, $fetchCallCo * Verify expose behaves as expected. * * @test - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function exposeShouldSetBasicParams() + public function exposeShouldSetBasicParams(): void { // when $basket = (new Basket())->setId('basketId'); @@ -351,7 +346,8 @@ public function exposeShouldSetBasicParams() ->setRedirectUrl('https://redirect.url') ->setOrderId('my order id') ->setInvoiceId('my invoice id') - ->setEffectiveInterestRate(4.99); + ->setEffectiveInterestRate(4.99) + ->setCss(['my' => 'style']); // then $expected = [ @@ -377,7 +373,8 @@ public function exposeShouldSetBasicParams() 'orderId' => 'my order id', 'invoiceId' => 'my invoice id', 'excludeTypes' => [], - 'additionalAttributes' => ['effectiveInterestRate' => 4.99] + 'additionalAttributes' => ['effectiveInterestRate' => 4.99], + 'css' => ['my' => 'style'] ]; $this->assertEquals($expected, $paypage->expose()); } @@ -386,11 +383,8 @@ public function exposeShouldSetBasicParams() * Verify resources are returned as null if no payment object exists. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function resourcesAreNullWithoutPaymentObject() + public function resourcesAreNullWithoutPaymentObject(): void { // when $paypage = new Paypage(123.4567, 'EUR', self::RETURN_URL); diff --git a/test/unit/Resources/PaymentTypes/PayPalTest.php b/test/unit/Resources/PaymentTypes/PayPalTest.php index 2a8bb840..92307cf9 100644 --- a/test/unit/Resources/PaymentTypes/PayPalTest.php +++ b/test/unit/Resources/PaymentTypes/PayPalTest.php @@ -1,4 +1,6 @@ assertNull($paypal->getEmail()); diff --git a/test/unit/Resources/PaymentTypes/SepaDirectDebitGuaranteedTest.php b/test/unit/Resources/PaymentTypes/SepaDirectDebitGuaranteedTest.php index 45761927..ad539d55 100755 --- a/test/unit/Resources/PaymentTypes/SepaDirectDebitGuaranteedTest.php +++ b/test/unit/Resources/PaymentTypes/SepaDirectDebitGuaranteedTest.php @@ -1,4 +1,6 @@ assertNull($sdd->getIban()); @@ -46,10 +46,8 @@ public function ibanShouldBeSetByConstructor() * Verify setter and getter work. * * @test - * - * @throws Exception */ - public function getterAndSetterWorkAsExpected() + public function getterAndSetterWorkAsExpected(): void { $sdd = new SepaDirectDebitGuaranteed('DE89370400440532013000'); $this->assertEquals('DE89370400440532013000', $sdd->getIban()); diff --git a/test/unit/Resources/PaymentTypes/SepaDirectDebitTest.php b/test/unit/Resources/PaymentTypes/SepaDirectDebitTest.php index 13ba8516..e6980cc9 100755 --- a/test/unit/Resources/PaymentTypes/SepaDirectDebitTest.php +++ b/test/unit/Resources/PaymentTypes/SepaDirectDebitTest.php @@ -1,4 +1,6 @@ assertNull($sdd->getIban()); @@ -46,10 +46,8 @@ public function ibanShouldBeSetByConstructor() * Verify setter and getter work. * * @test - * - * @throws Exception */ - public function getterAndSetterWorkAsExpected() + public function getterAndSetterWorkAsExpected(): void { $sdd = new SepaDirectDebit('DE89370400440532013000'); $this->assertEquals('DE89370400440532013000', $sdd->getIban()); diff --git a/test/unit/Resources/RecurringTest.php b/test/unit/Resources/RecurringTest.php index 9f30d2be..e13ad356 100644 --- a/test/unit/Resources/RecurringTest.php +++ b/test/unit/Resources/RecurringTest.php @@ -1,4 +1,6 @@ assertEquals('payment type id', $recurring->getPaymentTypeId()); diff --git a/test/unit/Resources/TransactionTypes/AbstractTransactionTypeTest.php b/test/unit/Resources/TransactionTypes/AbstractTransactionTypeTest.php index 534e0e99..9b1d7bda 100755 --- a/test/unit/Resources/TransactionTypes/AbstractTransactionTypeTest.php +++ b/test/unit/Resources/TransactionTypes/AbstractTransactionTypeTest.php @@ -1,4 +1,6 @@ getMockBuilder(Payment::class)->setMethods(['getRedirectUrl'])->getMock(); $paymentMock->expects($this->once())->method('getRedirectUrl')->willReturn('https://my-redirect-url.test'); @@ -143,11 +133,8 @@ public function getRedirectUrlShouldCallPaymentGetRedirectUrl() * Verify abstract transaction allows for updating. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function handleResponseShouldUpdateValuesOfAbstractTransaction() + public function handleResponseShouldUpdateValuesOfAbstractTransaction(): void { $payment = (new Payment())->setId('myPaymentId'); $transactionType = (new DummyTransactionType())->setPayment($payment); @@ -185,12 +172,8 @@ public function handleResponseShouldUpdateValuesOfAbstractTransaction() * * @param string $method * @param integer $timesCalled - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function updatePaymentShouldOnlyBeCalledOnNotRequests($method, $timesCalled) + public function updatePaymentShouldOnlyBeCalledOnNotRequests($method, $timesCalled): void { $transactionTypeMock = $this->getMockBuilder(DummyTransactionType::class)->setMethods(['fetchPayment'])->getMock(); @@ -204,23 +187,19 @@ public function updatePaymentShouldOnlyBeCalledOnNotRequests($method, $timesCall * Verify payment object is fetched on fetchPayment call using the heidelpays resource service object. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function fetchPaymentShouldFetchPaymentObject() + public function fetchPaymentShouldFetchPaymentObject(): void { $payment = (new Payment())->setId('myPaymentId'); /** @var ResourceService|MockObject $resourceServiceMock */ $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['fetchResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('fetchResource')->with($payment); $heidelpayObj = (new Heidelpay('s-priv-123'))->setResourceService($resourceServiceMock); $payment->setParentResource($heidelpayObj); - /** @var DummyTransactionType $transactionType */ $transactionType = (new DummyTransactionType())->setPayment($payment); $transactionType->fetchPayment(); } diff --git a/test/unit/Resources/TransactionTypes/AuthorizationTest.php b/test/unit/Resources/TransactionTypes/AuthorizationTest.php index 1967e803..626f09ad 100755 --- a/test/unit/Resources/TransactionTypes/AuthorizationTest.php +++ b/test/unit/Resources/TransactionTypes/AuthorizationTest.php @@ -1,4 +1,6 @@ assertNull($authorization->getAmount()); @@ -76,11 +73,8 @@ public function gettersAndSettersShouldWorkProperly() * Verify that an Authorization can be updated on handle response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function anAuthorizationShouldBeUpdatedThroughResponseHandling() + public function anAuthorizationShouldBeUpdatedThroughResponseHandling(): void { $authorization = new Authorization(); $this->assertNull($authorization->getAmount()); @@ -120,10 +114,8 @@ public function anAuthorizationShouldBeUpdatedThroughResponseHandling() * Verify getLinkedResources throws exception if the paymentType is not set. * * @test - * - * @throws RuntimeException */ - public function getLinkedResourcesShouldThrowExceptionWhenThePaymentTypeIsNotSet() + public function getLinkedResourcesShouldThrowExceptionWhenThePaymentTypeIsNotSet(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Payment type is missing!'); @@ -135,12 +127,8 @@ public function getLinkedResourcesShouldThrowExceptionWhenThePaymentTypeIsNotSet * Verify linked resource. * * @test - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function getLinkedResourceShouldReturnResourcesBelongingToAuthorization() + public function getLinkedResourceShouldReturnResourcesBelongingToAuthorization(): void { $heidelpayObj = new Heidelpay('s-priv-123345'); $paymentType = (new Sofort())->setId('123'); @@ -161,12 +149,8 @@ public function getLinkedResourceShouldReturnResourcesBelongingToAuthorization() * Verify cancel() calls cancelAuthorization() on heidelpay object with the given amount. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function cancelShouldCallCancelAuthorizationOnHeidelpayObject() + public function cancelShouldCallCancelAuthorizationOnHeidelpayObject(): void { $authorization = new Authorization(); $heidelpayMock = $this->getMockBuilder(Heidelpay::class) @@ -193,11 +177,8 @@ public function cancelShouldCallCancelAuthorizationOnHeidelpayObject() * @dataProvider chargeValueProvider * * @param float|null $value - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function chargeShouldThrowExceptionIfPaymentIsNotSet($value) + public function chargeShouldThrowExceptionIfPaymentIsNotSet($value): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Payment object is missing. Try fetching the object first!'); @@ -210,12 +191,8 @@ public function chargeShouldThrowExceptionIfPaymentIsNotSet($value) * Verify charge() calls chargeAuthorization() on heidelpay object with the given amount. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function chargeShouldCallChargeAuthorizationOnHeidelpayObject() + public function chargeShouldCallChargeAuthorizationOnHeidelpayObject(): void { $heidelpayMock = $this->getMockBuilder(Heidelpay::class) ->disableOriginalConstructor() @@ -240,10 +217,8 @@ public function chargeShouldCallChargeAuthorizationOnHeidelpayObject() * Verify getter for cancelled amount. * * @test - * - * @throws Exception */ - public function getCancelledAmountReturnsTheCancelledAmount() + public function getCancelledAmountReturnsTheCancelledAmount(): void { $authorization = new Authorization(); $this->assertEquals(0.0, $authorization->getCancelledAmount()); diff --git a/test/unit/Resources/TransactionTypes/CancellationTest.php b/test/unit/Resources/TransactionTypes/CancellationTest.php index c2104595..e5ac2b06 100755 --- a/test/unit/Resources/TransactionTypes/CancellationTest.php +++ b/test/unit/Resources/TransactionTypes/CancellationTest.php @@ -1,4 +1,6 @@ assertNull($cancellation->getAmount()); @@ -83,13 +79,8 @@ public function gettersAndSettersShouldWorkProperly() * Verify expose will translate amount to amountGross if payment type is Hire Purchase. * * @test - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function exposeWillReplaceAmountWithAmountGross() + public function exposeWillReplaceAmountWithAmountGross(): void { /** @var Cancellation|MockObject $cancelMock */ $cancelMock = $this->getMockBuilder(Cancellation::class)->setMethods(['getLinkedResources'])->getMock(); diff --git a/test/unit/Resources/TransactionTypes/ChargeTest.php b/test/unit/Resources/TransactionTypes/ChargeTest.php index b7eae7e4..15026b8d 100755 --- a/test/unit/Resources/TransactionTypes/ChargeTest.php +++ b/test/unit/Resources/TransactionTypes/ChargeTest.php @@ -1,4 +1,6 @@ assertNull($charge->getAmount()); @@ -79,11 +76,8 @@ public function gettersAndSettersShouldWorkProperly() * Verify that a Charge can be updated on handle response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function aChargeShouldBeUpdatedThroughResponseHandling() + public function aChargeShouldBeUpdatedThroughResponseHandling(): void { $charge = new Charge(); $this->assertNull($charge->getAmount()); @@ -122,10 +116,8 @@ public function aChargeShouldBeUpdatedThroughResponseHandling() * Verify getLinkedResources throws exception if the paymentType is not set. * * @test - * - * @throws RuntimeException */ - public function getLinkedResourcesShouldThrowExceptionWhenThePaymentTypeIsNotSet() + public function getLinkedResourcesShouldThrowExceptionWhenThePaymentTypeIsNotSet(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Payment type is missing!'); @@ -137,11 +129,8 @@ public function getLinkedResourcesShouldThrowExceptionWhenThePaymentTypeIsNotSet * Verify linked resource. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function getLinkedResourceShouldReturnResourcesBelongingToCharge() + public function getLinkedResourceShouldReturnResourcesBelongingToCharge(): void { $heidelpayObj = new Heidelpay('s-priv-123345'); $paymentType = (new Sofort())->setId('123'); @@ -162,12 +151,8 @@ public function getLinkedResourceShouldReturnResourcesBelongingToCharge() * Verify cancel() calls cancelCharge() on heidelpay object with the given amount. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function cancelShouldCallCancelChargeOnHeidelpayObject() + public function cancelShouldCallCancelChargeOnHeidelpayObject(): void { $charge = new Charge(); $heidelpayMock = $this->getMockBuilder(Heidelpay::class) @@ -191,10 +176,8 @@ public function cancelShouldCallCancelChargeOnHeidelpayObject() * Verify getter for cancelled amount. * * @test - * - * @throws Exception */ - public function getCancelledAmountReturnsTheCancelledAmount() + public function getCancelledAmountReturnsTheCancelledAmount(): void { $charge = new Charge(); $this->assertEquals(0.0, $charge->getCancelledAmount()); @@ -215,12 +198,8 @@ public function getCancelledAmountReturnsTheCancelledAmount() * Verify getter for total amount. * * @test - * - * @throws Exception - * @throws ReflectionException - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function getTotalAmountReturnsAmountMinusCancelledAmount() + public function getTotalAmountReturnsAmountMinusCancelledAmount(): void { /** @var MockObject|Charge $chargeMock */ $chargeMock = $this->getMockBuilder(Charge::class) diff --git a/test/unit/Resources/TransactionTypes/DummyTransactionType.php b/test/unit/Resources/TransactionTypes/DummyTransactionType.php index 5a075d7d..7f4e27f0 100755 --- a/test/unit/Resources/TransactionTypes/DummyTransactionType.php +++ b/test/unit/Resources/TransactionTypes/DummyTransactionType.php @@ -1,4 +1,6 @@ assertNull($payout->getAmount()); @@ -70,11 +68,8 @@ public function gettersAndSettersShouldWorkProperly() * Verify that an Payout can be updated on handle response. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function aPayoutShouldBeUpdatedThroughResponseHandling() + public function aPayoutShouldBeUpdatedThroughResponseHandling(): void { $payout = new Payout(); $this->assertNull($payout->getAmount()); @@ -101,10 +96,8 @@ public function aPayoutShouldBeUpdatedThroughResponseHandling() * Verify getLinkedResources throws exception if the paymentType is not set. * * @test - * - * @throws RuntimeException */ - public function getLinkedResourcesShouldThrowExceptionWhenThePaymentTypeIsNotSet() + public function getLinkedResourcesShouldThrowExceptionWhenThePaymentTypeIsNotSet(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Payment type is missing!'); @@ -116,12 +109,8 @@ public function getLinkedResourcesShouldThrowExceptionWhenThePaymentTypeIsNotSet * Verify linked resource. * * @test - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function getLinkedResourceShouldReturnResourcesBelongingToPayout() + public function getLinkedResourceShouldReturnResourcesBelongingToPayout(): void { $heidelpayObj = new Heidelpay('s-priv-123345'); $paymentType = $this->createCardObject()->setId('123'); diff --git a/test/unit/Resources/TransactionTypes/ShipmentTest.php b/test/unit/Resources/TransactionTypes/ShipmentTest.php index 324ecc30..8289ee03 100755 --- a/test/unit/Resources/TransactionTypes/ShipmentTest.php +++ b/test/unit/Resources/TransactionTypes/ShipmentTest.php @@ -1,4 +1,6 @@ amount = '987.6543'; diff --git a/test/unit/Resources/WebhookTest.php b/test/unit/Resources/WebhookTest.php index 805b6236..bac8deca 100755 --- a/test/unit/Resources/WebhookTest.php +++ b/test/unit/Resources/WebhookTest.php @@ -1,4 +1,6 @@ assertEquals('', $webhook->getUrl()); @@ -48,10 +47,8 @@ public function mandatoryConstructorParametersShouldDefaultToEmptyString() * Verify the getters and setters of the webhook resource. * * @test - * - * @throws Exception */ - public function gettersAndSettersOfWebhookShouldBehaveAsExpected() + public function gettersAndSettersOfWebhookShouldBehaveAsExpected(): void { $webhook = new Webhook('https://dev.heidelpay.com', 'anEventIMadeUp'); $this->assertEquals('https://dev.heidelpay.com', $webhook->getUrl()); diff --git a/test/unit/Resources/WebhooksTest.php b/test/unit/Resources/WebhooksTest.php index 0c1d8623..9c8d5695 100755 --- a/test/unit/Resources/WebhooksTest.php +++ b/test/unit/Resources/WebhooksTest.php @@ -1,4 +1,6 @@ assertEquals('', $webhooks->getUrl()); @@ -54,29 +52,25 @@ public function mandatoryConstructorParametersShouldDefaultToEmptyString() * Verify the getters and setters of the webhooks resource. * * @test - * - * @throws Exception */ - public function gettersAndSettersOfWebhookShouldBehaveAsExpected() + public function gettersAndSettersOfWebhookShouldBehaveAsExpected(): void { $webhook = new Webhooks('https://dev.heidelpay.com', [WebhookEvents::PAYMENT_COMPLETED]); $this->assertEquals('https://dev.heidelpay.com', $webhook->getUrl()); - $this->assertArraySubset([WebhookEvents::PAYMENT_COMPLETED], $webhook->getEventList()); + $this->assertEquals([WebhookEvents::PAYMENT_COMPLETED], $webhook->getEventList()); $webhook->setUrl('https://docs.heidelpay.com'); $webhook->addEvent(WebhookEvents::CHARGE); $this->assertEquals('https://docs.heidelpay.com', $webhook->getUrl()); - $this->assertArraySubset([WebhookEvents::PAYMENT_COMPLETED, WebhookEvents::CHARGE], $webhook->getEventList()); + $this->assertEquals([WebhookEvents::PAYMENT_COMPLETED, WebhookEvents::CHARGE], $webhook->getEventList()); } /** * Verify the event adder of the webhooks resource does only allow valid webhook events. * * @test - * - * @throws Exception */ - public function adderOfWebhookEventsOnlyAllowsValidEvents() + public function adderOfWebhookEventsOnlyAllowsValidEvents(): void { $webhooks = new Webhooks('https://dev.heidelpay.com', []); $this->assertIsEmptyArray($webhooks->getEventList()); @@ -91,11 +85,8 @@ public function adderOfWebhookEventsOnlyAllowsValidEvents() * Verify response handling for more then one event in a webhooks request. * * @test - * - * @throws Exception - * @throws RuntimeException */ - public function responseHandlingForEventsShouldBehaveAsExpected() + public function responseHandlingForEventsShouldBehaveAsExpected(): void { $webhooks = new Webhooks('https://dev.heidelpay.com', [WebhookEvents::CHARGE, WebhookEvents::AUTHORIZE]); $webhooks->setParentResource(new Heidelpay('s-priv-123')); @@ -122,7 +113,7 @@ public function responseHandlingForEventsShouldBehaveAsExpected() * @var Webhook $webhookA * @var Webhook $webhookB */ - list($webhookA, $webhookB) = $webhookList; + [$webhookA, $webhookB] = $webhookList; $this->assertInstanceOf(Webhook::class, $webhookA); $this->assertInstanceOf(Webhook::class, $webhookB); $this->assertEquals( @@ -139,11 +130,8 @@ public function responseHandlingForEventsShouldBehaveAsExpected() * Verify response handling of one event in a webhooks request. * * @test - * - * @throws Exception - * @throws RuntimeException */ - public function responseHandlingForOneEventShouldBehaveAsExpected() + public function responseHandlingForOneEventShouldBehaveAsExpected(): void { $webhooks = new Webhooks('https://dev.heidelpay.com', [WebhookEvents::CHARGE]); $webhooks->setParentResource(new Heidelpay('s-priv-123')); @@ -160,7 +148,7 @@ public function responseHandlingForOneEventShouldBehaveAsExpected() $this->assertCount(1, $webhookList); /** @var Webhook $webhook*/ - list($webhook) = $webhookList; + [$webhook] = $webhookList; $this->assertInstanceOf(Webhook::class, $webhook); $this->assertEquals( ['event' => 'authorize', 'id' => 's-whk-1085', 'url' => 'https://docs.heidelpay.de'], diff --git a/test/unit/Services/CancelServiceTest.php b/test/unit/Services/CancelServiceTest.php index 9d21b2f8..e505b84c 100644 --- a/test/unit/Services/CancelServiceTest.php +++ b/test/unit/Services/CancelServiceTest.php @@ -1,4 +1,6 @@ getMockBuilder(Payment::class)->setMethods(['cancelAmount'])->getMock(); $cancellation = new Cancellation(1.0); @@ -72,13 +67,9 @@ public function cancelShouldCallCancelAllChargesAndCancelAuthorizationAndReturnF * * @test * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * * @deprecated since 1.2.3.0 */ - public function cancelShouldThrowExceptionIfNoTransactionExistsToBeCancelled() + public function cancelShouldThrowExceptionIfNoTransactionExistsToBeCancelled(): void { /** @var CancelService|MockObject $cancelSrvMock */ $cancelSrvMock = $this->getMockBuilder(CancelService::class)->disableOriginalConstructor()->setMethods(['cancelAllCharges', 'cancelAuthorization'])->getMock(); @@ -99,13 +90,9 @@ public function cancelShouldThrowExceptionIfNoTransactionExistsToBeCancelled() * * @test * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * * @deprecated since 1.2.3.0 */ - public function cancelAllChargesShouldCallCancelOnAllChargesAndReturnCancelsAndExceptions() + public function cancelAllChargesShouldCallCancelOnAllChargesAndReturnCancelsAndExceptions(): void { $cancellation1 = new Cancellation(1.0); $cancellation2 = new Cancellation(2.0); @@ -138,9 +125,9 @@ public function cancelAllChargesShouldCallCancelOnAllChargesAndReturnCancelsAndE $payment = new Payment(); $payment->addCharge($chargeMock1)->addCharge($chargeMock2)->addCharge($chargeMock3)->addCharge($chargeMock4)->addCharge($chargeMock5); - list($cancellations, $exceptions) = $payment->cancelAllCharges(); - $this->assertArraySubset([$cancellation1, $cancellation2, $cancellation3], $cancellations); - $this->assertArraySubset([$exception1, $exception2], $exceptions); + [$cancellations, $exceptions] = $payment->cancelAllCharges(); + $this->assertEquals([$cancellation1, $cancellation2, $cancellation3], $cancellations); + $this->assertEquals([$exception1, $exception2], $exceptions); } /** @@ -149,12 +136,9 @@ public function cancelAllChargesShouldCallCancelOnAllChargesAndReturnCancelsAndE * * @test * - * @throws ReflectionException - * @throws RuntimeException - * * @deprecated since 1.2.3.0 */ - public function cancelAllChargesShouldThrowChargeCancelExceptionsOtherThanAlreadyCharged() + public function cancelAllChargesShouldThrowChargeCancelExceptionsOtherThanAlreadyCharged(): void { $ex1 = new HeidelpayApiException('', '', ApiResponseCodes::API_ERROR_ALREADY_CHARGED_BACK); $ex2 = new HeidelpayApiException('', '', ApiResponseCodes::API_ERROR_CHARGED_AMOUNT_HIGHER_THAN_EXPECTED); @@ -187,14 +171,8 @@ public function cancelAllChargesShouldThrowChargeCancelExceptionsOtherThanAlread * Charge cancel will not be called if the amount to cancel has been cancelled on the authorization. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws Exception - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function cancelAmountShouldCallCancelAuthorizationAmount() + public function cancelAmountShouldCallCancelAuthorizationAmount(): void { /** @var MockObject|CancelService $cancelSrvMock */ $cancelSrvMock = $this->getMockBuilder(CancelService::class)->disableOriginalConstructor()->setMethods(['cancelPaymentAuthorization'])->getMock(); @@ -217,14 +195,8 @@ public function cancelAmountShouldCallCancelAuthorizationAmount() * Verify that cancel amount will be cancelled on charges if auth does not exist. * * @test - * - * @throws Exception - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function chargesShouldBeCancelledIfAuthDoesNotExist1() + public function chargesShouldBeCancelledIfAuthDoesNotExist1(): void { /** @var MockObject|CancelService $cancelSrvMock */ $cancelSrvMock = $this->getMockBuilder(CancelService::class)->disableOriginalConstructor()->setMethods(['cancelPaymentAuthorization'])->getMock(); @@ -236,6 +208,7 @@ public function chargesShouldBeCancelledIfAuthDoesNotExist1() $cancellation = new Cancellation(10.0); $cancelSrvMock->expects($this->once())->method('cancelPaymentAuthorization')->willReturn(null); + /** @noinspection PhpParamsInspection */ $chargeMock->expects($this->once())->method('cancel')->with(10.0, 'CANCEL')->willReturn($cancellation); $payment = (new Payment($this->heidelpay))->addCharge($chargeMock); @@ -247,14 +220,8 @@ public function chargesShouldBeCancelledIfAuthDoesNotExist1() * Verify that cancel amount will be cancelled on charges if auth does not exist. * * @test - * - * @throws Exception - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function chargesShouldBeCancelledIfAuthDoesNotExist2() + public function chargesShouldBeCancelledIfAuthDoesNotExist2(): void { /** @var MockObject|CancelService $cancelSrvMock */ $cancelSrvMock = $this->getMockBuilder(CancelService::class)->disableOriginalConstructor()->setMethods(['cancelPaymentAuthorization'])->getMock(); @@ -287,14 +254,8 @@ public function chargesShouldBeCancelledIfAuthDoesNotExist2() * * @param string $allowedExceptionCode * @param bool $shouldHaveThrownException - * - * @throws Exception - * @throws ReflectionException - * @throws RuntimeException - * @throws AssertionFailedError - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function verifyAllowedErrorsWillBeIgnoredDuringChargeCancel($allowedExceptionCode, $shouldHaveThrownException) + public function verifyAllowedErrorsWillBeIgnoredDuringChargeCancel($allowedExceptionCode, $shouldHaveThrownException): void { /** @var MockObject|CancelService $cancelSrvMock */ $cancelSrvMock = $this->getMockBuilder(CancelService::class)->disableOriginalConstructor()->setMethods(['cancelPaymentAuthorization'])->getMock(); @@ -319,12 +280,8 @@ public function verifyAllowedErrorsWillBeIgnoredDuringChargeCancel($allowedExcep * Verify cancelAuthorizationAmount will call cancel on the authorization and will return a list of cancels. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function cancelAuthorizationAmountShouldCallCancelOnTheAuthorization() + public function cancelAuthorizationAmountShouldCallCancelOnTheAuthorization(): void { /** @var Authorization|MockObject $authorizationMock */ $authorizationMock = $this->getMockBuilder(Authorization::class)->setMethods(['cancel'])->getMock(); @@ -344,14 +301,8 @@ public function cancelAuthorizationAmountShouldCallCancelOnTheAuthorization() * Cancellation amount will be the remaining amount of the payment at max. * * @test - * - * @throws Exception - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function cancelAuthorizationAmountShouldCallCancelWithTheRemainingAmountAtMax() + public function cancelAuthorizationAmountShouldCallCancelWithTheRemainingAmountAtMax(): void { $cancellation = new Cancellation(); @@ -382,14 +333,8 @@ public function cancelAuthorizationAmountShouldCallCancelWithTheRemainingAmountA * * @param string $exceptionCode * @param bool $shouldHaveThrownException - * - * @throws Exception - * @throws ReflectionException - * @throws RuntimeException - * @throws AssertionFailedError - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function verifyAllowedErrorsWillBeIgnoredDuringAuthorizeCancel($exceptionCode, $shouldHaveThrownException) + public function verifyAllowedErrorsWillBeIgnoredDuringAuthorizeCancel($exceptionCode, $shouldHaveThrownException): void { /** @var MockObject|Payment $paymentMock */ $paymentMock = $this->getMockBuilder(Payment::class)->setMethods(['getAuthorization'])->getMock(); @@ -415,12 +360,8 @@ public function verifyAllowedErrorsWillBeIgnoredDuringAuthorizeCancel($exception * Verify cancelAuthorizationAmount will stop processing if there is no amount to cancel. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function cancelAuthorizationAmountWillNotCallCancelIfThereIsNoOpenAmount() + public function cancelAuthorizationAmountWillNotCallCancelIfThereIsNoOpenAmount(): void { /** @var MockObject|Payment $paymentMock */ /** @var MockObject|Authorization $authMock */ @@ -440,14 +381,8 @@ public function cancelAuthorizationAmountWillNotCallCancelIfThereIsNoOpenAmount( * Verify cancelPayment will fetch payment if the payment is referenced by paymentId. * * @test - * - * @throws Exception - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function paymentCancelShouldFetchPaymentIfPaymentIdIsPassed() + public function paymentCancelShouldFetchPaymentIfPaymentIdIsPassed(): void { /** @var MockObject|ResourceService $resourceServiceMock */ $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['fetchPayment'])->getMock(); @@ -455,6 +390,7 @@ public function paymentCancelShouldFetchPaymentIfPaymentIdIsPassed() $payment = (new Payment($this->heidelpay))->setId('paymentId'); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects(self::once())->method('fetchPayment')->with('paymentId')->willReturn($payment); $cancelService->cancelPayment('paymentId'); } diff --git a/test/unit/Services/DummyAdapter.php b/test/unit/Services/DummyAdapter.php index 3762808e..dda546d4 100755 --- a/test/unit/Services/DummyAdapter.php +++ b/test/unit/Services/DummyAdapter.php @@ -1,4 +1,6 @@ + * + * @package heidelpayPHP\test\unit\Services + */ +namespace heidelpayPHP\test\unit\Services; + +use heidelpayPHP\Services\EnvironmentService; +use PHPUnit\Framework\TestCase; + +class EnvironmentServiceTest extends TestCase +{ + // + + /** + * Verify test logging environment vars are correctly interpreted. + * + * @test + * @dataProvider envVarsShouldBeInterpretedAsExpectedDP + * + * @param mixed $logDisabled + * @param mixed $verboseLog + * @param bool $expectedLogEnabled + */ + public function envVarsShouldBeInterpretedAsExpected($logDisabled, $verboseLog, $expectedLogEnabled): void + { + unset( + $_SERVER[EnvironmentService::ENV_VAR_NAME_DISABLE_TEST_LOGGING], + $_SERVER[EnvironmentService::ENV_VAR_NAME_VERBOSE_TEST_LOGGING] + ); + + if ($logDisabled !== null) { + $_SERVER[EnvironmentService::ENV_VAR_NAME_DISABLE_TEST_LOGGING] = $logDisabled; + } + + if ($verboseLog !== null) { + $_SERVER[EnvironmentService::ENV_VAR_NAME_VERBOSE_TEST_LOGGING] = $verboseLog; + } + + $this->assertEquals($expectedLogEnabled, EnvironmentService::isTestLoggingActive()); + } + + /** + * Verify string is returned if the private test key environment variable is not set. + * + * @test + * + * @dataProvider keyStringIsReturnedCorrectlyDP + * + * @param string $keyEnvVar + * @param string $non3dsKeyEnvVar + * @param boolean $non3ds + * @param string $expected + */ + public function privateKeyStringIsReturnedCorrectly($keyEnvVar, $non3dsKeyEnvVar, $non3ds, $expected): void + { + unset( + $_SERVER[EnvironmentService::ENV_VAR_TEST_PRIVATE_KEY], + $_SERVER[EnvironmentService::ENV_VAR_TEST_PRIVATE_KEY_NON_3DS] + ); + + if ($keyEnvVar !== null) { + $_SERVER[EnvironmentService::ENV_VAR_TEST_PRIVATE_KEY] = $keyEnvVar; + } + + if ($non3dsKeyEnvVar !== null) { + $_SERVER[EnvironmentService::ENV_VAR_TEST_PRIVATE_KEY_NON_3DS] = $non3dsKeyEnvVar; + } + + $this->assertEquals($expected, EnvironmentService::getTestPrivateKey($non3ds)); + } + + /** + * Verify string is returned if the public test key environment variable is not set. + * + * @test + * + * @dataProvider keyStringIsReturnedCorrectlyDP + * + * @param string $keyEnvVar + * @param string $non3dsKeyEnvVar + * @param boolean $non3ds + * @param string $expected + */ + public function publicKeyStringIsReturnedCorrectly($keyEnvVar, $non3dsKeyEnvVar, $non3ds, $expected): void + { + unset( + $_SERVER[EnvironmentService::ENV_VAR_TEST_PUBLIC_KEY], + $_SERVER[EnvironmentService::ENV_VAR_TEST_PUBLIC_KEY_NON_3DS] + ); + + if ($keyEnvVar !== null) { + $_SERVER[EnvironmentService::ENV_VAR_TEST_PUBLIC_KEY] = $keyEnvVar; + } + + if ($non3dsKeyEnvVar !== null) { + $_SERVER[EnvironmentService::ENV_VAR_TEST_PUBLIC_KEY_NON_3DS] = $non3dsKeyEnvVar; + } + + $this->assertEquals($expected, EnvironmentService::getTestPublicKey($non3ds)); + } + + // + + // + + /** + * Data provider for envVarsShouldBeInterpretedAsExpected. + * + * @return array + */ + public function envVarsShouldBeInterpretedAsExpectedDP(): array + { + return [ + '#0' => [null, null, true], + '#1' => [0, null, true], + '#2' => [1, null, false], + '#3' => [null, 0, false], + '#4' => [null, 1, true], + '#5' => [0, 0, false], + '#6' => [0, 1, true], + '#7' => [1, 0, false], + '#8' => [1, 1, true], + '#9' => ["false", null, true], + '#10' => ["true", null, false], + '#11' => [null, "false", false], + '#12' => [null, "true", true], + '#13' => ["false", "false", false], + '#14' => ["false", "true", true], + '#15' => ["true", "false", false], + '#16' => ["true", "true", true], + '#17' => [false, null, true], + '#18' => [true, null, false], + '#19' => [null, false, false], + '#20' => [null, true, true], + '#21' => [false, false, false], + '#22' => [false, true, true], + '#23' => [true, false, false], + '#24' => [true, true, true], + '#25' => ['fals', null, true], + '#26' => ['tru', null, true], + '#27' => [null, 'fals', false], + '#28' => [null, 'tru', false], + '#29' => ['fals', 'fals', false], + '#30' => ['fals', 'tru', false], + '#31' => ['tru', 'fals', false], + '#32' => ['tru', 'tru', false], + '#33' => ['false', 'fals', false], + '#34' => ['false', 'tru', false], + '#35' => ['true', 'fals', false], + '#36' => ['true', 'tru', false], + '#37' => ['fals', 'false', false], + '#38' => ['fals', 'true', true], + '#39' => ['tru', 'false', false], + '#40' => ['tru', 'true', true], + ]; + } + + /** + * Data provider for privateKeyStringIsReturnedCorrectly and publicKeyStringIsReturnedCorrectly. + * + * @return array + */ + public function keyStringIsReturnedCorrectlyDP(): array + { + return [ + 'expect empty string for 3ds' => [null, null, false, ''], + 'expect empty string for non 3ds' => [null, null, true, ''], + 'expect string from 3ds Env Var' => ['I am the 3ds key', 'I am the non 3ds key', false, 'I am the 3ds key'], + 'expect string from non 3ds Env Var' => ['I am the 3ds key', 'I am the non 3ds key', true, 'I am the non 3ds key'] + ]; + } + + // +} diff --git a/test/unit/Services/HttpServiceTest.php b/test/unit/Services/HttpServiceTest.php index 8200e0b4..39a24e60 100755 --- a/test/unit/Services/HttpServiceTest.php +++ b/test/unit/Services/HttpServiceTest.php @@ -1,4 +1,6 @@ assertInstanceOf(CurlAdapter::class, $httpService->getAdapter()); @@ -58,10 +58,8 @@ public function getAdapterShouldReturnDefaultAdapterIfNonHasBeenSet() * Verify getAdapter will return custom adapter if it has been set. * * @test - * - * @throws RuntimeException */ - public function getAdapterShouldReturnCustomAdapterIfItHasBeenSet() + public function getAdapterShouldReturnCustomAdapterIfItHasBeenSet(): void { $dummyAdapter = new DummyAdapter(); $httpService = (new HttpService())->setHttpAdapter($dummyAdapter); @@ -73,7 +71,7 @@ public function getAdapterShouldReturnCustomAdapterIfItHasBeenSet() * * @test */ - public function environmentServiceShouldBeInjectable() + public function environmentServiceShouldBeInjectable(): void { $envService = new EnvironmentService(); $httpService = new HttpService(); @@ -86,11 +84,8 @@ public function environmentServiceShouldBeInjectable() * Verify send will throw exception if resource is null. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function sendShouldThrowExceptionIfResourceIsNotSet() + public function sendShouldThrowExceptionIfResourceIsNotSet(): void { $httpService = new HttpService(); $this->expectException(RuntimeException::class); @@ -102,12 +97,8 @@ public function sendShouldThrowExceptionIfResourceIsNotSet() * Verify send calls methods to setup and send request. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function sendShouldInitAndSendRequest() + public function sendShouldInitAndSendRequest(): void { $httpServiceMock = $this->getMockBuilder(HttpService::class)->setMethods(['getAdapter'])->getMock(); @@ -116,6 +107,7 @@ public function sendShouldInitAndSendRequest() )->getMock(); $resource = (new DummyResource())->setParentResource(new Heidelpay('s-priv-MyTestKey')); + /** @noinspection PhpParamsInspection */ $adapterMock->expects($this->once())->method('init')->with( $this->callback( static function ($url) { @@ -124,6 +116,7 @@ static function ($url) { '{"dummyResource": "JsonSerialized"}', 'GET' ); + /** @noinspection PhpParamsInspection */ $adapterMock->expects($this->once())->method('setUserAgent')->with('heidelpayPHP'); $headers = [ 'Authorization' => 'Basic cy1wcml2LU15VGVzdEtleTo=', @@ -152,12 +145,8 @@ static function ($url) { * @dataProvider languageShouldOnlyBeSetIfSpecificallyDefinedDP * * @param $locale - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function languageShouldOnlyBeSetIfSpecificallyDefined($locale) + public function languageShouldOnlyBeSetIfSpecificallyDefined($locale): void { $httpServiceMock = $this->getMockBuilder(HttpService::class)->setMethods(['getAdapter'])->getMock(); $adapterMock = $this->getMockBuilder(CurlAdapter::class)->setMethods(['setHeaders', 'execute'])->getMock(); @@ -165,6 +154,7 @@ public function languageShouldOnlyBeSetIfSpecificallyDefined($locale) $resource = (new DummyResource())->setParentResource(new Heidelpay('s-priv-MyTestKey', $locale)); + /** @noinspection PhpParamsInspection */ $adapterMock->expects($this->once())->method('setHeaders')->with( $this->callback( static function ($headers) use ($locale) { @@ -181,12 +171,8 @@ static function ($headers) use ($locale) { * Verify debugLog logs to debug handler if debug mode and a handler are set. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function sendShouldLogDebugMessagesIfDebugModeAndHandlerAreSet() + public function sendShouldLogDebugMessagesIfDebugModeAndHandlerAreSet(): void { $httpServiceMock = $this->getMockBuilder(HttpService::class)->setMethods(['getAdapter'])->getMock(); @@ -199,7 +185,7 @@ public function sendShouldLogDebugMessagesIfDebugModeAndHandlerAreSet() $loggerMock->expects($this->exactly(7))->method('log')->withConsecutive( [ $this->callback( static function ($string) { - return str_replace(['dev-api', 'stg-api'], 'api', $string) === '(' . (string)(getmypid()) . ') GET: https://api.heidelpay.com/v1/my/uri/123'; + return str_replace(['dev-api', 'stg-api'], 'api', $string) === '(' . (getmypid()) . ') GET: https://api.heidelpay.com/v1/my/uri/123'; }) ], [ $this->callback( @@ -211,10 +197,10 @@ static function ($string) { array_key_exists('SDK-TYPE', $elements) && array_key_exists('SDK-VERSION', $elements); }) ], - ['(' . (string)(getmypid()) . ') Response: (200) {"response":"myResponseString"}'], + ['(' . (getmypid()) . ') Response: (200) {"response":"myResponseString"}'], [ $this->callback( static function ($string) { - return str_replace(['dev-api', 'stg-api'], 'api', $string) === '(' . (string)(getmypid()) . ') POST: https://api.heidelpay.com/v1/my/uri/123'; + return str_replace(['dev-api', 'stg-api'], 'api', $string) === '(' . (getmypid()) . ') POST: https://api.heidelpay.com/v1/my/uri/123'; }) ], [ $this->callback( @@ -226,8 +212,8 @@ static function ($string) { array_key_exists('SDK-TYPE', $elements) && array_key_exists('SDK-VERSION', $elements); }) ], - ['(' . (string)(getmypid()) . ') Request: {"dummyResource": "JsonSerialized"}'], - ['(' . (string)(getmypid()) . ') Response: (201) {"response":"myResponseString"}'] + ['(' . (getmypid()) . ') Request: {"dummyResource": "JsonSerialized"}'], + ['(' . (getmypid()) . ') Response: (201) {"response":"myResponseString"}'] ); /** @var DebugHandlerInterface $loggerMock */ @@ -246,12 +232,8 @@ static function ($string) { * Verify handleErrors will throw Exception if response string is null. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function handleErrorsShouldThrowExceptionIfResponseIsEmpty() + public function handleErrorsShouldThrowExceptionIfResponseIsEmpty(): void { $httpServiceMock = $this->getMockBuilder(HttpService::class)->setMethods(['getAdapter'])->getMock(); @@ -278,12 +260,8 @@ public function handleErrorsShouldThrowExceptionIfResponseIsEmpty() * @dataProvider responseCodeProvider * * @param string $responseCode - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function handleErrorsShouldThrowExceptionIfResponseCodeIsGoE400($responseCode) + public function handleErrorsShouldThrowExceptionIfResponseCodeIsGoE400($responseCode): void { $httpServiceMock = $this->getMockBuilder(HttpService::class)->setMethods(['getAdapter'])->getMock(); @@ -308,11 +286,8 @@ public function handleErrorsShouldThrowExceptionIfResponseCodeIsGoE400($response * Verify handleErrors will throw Exception if response contains errors field. * * @test - * - * @throws ReflectionException - * @throws RuntimeException */ - public function handleErrorsShouldThrowExceptionIfResponseContainsErrorField() + public function handleErrorsShouldThrowExceptionIfResponseContainsErrorField(): void { $httpServiceMock = $this->getMockBuilder(HttpService::class)->setMethods(['getAdapter'])->getMock(); $adapterMock = $this->getMockBuilder(CurlAdapter::class)->setMethods( @@ -402,15 +377,11 @@ public function handleErrorsShouldThrowExceptionIfResponseContainsErrorField() * * @param $environment * @param $apiUrl - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws Exception */ - public function environmentUrlSwitchesWithEnvironmentVariable($environment, $apiUrl) + public function environmentUrlSwitchesWithEnvironmentVariable($environment, $apiUrl): void { $adapterMock = $this->getMockBuilder(CurlAdapter::class)->setMethods(['init', 'setUserAgent', 'setHeaders', 'execute', 'getResponseCode', 'close'])->getMock(); + /** @noinspection PhpParamsInspection */ $adapterMock->expects($this->once())->method('init')->with($apiUrl, self::anything(), self::anything()); $resource = (new DummyResource())->setParentResource(new Heidelpay('s-priv-MyTestKey')); $adapterMock->method('execute')->willReturn('myResponseString'); diff --git a/test/unit/Services/PaymentServiceTest.php b/test/unit/Services/PaymentServiceTest.php index 76a409ca..d607fcda 100755 --- a/test/unit/Services/PaymentServiceTest.php +++ b/test/unit/Services/PaymentServiceTest.php @@ -1,4 +1,6 @@ /** - * Verify authorizeWithPayment calls create for a new authorization using the passed values. + * Verify authorize calls create for a new authorization using the passed values. * * @test * * @param $card3ds - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException * @dataProvider card3dsDataProvider */ - public function authorizeShouldCreateNewAuthorizationAndPayment($card3ds) + public function authorizeShouldCreateNewAuthorizationAndPayment($card3ds): void { $customer = (new Customer())->setId('myCustomerId'); $metadata = (new Metadata())->setId('myMetadataId'); @@ -102,6 +97,7 @@ public function authorizeShouldCreateNewAuthorizationAndPayment($card3ds) /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['createResource'])->getMock(); $paymentSrv = (new Heidelpay('s-priv-123'))->setResourceService($resourceSrvMock)->getPaymentService(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource') ->with($this->callback(static function ($authorize) use ($customer, $metadata, $basket, $card3ds) { /** @var Authorization $authorize */ @@ -133,13 +129,9 @@ public function authorizeShouldCreateNewAuthorizationAndPayment($card3ds) * @test * * @param $card3ds - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException * @dataProvider card3dsDataProvider */ - public function chargeShouldCreateNewPaymentAndCharge($card3ds) + public function chargeShouldCreateNewPaymentAndCharge($card3ds): void { $customer = (new Customer())->setId('myCustomerId'); $heidelpay = new Heidelpay('s-priv-123'); @@ -148,6 +140,7 @@ public function chargeShouldCreateNewPaymentAndCharge($card3ds) $basket = (new Basket())->setId('myBasketId'); $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['createResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource') ->with($this->callback(static function ($charge) use ($customer, $paymentType, $basket, $card3ds) { /** @var Charge $charge */ @@ -175,12 +168,8 @@ public function chargeShouldCreateNewPaymentAndCharge($card3ds) * Verify chargeAuthorization calls chargePayment with the given payment object. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function chargeAuthorizationShouldCallChargePaymentWithTheGivenPaymentObject() + public function chargeAuthorizationShouldCallChargePaymentWithTheGivenPaymentObject(): void { $paymentObject = (new Payment())->setId('myPaymentId'); /** @var PaymentService|MockObject $paymentSrvMock */ @@ -196,12 +185,8 @@ public function chargeAuthorizationShouldCallChargePaymentWithTheGivenPaymentObj * Verify chargeAuthorization calls fetchPayment if the payment object is passed as id string. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function chargeAuthorizationShouldCallFetchPaymentIfThePaymentIsPassedAsIdString() + public function chargeAuthorizationShouldCallFetchPaymentIfThePaymentIsPassedAsIdString(): void { /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchPayment'])->disableOriginalConstructor()->getMock(); @@ -218,18 +203,15 @@ public function chargeAuthorizationShouldCallFetchPaymentIfThePaymentIsPassedAsI * Verify chargePayment will create a charge object and call create on ResourceService with it. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function chargePaymentShouldCallCreateOnResourceServiceWithNewCharge() + public function chargePaymentShouldCallCreateOnResourceServiceWithNewCharge(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('myPaymentId'); /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['createResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource') ->with($this->callback(static function ($charge) use ($payment) { /** @var Charge $charge */ @@ -246,25 +228,22 @@ public function chargePaymentShouldCallCreateOnResourceServiceWithNewCharge() $paymentSrv = $heidelpay->setResourceService($resourceSrvMock)->getPaymentService(); $returnedCharge = $paymentSrv->chargePayment($payment, 1.234, 'myTestCurrency'); - $this->assertArraySubset([$returnedCharge], $payment->getCharges()); + $this->assertEquals([$returnedCharge], $payment->getCharges()); } /** * Verify chargePayment will set Ids if they are defined. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function chargePaymentShouldSetArgumentsInNewChargeObject() + public function chargePaymentShouldSetArgumentsInNewChargeObject(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('myPaymentId'); /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['createResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource') ->with($this->callback(static function ($charge) use ($payment) { /** @var Charge $charge */ @@ -281,7 +260,7 @@ public function chargePaymentShouldSetArgumentsInNewChargeObject() $paymentSrv = $heidelpay->setResourceService($resourceSrvMock)->getPaymentService(); $returnedCharge = $paymentSrv->chargePayment($payment, 1.234, 'myTestCurrency', 'orderId', 'invoiceId'); - $this->assertArraySubset([$returnedCharge], $payment->getCharges()); + $this->assertEquals([$returnedCharge], $payment->getCharges()); } // @@ -292,12 +271,8 @@ public function chargePaymentShouldSetArgumentsInNewChargeObject() * Verify cancelAuthorization will create a cancellation object and call create on ResourceService with it. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function cancelAuthorizationShouldCallCreateOnResourceServiceWithNewCancellation() + public function cancelAuthorizationShouldCallCreateOnResourceServiceWithNewCancellation(): void { $heidelpay = new Heidelpay('s-priv-123'); $payment = (new Payment())->setParentResource($heidelpay)->setId('myPaymentId'); @@ -305,6 +280,7 @@ public function cancelAuthorizationShouldCallCreateOnResourceServiceWithNewCance /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['createResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource') ->with($this->callback(static function ($cancellation) use ($payment) { /** @var Cancellation $cancellation */ @@ -326,10 +302,6 @@ public function cancelAuthorizationShouldCallCreateOnResourceServiceWithNewCance * Verify cancelAuthorization will create a cancellation object and call create on ResourceService with it. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ public function cancelAuthorizationShouldNotAddCancellationIfCancellationFails(): void { @@ -357,12 +329,8 @@ public function cancelAuthorizationShouldNotAddCancellationIfCancellationFails() * Verify cancelAuthorizationByPayment will propagate to cancelAuthorization method. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function cancelAuthorizationByPaymentShouldCallCancelAuthorization() + public function cancelAuthorizationByPaymentShouldCallCancelAuthorization(): void { $authorization = (new Authorization())->setId('s-aut-1'); $heidelpay = new Heidelpay('s-priv-1234'); @@ -383,18 +351,15 @@ public function cancelAuthorizationByPaymentShouldCallCancelAuthorization() * Verify cancelChargeById fetches Charge and propagates to cancelCharge method. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function cancelChargeByIdShouldFetchChargeAndPropagateToCancelCharge() + public function cancelChargeByIdShouldFetchChargeAndPropagateToCancelCharge(): void { $payment = (new Payment())->setId('myPaymentId'); $charge = new Charge(); /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchChargeById'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->exactly(2))->method('fetchChargeById')->with($payment, 's-chg-1')->willReturn($charge); /** @var CancelServiceInterface|MockObject $cancelSrvMock */ @@ -410,12 +375,8 @@ public function cancelChargeByIdShouldFetchChargeAndPropagateToCancelCharge() * Verify cancelCharge creates new Cancellation and calls create on resourceService with it. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function cancelChargeShouldCreateCancellationAndCallsCreate() + public function cancelChargeShouldCreateCancellationAndCallsCreate(): void { $heidelpay = new Heidelpay('s-priv-1234'); $cancelSrv = $heidelpay->getCancelService(); @@ -424,6 +385,7 @@ public function cancelChargeShouldCreateCancellationAndCallsCreate() /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['createResource'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource') ->with($this->callback(static function ($cancellation) use ($payment, $charge) { return $cancellation instanceof Cancellation && @@ -445,18 +407,15 @@ public function cancelChargeShouldCreateCancellationAndCallsCreate() * ResourceService with the shipment object. * * @test - * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function shipShouldCreateShipmentAndCallCreateOnResourceServiceWithIt() + public function shipShouldCreateShipmentAndCallCreateOnResourceServiceWithIt(): void { $heidelpay = new Heidelpay('s-priv-1234'); $payment = new Payment(); /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['createResource'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->exactly(2))->method('createResource') ->with($this->callback(static function ($shipment) use ($payment) { return $shipment instanceof Shipment && @@ -480,12 +439,8 @@ public function shipShouldCreateShipmentAndCallCreateOnResourceServiceWithIt() * Verify payout method calls payout with payment. * * @test - * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function payoutShouldCreatePaymentAndCallPayoutWithPayment() + public function payoutShouldCreatePaymentAndCallPayoutWithPayment(): void { $paymentType = (new SepaDirectDebit('1234'))->setId('typeId'); $customer = (new Customer())->setId('customerId'); @@ -493,6 +448,7 @@ public function payoutShouldCreatePaymentAndCallPayoutWithPayment() /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['createResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects(self::once())->method('createResource') ->with(self::callback(static function ($payout) use ($customer, $metadata) { return $payout instanceof Payout && @@ -511,12 +467,8 @@ public function payoutShouldCreatePaymentAndCallPayoutWithPayment() * Verify payoutWithPayment calls create for a new payout using the passed values. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function payoutShouldCreateNewPayout() + public function payoutShouldCreateNewPayout(): void { // we provide some fake resources with ids to avoid them to be automatically created $customer = (new Customer())->setId('id-1'); @@ -526,6 +478,7 @@ public function payoutShouldCreateNewPayout() /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['createResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource') ->with($this->callback(static function ($payout) use ($customer, $basket, $metadata) { /** @var Payout $payout */ @@ -568,14 +521,8 @@ public function payoutShouldCreateNewPayout() * @dataProvider paymentShouldBeCreatedByInitPayPageDP * * @param string $action - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws Exception - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function paymentShouldBeCreatedByInitPayPage(string $action) + public function paymentShouldBeCreatedByInitPayPage(string $action): void { $method = 'initPayPage' . $action; @@ -590,6 +537,7 @@ public function paymentShouldBeCreatedByInitPayPage(string $action) $metadata = (new Metadata())->setId('metadataId'); // should + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource') ->with($this->callback(static function ($paypage) use ($basket, $customer, $metadata, $action) { return $paypage instanceof Paypage && @@ -612,15 +560,8 @@ public function paymentShouldBeCreatedByInitPayPage(string $action) * Verify fetch hdd instalment plans. * * @test - * - * @throws Exception - * @throws ReflectionException - * @throws \PHPUnit\Framework\MockObject\RuntimeException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws \Exception */ - public function fetchInstalmentPlansWillCallFetchOnResourceService() + public function fetchInstalmentPlansWillCallFetchOnResourceService(): void { $heidelpay = new Heidelpay('s-priv-1234'); /** @var MockObject|ResourceService $resourceSrvMock */ @@ -628,6 +569,7 @@ public function fetchInstalmentPlansWillCallFetchOnResourceService() $heidelpay->setResourceService($resourceSrvMock); $date = $this->getYesterdaysTimestamp(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchResource') ->with($this->callback(static function ($param) use ($date) { return $param instanceof InstalmentPlans && diff --git a/test/unit/Services/ResourceNameServiceTest.php b/test/unit/Services/ResourceNameServiceTest.php index 06546b55..7552c622 100755 --- a/test/unit/Services/ResourceNameServiceTest.php +++ b/test/unit/Services/ResourceNameServiceTest.php @@ -1,4 +1,6 @@ assertEquals($expected, ResourceNameService::getClassShortNameKebapCase($className)); } diff --git a/test/unit/Services/ResourceServiceTest.php b/test/unit/Services/ResourceServiceTest.php index e58581e3..debbd8ee 100755 --- a/test/unit/Services/ResourceServiceTest.php +++ b/test/unit/Services/ResourceServiceTest.php @@ -1,4 +1,6 @@ getResourceService(); $this->assertSame($heidelpay, $resourceService->getHeidelpay()); @@ -104,17 +101,12 @@ public function gettersAndSettersShouldWorkProperly() * @param string $method * @param string $uri * @param bool $appendId - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws \PHPUnit\Framework\Exception - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function sendShouldCallSendOnHttpService(string $method, string $uri, bool $appendId) + public function sendShouldCallSendOnHttpService(string $method, string $uri, bool $appendId): void { $heidelpay = new Heidelpay('s-priv-1234'); $resourceMock = $this->getMockBuilder(DummyResource::class)->setMethods(['getUri', 'getHeidelpayObject'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceMock->expects($this->once())->method('getUri')->with($appendId)->willReturn($uri); $resourceMock->method('getHeidelpayObject')->willReturn($heidelpay); $httpSrvMock = $this->getMockBuilder(HttpService::class)->setMethods(['send'])->getMock(); @@ -122,6 +114,7 @@ public function sendShouldCallSendOnHttpService(string $method, string $uri, boo /** @var HttpService $httpSrvMock */ $heidelpay->setHttpService($httpSrvMock); + /** @noinspection PhpParamsInspection */ $httpSrvMock->expects($this->once())->method('send')->with($uri, $resourceMock, $method)->willReturn('{"response": "This is the response"}'); /** @var AbstractHeidelpayResource $resourceMock */ @@ -142,11 +135,12 @@ public function sendShouldCallSendOnHttpService(string $method, string $uri, boo * @param string $expected * @param string $uri * @param string $idString - * - * @throws RuntimeException */ - public function getResourceIdFromUrlShouldIdentifyAndReturnTheIdStringFromAGivenString($expected, $uri, $idString) - { + public function getResourceIdFromUrlShouldIdentifyAndReturnTheIdStringFromAGivenString( + $expected, + $uri, + $idString + ): void { $this->assertEquals($expected, IdService::getResourceIdFromUrl($uri, $idString)); } @@ -156,12 +150,10 @@ public function getResourceIdFromUrlShouldIdentifyAndReturnTheIdStringFromAGiven * @test * @dataProvider failingUrlIdStringProvider * - * @throws RuntimeException - * * @param mixed $uri * @param mixed $idString */ - public function getResourceIdFromUrlShouldThrowExceptionIfTheIdCanNotBeFound($uri, $idString) + public function getResourceIdFromUrlShouldThrowExceptionIfTheIdCanNotBeFound($uri, $idString): void { $this->expectException(RuntimeException::class); IdService::getResourceIdFromUrl($uri, $idString); @@ -179,12 +171,8 @@ public function getResourceIdFromUrlShouldThrowExceptionIfTheIdCanNotBeFound($ur * * @param $resource * @param $timesFetchIsCalled - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchResourceIfTheResourcesIdIsSetAndItHasNotBeenFetchedBefore($resource, $timesFetchIsCalled) + public function fetchResourceIfTheResourcesIdIsSetAndItHasNotBeenFetchedBefore($resource, $timesFetchIsCalled): void { /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchResource'])->disableOriginalConstructor()->getMock(); @@ -197,22 +185,20 @@ public function fetchResourceIfTheResourcesIdIsSetAndItHasNotBeenFetchedBefore($ * Verify create method will call send method and call the resources handleResponse method with the response. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function createShouldCallSendAndThenHandleResponseWithTheResponseData() + public function createShouldCallSendAndThenHandleResponseWithTheResponseData(): void { $response = new stdClass(); $response->id = 'myTestId'; /** @var Customer|MockObject $testResource */ $testResource = $this->getMockBuilder(Customer::class)->setMethods(['handleResponse'])->getMock(); + /** @noinspection PhpParamsInspection */ $testResource->expects($this->once())->method('handleResponse')->with($response, HttpAdapterInterface::REQUEST_POST); /** @var ResourceService|MockObject $resourceServiceMock */ $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->setMethods(['send'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('send')->with($testResource, HttpAdapterInterface::REQUEST_POST)->willReturn($response); $this->assertSame($testResource, $resourceServiceMock->createResource($testResource)); @@ -223,12 +209,8 @@ public function createShouldCallSendAndThenHandleResponseWithTheResponseData() * Verify create does not handle response with error. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function createShouldNotHandleResponseWithError() + public function createShouldNotHandleResponseWithError(): void { $response = new stdClass(); $response->isError = true; @@ -240,6 +222,7 @@ public function createShouldNotHandleResponseWithError() /** @var ResourceService|MockObject $resourceServiceMock */ $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->setMethods(['send'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('send')->with($testResource, HttpAdapterInterface::REQUEST_POST)->willReturn($response); $this->assertSame($testResource, $resourceServiceMock->createResource($testResource)); @@ -250,21 +233,19 @@ public function createShouldNotHandleResponseWithError() * Verify update method will call send method and call the resources handleResponse method with the response. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function updateShouldCallSendAndThenHandleResponseWithTheResponseData() + public function updateShouldCallSendAndThenHandleResponseWithTheResponseData(): void { $response = new stdClass(); /** @var Customer|MockObject $testResource */ $testResource = $this->getMockBuilder(Customer::class)->setMethods(['handleResponse'])->getMock(); + /** @noinspection PhpParamsInspection */ $testResource->expects($this->once())->method('handleResponse')->with($response, HttpAdapterInterface::REQUEST_PUT); /** @var ResourceService|MockObject $resourceServiceMock */ $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->setMethods(['send'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('send')->with($testResource, HttpAdapterInterface::REQUEST_PUT)->willReturn($response); $this->assertSame($testResource, $resourceServiceMock->updateResource($testResource)); @@ -274,12 +255,8 @@ public function updateShouldCallSendAndThenHandleResponseWithTheResponseData() * Verify update does not handle response with error. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function updateShouldNotHandleResponseWithError() + public function updateShouldNotHandleResponseWithError(): void { /** @var Customer|MockObject $testResource */ $testResource = $this->getMockBuilder(Customer::class)->setMethods(['handleResponse'])->getMock(); @@ -287,6 +264,7 @@ public function updateShouldNotHandleResponseWithError() /** @var ResourceService|MockObject $resourceServiceMock */ $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->setMethods(['send'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('send')->with($testResource, HttpAdapterInterface::REQUEST_PUT)->willReturn((object)['isError' => true]); $this->assertSame($testResource, $resourceServiceMock->updateResource($testResource)); @@ -296,18 +274,15 @@ public function updateShouldNotHandleResponseWithError() * Verify delete method will call send method and set resource null if successful. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function deleteShouldCallSendAndThenSetTheResourceNull() + public function deleteShouldCallSendAndThenSetTheResourceNull(): void { /** @var Customer|MockObject $testResource */ $testResource = $this->getMockBuilder(Customer::class)->getMock(); /** @var ResourceService|MockObject $resourceServiceMock */ $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->setMethods(['send'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('send')->with($testResource, HttpAdapterInterface::REQUEST_DELETE)->willReturn(new stdClass()); $this->assertNull($resourceServiceMock->deleteResource($testResource)); @@ -318,18 +293,15 @@ public function deleteShouldCallSendAndThenSetTheResourceNull() * Verify delete does not delete resource object on error response. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function deleteShouldNotDeleteObjectOnResponseWithError() + public function deleteShouldNotDeleteObjectOnResponseWithError(): void { /** @var Customer|MockObject $testResource */ $testResource = $this->getMockBuilder(Customer::class)->getMock(); /** @var ResourceService|MockObject $resourceServiceMock */ $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->setMethods(['send'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('send')->with($testResource, HttpAdapterInterface::REQUEST_DELETE)->willReturn((object)['isError' => true]); $responseResource = $resourceServiceMock->deleteResource($testResource); @@ -342,23 +314,20 @@ public function deleteShouldNotDeleteObjectOnResponseWithError() * Verify fetch method will call send with GET the resource and then call handleResponse. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws Exception */ - public function fetchShouldCallSendWithGetUpdateFetchedAtAndCallHandleResponse() + public function fetchShouldCallSendWithGetUpdateFetchedAtAndCallHandleResponse(): void { $response = new stdClass(); $response->test = '234'; /** @var AbstractHeidelpayResource|MockObject $resourceMock */ $resourceMock = $this->getMockBuilder(Customer::class)->setMethods(['handleResponse'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceMock->expects($this->once())->method('handleResponse')->with($response); /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['send'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('send')->with($resourceMock, HttpAdapterInterface::REQUEST_GET)->willReturn($response); $this->assertNull($resourceMock->getFetchedAt()); @@ -378,13 +347,8 @@ public function fetchShouldCallSendWithGetUpdateFetchedAtAndCallHandleResponse() * @param string $fetchMethod * @param mixed $arguments * @param string $resourceUrl - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is a error while using the SDK. - * @throws ReflectionException */ - public function fetchResourceByUrlShouldFetchTheDesiredResource($fetchMethod, $arguments, $resourceUrl) + public function fetchResourceByUrlShouldFetchTheDesiredResource($fetchMethod, $arguments, $resourceUrl): void { /** @var Heidelpay|MockObject $heidelpayMock */ $heidelpayMock = $this->getMockBuilder(Heidelpay::class)->disableOriginalConstructor()->setMethods([$fetchMethod])->getMock(); @@ -400,18 +364,14 @@ public function fetchResourceByUrlShouldFetchTheDesiredResource($fetchMethod, $a * @test * @dataProvider fetchResourceByUrlForAPaymentTypeShouldCallFetchPaymentTypeDP * - * @param $paymentTypeId + * @param string $paymentTypeId * @param string $resourceUrl - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is a error while using the SDK. - * @throws ReflectionException */ - public function fetchResourceByUrlForAPaymentTypeShouldCallFetchPaymentType($paymentTypeId, $resourceUrl) + public function fetchResourceByUrlForAPaymentTypeShouldCallFetchPaymentType($paymentTypeId, $resourceUrl): void { /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['fetchPaymentType'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchPaymentType')->with($paymentTypeId); $resourceSrvMock->fetchResourceByUrl($resourceUrl); @@ -421,13 +381,8 @@ public function fetchResourceByUrlForAPaymentTypeShouldCallFetchPaymentType($pay * Verify does not call fetchResourceByUrl and returns null if the resource type is unknown. * * @test - * - * @throws Exception - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is a error while using the SDK. - * @throws ReflectionException */ - public function fetchResourceByUrlForAPaymentTypeShouldReturnNullIfTheTypeIsUnknown() + public function fetchResourceByUrlForAPaymentTypeShouldReturnNullIfTheTypeIsUnknown(): void { /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['fetchPaymentType'])->getMock(); @@ -445,18 +400,14 @@ public function fetchResourceByUrlForAPaymentTypeShouldReturnNullIfTheTypeIsUnkn * @param string $fetchMethod * @param array $arguments * @param mixed $callback - * - * @throws ReflectionException - * @throws \PHPUnit\Framework\Exception - * @throws \PHPUnit\Framework\MockObject\RuntimeException - * @throws RuntimeException */ - public function fetchShouldCallFetchResource(string $fetchMethod, array $arguments, $callback) + public function fetchShouldCallFetchResource(string $fetchMethod, array $arguments, $callback): void { $heidelpay = new Heidelpay('s-priv-1234'); /** @var ResourceService|MockObject $resourceServiceMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchResource'])->setConstructorArgs([$heidelpay])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchResource')->with($this->callback( static function ($resource) use ($callback, $heidelpay) { /** @var AbstractHeidelpayResource $resource */ @@ -478,17 +429,14 @@ static function ($resource) use ($callback, $heidelpay) { * Verify createPaymentType method will set parentResource to heidelpay object and call create. * * @test - * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function createPaymentTypeShouldSetHeidelpayObjectAndCallCreate() + public function createPaymentTypeShouldSetHeidelpayObjectAndCallCreate(): void { $heidelpay = new Heidelpay('s-priv-1234'); $paymentType = new Sofort(); $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['createResource'])->setConstructorArgs([$heidelpay])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource') ->with($this->callback(static function ($type) use ($heidelpay, $paymentType) { return $type === $paymentType && $type->getHeidelpayObject() === $heidelpay; @@ -507,12 +455,8 @@ public function createPaymentTypeShouldSetHeidelpayObjectAndCallCreate() * @dataProvider paymentTypeIdProviderInvalid * * @param string $typeId - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchPaymentTypeShouldThrowExceptionOnInvalidTypeId($typeId) + public function fetchPaymentTypeShouldThrowExceptionOnInvalidTypeId($typeId): void { $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchResource'])->disableOriginalConstructor()->getMock(); $resourceSrvMock->expects($this->never())->method('fetchResource'); @@ -528,19 +472,14 @@ public function fetchPaymentTypeShouldThrowExceptionOnInvalidTypeId($typeId) * Update payment type should call update method. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws \PHPUnit\Framework\Exception - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function updatePaymentTypeShouldCallUpdateMethod() + public function updatePaymentTypeShouldCallUpdateMethod(): void { $paymentType = (new HirePurchaseDirectDebit())->setId('paymentTypeId'); /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['updateResource'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('updateResource')->with($paymentType)->willReturn($paymentType); $returnedPaymentType = $resourceSrvMock->updatePaymentType($paymentType); @@ -556,17 +495,14 @@ public function updatePaymentTypeShouldCallUpdateMethod() * Verify createCustomer calls create with customer object and the heidelpay resource is set. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function createCustomerShouldCallCreateWithCustomerObjectAndSetHeidelpayReference() + public function createCustomerShouldCallCreateWithCustomerObjectAndSetHeidelpayReference(): void { $heidelpay = new Heidelpay('s-priv-1234'); $customer = new Customer(); $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['createResource'])->setConstructorArgs([$heidelpay])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource') ->with($this->callback(static function ($resource) use ($heidelpay, $customer) { return $resource === $customer && $resource->getHeidelpayObject() === $heidelpay; @@ -582,12 +518,8 @@ public function createCustomerShouldCallCreateWithCustomerObjectAndSetHeidelpayR * Verify createOrUpdateCustomer method tries to fetch and update the given customer. * * @test - * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function createOrUpdateCustomerShouldFetchAndUpdateCustomerIfItAlreadyExists() + public function createOrUpdateCustomerShouldFetchAndUpdateCustomerIfItAlreadyExists(): void { $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['createCustomer', 'fetchCustomerByExtCustomerId', 'updateCustomer'])->getMock(); @@ -598,15 +530,18 @@ public function createOrUpdateCustomerShouldFetchAndUpdateCustomerIfItAlreadyExi $fetchedCustomer = CustomerFactory::createCustomer('Max', 'Mustermann')->setCustomerId('externalCustomerId')->setId('customerId'); // throw exception to indicate a customer with the given customerId already exists + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createCustomer')->with($customer)->willThrowException(new HeidelpayApiException('', '', ApiResponseCodes::API_ERROR_CUSTOMER_ID_ALREADY_EXISTS)); // Expect the customer to be fetched by its customerId if it already exists and has to be updated. + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchCustomerByExtCustomerId') ->with($this->callback(static function ($customerId) use ($customer) { return $customerId === $customer->getCustomerId(); }))->willReturn($fetchedCustomer); // Expect the fetched customer is then updated with the new data. + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('updateCustomer') ->with($this->callback(static function ($customerToUpdate) use ($customer) { /** @var Customer $customerToUpdate */ @@ -628,18 +563,15 @@ public function createOrUpdateCustomerShouldFetchAndUpdateCustomerIfItAlreadyExi * to another reason then id already exists. * * @test - * - * @throws ReflectionException - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function createOrUpdateCustomerShouldThrowTheExceptionIfItIsNotCustomerIdAlreadyExists() + public function createOrUpdateCustomerShouldThrowTheExceptionIfItIsNotCustomerIdAlreadyExists(): void { $customer = (new Customer())->setCustomerId('externalCustomerId')->setEmail('customer@email.de'); $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['createCustomer', 'fetchCustomer', 'updateCustomer'])->getMock(); $exc = new HeidelpayApiException('', '', ApiResponseCodes::API_ERROR_CUSTOMER_ID_REQUIRED); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createCustomer')->with($customer)->willThrowException($exc); $resourceSrvMock->expects($this->never())->method('fetchCustomer'); $resourceSrvMock->expects($this->never())->method('updateCustomer'); @@ -655,17 +587,14 @@ public function createOrUpdateCustomerShouldThrowTheExceptionIfItIsNotCustomerId * Verify fetchCustomer method calls fetch with the customer object provided. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchCustomerShouldCallFetchWithTheGivenCustomerAndSetHeidelpayReference() + public function fetchCustomerShouldCallFetchWithTheGivenCustomerAndSetHeidelpayReference(): void { $heidelpay = new Heidelpay('s-priv-123'); $customer = (new Customer())->setId('myCustomerId'); $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchResource'])->setConstructorArgs([$heidelpay])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchResource')->with($customer); try { @@ -686,17 +615,14 @@ public function fetchCustomerShouldCallFetchWithTheGivenCustomerAndSetHeidelpayR * Verify updateCustomer calls update with customer object. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function updateCustomerShouldCallUpdateWithCustomerObject() + public function updateCustomerShouldCallUpdateWithCustomerObject(): void { $customer = (new Customer())->setId('customerId'); /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['updateResource'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('updateResource')->with($customer); $returnedCustomer = $resourceSrvMock->updateCustomer($customer); @@ -707,42 +633,35 @@ public function updateCustomerShouldCallUpdateWithCustomerObject() * Verify deleteCustomer method calls delete with customer object. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function deleteCustomerShouldCallDeleteWithTheGivenCustomer() + public function deleteCustomerShouldCallDeleteWithTheGivenCustomer(): void { $customer = (new Customer())->setId('customerId'); /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['deleteResource'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('deleteResource')->with($customer); - $returnedCustomer = $resourceSrvMock->deleteCustomer($customer); - $this->assertSame($customer, $returnedCustomer); + $resourceSrvMock->deleteCustomer($customer); } /** * Verify deleteCustomer calls fetchCustomer with id if the customer object is referenced by id. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function deleteCustomerShouldFetchCustomerByIdIfTheIdIsGiven() + public function deleteCustomerShouldFetchCustomerByIdIfTheIdIsGiven(): void { $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['deleteResource', 'fetchCustomer'])->disableOriginalConstructor()->getMock(); $customer = CustomerFactory::createCustomer('Max', 'Mustermann'); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchCustomer')->with('myCustomerId')->willReturn($customer); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('deleteResource')->with($customer); /** @var ResourceServiceInterface $resourceSrvMock */ - $returnedCustomer = $resourceSrvMock->deleteCustomer('myCustomerId'); - $this->assertSame($customer, $returnedCustomer); + $resourceSrvMock->deleteCustomer('myCustomerId'); } // @@ -753,12 +672,8 @@ public function deleteCustomerShouldFetchCustomerByIdIfTheIdIsGiven() * Verify fetchAuthorization fetches payment object and returns its authorization. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchAuthorizationShouldFetchPaymentAndReturnItsAuthorization() + public function fetchAuthorizationShouldFetchPaymentAndReturnItsAuthorization(): void { $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchPayment', 'fetchResource'])->disableOriginalConstructor()->getMock(); $paymentMock = $this->getMockBuilder(Payment::class)->setMethods(['getAuthorization'])->getMock(); @@ -766,8 +681,10 @@ public function fetchAuthorizationShouldFetchPaymentAndReturnItsAuthorization() $authorize = (new Authorization())->setId('s-aut-1'); /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchPayment')->with($paymentMock)->willReturn($paymentMock); $paymentMock->expects($this->once())->method('getAuthorization')->willReturn($authorize); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchResource')->with($authorize)->willReturn($authorize); $returnedAuthorize = $resourceSrvMock->fetchAuthorization($paymentMock); @@ -778,14 +695,8 @@ public function fetchAuthorizationShouldFetchPaymentAndReturnItsAuthorization() * Verify fetchAuthorization will throw runtime error if the given payment does not seem to have an authorization. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws \PHPUnit\Framework\Exception - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function fetchAuthorizationShouldThrowExceptionIfNoAuthorizationIsPresent() + public function fetchAuthorizationShouldThrowExceptionIfNoAuthorizationIsPresent(): void { /** @var MockObject|ResourceService $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['fetchPayment'])->getMock(); @@ -808,19 +719,17 @@ public function fetchAuthorizationShouldThrowExceptionIfNoAuthorizationIsPresent * Verify fetchPayout fetches payment object and returns its payout. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchPayoutShouldFetchPaymentAndReturnItsPayout() + public function fetchPayoutShouldFetchPaymentAndReturnItsPayout(): void { $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchPayment', 'fetchResource'])->disableOriginalConstructor()->getMock(); $paymentMock = $this->getMockBuilder(Payment::class)->setMethods(['getPayout'])->getMock(); $payout = (new Payout())->setId('s-out-1'); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchPayment')->with($paymentMock)->willReturn($paymentMock); $paymentMock->expects($this->once())->method('getPayout')->willReturn($payout); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchResource')->with($payout)->willReturn($payout); /** @var ResourceServiceInterface $resourceSrvMock */ @@ -836,21 +745,20 @@ public function fetchPayoutShouldFetchPaymentAndReturnItsPayout() * Verify fetchChargeById fetches payment object and gets and returns the charge object from it. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchChargeByIdShouldFetchPaymentAndReturnTheChargeOfThePayment() + public function fetchChargeByIdShouldFetchPaymentAndReturnTheChargeOfThePayment(): void { $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchPayment', 'fetchResource'])->disableOriginalConstructor()->getMock(); $paymentMock = $this->getMockBuilder(Payment::class)->setMethods(['getCharge'])->getMock(); $charge = (new Charge())->setId('chargeId'); + /** @noinspection PhpParamsInspection */ $paymentMock->expects($this->once())->method('getCharge')->with('chargeId')->willReturn($charge); /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchPayment')->with($paymentMock)->willReturn($paymentMock); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchResource')->with($charge)->willReturn($charge); $returnedCharge = $resourceSrvMock->fetchChargeById($paymentMock, 'chargeId'); @@ -861,17 +769,14 @@ public function fetchChargeByIdShouldFetchPaymentAndReturnTheChargeOfThePayment( * Verify fetchCharge fetches payment object and gets and returns the charge object from it. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchChargeShouldFetchPaymentAndReturnTheChargeOfThePayment() + public function fetchChargeShouldFetchPaymentAndReturnTheChargeOfThePayment(): void { /** @var ResourceService|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchResource'])->disableOriginalConstructor()->getMock(); $charge = (new Charge())->setId('chargeId'); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchResource')->with($charge)->willReturn($charge); $this->assertSame($charge, $resourceSrvMock->fetchCharge($charge)); @@ -881,19 +786,17 @@ public function fetchChargeShouldFetchPaymentAndReturnTheChargeOfThePayment() * Verify fetchChargeById throws exception if the charge can not be found. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchChargeByIdShouldThrowExceptionIfChargeDoesNotExist() + public function fetchChargeByIdShouldThrowExceptionIfChargeDoesNotExist(): void { /** @var MockObject|Payment $paymentMock */ $paymentMock = $this->getMockBuilder(Payment::class)->setMethods(['getCharge'])->getMock(); + /** @noinspection PhpParamsInspection */ $paymentMock->expects($this->once())->method('getCharge')->with('chargeId')->willReturn(null); /** @var MockObject|ResourceService $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchPayment'])->disableOriginalConstructor()->getMock(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchPayment')->with($paymentMock)->willReturn($paymentMock); $this->expectException(RuntimeException::class); @@ -909,12 +812,8 @@ public function fetchChargeByIdShouldThrowExceptionIfChargeDoesNotExist() * Verify fetchReversalByAuthorization fetches authorization and gets and returns the reversal object from it. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchReversalByAuthorizationShouldFetchAuthorizeAndReturnTheReversalFromIt() + public function fetchReversalByAuthorizationShouldFetchAuthorizeAndReturnTheReversalFromIt(): void { /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchResource'])->disableOriginalConstructor()->getMock(); @@ -922,7 +821,9 @@ public function fetchReversalByAuthorizationShouldFetchAuthorizeAndReturnTheReve $authorizeMock = $this->getMockBuilder(Authorization::class)->setMethods(['getCancellation'])->getMock(); $cancellation = new Cancellation(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchResource')->with($authorizeMock); + /** @noinspection PhpParamsInspection */ $authorizeMock->expects($this->once())->method('getCancellation')->with('cancelId')->willReturn($cancellation); $returnedCancel = $resourceSrvMock->fetchReversalByAuthorization($authorizeMock, 'cancelId'); @@ -933,12 +834,8 @@ public function fetchReversalByAuthorizationShouldFetchAuthorizeAndReturnTheReve * Verify fetchReversal will fetch payment by id and get and return the desired reversal from it. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchReversalShouldFetchPaymentAndReturnDesiredReversalFromIt() + public function fetchReversalShouldFetchPaymentAndReturnDesiredReversalFromIt(): void { $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchPayment'])->disableOriginalConstructor()->getMock(); $paymentMock = $this->getMockBuilder(Payment::class)->setMethods(['getAuthorization'])->getMock(); @@ -958,12 +855,8 @@ public function fetchReversalShouldFetchPaymentAndReturnDesiredReversalFromIt() * Verify fetchRefundById fetches charge object by id and fetches desired refund from it. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchRefundByIdShouldFetchChargeByIdAndThenFetchTheDesiredRefundFromIt() + public function fetchRefundByIdShouldFetchChargeByIdAndThenFetchTheDesiredRefundFromIt(): void { $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchChargeById', 'fetchRefund'])->disableOriginalConstructor()->getMock(); @@ -971,7 +864,9 @@ public function fetchRefundByIdShouldFetchChargeByIdAndThenFetchTheDesiredRefund $cancel = (new Cancellation())->setId('cancellationId'); /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchChargeById')->with('paymentId', 'chargeId')->willReturn($charge); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchRefund')->with($charge, 'cancellationId')->willReturn($cancel); $returnedCancellation = $resourceSrvMock->fetchRefundById('paymentId', 'chargeId', 'cancellationId'); @@ -982,18 +877,16 @@ public function fetchRefundByIdShouldFetchChargeByIdAndThenFetchTheDesiredRefund * Verify fetchRefund gets and fetches desired charge cancellation. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchRefundShouldGetAndFetchDesiredChargeCancellation() + public function fetchRefundShouldGetAndFetchDesiredChargeCancellation(): void { /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchResource'])->disableOriginalConstructor()->getMock(); $cancel = (new Cancellation())->setId('cancellationId'); $chargeMock = $this->getMockBuilder(Charge::class)->setMethods(['getCancellation'])->getMock(); + /** @noinspection PhpParamsInspection */ $chargeMock->expects($this->once())->method('getCancellation')->with('cancellationId', true)->willReturn($cancel); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchResource')->with($cancel)->willReturn($cancel); /** @var Charge $chargeMock*/ @@ -1009,18 +902,16 @@ public function fetchRefundShouldGetAndFetchDesiredChargeCancellation() * Verify fetchShipment fetches payment object and returns the desired shipment from it. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function fetchShipmentShouldFetchPaymentAndReturnTheDesiredShipmentFromIt() + public function fetchShipmentShouldFetchPaymentAndReturnTheDesiredShipmentFromIt(): void { /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['fetchPayment'])->disableOriginalConstructor()->getMock(); $paymentMock = $this->getMockBuilder(Payment::class)->setMethods(['getShipment'])->getMock(); $shipment = (new Shipment())->setId('shipmentId'); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('fetchPayment')->with('paymentId')->willReturn($paymentMock); + /** @noinspection PhpParamsInspection */ $paymentMock->expects($this->once())->method('getShipment')->with('shipmentId', false)->willReturn($shipment); /** @var Payment $paymentMock */ @@ -1036,16 +927,13 @@ public function fetchShipmentShouldFetchPaymentAndReturnTheDesiredShipmentFromIt * Verify createMetadata calls create with the given metadata object. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function createMetadataShouldCallCreateWithTheGivenMetadataObject() + public function createMetadataShouldCallCreateWithTheGivenMetadataObject(): void { /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setMethods(['createResource'])->disableOriginalConstructor()->getMock(); $metadata = new Metadata(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('createResource')->with($metadata); $this->assertSame($metadata, $resourceSrvMock->createMetadata($metadata)); @@ -1059,12 +947,8 @@ public function createMetadataShouldCallCreateWithTheGivenMetadataObject() * Verify createBasket will set parentResource and call create with the given basket. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function createBasketShouldSetTheParentResourceAndCallCreateWithTheGivenBasket() + public function createBasketShouldSetTheParentResourceAndCallCreateWithTheGivenBasket(): void { $heidelpay = new Heidelpay('s-priv-123'); /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ @@ -1087,17 +971,14 @@ public function createBasketShouldSetTheParentResourceAndCallCreateWithTheGivenB * Verify updateBasket calls update with the given basket and returns it. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException */ - public function updateBasketShouldCallUpdateAndReturnTheGivenBasket() + public function updateBasketShouldCallUpdateAndReturnTheGivenBasket(): void { $heidelpay = new Heidelpay('s-priv-123'); /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setConstructorArgs([$heidelpay])->setMethods(['updateResource'])->getMock(); $basket = new Basket(); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects($this->once())->method('updateResource')->with($basket); $returnedBasket = $resourceSrvMock->updateBasket($basket); @@ -1115,19 +996,15 @@ public function updateBasketShouldCallUpdateAndReturnTheGivenBasket() * Verify createRecurring calls fetch for the payment type if it is given the id. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws \PHPUnit\Framework\Exception - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function createRecurringShouldFetchThePaymentTypeById() + public function createRecurringShouldFetchThePaymentTypeById(): void { $paymentType = new TraitDummyCanRecur(); $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['fetchPaymentType', 'createResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects(self::once())->method('fetchPaymentType')->with('typeId')->willReturn($paymentType); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects(self::once())->method('createResource') ->with($this::callback(static function ($data) { return $data instanceof Recurring && $data->getReturnUrl() === 'returnUrl' && $data->getPaymentTypeId() === 'myId'; @@ -1141,19 +1018,14 @@ public function createRecurringShouldFetchThePaymentTypeById() * Verify createRecurring does not call fetch for the payment type if it is given the object itself. * * @test - * - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws \PHPUnit\Framework\Exception - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function createRecurringShouldNotFetchThePaymentTypeByObject() + public function createRecurringShouldNotFetchThePaymentTypeByObject(): void { $paymentType = new TraitDummyCanRecur(); /** @var ResourceServiceInterface|MockObject $resourceSrvMock */ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['fetchPaymentType', 'createResource'])->getMock(); $resourceSrvMock->expects(self::never())->method('fetchPaymentType'); + /** @noinspection PhpParamsInspection */ $resourceSrvMock->expects(self::once())->method('createResource') ->with($this::callback(static function ($data) { return $data instanceof Recurring && $data->getReturnUrl() === 'returnUrl' && $data->getPaymentTypeId() === 'myId'; @@ -1166,12 +1038,8 @@ public function createRecurringShouldNotFetchThePaymentTypeByObject() * Verify createRecurring throws exception if it is called with a payment type which does not support recurring payment. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws \PHPUnit\Framework\Exception */ - public function createRecurringShouldThrowExceptionWhenRecurringPaymentIsNotSupportedByType() + public function createRecurringShouldThrowExceptionWhenRecurringPaymentIsNotSupportedByType(): void { $resourceService = new ResourceService(new Heidelpay('s-priv-123')); $this->expectException(RuntimeException::class); @@ -1215,8 +1083,6 @@ public function failingUrlIdStringProvider(): array * Data provider for getResourceShouldFetchIfTheResourcesIdIsSetAndItHasNotBeenFetchedBefore. * * @return array - * - * @throws Exception */ public function fetchResourceFetchCallDP(): array { diff --git a/test/unit/Services/WebhooksServiceTest.php b/test/unit/Services/WebhooksServiceTest.php index b693cba7..846863a1 100755 --- a/test/unit/Services/WebhooksServiceTest.php +++ b/test/unit/Services/WebhooksServiceTest.php @@ -1,4 +1,6 @@ setMethods(['createResource'])->getMock(); /** @var ResourceServiceInterface $resourceServiceMock */ $webhookService->setResourceService($resourceServiceMock); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('createResource')->with($this->callback( static function ($param) use ($heidelpay) { return $param instanceof Webhook && @@ -105,12 +99,8 @@ static function ($param) use ($heidelpay) { * Verify fetch webhook calls resource service with the given webhook object. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function fetchWebhookShouldCallResourceServiceWithTheGivenWebhookObject() + public function fetchWebhookShouldCallResourceServiceWithTheGivenWebhookObject(): void { $heidelpay = new Heidelpay('s-priv-123'); $webhookService = new WebhookService($heidelpay); @@ -118,6 +108,7 @@ public function fetchWebhookShouldCallResourceServiceWithTheGivenWebhookObject() ->setMethods(['fetchResource'])->getMock(); /** @var ResourceServiceInterface $resourceServiceMock */ $webhookService->setResourceService($resourceServiceMock); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('fetchResource')->with($this->callback( static function ($param) use ($heidelpay) { return $param instanceof Webhook && $param->getHeidelpayObject() === $heidelpay; @@ -132,12 +123,8 @@ static function ($param) use ($heidelpay) { * Verify fetch webhook calls resource service with a new webhook object with the given id. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function fetchWebhookShouldCallResourceServiceWithANewWebhookObjectWithTheGivenId() + public function fetchWebhookShouldCallResourceServiceWithANewWebhookObjectWithTheGivenId(): void { $heidelpay = new Heidelpay('s-priv-123'); $webhookService = new WebhookService($heidelpay); @@ -145,6 +132,7 @@ public function fetchWebhookShouldCallResourceServiceWithANewWebhookObjectWithTh ->setMethods(['fetchResource'])->getMock(); /** @var ResourceServiceInterface $resourceServiceMock */ $webhookService->setResourceService($resourceServiceMock); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('fetchResource')->with($this->callback( static function ($param) use ($heidelpay) { return $param instanceof Webhook && @@ -160,12 +148,8 @@ static function ($param) use ($heidelpay) { * Verify update webhook calls resource service with the given webhook object. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function updateWebhookShouldCallResourceServiceWithTheGivenWebhookObject() + public function updateWebhookShouldCallResourceServiceWithTheGivenWebhookObject(): void { $heidelpay = new Heidelpay('s-priv-123'); $webhookService = new WebhookService($heidelpay); @@ -173,6 +157,7 @@ public function updateWebhookShouldCallResourceServiceWithTheGivenWebhookObject( ->setMethods(['updateResource'])->getMock(); /** @var ResourceServiceInterface $resourceServiceMock */ $webhookService->setResourceService($resourceServiceMock); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('updateResource')->with($this->callback( static function ($param) use ($heidelpay) { return $param instanceof Webhook && @@ -190,12 +175,8 @@ static function ($param) use ($heidelpay) { * Verify delete webhook calls resource service with the given webhook object. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function deleteWebhookShouldCallResourceServiceWithTheGivenWebhookObject() + public function deleteWebhookShouldCallResourceServiceWithTheGivenWebhookObject(): void { $heidelpay = new Heidelpay('s-priv-123'); $webhookService = new WebhookService($heidelpay); @@ -203,6 +184,7 @@ public function deleteWebhookShouldCallResourceServiceWithTheGivenWebhookObject( ->setMethods(['deleteResource'])->getMock(); /** @var ResourceServiceInterface $resourceServiceMock */ $webhookService->setResourceService($resourceServiceMock); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('deleteResource')->with($this->callback( static function ($param) { return $param instanceof Webhook && @@ -219,12 +201,8 @@ static function ($param) { * Verify delete webhook calls resource service with the given webhook object. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function deleteWebhookShouldCallResourceServiceFetchingAndDeletingTheWebhookWithTheGivenId() + public function deleteWebhookShouldCallResourceServiceFetchingAndDeletingTheWebhookWithTheGivenId(): void { $heidelpay = new Heidelpay('s-priv-123'); $webhookServiceMock = $this->getMockBuilder(WebhookService::class)->setConstructorArgs([$heidelpay]) @@ -238,8 +216,10 @@ public function deleteWebhookShouldCallResourceServiceFetchingAndDeletingTheWebh $webhookServiceMock->setResourceService($resourceServiceMock); $webhook = new Webhook('WebhookId', 'TestEvent'); + /** @noinspection PhpParamsInspection */ $webhookServiceMock->expects($this->once())->method('fetchWebhook')->with('WebhookId') ->willReturn($webhook); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('deleteResource')->with($this->callback( static function ($param) use ($webhook) { return $param === $webhook; @@ -259,12 +239,8 @@ static function ($param) use ($webhook) { * webhooks object as the fetch method is called. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function fetchWebhooksShouldCallResourceService() + public function fetchWebhooksShouldCallResourceService(): void { $heidelpay = new Heidelpay('s-priv-123'); $webhookService = new WebhookService($heidelpay); @@ -278,6 +254,7 @@ public function fetchWebhooksShouldCallResourceService() $webhookArray = ['webhook1', 'webhook2']; $webhooksMock->expects($this->once())->method('getWebhookList')->willReturn($webhookArray); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('fetchResource')->with($this->callback( static function ($param) use ($heidelpay) { return $param instanceof Webhooks && $param->getHeidelpayObject() === $heidelpay; @@ -291,12 +268,8 @@ static function ($param) use ($heidelpay) { * Verify delete webhooks calls resource service with a new webhooks object. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function deleteWebhooksShouldCallResourceServiceWithANewWebhooksObject() + public function deleteWebhooksShouldCallResourceServiceWithANewWebhooksObject(): void { $heidelpay = new Heidelpay('s-priv-123'); $webhookService = new WebhookService($heidelpay); @@ -304,6 +277,7 @@ public function deleteWebhooksShouldCallResourceServiceWithANewWebhooksObject() ->setMethods(['deleteResource'])->getMock(); /** @var ResourceServiceInterface $resourceServiceMock */ $webhookService->setResourceService($resourceServiceMock); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('deleteResource')->with($this->callback( static function ($param) use ($heidelpay) { return $param instanceof Webhooks && $param->getHeidelpayObject() === $heidelpay; @@ -317,12 +291,8 @@ static function ($param) use ($heidelpay) { * Verify create webhooks calls resource service with webhooks object. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. - * @throws ReflectionException */ - public function createWebhooksShouldCallResourceServiceWithNewWebhooksObject() + public function createWebhooksShouldCallResourceServiceWithNewWebhooksObject(): void { $heidelpay = new Heidelpay('s-priv-123'); $webhookService = new WebhookService($heidelpay); @@ -334,6 +304,7 @@ public function createWebhooksShouldCallResourceServiceWithNewWebhooksObject() $webhooksMock = $this->getMockBuilder(Webhooks::class)->setMethods(['getWebhookList'])->getMock(); $webhookList = ['ListItem1', 'ListItem2']; $webhooksMock->expects($this->once())->method('getWebhookList')->willReturn($webhookList); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('createResource')->with($this->callback( static function ($param) use ($heidelpay) { return $param instanceof Webhooks && @@ -357,13 +328,8 @@ static function ($param) use ($heidelpay) { * Verify exception is thrown if the retrieveURL is empty. * * @test - * - * @throws ReflectionException - * @throws RuntimeException - * @throws Exception - * @throws HeidelpayApiException */ - public function fetchResourceByEventWithEmptyRetrieveUrlShouldThrowException() + public function fetchResourceByEventWithEmptyRetrieveUrlShouldThrowException(): void { // override readInputStreamTo provide custom retrieveURL $webhookService = $this->getMockBuilder(WebhookService::class) @@ -381,13 +347,8 @@ public function fetchResourceByEventWithEmptyRetrieveUrlShouldThrowException() * Verify exception is thrown if the retrieveURL is empty. * * @test - * - * @throws ReflectionException - * @throws RuntimeException - * @throws Exception - * @throws HeidelpayApiException */ - public function fetchResourceByEventShouldThrowExceptionIfResourceObjectCanNotBeRetrieved() + public function fetchResourceByEventShouldThrowExceptionIfResourceObjectCanNotBeRetrieved(): void { // override readInputStreamTo provide custom retrieveURL $webhookService = $this->getMockBuilder(WebhookService::class) @@ -415,13 +376,8 @@ public function fetchResourceByEventShouldThrowExceptionIfResourceObjectCanNotBe * Verify fetch resource by event. * * @test - * - * @throws ReflectionException - * @throws RuntimeException - * @throws Exception - * @throws HeidelpayApiException */ - public function fetchResourceByEventShouldGetResourceServiceWithRetrieveUrl() + public function fetchResourceByEventShouldGetResourceServiceWithRetrieveUrl(): void { // setup received event $retrieveUrl = 'https://test/url'; @@ -436,6 +392,7 @@ public function fetchResourceByEventShouldGetResourceServiceWithRetrieveUrl() // inject resource service mock into webhook service to verify fetchResourceByUrl is called with the received url $resourceServiceMock = $this->getMockBuilder(ResourceService::class)->disableOriginalConstructor()->setMethods(['fetchResourceByUrl'])->getMock(); $dummyResource = new DummyResource(); + /** @noinspection PhpParamsInspection */ $resourceServiceMock->expects($this->once())->method('fetchResourceByUrl')->with($retrieveUrl)->willReturn($dummyResource); /** * @var ResourceServiceInterface $resourceServiceMock diff --git a/test/unit/Traits/CanAuthorizeTest.php b/test/unit/Traits/CanAuthorizeTest.php index 7dfcb303..d0fa54c0 100755 --- a/test/unit/Traits/CanAuthorizeTest.php +++ b/test/unit/Traits/CanAuthorizeTest.php @@ -1,4 +1,6 @@ getMockBuilder(Heidelpay::class)->setMethods(['authorize'])->disableOriginalConstructor()->getMock(); $dummyMock = $this->getMockBuilder(TraitDummyWithoutCustomerWithParentIF::class)->setMethods(['getHeidelpayObject'])->getMock(); diff --git a/test/unit/Traits/CanAuthorizeWithCustomerTest.php b/test/unit/Traits/CanAuthorizeWithCustomerTest.php index 5ffe4439..da88a722 100755 --- a/test/unit/Traits/CanAuthorizeWithCustomerTest.php +++ b/test/unit/Traits/CanAuthorizeWithCustomerTest.php @@ -1,4 +1,6 @@ getMockBuilder(Heidelpay::class)->setMethods(['authorize'])->disableOriginalConstructor()->getMock(); $dummyMock = $this->getMockBuilder(TraitDummyWithCustomerWithParentIF::class)->setMethods(['getHeidelpayObject'])->getMock(); diff --git a/test/unit/Traits/CanDirectChargeTest.php b/test/unit/Traits/CanDirectChargeTest.php index f88c18f7..75f41930 100755 --- a/test/unit/Traits/CanDirectChargeTest.php +++ b/test/unit/Traits/CanDirectChargeTest.php @@ -1,4 +1,6 @@ getMockBuilder(Heidelpay::class)->setMethods(['charge'])->disableOriginalConstructor()->getMock(); $dummyMock = $this->getMockBuilder(TraitDummyWithoutCustomerWithParentIF::class)->setMethods(['getHeidelpayObject'])->getMock(); diff --git a/test/unit/Traits/CanDirectChargeWithCustomerTest.php b/test/unit/Traits/CanDirectChargeWithCustomerTest.php index d36d7fea..d7623461 100755 --- a/test/unit/Traits/CanDirectChargeWithCustomerTest.php +++ b/test/unit/Traits/CanDirectChargeWithCustomerTest.php @@ -1,4 +1,6 @@ getMockBuilder(Heidelpay::class)->setMethods(['charge'])->disableOriginalConstructor()->getMock(); $dummyMock = $this->getMockBuilder(TraitDummyWithCustomerWithParentIF::class)->setMethods(['getHeidelpayObject'])->getMock(); diff --git a/test/unit/Traits/CanPayoutTest.php b/test/unit/Traits/CanPayoutTest.php index 09522314..23abf82b 100644 --- a/test/unit/Traits/CanPayoutTest.php +++ b/test/unit/Traits/CanPayoutTest.php @@ -1,4 +1,6 @@ getMockBuilder(Heidelpay::class)->setMethods(['payout'])->disableOriginalConstructor()->getMock(); $dummyMock = $this->getMockBuilder(TraitDummyWithoutCustomerWithParentIF::class)->setMethods(['getHeidelpayObject'])->getMock(); diff --git a/test/unit/Traits/CanPayoutWithCustomerTest.php b/test/unit/Traits/CanPayoutWithCustomerTest.php index 8ba0c129..c7899d6c 100644 --- a/test/unit/Traits/CanPayoutWithCustomerTest.php +++ b/test/unit/Traits/CanPayoutWithCustomerTest.php @@ -1,4 +1,6 @@ getMockBuilder(Heidelpay::class)->setMethods(['payout'])->disableOriginalConstructor()->getMock(); $dummyMock = $this->getMockBuilder(TraitDummyWithCustomerWithParentIF::class)->setMethods(['getHeidelpayObject'])->getMock(); diff --git a/test/unit/Traits/CanRecurTest.php b/test/unit/Traits/CanRecurTest.php index 293bd00f..23ee6f4c 100644 --- a/test/unit/Traits/CanRecurTest.php +++ b/test/unit/Traits/CanRecurTest.php @@ -1,4 +1,6 @@ assertFalse($dummy->isRecurring()); @@ -57,11 +53,8 @@ public function gettersAndSettersShouldWorkProperly() * Verify recurring activation on a resource which is not an abstract resource will throw an exception. * * @test - * - * @throws HeidelpayApiException A HeidelpayApiException is thrown if there is an error returned on API-request. - * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK. */ - public function activateRecurringWillThrowExceptionIfTheObjectHasWrongType() + public function activateRecurringWillThrowExceptionIfTheObjectHasWrongType(): void { $dummy = new TraitDummyCanRecurNonResource(); @@ -73,19 +66,14 @@ public function activateRecurringWillThrowExceptionIfTheObjectHasWrongType() * Verify activation on object will call heidelpay. * * @test - * - * @throws Exception - * @throws HeidelpayApiException - * @throws ReflectionException - * @throws RuntimeException - * @throws \PHPUnit\Framework\MockObject\RuntimeException */ - public function activateRecurringWillCallHeidelpayMethod() + public function activateRecurringWillCallHeidelpayMethod(): void { $heidelpayMock = $this->getMockBuilder(Heidelpay::class)->disableOriginalConstructor()->setMethods(['activateRecurringPayment'])->getMock(); /** @var Heidelpay $heidelpayMock */ $dummy = (new TraitDummyCanRecur())->setParentResource($heidelpayMock); + /** @noinspection PhpParamsInspection */ $heidelpayMock->expects(self::once())->method('activateRecurringPayment')->with($dummy, 'return url')->willReturn(new Recurring('', '')); $dummy->activateRecurring('return url'); diff --git a/test/unit/Traits/HasCancellationsTest.php b/test/unit/Traits/HasCancellationsTest.php index 24904f05..9b98071e 100755 --- a/test/unit/Traits/HasCancellationsTest.php +++ b/test/unit/Traits/HasCancellationsTest.php @@ -1,4 +1,6 @@ assertIsEmptyArray($dummy->getCancellations()); @@ -56,7 +52,7 @@ public function hasCancellationGettersAndSettersShouldWorkProperly() $dummy->addCancellation($cancellation1); $dummy->addCancellation($cancellation2); $dummy->addCancellation($cancellation3); - $this->assertArraySubset([$cancellation1, $cancellation2, $cancellation3], $dummy->getCancellations()); + $this->assertEquals([$cancellation1, $cancellation2, $cancellation3], $dummy->getCancellations()); // assert getCancellation $this->assertSame($cancellation3, $dummy->getCancellation('3', true)); @@ -66,22 +62,19 @@ public function hasCancellationGettersAndSettersShouldWorkProperly() $cancellation5 = (new Cancellation())->setId('5'); $cancellation6 = (new Cancellation())->setId('6'); $dummy->setCancellations([$cancellation4, $cancellation5, $cancellation6]); - $this->assertArraySubset([$cancellation4, $cancellation5, $cancellation6], $dummy->getCancellations()); + $this->assertEquals([$cancellation4, $cancellation5, $cancellation6], $dummy->getCancellations()); } /** * Verify getCancellation will call getResource with the selected Cancellation if it is not lazy loaded. * * @test - * - * @throws RuntimeException - * @throws ReflectionException - * @throws HeidelpayApiException */ - public function getCancellationShouldCallGetResourceIfItIsNotLazyLoaded() + public function getCancellationShouldCallGetResourceIfItIsNotLazyLoaded(): void { $cancel = (new Cancellation())->setId('myCancelId'); $authorizeMock = $this->getMockBuilder(Authorization::class)->setMethods(['getResource'])->getMock(); + /** @noinspection PhpParamsInspection */ $authorizeMock->expects($this->once())->method('getResource')->with($cancel); /** @var Authorization $authorizeMock */ diff --git a/test/unit/Traits/HasInvoiceIdTest.php b/test/unit/Traits/HasInvoiceIdTest.php index 180628fa..ec282b8e 100755 --- a/test/unit/Traits/HasInvoiceIdTest.php +++ b/test/unit/Traits/HasInvoiceIdTest.php @@ -1,4 +1,6 @@ assertNull($dummy->getInvoiceId()); diff --git a/test/unit/Traits/HasPaymentStateTest.php b/test/unit/Traits/HasPaymentStateTest.php index 3cfb5504..7290dc0d 100755 --- a/test/unit/Traits/HasPaymentStateTest.php +++ b/test/unit/Traits/HasPaymentStateTest.php @@ -1,4 +1,6 @@ assertEquals(PaymentState::STATE_PENDING, $traitDummy->getState()); $this->assertEquals(PaymentState::STATE_NAME_PENDING, $traitDummy->getStateName()); diff --git a/test/unit/Traits/TraitDummyCanRecur.php b/test/unit/Traits/TraitDummyCanRecur.php index c607da43..095b8c62 100644 --- a/test/unit/Traits/TraitDummyCanRecur.php +++ b/test/unit/Traits/TraitDummyCanRecur.php @@ -1,4 +1,6 @@ assertEquals($expectedResult, PrivateKeyValidator::validate($key)); } diff --git a/test/unit/Validators/PublicKeyValidatorTest.php b/test/unit/Validators/PublicKeyValidatorTest.php index 46be7063..c0cba973 100755 --- a/test/unit/Validators/PublicKeyValidatorTest.php +++ b/test/unit/Validators/PublicKeyValidatorTest.php @@ -1,4 +1,6 @@ assertEquals($expectedResult, PublicKeyValidator::validate($key)); }