From 90d646b59623a796cd167d3795f333c1224d7194 Mon Sep 17 00:00:00 2001 From: sixer1182 Date: Tue, 26 Nov 2019 09:35:46 +0100 Subject: [PATCH 1/2] [bugfix] (PHPLIB-275) Fix a bug leading to an error when cancelling first charge of a charged invoice payment. --- CHANGELOG.md | 6 ++++++ src/Heidelpay.php | 2 +- src/Resources/Payment.php | 1 + test/unit/Resources/PaymentCancelTest.php | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c25a99ff..54f436da 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ 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.5.1][1.2.5.1] + +### Fix +* A bug which led to an error when trying to cancel the initial transaction of a charged invoice. + ## [1.2.5.0][1.2.5.0] ### Added @@ -332,3 +337,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [1.2.3.0]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.2.0..1.2.3.0 [1.2.4.0]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.3.0..1.2.4.0 [1.2.5.0]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.4.0..1.2.5.0 +[1.2.5.1]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.5.0..1.2.5.1 diff --git a/src/Heidelpay.php b/src/Heidelpay.php index 9eb65262..4402db82 100755 --- a/src/Heidelpay.php +++ b/src/Heidelpay.php @@ -58,7 +58,7 @@ class Heidelpay implements HeidelpayParentInterface const BASE_URL = 'api.heidelpay.com'; const API_VERSION = 'v1'; const SDK_TYPE = 'HeidelpayPHP'; - const SDK_VERSION = '1.2.5.0'; + const SDK_VERSION = '1.2.5.1'; /** @var string $key */ private $key; diff --git a/src/Resources/Payment.php b/src/Resources/Payment.php index 9df4e8c0..b7c6724c 100755 --- a/src/Resources/Payment.php +++ b/src/Resources/Payment.php @@ -713,6 +713,7 @@ public function cancelAmount( } catch (HeidelpayApiException $e) { $allowedErrors = [ ApiResponseCodes::API_ERROR_ALREADY_CANCELLED, + ApiResponseCodes::API_ERROR_ALREADY_CHARGED, ApiResponseCodes::API_ERROR_ALREADY_CHARGED_BACK ]; diff --git a/test/unit/Resources/PaymentCancelTest.php b/test/unit/Resources/PaymentCancelTest.php index 47a89939..56abc43d 100644 --- a/test/unit/Resources/PaymentCancelTest.php +++ b/test/unit/Resources/PaymentCancelTest.php @@ -426,7 +426,7 @@ public function allowedErrorCodesDuringChargeCancel(): array { return [ 'already cancelled' => [ApiResponseCodes::API_ERROR_ALREADY_CANCELLED, false], - 'already chargedBack' => [ApiResponseCodes::API_ERROR_ALREADY_CANCELLED, false], + 'already chargedBack' => [ApiResponseCodes::API_ERROR_ALREADY_CHARGED, false], 'other' => [ApiResponseCodes::API_ERROR_BASKET_ITEM_IMAGE_INVALID_URL, true] ]; } From 46f15b061fe368c7813eb8951301a12b5eff602d Mon Sep 17 00:00:00 2001 From: sixer1182 Date: Tue, 26 Nov 2019 10:23:34 +0100 Subject: [PATCH 2/2] [bugfix] (PHPLIB-275) Refactor tests. --- test/unit/Resources/PaymentCancelTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/Resources/PaymentCancelTest.php b/test/unit/Resources/PaymentCancelTest.php index 56abc43d..bb17815a 100644 --- a/test/unit/Resources/PaymentCancelTest.php +++ b/test/unit/Resources/PaymentCancelTest.php @@ -426,7 +426,8 @@ public function allowedErrorCodesDuringChargeCancel(): array { return [ 'already cancelled' => [ApiResponseCodes::API_ERROR_ALREADY_CANCELLED, false], - 'already chargedBack' => [ApiResponseCodes::API_ERROR_ALREADY_CHARGED, false], + 'already charged' => [ApiResponseCodes::API_ERROR_ALREADY_CHARGED, false], + 'already chargedBack' => [ApiResponseCodes::API_ERROR_ALREADY_CHARGED_BACK, false], 'other' => [ApiResponseCodes::API_ERROR_BASKET_ITEM_IMAGE_INVALID_URL, true] ]; }