From 8cc2820e4082a797cdad15edb20e5138501b87b4 Mon Sep 17 00:00:00 2001 From: Georgios Date: Tue, 12 Oct 2021 09:52:43 +0100 Subject: [PATCH] fix: payment expiry year should be a 4 digit number (#8) --- CHANGELOG.md | 8 ++++++++ src/Katanox/Model/Booking/Payment.php | 6 +++--- tests/Katanox/ModelTest.php | 6 +++--- tests/Katanox/Resource/BookingResourceTest.php | 8 ++++---- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09793cf7..5076d48e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to `katanox-php` will be documented in this file. Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) principles. +## [3.2.0] - 2021-10-11 +### Changed +- The expiry year should now be a 4 digit number + +## [3.1.1] - 2021-09-29 +### Changed +- Resource url is now a variable instead of const + ## [3.1.0] - 2021-09-29 ### Bugfix - Include parameters of AvailabilityQuery are now used as expected in query string diff --git a/src/Katanox/Model/Booking/Payment.php b/src/Katanox/Model/Booking/Payment.php index 2eba3fcb..947404f3 100644 --- a/src/Katanox/Model/Booking/Payment.php +++ b/src/Katanox/Model/Booking/Payment.php @@ -103,7 +103,7 @@ public function getExpiryMonth(): string /** * @throws InvalidArgumentException */ - public function setExpirtyMonth(string $expiryMonth): Payment + public function setExpiryMonth(string $expiryMonth): Payment { if (2 !== strlen($expiryMonth)) { throw new InvalidArgumentException('Invalid expiry month. Format must be: xx'); @@ -118,8 +118,8 @@ public function setExpirtyMonth(string $expiryMonth): Payment */ public function setExpiryYear(string $expiryYear): Payment { - if (2 !== strlen($expiryYear)) { - throw new InvalidArgumentException('Invalid expiry year. Format must be: xx'); + if (4 !== strlen($expiryYear)) { + throw new InvalidArgumentException('Invalid expiry year. Format must be: xxxx'); } $this->expiry_year = $expiryYear; diff --git a/tests/Katanox/ModelTest.php b/tests/Katanox/ModelTest.php index 7eb32150..d4bb87a8 100644 --- a/tests/Katanox/ModelTest.php +++ b/tests/Katanox/ModelTest.php @@ -291,7 +291,7 @@ public function testBookingToArray() 'cvv' => '111', 'card_holder' => 'Holder', 'expiry_month' => '08', - 'expiry_year' => '22', + 'expiry_year' => '2022', ], ]; @@ -329,8 +329,8 @@ private function createPayment() $payment->setCardHolder('Holder'); $payment->setCVV('111'); $payment->setType('VISA'); - $payment->setExpirtyMonth('08'); - $payment->setExpiryYear('22'); + $payment->setExpiryMonth('08'); + $payment->setExpiryYear('2022'); $payment->setCardNumber('11111111111111111111'); return $payment; diff --git a/tests/Katanox/Resource/BookingResourceTest.php b/tests/Katanox/Resource/BookingResourceTest.php index 800c84c9..4f9dd8cb 100644 --- a/tests/Katanox/Resource/BookingResourceTest.php +++ b/tests/Katanox/Resource/BookingResourceTest.php @@ -101,7 +101,7 @@ public function testSuccesfulCreateBooking() 'cvv' => '111', 'card_holder' => 'Holder', 'expiry_month' => '08', - 'expiry_year' => '22', + 'expiry_year' => '2022', ], ], ['Content-Type' => 'application/json'] @@ -188,7 +188,7 @@ public function testCreateBookingUnsuccesfulResponse() 'cvv' => '111', 'card_holder' => 'Holder', 'expiry_month' => '08', - 'expiry_year' => '22', + 'expiry_year' => '2022', ], ], ['Content-Type' => 'application/json'] @@ -581,8 +581,8 @@ private function createPayment() $payment->setCardHolder('Holder') ->setCVV('111') ->setType('VISA') - ->setExpirtyMonth('08') - ->setExpiryYear('22') + ->setExpiryMonth('08') + ->setExpiryYear('2022') ->setCardNumber('11111111111111111111') ;