Skip to content

Commit

Permalink
fix: payment expiry year should be a 4 digit number (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggeorgiadis authored Oct 12, 2021
1 parent 64aba26 commit 8cc2820
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Katanox/Model/Booking/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions tests/Katanox/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public function testBookingToArray()
'cvv' => '111',
'card_holder' => 'Holder',
'expiry_month' => '08',
'expiry_year' => '22',
'expiry_year' => '2022',
],
];

Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions tests/Katanox/Resource/BookingResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -581,8 +581,8 @@ private function createPayment()
$payment->setCardHolder('Holder')
->setCVV('111')
->setType('VISA')
->setExpirtyMonth('08')
->setExpiryYear('22')
->setExpiryMonth('08')
->setExpiryYear('2022')
->setCardNumber('11111111111111111111')
;

Expand Down

0 comments on commit 8cc2820

Please sign in to comment.