From fb17f0abba02b3620a9b3abc2a7ea9e8df944335 Mon Sep 17 00:00:00 2001 From: Piotr Synowiec Date: Fri, 20 May 2022 16:36:55 +0200 Subject: [PATCH 1/4] additional-tests: TestAccess tests --- tests/Message/TestAccessRequestTest.php | 64 +++++++++++++++++++++ tests/Mock/TestAccessAuthFailure.txt | 16 ++++++ tests/Mock/TestAccessInvalidDataFailure.txt | 16 ++++++ tests/Mock/TestAccessSuccess.txt | 16 ++++++ 4 files changed, 112 insertions(+) create mode 100644 tests/Message/TestAccessRequestTest.php create mode 100644 tests/Mock/TestAccessAuthFailure.txt create mode 100644 tests/Mock/TestAccessInvalidDataFailure.txt create mode 100644 tests/Mock/TestAccessSuccess.txt diff --git a/tests/Message/TestAccessRequestTest.php b/tests/Message/TestAccessRequestTest.php new file mode 100644 index 0000000..e7e469c --- /dev/null +++ b/tests/Message/TestAccessRequestTest.php @@ -0,0 +1,64 @@ +request = new TestAccessRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize([]); + } + + public function testGetData(): void + { + $data = $this->request->getData(); + + $this->assertSame([], $data); + } + + public function testSendSuccess(): void + { + $this->setMockHttpResponse('TestAccessSuccess.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(TestAccessResponse::class, $response); + $this->assertTrue($response->isSuccessful()); + $this->assertSame(Response::HTTP_OK, $response->getCode()); + $this->assertSame('', $response->getMessage()); + } + + public function testSendAuthFailure() + { + $this->setMockHttpResponse('TestAccessAuthFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(TestAccessResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getCode()); + $this->assertSame('Incorrect authentication', $response->getMessage()); + } + + public function testSendInvalidDataFailure() + { + $this->setMockHttpResponse('TestAccessInvalidDataFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(TestAccessResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertSame(Response::HTTP_BAD_REQUEST, $response->getCode()); + $this->assertSame('Invalid input data', $response->getMessage()); + } +} diff --git a/tests/Mock/TestAccessAuthFailure.txt b/tests/Mock/TestAccessAuthFailure.txt new file mode 100644 index 0000000..86a8031 --- /dev/null +++ b/tests/Mock/TestAccessAuthFailure.txt @@ -0,0 +1,16 @@ +HTTP/1.1 422 Unprocessable Entity +Server: nginx/1.4.4 +Date: Sat, 20 May 2022 17:00:00 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "error": "Incorrect authentication", + "code": 401 +} diff --git a/tests/Mock/TestAccessInvalidDataFailure.txt b/tests/Mock/TestAccessInvalidDataFailure.txt new file mode 100644 index 0000000..6b02668 --- /dev/null +++ b/tests/Mock/TestAccessInvalidDataFailure.txt @@ -0,0 +1,16 @@ +HTTP/1.1 422 Unprocessable Entity +Server: nginx/1.4.4 +Date: Sat, 20 May 2022 17:00:00 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "error": "Invalid input data", + "code": 400 +} diff --git a/tests/Mock/TestAccessSuccess.txt b/tests/Mock/TestAccessSuccess.txt new file mode 100644 index 0000000..4f70800 --- /dev/null +++ b/tests/Mock/TestAccessSuccess.txt @@ -0,0 +1,16 @@ +HTTP/1.1 422 Unprocessable Entity +Server: nginx/1.4.4 +Date: Sat, 20 May 2022 17:00:00 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "data": true, + "error": "" +} From ad009c18ef068f67bd5df206fbe0b67151fe32df Mon Sep 17 00:00:00 2001 From: Piotr Synowiec Date: Fri, 20 May 2022 16:58:49 +0200 Subject: [PATCH 2/4] additional-tests: Methods tests --- src/Message/AbstractResponse.php | 16 + tests/Message/MethodsRequestTest.php | 86 ++++ tests/Mock/MethodsAuthFailure.txt | 16 + tests/Mock/MethodsNotFoundFailure.txt | 16 + tests/Mock/MethodsSuccess.txt | 663 ++++++++++++++++++++++++++ 5 files changed, 797 insertions(+) create mode 100644 tests/Message/MethodsRequestTest.php create mode 100644 tests/Mock/MethodsAuthFailure.txt create mode 100644 tests/Mock/MethodsNotFoundFailure.txt create mode 100644 tests/Mock/MethodsSuccess.txt diff --git a/src/Message/AbstractResponse.php b/src/Message/AbstractResponse.php index 0d65ea5..4b776dc 100644 --- a/src/Message/AbstractResponse.php +++ b/src/Message/AbstractResponse.php @@ -24,6 +24,14 @@ public function getCode(): int return (int) $this->data['code']; } + if ( + ! isset($this->data['code']) + && isset($this->data['responseCode']) + && 0 !== (int) $this->data['responseCode'] + ) { + return (int) $this->data['responseCode']; + } + return Response::HTTP_OK; } @@ -36,6 +44,14 @@ public function getMessage() return $this->data['error']; } + if ( + Response::HTTP_NOT_FOUND === $this->getCode() + && isset($this->data['data']) + && ! is_array($this->data['data']) + ) { + return $this->data['data']; + } + return ''; } diff --git a/tests/Message/MethodsRequestTest.php b/tests/Message/MethodsRequestTest.php new file mode 100644 index 0000000..b90aa1f --- /dev/null +++ b/tests/Message/MethodsRequestTest.php @@ -0,0 +1,86 @@ +request = new MethodsRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize([ + "lang" => "en", + ]); + } + + public function testGetData(): void + { + $data = $this->request->getData(); + + $this->assertSame('en', $data['lang']); + } + + public function testSendSuccess(): void + { + $this->setMockHttpResponse('MethodsSuccess.txt'); + /** @var MethodsResponse $response */ + $response = $this->request->send(); + + $this->assertInstanceOf(MethodsResponse::class, $response); + $this->assertTrue($response->isSuccessful()); + $this->assertSame(Response::HTTP_OK, $response->getCode()); + $this->assertSame('', $response->getMessage()); + $this->assertCount(43, $response->getMethods()); + + $method = $response->getMethods()[0]; + + $this->assertSame('Przelew z BPH', $method['name']); + $this->assertSame(35, $method['id']); + $this->assertSame('FastTransfers', $method['group']); + $this->assertSame('FastTransfers', $method['subgroup']); + $this->assertSame(true, $method['status']); + $this->assertSame('https://static.przelewy24.pl/payment-form-logo/svg/35', $method['imgUrl']); + $this->assertSame( + 'https://static.przelewy24.pl/payment-form-logo/svg/mobile/35', + $method['mobileImgUrl'] + ); + $this->assertSame(true, $method['mobile']); + $this->assertCount(3, $method['availabilityHours']); + $this->assertSame('08-20', $method['availabilityHours']['mondayToFriday']); + $this->assertSame('unavailable', $method['availabilityHours']['saturday']); + $this->assertSame('unavailable', $method['availabilityHours']['sunday']); + } + + public function testSendAuthFailure() + { + $this->setMockHttpResponse('MethodsAuthFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(MethodsResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getCode()); + $this->assertSame('Incorrect authentication', $response->getMessage()); + } + + public function testSendNotFoundFailure() + { + $this->setMockHttpResponse('MethodsNotFoundFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(MethodsResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertSame(Response::HTTP_NOT_FOUND, $response->getCode()); + $this->assertSame('Payment methods not found', $response->getMessage()); + } +} diff --git a/tests/Mock/MethodsAuthFailure.txt b/tests/Mock/MethodsAuthFailure.txt new file mode 100644 index 0000000..86a8031 --- /dev/null +++ b/tests/Mock/MethodsAuthFailure.txt @@ -0,0 +1,16 @@ +HTTP/1.1 422 Unprocessable Entity +Server: nginx/1.4.4 +Date: Sat, 20 May 2022 17:00:00 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "error": "Incorrect authentication", + "code": 401 +} diff --git a/tests/Mock/MethodsNotFoundFailure.txt b/tests/Mock/MethodsNotFoundFailure.txt new file mode 100644 index 0000000..a1e1939 --- /dev/null +++ b/tests/Mock/MethodsNotFoundFailure.txt @@ -0,0 +1,16 @@ +HTTP/1.1 422 Unprocessable Entity +Server: nginx/1.4.4 +Date: Sat, 20 May 2022 17:00:00 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "data": "Payment methods not found", + "responseCode": 404 +} diff --git a/tests/Mock/MethodsSuccess.txt b/tests/Mock/MethodsSuccess.txt new file mode 100644 index 0000000..955e32d --- /dev/null +++ b/tests/Mock/MethodsSuccess.txt @@ -0,0 +1,663 @@ +HTTP/1.1 422 Unprocessable Entity +Server: nginx/1.4.4 +Date: Sat, 20 May 2022 17:00:00 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "data": [ + { + "name": "Przelew z BPH", + "id": 35, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/35", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/35", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "08-20", + "saturday": "unavailable", + "sunday": "unavailable" + } + }, + { + "name": "Credit Agricole", + "id": 45, + "group": "eTransfer", + "subgroup": "eTransfer", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/45", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/45", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Toyota Bank", + "id": 64, + "group": "eTransfer", + "subgroup": "eTransfer", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/64", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/64", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Allianz Bank", + "id": 68, + "group": "eTransfer", + "subgroup": "eTransfer", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/68", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/68", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "08-18", + "saturday": "unavailable", + "sunday": "unavailable" + } + }, + { + "name": "Volkswagen Bank", + "id": 69, + "group": "eTransfer", + "subgroup": "eTransfer", + "status": false, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/69", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/69", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "07-24", + "saturday": "unavailable", + "sunday": "unavailable" + } + }, + { + "name": "Polbank", + "id": 82, + "group": "eTransfer", + "subgroup": "eTransfer", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/82", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/82", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "unavailable", + "sunday": "unavailable" + } + }, + { + "name": "Bank Millennium", + "id": 85, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/85", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/85", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "05-22", + "saturday": "05-22", + "sunday": "unavailable" + } + }, + { + "name": "SkyCash", + "id": 87, + "group": "Wallet", + "subgroup": "Wallet", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/87", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/87", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Euro Bank", + "id": 94, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/94", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/94", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "mPay", + "id": 97, + "group": "Wallet", + "subgroup": "Wallet", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/97", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/97", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Pay with BOŚ", + "id": 99, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/99", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/99", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Raiffeisen Bank PBL", + "id": 102, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/102", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/102", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "DnB Nord", + "id": 103, + "group": "eTransfer", + "subgroup": "eTransfer", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/103", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/103", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "08-18", + "saturday": "unavailable", + "sunday": "unavailable" + } + }, + { + "name": "E-SKOK", + "id": 105, + "group": "eTransfer", + "subgroup": "eTransfer", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/105", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/105", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "db Transfer", + "id": 110, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/110", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/110", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Pay with CitiHandlowy", + "id": 119, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/119", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/119", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "T-Mobile Usługi Bankowe", + "id": 121, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/121", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/121", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Alior - Raty", + "id": 129, + "group": "Installments", + "subgroup": "Installments", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/129", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/129", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Pay with Plus Bank", + "id": 131, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/131", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/131", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Pay with IKO", + "id": 135, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/135", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/135", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "mBank - Raty", + "id": 136, + "group": "Installments", + "subgroup": "Installments", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/136", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/136", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "e-transfer Pocztowy24", + "id": 141, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/141", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/141", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Banki Spółdzielcze", + "id": 143, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/143", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/143", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Podkarpacki BS", + "id": 144, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/144", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/144", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Getin Bank", + "id": 153, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/153", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/153", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "BLIK - PSP", + "id": 154, + "group": "Blik", + "subgroup": "Blik", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/154", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/154", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Noble Pay", + "id": 158, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/158", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/158", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "eBGŻ", + "id": 160, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/160", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/160", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Pay with IdeaBank", + "id": 161, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/161", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/161", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Pay in Żabka", + "id": 176, + "group": "eTransfer", + "subgroup": "eTransfer", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/176", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/176", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Use prepayment", + "id": 177, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/177", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/177", + "mobile": false, + "availabilityHours": { + "mondayToFriday": true, + "saturday": true, + "sunday": true + } + }, + { + "name": "Manual transfer", + "id": 178, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/178", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/178", + "mobile": false, + "availabilityHours": { + "mondayToFriday": true, + "saturday": true, + "sunday": true + } + }, + { + "name": "Credit Card", + "id": 218, + "group": "Credit Card", + "subgroup": "Credit Card", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/218", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/218", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "NestPrzelew", + "id": 222, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/222", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/222", + "mobile": false, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Google Pay", + "id": 229, + "group": "TraditionalTransfer", + "subgroup": "TraditionalTransfer", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/229", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/229", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "P24NOW LIMIT - pay later or installments", + "id": 266, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/266", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/266", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "mBank", + "id": 270, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/270", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/270", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "ING Bank Śląski", + "id": 271, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/271", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/271", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Bank Pekao S.A.", + "id": 273, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/273", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/273", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "PKO BP", + "id": 274, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/274", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/274", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Santander", + "id": 275, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/275", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/275", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Inteligo", + "id": 279, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/279", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/279", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + }, + { + "name": "Alior", + "id": 280, + "group": "FastTransfers", + "subgroup": "FastTransfers", + "status": true, + "imgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/280", + "mobileImgUrl": "https://static.przelewy24.pl/payment-form-logo/svg/mobile/280", + "mobile": true, + "availabilityHours": { + "mondayToFriday": "00-24", + "saturday": "00-24", + "sunday": "00-24" + } + } + ], + "agreements": [], + "responseCode": 0 +} From 3f6408380e09a4643eb3de13457d5b5aec281ce7 Mon Sep 17 00:00:00 2001 From: Piotr Synowiec Date: Sat, 21 May 2022 17:36:28 +0200 Subject: [PATCH 3/4] [/api/v1/card/chargeWith3ds] (#22) * card-chargeWith3ds: update README * card-chargeWith3ds: method with no tests * card-chargeWith3ds: tests --- README.md | 1 + src/Message/CardCharge3dsRequest.php | 26 ++++++++ src/Message/CardCharge3dsResponse.php | 30 +++++++++ src/Message/TestAccessResponse.php | 19 ++++++ tests/Message/CardCharge3dsRequestTest.php | 66 +++++++++++++++++++ tests/Message/TestAccessRequestTest.php | 3 + tests/Mock/CardCharge3dsAuthFailure.txt | 16 +++++ .../Mock/CardCharge3dsInvalidDataFailure.txt | 16 +++++ tests/Mock/CardCharge3dsSuccess.txt | 18 +++++ tests/Mock/CardChargeAuthFailure.txt | 2 +- tests/Mock/CardChargeInvalidDataFailure.txt | 2 +- tests/Mock/CardChargeSuccess.txt | 2 +- tests/Mock/CardInfoAuthFailure.txt | 2 +- tests/Mock/CardInfoInvalidDataFailure.txt | 2 +- tests/Mock/CardInfoNotFoundFailure.txt | 2 +- tests/Mock/CardInfoSuccess.txt | 2 +- tests/Mock/CardPayAuthFailure.txt | 2 +- tests/Mock/CardPayInvalidDataFailure.txt | 2 +- tests/Mock/CardPaySuccess.txt | 2 +- tests/Mock/CardPayUnableToPayFailure.txt | 2 +- tests/Mock/MethodsAuthFailure.txt | 2 +- tests/Mock/MethodsNotFoundFailure.txt | 2 +- tests/Mock/MethodsSuccess.txt | 2 +- tests/Mock/PurchaseInfoAuthFailure.txt | 2 +- tests/Mock/PurchaseInfoInvalidDataFailure.txt | 2 +- tests/Mock/PurchaseInfoNotFound.txt | 2 +- tests/Mock/PurchaseInfoNotFoundFailure.txt | 2 +- tests/Mock/PurchaseInfoSuccess.txt | 2 +- tests/Mock/TestAccessAuthFailure.txt | 2 +- tests/Mock/TestAccessInvalidDataFailure.txt | 2 +- tests/Mock/TestAccessSuccess.txt | 2 +- 31 files changed, 217 insertions(+), 22 deletions(-) create mode 100644 src/Message/CardCharge3dsRequest.php create mode 100644 src/Message/CardCharge3dsResponse.php create mode 100644 tests/Message/CardCharge3dsRequestTest.php create mode 100644 tests/Mock/CardCharge3dsAuthFailure.txt create mode 100644 tests/Mock/CardCharge3dsInvalidDataFailure.txt create mode 100644 tests/Mock/CardCharge3dsSuccess.txt diff --git a/README.md b/README.md index c287175..1806fb1 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ | /api/v1/card/info | cardInfo | | /api/v1/card/pay | cardPay | | /api/v1/card/charge | cardCharge | +| /api/v1/card/chargeWith3ds | cardCharge3ds | ## Install diff --git a/src/Message/CardCharge3dsRequest.php b/src/Message/CardCharge3dsRequest.php new file mode 100644 index 0000000..894a820 --- /dev/null +++ b/src/Message/CardCharge3dsRequest.php @@ -0,0 +1,26 @@ +validate('token'); + + return [ + 'token' => $this->getToken(), + ]; + } + + public function sendData($data): CardCharge3dsResponse + { + $httpResponse = $this->sendRequest('POST', 'card/chargeWith3ds', $data); + + $responseData = json_decode($httpResponse->getBody()->getContents(), true); + + return $this->response = new CardCharge3dsResponse($this, $responseData); + } +} diff --git a/src/Message/CardCharge3dsResponse.php b/src/Message/CardCharge3dsResponse.php new file mode 100644 index 0000000..84f6e6f --- /dev/null +++ b/src/Message/CardCharge3dsResponse.php @@ -0,0 +1,30 @@ +transactionId = (string) $data['data']['orderId']; + } + } + } + + public function getTransactionId(): ?string + { + return $this->transactionId; + } +} diff --git a/src/Message/TestAccessResponse.php b/src/Message/TestAccessResponse.php index 5d9f3bc..d34b184 100644 --- a/src/Message/TestAccessResponse.php +++ b/src/Message/TestAccessResponse.php @@ -4,6 +4,25 @@ namespace Omnipay\Przelewy24\Message; +use Omnipay\Common\Message\RequestInterface; + class TestAccessResponse extends AbstractResponse { + /** + * @var bool + */ + private $test = false; + + public function __construct(RequestInterface $request, $data) + { + parent::__construct($request, $data); + if (isset($data['data'])) { + $this->test = $data['data']; + } + } + + public function getTest(): bool + { + return $this->test; + } } diff --git a/tests/Message/CardCharge3dsRequestTest.php b/tests/Message/CardCharge3dsRequestTest.php new file mode 100644 index 0000000..b706979 --- /dev/null +++ b/tests/Message/CardCharge3dsRequestTest.php @@ -0,0 +1,66 @@ +request = new CardCharge3dsRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize([ + "token" => "29fa01f8-6bb8-4187-9fb0-ec6e1a62a731", + ]); + } + + public function testGetData(): void + { + $data = $this->request->getData(); + + $this->assertSame('29fa01f8-6bb8-4187-9fb0-ec6e1a62a731', $data['token']); + } + + public function testSendSuccess() + { + $this->setMockHttpResponse('CardCharge3dsSuccess.txt'); + /** @var CardCharge3dsResponse $response */ + $response = $this->request->send(); + + $this->assertInstanceOf(CardCharge3dsResponse::class, $response); + $this->assertTrue($response->isSuccessful()); + $this->assertSame('1234567890123', $response->getTransactionId()); + } + + public function testSendAuthFailure() + { + $this->setMockHttpResponse('CardCharge3dsAuthFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(CardCharge3dsResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getCode()); + $this->assertSame('Incorrect authentication', $response->getMessage()); + } + + public function testSendInvalidDataFailure() + { + $this->setMockHttpResponse('CardCharge3dsInvalidDataFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(CardCharge3dsResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertSame(Response::HTTP_BAD_REQUEST, $response->getCode()); + $this->assertSame('Invalid input data', $response->getMessage()); + } +} diff --git a/tests/Message/TestAccessRequestTest.php b/tests/Message/TestAccessRequestTest.php index e7e469c..909e799 100644 --- a/tests/Message/TestAccessRequestTest.php +++ b/tests/Message/TestAccessRequestTest.php @@ -38,6 +38,7 @@ public function testSendSuccess(): void $this->assertTrue($response->isSuccessful()); $this->assertSame(Response::HTTP_OK, $response->getCode()); $this->assertSame('', $response->getMessage()); + $this->assertTrue($response->getTest()); } public function testSendAuthFailure() @@ -49,6 +50,7 @@ public function testSendAuthFailure() $this->assertFalse($response->isSuccessful()); $this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getCode()); $this->assertSame('Incorrect authentication', $response->getMessage()); + $this->assertFalse($response->getTest()); } public function testSendInvalidDataFailure() @@ -60,5 +62,6 @@ public function testSendInvalidDataFailure() $this->assertFalse($response->isSuccessful()); $this->assertSame(Response::HTTP_BAD_REQUEST, $response->getCode()); $this->assertSame('Invalid input data', $response->getMessage()); + $this->assertFalse($response->getTest()); } } diff --git a/tests/Mock/CardCharge3dsAuthFailure.txt b/tests/Mock/CardCharge3dsAuthFailure.txt new file mode 100644 index 0000000..d09b56b --- /dev/null +++ b/tests/Mock/CardCharge3dsAuthFailure.txt @@ -0,0 +1,16 @@ +HTTP/1.1 422 Unprocessable Entity +Server: nginx/1.4.4 +Date: Sat, 21 May 2022 16:40:00 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "error": "Incorrect authentication", + "code": 401 +} diff --git a/tests/Mock/CardCharge3dsInvalidDataFailure.txt b/tests/Mock/CardCharge3dsInvalidDataFailure.txt new file mode 100644 index 0000000..ab1eefb --- /dev/null +++ b/tests/Mock/CardCharge3dsInvalidDataFailure.txt @@ -0,0 +1,16 @@ +HTTP/1.1 422 Unprocessable Entity +Server: nginx/1.4.4 +Date: Sat, 21 May 2022 16:40:00 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "error": "Invalid input data", + "code": 400 +} diff --git a/tests/Mock/CardCharge3dsSuccess.txt b/tests/Mock/CardCharge3dsSuccess.txt new file mode 100644 index 0000000..8550867 --- /dev/null +++ b/tests/Mock/CardCharge3dsSuccess.txt @@ -0,0 +1,18 @@ +HTTP/1.1 422 Unprocessable Entity +Server: nginx/1.4.4 +Date: Sat, 21 May 2022 16:40:00 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "data": { + "orderId": 1234567890123 + }, + "responseCode": 0 +} diff --git a/tests/Mock/CardChargeAuthFailure.txt b/tests/Mock/CardChargeAuthFailure.txt index 188b2a2..0221e62 100644 --- a/tests/Mock/CardChargeAuthFailure.txt +++ b/tests/Mock/CardChargeAuthFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 20 May 2022 07:00:00 GMT +Date: Fri, 20 May 2022 07:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/CardChargeInvalidDataFailure.txt b/tests/Mock/CardChargeInvalidDataFailure.txt index 51f71e3..feef55f 100644 --- a/tests/Mock/CardChargeInvalidDataFailure.txt +++ b/tests/Mock/CardChargeInvalidDataFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 20 May 2022 07:00:00 GMT +Date: Fri, 20 May 2022 07:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/CardChargeSuccess.txt b/tests/Mock/CardChargeSuccess.txt index bc2d170..dd40edf 100644 --- a/tests/Mock/CardChargeSuccess.txt +++ b/tests/Mock/CardChargeSuccess.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 20 May 2022 07:00:00 GMT +Date: Fri, 20 May 2022 07:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/CardInfoAuthFailure.txt b/tests/Mock/CardInfoAuthFailure.txt index 649f956..6b7051e 100644 --- a/tests/Mock/CardInfoAuthFailure.txt +++ b/tests/Mock/CardInfoAuthFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 17 May 2022 17:00:00 GMT +Date: Tue, 17 May 2022 17:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/CardInfoInvalidDataFailure.txt b/tests/Mock/CardInfoInvalidDataFailure.txt index e4fb5fc..d2992ff 100644 --- a/tests/Mock/CardInfoInvalidDataFailure.txt +++ b/tests/Mock/CardInfoInvalidDataFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 17 May 2022 17:00:00 GMT +Date: Tue, 17 May 2022 17:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/CardInfoNotFoundFailure.txt b/tests/Mock/CardInfoNotFoundFailure.txt index a6b1905..748a131 100644 --- a/tests/Mock/CardInfoNotFoundFailure.txt +++ b/tests/Mock/CardInfoNotFoundFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 17 May 2022 17:00:00 GMT +Date: Tue, 17 May 2022 17:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/CardInfoSuccess.txt b/tests/Mock/CardInfoSuccess.txt index 5124528..e1bbc59 100644 --- a/tests/Mock/CardInfoSuccess.txt +++ b/tests/Mock/CardInfoSuccess.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 17 May 2022 17:00:00 GMT +Date: Tue, 17 May 2022 17:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/CardPayAuthFailure.txt b/tests/Mock/CardPayAuthFailure.txt index 188b2a2..0221e62 100644 --- a/tests/Mock/CardPayAuthFailure.txt +++ b/tests/Mock/CardPayAuthFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 20 May 2022 07:00:00 GMT +Date: Fri, 20 May 2022 07:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/CardPayInvalidDataFailure.txt b/tests/Mock/CardPayInvalidDataFailure.txt index 51f71e3..feef55f 100644 --- a/tests/Mock/CardPayInvalidDataFailure.txt +++ b/tests/Mock/CardPayInvalidDataFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 20 May 2022 07:00:00 GMT +Date: Fri, 20 May 2022 07:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/CardPaySuccess.txt b/tests/Mock/CardPaySuccess.txt index a2d196f..1a01bec 100644 --- a/tests/Mock/CardPaySuccess.txt +++ b/tests/Mock/CardPaySuccess.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 20 May 2022 07:00:00 GMT +Date: Fri, 20 May 2022 07:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/CardPayUnableToPayFailure.txt b/tests/Mock/CardPayUnableToPayFailure.txt index b2c2852..0c73c8e 100644 --- a/tests/Mock/CardPayUnableToPayFailure.txt +++ b/tests/Mock/CardPayUnableToPayFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 20 May 2022 07:00:00 GMT +Date: Fri, 20 May 2022 07:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/MethodsAuthFailure.txt b/tests/Mock/MethodsAuthFailure.txt index 86a8031..525fd8d 100644 --- a/tests/Mock/MethodsAuthFailure.txt +++ b/tests/Mock/MethodsAuthFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 20 May 2022 17:00:00 GMT +Date: Fri, 20 May 2022 17:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/MethodsNotFoundFailure.txt b/tests/Mock/MethodsNotFoundFailure.txt index a1e1939..7b17125 100644 --- a/tests/Mock/MethodsNotFoundFailure.txt +++ b/tests/Mock/MethodsNotFoundFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 20 May 2022 17:00:00 GMT +Date: Fri, 20 May 2022 17:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/MethodsSuccess.txt b/tests/Mock/MethodsSuccess.txt index 955e32d..9cad84b 100644 --- a/tests/Mock/MethodsSuccess.txt +++ b/tests/Mock/MethodsSuccess.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 20 May 2022 17:00:00 GMT +Date: Fri, 20 May 2022 17:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/PurchaseInfoAuthFailure.txt b/tests/Mock/PurchaseInfoAuthFailure.txt index dcd3fbf..2a1fa41 100644 --- a/tests/Mock/PurchaseInfoAuthFailure.txt +++ b/tests/Mock/PurchaseInfoAuthFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 201 Created Server: nginx/1.4.4 -Date: Sat, 16 May 2022 17:30:00 GMT +Date: Mon, 16 May 2022 17:30:00 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Cache-Control: no-cache, no-store diff --git a/tests/Mock/PurchaseInfoInvalidDataFailure.txt b/tests/Mock/PurchaseInfoInvalidDataFailure.txt index 4383bc8..1a64383 100644 --- a/tests/Mock/PurchaseInfoInvalidDataFailure.txt +++ b/tests/Mock/PurchaseInfoInvalidDataFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 201 Created Server: nginx/1.4.4 -Date: Sat, 16 May 2022 17:30:00 GMT +Date: Mon, 16 May 2022 17:30:00 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Cache-Control: no-cache, no-store diff --git a/tests/Mock/PurchaseInfoNotFound.txt b/tests/Mock/PurchaseInfoNotFound.txt index 32b458e..9e504f8 100644 --- a/tests/Mock/PurchaseInfoNotFound.txt +++ b/tests/Mock/PurchaseInfoNotFound.txt @@ -1,6 +1,6 @@ HTTP/1.1 201 Created Server: nginx/1.4.4 -Date: Sat, 16 May 2022 17:30:00 GMT +Date: Mon, 16 May 2022 17:30:00 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Cache-Control: no-cache, no-store diff --git a/tests/Mock/PurchaseInfoNotFoundFailure.txt b/tests/Mock/PurchaseInfoNotFoundFailure.txt index 32b458e..9e504f8 100644 --- a/tests/Mock/PurchaseInfoNotFoundFailure.txt +++ b/tests/Mock/PurchaseInfoNotFoundFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 201 Created Server: nginx/1.4.4 -Date: Sat, 16 May 2022 17:30:00 GMT +Date: Mon, 16 May 2022 17:30:00 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Cache-Control: no-cache, no-store diff --git a/tests/Mock/PurchaseInfoSuccess.txt b/tests/Mock/PurchaseInfoSuccess.txt index 9f21937..eb4305c 100644 --- a/tests/Mock/PurchaseInfoSuccess.txt +++ b/tests/Mock/PurchaseInfoSuccess.txt @@ -1,6 +1,6 @@ HTTP/1.1 201 Created Server: nginx/1.4.4 -Date: Sat, 16 May 2022 17:30:00 GMT +Date: Mon, 16 May 2022 17:30:00 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Cache-Control: no-cache, no-store diff --git a/tests/Mock/TestAccessAuthFailure.txt b/tests/Mock/TestAccessAuthFailure.txt index 86a8031..525fd8d 100644 --- a/tests/Mock/TestAccessAuthFailure.txt +++ b/tests/Mock/TestAccessAuthFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 20 May 2022 17:00:00 GMT +Date: Fri, 20 May 2022 17:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/TestAccessInvalidDataFailure.txt b/tests/Mock/TestAccessInvalidDataFailure.txt index 6b02668..8595803 100644 --- a/tests/Mock/TestAccessInvalidDataFailure.txt +++ b/tests/Mock/TestAccessInvalidDataFailure.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 20 May 2022 17:00:00 GMT +Date: Fri, 20 May 2022 17:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive diff --git a/tests/Mock/TestAccessSuccess.txt b/tests/Mock/TestAccessSuccess.txt index 4f70800..4a27f28 100644 --- a/tests/Mock/TestAccessSuccess.txt +++ b/tests/Mock/TestAccessSuccess.txt @@ -1,6 +1,6 @@ HTTP/1.1 422 Unprocessable Entity Server: nginx/1.4.4 -Date: Sat, 20 May 2022 17:00:00 GMT +Date: Fri, 20 May 2022 17:00:00 GMT Content-Type: application/json; charset=utf-8 Content-Length: 101 Connection: keep-alive From 14e7dba0df283cab7e5385a443311907271d16c3 Mon Sep 17 00:00:00 2001 From: Piotr Synowiec Date: Sat, 21 May 2022 18:10:53 +0200 Subject: [PATCH 4/4] [/api/v1/transaction/registerOffline] (#23) * transaction-registerOffline: update README * transaction-registerOffline: request, object, tests & some code clean up --- README.md | 27 +++--- ecs.php | 1 + src/Gateway.php | 16 ++++ src/Message/AbstractRequest.php | 5 +- src/Message/AbstractResponse.php | 5 +- src/Message/CardChargeResponse.php | 2 +- src/Message/CardInfoResponse.php | 4 +- src/Message/CardPayResponse.php | 4 +- src/Message/MethodsRequest.php | 3 +- src/Message/PurchaseInfoResponse.php | 6 +- src/Message/PurchaseOfflineRequest.php | 26 ++++++ src/Message/PurchaseOfflineResponse.php | 30 +++++++ src/Message/PurchaseRequest.php | 2 +- src/Message/RefundsRequest.php | 13 +-- src/Message/RefundsResponse.php | 2 +- src/Message/TestAccessRequest.php | 1 + tests-api/GatewayTest.php | 7 +- tests/GatewayTest.php | 51 +++++++---- tests/Message/CardChargeRequestTest.php | 10 +-- tests/Message/CardInfoRequestTest.php | 10 +-- tests/Message/CardPayRequestTest.php | 20 ++--- tests/Message/CompletePurchaseRequestTest.php | 8 +- tests/Message/MethodsRequestTest.php | 8 +- tests/Message/PurchaseInfoRequestTest.php | 12 +-- tests/Message/PurchaseOfflineRequestTest.php | 86 +++++++++++++++++++ tests/Message/PurchaseRequestTest.php | 20 +++-- tests/Message/RefundsRequestTest.php | 13 ++- tests/Message/TestAccessRequestTest.php | 6 +- tests/Mock/PurchaseOfflineAuthFailure.txt | 16 ++++ .../PurchaseOfflineInvalidDataFailure.txt | 16 ++++ tests/Mock/PurchaseOfflineSuccess.txt | 20 +++++ .../PurchaseOfflineUnableToCreateFailure.txt | 16 ++++ 32 files changed, 358 insertions(+), 108 deletions(-) create mode 100644 src/Message/PurchaseOfflineRequest.php create mode 100644 src/Message/PurchaseOfflineResponse.php create mode 100644 tests/Message/PurchaseOfflineRequestTest.php create mode 100644 tests/Mock/PurchaseOfflineAuthFailure.txt create mode 100644 tests/Mock/PurchaseOfflineInvalidDataFailure.txt create mode 100644 tests/Mock/PurchaseOfflineSuccess.txt create mode 100644 tests/Mock/PurchaseOfflineUnableToCreateFailure.txt diff --git a/README.md b/README.md index 1806fb1..d77ffed 100644 --- a/README.md +++ b/README.md @@ -13,18 +13,19 @@ ## API endpoints implemented -| API endpoint | Gateway method | -|:---------------------------------|:-----------------| -| /api/v1/testAccess | testAccess | -| /api/v1/payment/methods | methods | -| /api/v1/transaction/register | purchase | -| /api/v1/transaction/verify | completePurchase | -| /api/v1/transaction/refund | refund | -| /api/v1/transaction/by/sessionId | purchaseInfo | -| /api/v1/card/info | cardInfo | -| /api/v1/card/pay | cardPay | -| /api/v1/card/charge | cardCharge | -| /api/v1/card/chargeWith3ds | cardCharge3ds | +| API endpoint | Gateway method | +|:------------------------------------|:-----------------| +| /api/v1/testAccess | testAccess | +| /api/v1/payment/methods | methods | +| /api/v1/transaction/register | purchase | +| /api/v1/transaction/verify | completePurchase | +| /api/v1/transaction/refund | refund | +| /api/v1/transaction/by/sessionId | purchaseInfo | +| /api/v1/card/info | cardInfo | +| /api/v1/card/pay | cardPay | +| /api/v1/card/charge | cardCharge | +| /api/v1/card/chargeWith3ds | cardCharge3ds | +| /api/v1/transaction/registerOffline | purchaseOffline | ## Install @@ -40,7 +41,7 @@ The following gateways are provided by this package: * Przelewy24 -Reference official documentation https://developers.przelewy24.pl/index.php +Reference official documentation https://developers.przelewy24.pl/index.php?en ## Example diff --git a/ecs.php b/ecs.php index 0d9592a..160ac3a 100644 --- a/ecs.php +++ b/ecs.php @@ -22,6 +22,7 @@ ]]); $ecsConfig->import(SetList::SPACES); + $ecsConfig->import(SetList::STRICT); $ecsConfig->import(SetList::ARRAY); $ecsConfig->import(SetList::DOCBLOCK); $ecsConfig->import(SetList::PSR_12); diff --git a/src/Gateway.php b/src/Gateway.php index 3d8c5f8..570c48b 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -12,6 +12,7 @@ use Omnipay\Przelewy24\Message\CompletePurchaseRequest; use Omnipay\Przelewy24\Message\MethodsRequest; use Omnipay\Przelewy24\Message\PurchaseInfoRequest; +use Omnipay\Przelewy24\Message\PurchaseOfflineRequest; use Omnipay\Przelewy24\Message\PurchaseRequest; use Omnipay\Przelewy24\Message\RefundsRequest; use Omnipay\Przelewy24\Message\TestAccessRequest; @@ -130,6 +131,7 @@ public function methods(string $lang = 'en'): MethodsRequest /** * @param string[] $options + * * @return AbstractRequest|PurchaseRequest */ public function purchase(array $options = []): PurchaseRequest @@ -139,6 +141,7 @@ public function purchase(array $options = []): PurchaseRequest /** * @param string[] $options + * * @return AbstractRequest|CompletePurchaseRequest */ public function completePurchase(array $options = []): CompletePurchaseRequest @@ -168,6 +171,7 @@ public function cardInfo(string $transactionId): CardInfoRequest /** * @param string[] $options + * * @return AbstractRequest|RefundsRequest */ public function refund(array $options = []): RefundsRequest @@ -177,6 +181,7 @@ public function refund(array $options = []): RefundsRequest /** * @param string[] $options + * * @return AbstractRequest|CardPayRequest */ public function cardPay(array $options): CardPayRequest @@ -186,10 +191,21 @@ public function cardPay(array $options): CardPayRequest /** * @param string[] $options + * * @return AbstractRequest|CardChargeRequest */ public function cardCharge(array $options): CardChargeRequest { return $this->createRequest(CardChargeRequest::class, $options); } + + /** + * @param string[] $options + * + * @return AbstractRequest|PurchaseOfflineRequest + */ + public function purchaseOffline(array $options): PurchaseOfflineRequest + { + return $this->createRequest(PurchaseOfflineRequest::class, $options); + } } diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index 2fec807..ea9ddb1 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -9,6 +9,8 @@ abstract class AbstractRequest extends BaseAbstractRequest { + protected const SIGN_ALGO = 'sha384'; + protected $liveEndpoint = 'https://secure.przelewy24.pl/api/v1/'; protected $testEndpoint = 'https://sandbox.przelewy24.pl/api/v1/'; @@ -17,8 +19,6 @@ abstract class AbstractRequest extends BaseAbstractRequest protected $testRedirectEndpoint = 'https://sandbox.przelewy24.pl/'; - protected const SIGN_ALGO = 'sha384'; - public function getMerchantId() { return $this->getParameter('merchantId'); @@ -111,6 +111,7 @@ protected function sendRequest(string $method, string $endpoint, $data): Respons /** * @param mixed $value + * * @throws */ protected function internalAmountValue($value = null): int diff --git a/src/Message/AbstractResponse.php b/src/Message/AbstractResponse.php index 4b776dc..263027c 100644 --- a/src/Message/AbstractResponse.php +++ b/src/Message/AbstractResponse.php @@ -36,7 +36,7 @@ public function getCode(): int } /** - * @return array|string|null + * @return null|array|string */ public function getMessage() { @@ -59,7 +59,7 @@ public function isSuccessful(): bool { $code = $this->getCode(); - return in_array($code, [Response::HTTP_CREATED, Response::HTTP_OK]); + return in_array($code, [Response::HTTP_CREATED, Response::HTTP_OK], true); } protected function getAmountFromInternal(int $amount): string @@ -69,6 +69,7 @@ protected function getAmountFromInternal(int $amount): string /** * @param string[] $data + * * @return string[] */ protected function replaceInfoKeys(array $data, string $oldKey, string $newKey): array diff --git a/src/Message/CardChargeResponse.php b/src/Message/CardChargeResponse.php index 8b49eb2..8b56694 100644 --- a/src/Message/CardChargeResponse.php +++ b/src/Message/CardChargeResponse.php @@ -11,7 +11,7 @@ class CardChargeResponse extends AbstractResponse /** * @var null|string */ - private $transactionId = null; + private $transactionId; public function __construct(RequestInterface $request, $data) { diff --git a/src/Message/CardInfoResponse.php b/src/Message/CardInfoResponse.php index 7523eb7..e36c188 100644 --- a/src/Message/CardInfoResponse.php +++ b/src/Message/CardInfoResponse.php @@ -31,6 +31,7 @@ public function getInfo(): array /** * @param string[] $data + * * @return string[] */ private function formatInfo(array $data): array @@ -39,8 +40,7 @@ private function formatInfo(array $data): array // replace keys $formatted = $this->replaceInfoKeys($formatted, 'cardType', 'brand'); - $formatted = $this->replaceInfoKeys($formatted, 'cardDate', 'expiry'); - return $formatted; + return $this->replaceInfoKeys($formatted, 'cardDate', 'expiry'); } } diff --git a/src/Message/CardPayResponse.php b/src/Message/CardPayResponse.php index 98d8f42..8b5f97f 100644 --- a/src/Message/CardPayResponse.php +++ b/src/Message/CardPayResponse.php @@ -12,12 +12,12 @@ class CardPayResponse extends AbstractResponse /** * @var null|string */ - private $transactionId = null; + private $transactionId; /** * @var null */ - private $redirectUrl = null; + private $redirectUrl; public function __construct(RequestInterface $request, $data) { diff --git a/src/Message/MethodsRequest.php b/src/Message/MethodsRequest.php index e28f7e2..588a557 100644 --- a/src/Message/MethodsRequest.php +++ b/src/Message/MethodsRequest.php @@ -29,7 +29,8 @@ public function getData(): array /** * @param string[] $data - * @return ResponseInterface|MethodsResponse + * + * @return MethodsResponse|ResponseInterface */ public function sendData($data): ResponseInterface { diff --git a/src/Message/PurchaseInfoResponse.php b/src/Message/PurchaseInfoResponse.php index 1168cbf..588a800 100644 --- a/src/Message/PurchaseInfoResponse.php +++ b/src/Message/PurchaseInfoResponse.php @@ -32,7 +32,7 @@ public function getInfo(): array public function getCode(): int { - if (isset($this->data['responseCode']) && isset($this->data['error']) && strlen($this->data['error']) > 0) { + if (isset($this->data['responseCode'], $this->data['error']) && strlen($this->data['error']) > 0) { return Response::HTTP_NOT_FOUND; } @@ -45,6 +45,7 @@ public function getCode(): int /** * @param string[] $data + * * @return string[] */ private function formatInfo(array $data): array @@ -61,8 +62,7 @@ private function formatInfo(array $data): array $formatted = $this->replaceInfoKeys($formatted, 'clientName', 'name'); $formatted = $this->replaceInfoKeys($formatted, 'clientAddress', 'address'); $formatted = $this->replaceInfoKeys($formatted, 'clientCity', 'city'); - $formatted = $this->replaceInfoKeys($formatted, 'clientPostcode', 'postcode'); - return $formatted; + return $this->replaceInfoKeys($formatted, 'clientPostcode', 'postcode'); } } diff --git a/src/Message/PurchaseOfflineRequest.php b/src/Message/PurchaseOfflineRequest.php new file mode 100644 index 0000000..5a18afd --- /dev/null +++ b/src/Message/PurchaseOfflineRequest.php @@ -0,0 +1,26 @@ +validate('token'); + + return [ + 'token' => $this->getToken(), + ]; + } + + public function sendData($data): PurchaseOfflineResponse + { + $httpResponse = $this->sendRequest('POST', 'transaction/registerOffline', $data); + + $responseData = json_decode($httpResponse->getBody()->getContents(), true); + + return $this->response = new PurchaseOfflineResponse($this, $responseData); + } +} diff --git a/src/Message/PurchaseOfflineResponse.php b/src/Message/PurchaseOfflineResponse.php new file mode 100644 index 0000000..2d2ab1e --- /dev/null +++ b/src/Message/PurchaseOfflineResponse.php @@ -0,0 +1,30 @@ +data['data'])) { + $this->info = $this->data['data']; + $this->info = $this->replaceInfoKeys($this->info, 'orderId', 'transactionId'); + } + } + + public function getInfo(): array + { + return $this->info; + } +} diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index 976ac9d..269b0ef 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -214,7 +214,7 @@ public function getData() ]; return array_filter($data, function ($val) { - return ! is_null($val); + return null !== $val; }); } diff --git a/src/Message/RefundsRequest.php b/src/Message/RefundsRequest.php index 3bce2e7..e76e478 100644 --- a/src/Message/RefundsRequest.php +++ b/src/Message/RefundsRequest.php @@ -1,5 +1,7 @@ getParameter('refunds'); - if (is_null($refunds) || empty($refunds)) { - throw new InvalidRequestException("The parameter `refunds` can not be empty"); + if (null === $refunds || empty($refunds)) { + throw new InvalidRequestException('The parameter `refunds` can not be empty'); } $requiredFields = ['orderId', 'sessionId', 'amount']; foreach ($refunds as $key => $refund) { if (! is_array($refund)) { - throw new InvalidRequestException("Values in `refunds` need to be an array"); + throw new InvalidRequestException('Values in `refunds` need to be an array'); } foreach ($requiredFields as $requiredField) { if (! array_key_exists($requiredField, $refund)) { - throw new InvalidRequestException("The $requiredField parameter is required in index $key of `refunds` array"); + throw new InvalidRequestException("The {$requiredField} parameter is required in index {$key} of `refunds` array"); } } } diff --git a/src/Message/RefundsResponse.php b/src/Message/RefundsResponse.php index 5ca8a52..c674c74 100644 --- a/src/Message/RefundsResponse.php +++ b/src/Message/RefundsResponse.php @@ -33,7 +33,7 @@ public function getResponseCode(): ?int public function getCode(): int { - if (! is_null($this->getResponseCode())) { + if (null !== $this->getResponseCode()) { return $this->getResponseCode(); } diff --git a/src/Message/TestAccessRequest.php b/src/Message/TestAccessRequest.php index 5e9c422..80b8ac0 100644 --- a/src/Message/TestAccessRequest.php +++ b/src/Message/TestAccessRequest.php @@ -18,6 +18,7 @@ public function getData(): array /** * @param string[] $data + * * @return ResponseInterface|TestAccessResponse */ public function sendData($data): ResponseInterface diff --git a/tests-api/GatewayTest.php b/tests-api/GatewayTest.php index d1c9707..a26442d 100644 --- a/tests-api/GatewayTest.php +++ b/tests-api/GatewayTest.php @@ -24,7 +24,7 @@ public function setUp() 'testMode' => true, ]; - $this->gateway = Omnipay::create("Przelewy24"); + $this->gateway = Omnipay::create('Przelewy24'); $this->gateway->initialize($settings); } @@ -40,7 +40,7 @@ public function testAccess(): void $this->assertFalse($response->isSuccessful()); $this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getCode()); - $this->assertSame("Incorrect authentication", $response->getMessage()); + $this->assertSame('Incorrect authentication', $response->getMessage()); } public function testMethods(): void @@ -165,9 +165,10 @@ private function randomString(int $length = 15): string $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; - for ($i = 0; $i < $length; $i++) { + for ($i = 0; $i < $length; ++$i) { $randomString .= $characters[random_int(0, $charactersLength - 1)]; } + return $randomString; } } diff --git a/tests/GatewayTest.php b/tests/GatewayTest.php index 5d2ee59..adeb3fc 100644 --- a/tests/GatewayTest.php +++ b/tests/GatewayTest.php @@ -9,6 +9,7 @@ use Omnipay\Przelewy24\Message\CompletePurchaseRequest; use Omnipay\Przelewy24\Message\MethodsRequest; use Omnipay\Przelewy24\Message\PurchaseInfoRequest; +use Omnipay\Przelewy24\Message\PurchaseOfflineRequest; use Omnipay\Przelewy24\Message\PurchaseRequest; use Omnipay\Przelewy24\Message\RefundsRequest; use Omnipay\Przelewy24\Message\TestAccessRequest; @@ -31,7 +32,7 @@ public function setUp() /** * @test */ - public function it_should_return_the_name() + public function itShouldReturnTheName() { $this->assertSame('Przelewy24', $this->gateway->getName()); } @@ -39,7 +40,7 @@ public function it_should_return_the_name() /** * @test */ - public function it_should_return_default_parameters() + public function itShouldReturnDefaultParameters() { $defaultParameters = $this->gateway->getDefaultParameters(); $this->assertSame('', $defaultParameters['merchantId']); @@ -53,7 +54,7 @@ public function it_should_return_default_parameters() /** * @test */ - public function it_should_set_and_get_merchant_id() + public function itShouldSetAndGetMerchantId() { $merchantId = '42'; @@ -64,7 +65,7 @@ public function it_should_set_and_get_merchant_id() /** * @test */ - public function it_should_set_and_get_pos_id() + public function itShouldSetAndGetPosId() { $posId = '13'; @@ -75,7 +76,7 @@ public function it_should_set_and_get_pos_id() /** * @test */ - public function it_should_set_and_get_crc() + public function itShouldSetAndGetCrc() { $crc = '1288348798'; @@ -86,7 +87,7 @@ public function it_should_set_and_get_crc() /** * @test */ - public function it_should_set_and_get_report_key() + public function itShouldSetAndGetReportKey() { $crc = '6c2f6d86-3091-4291-b1e4-2568492605e4'; @@ -97,7 +98,7 @@ public function it_should_set_and_get_report_key() /** * @test */ - public function it_should_set_and_get_channel() + public function itShouldSetAndGetChannel() { $channel = 32; @@ -108,7 +109,7 @@ public function it_should_set_and_get_channel() /** * @test */ - public function it_should_set_and_get_language() + public function itShouldSetAndGetLanguage() { $language = 'pl'; $this->gateway->setLanguage($language); @@ -118,7 +119,7 @@ public function it_should_set_and_get_language() /** * @test */ - public function it_should_create_a_test_access() + public function itShouldCreateATestAccess() { $request = $this->gateway->testAccess(); $this->assertInstanceOf(TestAccessRequest::class, $request); @@ -127,7 +128,7 @@ public function it_should_create_a_test_access() /** * @test */ - public function it_should_create_a_methods() + public function itShouldCreateAMethods() { $request = $this->gateway->methods(); $this->assertInstanceOf(MethodsRequest::class, $request); @@ -136,7 +137,7 @@ public function it_should_create_a_methods() /** * @test */ - public function it_should_create_a_purchase() + public function itShouldCreateAPurchase() { $request = $this->gateway->purchase([ 'amount' => '10.00', @@ -148,7 +149,7 @@ public function it_should_create_a_purchase() /** * @test */ - public function it_should_set_and_get_amount_on_purchase() + public function itShouldSetAndGetAmountOnPurchase() { $request = $this->gateway->purchase([ 'amount' => '1000', @@ -160,7 +161,7 @@ public function it_should_set_and_get_amount_on_purchase() /** * @test */ - public function it_should_set_and_get_shipping_on_purchase() + public function itShouldSetAndGetShippingOnPurchase() { $request = $this->gateway->purchase([ 'amount' => '1000', @@ -172,7 +173,7 @@ public function it_should_set_and_get_shipping_on_purchase() /** * @test */ - public function it_should_create_a_complete_purchase() + public function itShouldCreateACompletePurchase() { $request = $this->gateway->completePurchase([ 'amount' => '10.00', @@ -185,7 +186,7 @@ public function it_should_create_a_complete_purchase() * @test * @dataProvider refund_data_provider */ - public function it_should_create_a_refund( + public function itShouldCreateARefund( string $requestId, array $refunds, string $refundsUuid, @@ -211,7 +212,7 @@ public function it_should_create_a_refund( /** * @test */ - public function it_should_create_a_purchase_info() + public function itShouldCreateAPurchaseInfo() { $request = $this->gateway->purchaseInfo('session-id'); $this->assertInstanceOf(PurchaseInfoRequest::class, $request); @@ -221,7 +222,7 @@ public function it_should_create_a_purchase_info() /** * @test */ - public function it_should_create_card_info() + public function itShouldCreateCardInfo() { $request = $this->gateway->cardInfo('transaction-id'); $this->assertInstanceOf(CardInfoRequest::class, $request); @@ -230,7 +231,7 @@ public function it_should_create_card_info() /** * @test */ - public function it_should_create_card_pay() + public function itShouldCreateCardPay() { $request = $this->gateway->cardPay([]); $this->assertInstanceOf(CardPayRequest::class, $request); @@ -239,12 +240,24 @@ public function it_should_create_card_pay() /** * @test */ - public function it_should_create_card_charge() + public function itShouldCreateCardCharge() { $request = $this->gateway->cardCharge([]); $this->assertInstanceOf(CardChargeRequest::class, $request); } + /** + * @test + */ + public function itShouldCreatePurchaseOffline() + { + $request = $this->gateway->purchaseOffline([ + 'token' => 'token-abc', + ]); + $this->assertInstanceOf(PurchaseOfflineRequest::class, $request); + $this->assertSame('token-abc', $request->getToken()); + } + public function refund_data_provider(): array { return [ diff --git a/tests/Message/CardChargeRequestTest.php b/tests/Message/CardChargeRequestTest.php index 5e2c791..ccf2b79 100644 --- a/tests/Message/CardChargeRequestTest.php +++ b/tests/Message/CardChargeRequestTest.php @@ -16,11 +16,11 @@ class CardChargeRequestTest extends TestCase */ private $request; - public function setUp() + public function setUp(): void { $this->request = new CardChargeRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize([ - "token" => "29fa01f8-6bb8-4187-9fb0-ec6e1a62a731", + 'token' => '29fa01f8-6bb8-4187-9fb0-ec6e1a62a731', ]); } @@ -31,7 +31,7 @@ public function testGetData(): void $this->assertSame('29fa01f8-6bb8-4187-9fb0-ec6e1a62a731', $data['token']); } - public function testSendSuccess() + public function testSendSuccess(): void { $this->setMockHttpResponse('CardChargeSuccess.txt'); /** @var CardChargeResponse $response */ @@ -42,7 +42,7 @@ public function testSendSuccess() $this->assertSame('1234567890', $response->getTransactionId()); } - public function testSendAuthFailure() + public function testSendAuthFailure(): void { $this->setMockHttpResponse('CardChargeAuthFailure.txt'); $response = $this->request->send(); @@ -53,7 +53,7 @@ public function testSendAuthFailure() $this->assertSame('Incorrect authentication', $response->getMessage()); } - public function testSendInvalidDataFailure() + public function testSendInvalidDataFailure(): void { $this->setMockHttpResponse('CardChargeInvalidDataFailure.txt'); $response = $this->request->send(); diff --git a/tests/Message/CardInfoRequestTest.php b/tests/Message/CardInfoRequestTest.php index 2ec4f9a..252e417 100644 --- a/tests/Message/CardInfoRequestTest.php +++ b/tests/Message/CardInfoRequestTest.php @@ -16,7 +16,7 @@ class CardInfoRequestTest extends TestCase */ private $request; - public function setUp() + public function setUp(): void { $this->request = new CardInfoRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize([ @@ -31,7 +31,7 @@ public function testGetData(): void $this->assertSame(1234567890, $data['transactionId']); } - public function testSendInvalidDataFailure() + public function testSendInvalidDataFailure(): void { $this->setMockHttpResponse('CardInfoInvalidDataFailure.txt'); $response = $this->request->send(); @@ -42,7 +42,7 @@ public function testSendInvalidDataFailure() $this->assertSame('Wrong input data', $response->getMessage()); } - public function testSendAuthFailure() + public function testSendAuthFailure(): void { $this->setMockHttpResponse('CardInfoAuthFailure.txt'); $response = $this->request->send(); @@ -53,7 +53,7 @@ public function testSendAuthFailure() $this->assertSame('Incorrect authentication', $response->getMessage()); } - public function testSendNotFoundFailure() + public function testSendNotFoundFailure(): void { $this->setMockHttpResponse('CardInfoNotFoundFailure.txt'); $response = $this->request->send(); @@ -64,7 +64,7 @@ public function testSendNotFoundFailure() $this->assertSame('Transaction not exists', $response->getMessage()); } - public function testSendSuccess() + public function testSendSuccess(): void { $this->setMockHttpResponse('CardInfoSuccess.txt'); $response = $this->request->send(); diff --git a/tests/Message/CardPayRequestTest.php b/tests/Message/CardPayRequestTest.php index c6f5a16..55d5f8b 100644 --- a/tests/Message/CardPayRequestTest.php +++ b/tests/Message/CardPayRequestTest.php @@ -16,15 +16,15 @@ class CardPayRequestTest extends TestCase */ private $request; - public function setUp() + public function setUp(): void { $this->request = new CardPayRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize([ - "transactionId" => "29fa01f8-6bb8-4187-9fb0-ec6e1a62a731", - "number" => "9010100052000004", - "expiry" => "0535", - "cvv" => "1234", - "name" => "Franek Dolas", + 'transactionId' => '29fa01f8-6bb8-4187-9fb0-ec6e1a62a731', + 'number' => '9010100052000004', + 'expiry' => '0535', + 'cvv' => '1234', + 'name' => 'Franek Dolas', ]); } @@ -39,7 +39,7 @@ public function testGetData(): void $this->assertSame('Franek Dolas', $data['clientName']); } - public function testSendSuccess() + public function testSendSuccess(): void { $this->setMockHttpResponse('CardPaySuccess.txt'); /** @var CardPayResponse $response */ @@ -52,7 +52,7 @@ public function testSendSuccess() $this->assertSame('https://this-is-redirect-url.com', $response->getRedirectUrl()); } - public function testSendAuthFailure() + public function testSendAuthFailure(): void { $this->setMockHttpResponse('CardPayAuthFailure.txt'); $response = $this->request->send(); @@ -63,7 +63,7 @@ public function testSendAuthFailure() $this->assertSame('Incorrect authentication', $response->getMessage()); } - public function testSendInvalidDataFailure() + public function testSendInvalidDataFailure(): void { $this->setMockHttpResponse('CardPayInvalidDataFailure.txt'); $response = $this->request->send(); @@ -74,7 +74,7 @@ public function testSendInvalidDataFailure() $this->assertSame('Invalid input data', $response->getMessage()); } - public function testSendUnableToPayFailure() + public function testSendUnableToPayFailure(): void { $this->setMockHttpResponse('CardPayUnableToPayFailure.txt'); $response = $this->request->send(); diff --git a/tests/Message/CompletePurchaseRequestTest.php b/tests/Message/CompletePurchaseRequestTest.php index 4648d0e..8a1e6cc 100644 --- a/tests/Message/CompletePurchaseRequestTest.php +++ b/tests/Message/CompletePurchaseRequestTest.php @@ -16,7 +16,7 @@ class CompletePurchaseRequestTest extends TestCase */ private $request; - public function setUp() + public function setUp(): void { $this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize([ @@ -30,7 +30,7 @@ public function setUp() ]); } - public function testGetData() + public function testGetData(): void { $data = $this->request->getData(); @@ -42,7 +42,7 @@ public function testGetData() $this->assertCount(7, $data); } - public function testSendSuccess() + public function testSendSuccess(): void { $this->setMockHttpResponse('CompletePurchaseSuccess.txt'); $response = $this->request->send(); @@ -54,7 +54,7 @@ public function testSendSuccess() $this->assertSame(Response::HTTP_OK, $response->getCode()); } - public function testSendFailure() + public function testSendFailure(): void { $this->setMockHttpResponse('CompletePurchaseFailure.txt'); $response = $this->request->send(); diff --git a/tests/Message/MethodsRequestTest.php b/tests/Message/MethodsRequestTest.php index b90aa1f..d3e7349 100644 --- a/tests/Message/MethodsRequestTest.php +++ b/tests/Message/MethodsRequestTest.php @@ -16,11 +16,11 @@ class MethodsRequestTest extends TestCase */ private $request; - public function setUp() + public function setUp(): void { $this->request = new MethodsRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize([ - "lang" => "en", + 'lang' => 'en', ]); } @@ -62,7 +62,7 @@ public function testSendSuccess(): void $this->assertSame('unavailable', $method['availabilityHours']['sunday']); } - public function testSendAuthFailure() + public function testSendAuthFailure(): void { $this->setMockHttpResponse('MethodsAuthFailure.txt'); $response = $this->request->send(); @@ -73,7 +73,7 @@ public function testSendAuthFailure() $this->assertSame('Incorrect authentication', $response->getMessage()); } - public function testSendNotFoundFailure() + public function testSendNotFoundFailure(): void { $this->setMockHttpResponse('MethodsNotFoundFailure.txt'); $response = $this->request->send(); diff --git a/tests/Message/PurchaseInfoRequestTest.php b/tests/Message/PurchaseInfoRequestTest.php index f009e58..b94a725 100644 --- a/tests/Message/PurchaseInfoRequestTest.php +++ b/tests/Message/PurchaseInfoRequestTest.php @@ -16,7 +16,7 @@ class PurchaseInfoRequestTest extends TestCase */ private $request; - public function setUp() + public function setUp(): void { $this->request = new PurchaseInfoRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize([ @@ -31,7 +31,7 @@ public function testGetData(): void $this->assertSame('1234567890', $data['sessionId']); } - public function testSendSuccess() + public function testSendSuccess(): void { $this->setMockHttpResponse('PurchaseInfoSuccess.txt'); $response = $this->request->send(); @@ -51,8 +51,8 @@ public function testSendSuccess() $this->assertSame(154, $response->getInfo()['paymentMethod']); $this->assertSame('transaction description', $response->getInfo()['description']); $this->assertSame(0, $response->getInfo()['batchId']); - $this->assertSame("12", $response->getInfo()['fee']); - $this->assertSame("P24-K12-B34-H56", $response->getInfo()['statement']); + $this->assertSame('12', $response->getInfo()['fee']); + $this->assertSame('P24-K12-B34-H56', $response->getInfo()['statement']); $this->assertSame('franek@dolas.com', $response->getInfo()['email']); $this->assertSame('Franek Dolas', $response->getInfo()['name']); $this->assertSame('Kościuszki 12', $response->getInfo()['address']); @@ -60,7 +60,7 @@ public function testSendSuccess() $this->assertSame('30-611', $response->getInfo()['postcode']); } - public function testSendAuthFailure() + public function testSendAuthFailure(): void { $this->setMockHttpResponse('PurchaseInfoAuthFailure.txt'); $response = $this->request->send(); @@ -71,7 +71,7 @@ public function testSendAuthFailure() $this->assertSame('Incorrect authentication', $response->getMessage()); } - public function testSendInvalidDataFailure() + public function testSendInvalidDataFailure(): void { $this->setMockHttpResponse('PurchaseInfoInvalidDataFailure.txt'); $response = $this->request->send(); diff --git a/tests/Message/PurchaseOfflineRequestTest.php b/tests/Message/PurchaseOfflineRequestTest.php new file mode 100644 index 0000000..de5d498 --- /dev/null +++ b/tests/Message/PurchaseOfflineRequestTest.php @@ -0,0 +1,86 @@ +request = new PurchaseOfflineRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize([ + 'token' => '29fa01f8-6bb8-4187-9fb0-ec6e1a62a731', + ]); + } + + public function testGetData(): void + { + $data = $this->request->getData(); + + $this->assertSame('29fa01f8-6bb8-4187-9fb0-ec6e1a62a731', $data['token']); + } + + public function testSendSuccess(): void + { + $this->setMockHttpResponse('PurchaseOfflineSuccess.txt'); + /** @var PurchaseOfflineResponse $response */ + $response = $this->request->send(); + + $this->assertInstanceOf(PurchaseOfflineResponse::class, $response); + $this->assertTrue($response->isSuccessful()); + $this->assertSame(Response::HTTP_OK, $response->getCode()); + $data = $response->getInfo(); + $this->assertCount(7, $data); + $this->assertSame(1234567890, $data['transactionId']); + $this->assertSame('cb53d93f-3933-48dd-9756-13e6c03a74c0', $data['sessionId']); + $this->assertSame(1234, $data['amount']); + $this->assertSame('statement-full', $data['statement']); + $this->assertSame('PL21109024021694854264921521', $data['iban']); + $this->assertSame('Franek Dolas', $data['ibanOwner']); + $this->assertSame('Strzebrzeszyn 123', $data['ibanOwnerAddress']); + } + + public function testSendAuthFailure(): void + { + $this->setMockHttpResponse('PurchaseOfflineAuthFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(PurchaseOfflineResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getCode()); + $this->assertSame('Incorrect authentication', $response->getMessage()); + } + + public function testSendInvalidDataFailure(): void + { + $this->setMockHttpResponse('PurchaseOfflineInvalidDataFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(PurchaseOfflineResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertSame(Response::HTTP_BAD_REQUEST, $response->getCode()); + $this->assertSame('Invalid input data', $response->getMessage()); + } + + public function testSendUnableToCreateFailure(): void + { + $this->setMockHttpResponse('PurchaseOfflineUnableToCreateFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(PurchaseOfflineResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertSame(Response::HTTP_CONFLICT, $response->getCode()); + $this->assertSame('Unable to create offline transaction', $response->getMessage()); + } +} diff --git a/tests/Message/PurchaseRequestTest.php b/tests/Message/PurchaseRequestTest.php index fd9492e..0c2d9c1 100644 --- a/tests/Message/PurchaseRequestTest.php +++ b/tests/Message/PurchaseRequestTest.php @@ -18,7 +18,7 @@ class PurchaseRequestTest extends TestCase */ private $request; - public function setUp() + public function setUp(): void { $card = new CreditCard([ 'email' => 'franek@dolas.com', @@ -42,7 +42,7 @@ public function setUp() ]); } - public function channelProvider() + public function channelProvider(): array { return [ [Gateway::P24_CHANNEL_ALL], @@ -52,8 +52,10 @@ public function channelProvider() /** * @dataProvider channelProvider + * + * @param mixed $channel */ - public function testGetData($channel) + public function testGetData($channel): void { $card = new CreditCard([ 'email' => 'franek@dolas.com', @@ -78,12 +80,12 @@ public function testGetData($channel) $data = $this->request->getData(); - $this->assertSame("42", $data['sessionId']); + $this->assertSame('42', $data['sessionId']); $this->assertSame(1266, $data['amount']); - $this->assertSame("PLN", $data['currency']); + $this->assertSame('PLN', $data['currency']); $this->assertSame('Transaction Description', $data['description']); - $this->assertSame("franek@dolas.com", $data['email']); - $this->assertSame("PL", $data['country']); + $this->assertSame('franek@dolas.com', $data['email']); + $this->assertSame('PL', $data['country']); $this->assertSame('https://www.example.com/return', $data['urlReturn']); $this->assertSame('https://www.example.com/notify', $data['urlStatus']); $this->assertSame('15276e08cc84868619e1054ccf15d638337cae2bced6cb5a48bb799a3b52144692bce63408db85c84a6ca0461a999885', $data['sign']); @@ -96,7 +98,7 @@ public function testGetData($channel) } } - public function testSendSuccess() + public function testSendSuccess(): void { $this->setMockHttpResponse('PurchaseSuccess.txt'); $response = $this->request->send(); @@ -115,7 +117,7 @@ public function testSendSuccess() $this->assertSame('', $response->getMessage()); } - public function testSendSignatureFailure() + public function testSendSignatureFailure(): void { $this->setMockHttpResponse('PurchaseSignatureFailure.txt'); $response = $this->request->send(); diff --git a/tests/Message/RefundsRequestTest.php b/tests/Message/RefundsRequestTest.php index 4fac2ce..4e99e8b 100644 --- a/tests/Message/RefundsRequestTest.php +++ b/tests/Message/RefundsRequestTest.php @@ -1,5 +1,7 @@ request->initialize($data); - if (! is_null($expectedExceptionMessage)) { + if (null !== $expectedExceptionMessage) { $this->expectException(InvalidRequestException::class); $this->expectExceptionMessage($expectedExceptionMessage); } diff --git a/tests/Message/TestAccessRequestTest.php b/tests/Message/TestAccessRequestTest.php index 909e799..5231355 100644 --- a/tests/Message/TestAccessRequestTest.php +++ b/tests/Message/TestAccessRequestTest.php @@ -16,7 +16,7 @@ class TestAccessRequestTest extends TestCase */ private $request; - public function setUp() + public function setUp(): void { $this->request = new TestAccessRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize([]); @@ -41,7 +41,7 @@ public function testSendSuccess(): void $this->assertTrue($response->getTest()); } - public function testSendAuthFailure() + public function testSendAuthFailure(): void { $this->setMockHttpResponse('TestAccessAuthFailure.txt'); $response = $this->request->send(); @@ -53,7 +53,7 @@ public function testSendAuthFailure() $this->assertFalse($response->getTest()); } - public function testSendInvalidDataFailure() + public function testSendInvalidDataFailure(): void { $this->setMockHttpResponse('TestAccessInvalidDataFailure.txt'); $response = $this->request->send(); diff --git a/tests/Mock/PurchaseOfflineAuthFailure.txt b/tests/Mock/PurchaseOfflineAuthFailure.txt new file mode 100644 index 0000000..6687897 --- /dev/null +++ b/tests/Mock/PurchaseOfflineAuthFailure.txt @@ -0,0 +1,16 @@ +HTTP/1.1 422 Unprocessable Entity +Server: nginx/1.4.4 +Date: Sat, 21 May 2022 17:20:00 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "error": "Incorrect authentication", + "code": 401 +} diff --git a/tests/Mock/PurchaseOfflineInvalidDataFailure.txt b/tests/Mock/PurchaseOfflineInvalidDataFailure.txt new file mode 100644 index 0000000..51f71e3 --- /dev/null +++ b/tests/Mock/PurchaseOfflineInvalidDataFailure.txt @@ -0,0 +1,16 @@ +HTTP/1.1 422 Unprocessable Entity +Server: nginx/1.4.4 +Date: Sat, 20 May 2022 07:00:00 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "error": "Invalid input data", + "code": 400 +} diff --git a/tests/Mock/PurchaseOfflineSuccess.txt b/tests/Mock/PurchaseOfflineSuccess.txt new file mode 100644 index 0000000..7ac5b7f --- /dev/null +++ b/tests/Mock/PurchaseOfflineSuccess.txt @@ -0,0 +1,20 @@ +HTTP/1.1 201 Created +Server: nginx/1.4.4 +Date: Sat, 16 May 2022 17:30:00 GMT +Content-Type: application/json; charset=utf-8 +Connection: keep-alive +Cache-Control: no-cache, no-store +X-Request-Id: 53e398c2-1c9a-4e8b-a3a7-9dcf3cad90b1 + +{ + "data": { + "orderId": 1234567890, + "sessionId": "cb53d93f-3933-48dd-9756-13e6c03a74c0", + "amount": 1234, + "statement": "statement-full", + "iban": "PL21109024021694854264921521", + "ibanOwner": "Franek Dolas", + "ibanOwnerAddress": "Strzebrzeszyn 123" + }, + "responseCode": 0 +} diff --git a/tests/Mock/PurchaseOfflineUnableToCreateFailure.txt b/tests/Mock/PurchaseOfflineUnableToCreateFailure.txt new file mode 100644 index 0000000..3b27494 --- /dev/null +++ b/tests/Mock/PurchaseOfflineUnableToCreateFailure.txt @@ -0,0 +1,16 @@ +HTTP/1.1 422 Unprocessable Entity +Server: nginx/1.4.4 +Date: Sat, 21 May 2022 17:20:00 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "error": "Unable to create offline transaction", + "code": 409 +}