From 64d22c0c5ba1c482f683bb93cde049548ec1e8a6 Mon Sep 17 00:00:00 2001 From: Marmolada Date: Wed, 18 May 2022 16:25:13 +0200 Subject: [PATCH] [Refund] api/v1/transaction/refund (#4) * transaction-register: in progress * Refund save work [refund] * ECS fix [refund] * tests for refund [refund] * Remove junk, remove amount auto-calc [refund] * Remove junk, fix tests [refund] * Typing [refund] * fix mistake [refund] * Remove VarDumper [refund] * Composer changes [refund] * bump authors [refund] * refund: merged dev Co-authored-by: Piotr Synowiec --- README.md | 3 + composer.json | 7 +- ecs.php | 10 +- src/Gateway.php | 10 + src/Message/AbstractRequest.php | 2 +- src/Message/AbstractResponse.php | 20 +- src/Message/PurchaseInfoResponse.php | 2 +- src/Message/PurchaseRequest.php | 2 +- src/Message/RefundsRequest.php | 115 ++++++++++ src/Message/RefundsResponse.php | 42 ++++ tests-api/GatewayTest.php | 9 +- tests/GatewayTest.php | 66 ++++++ tests/Message/CompletePurchaseRequestTest.php | 6 +- tests/Message/PurchaseRequestTest.php | 6 +- tests/Message/RefundsRequestTest.php | 211 ++++++++++++++++++ .../RefundsRequestFailedAuthorization.txt | 9 + tests/Mock/RefundsRequestFailedConflict.txt | 9 + tests/Mock/RefundsRequestFailure.txt | 9 + tests/Mock/RefundsRequestSuccess.txt | 9 + 19 files changed, 517 insertions(+), 30 deletions(-) create mode 100644 src/Message/RefundsRequest.php create mode 100644 src/Message/RefundsResponse.php create mode 100644 tests/Message/RefundsRequestTest.php create mode 100644 tests/Mock/RefundsRequestFailedAuthorization.txt create mode 100644 tests/Mock/RefundsRequestFailedConflict.txt create mode 100644 tests/Mock/RefundsRequestFailure.txt create mode 100644 tests/Mock/RefundsRequestSuccess.txt diff --git a/README.md b/README.md index 2854b0b..2e1cb36 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ | /api/v1/transaction/verify | completePurchase | | /api/v1/transaction/by/sessionId | purchaseInfo | | /api/v1/card/info | cardInfo | +| /api/v1/transaction/refund | refund | ## Install @@ -35,6 +36,8 @@ The following gateways are provided by this package: * Przelewy24 +Reference official documentation https://developers.przelewy24.pl/index.php + ## Example ```php diff --git a/composer.json b/composer.json index 9fc5e51..f6ced46 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,10 @@ { "name": "Piotr Synowiec", "email": "psynowiec@gmail.com" + }, + { + "name": "Adam Migacz", + "email": "smigi1997@gmail.com" } ], "autoload": { @@ -26,8 +30,9 @@ }, "require": { "omnipay/common": "^3", + "ext-json": "*", "ext-bcmath": "*", - "ext-json": "*" + "php": "^7.2|^8.0" }, "require-dev": { "omnipay/tests": "^3", diff --git a/ecs.php b/ecs.php index 27b97c5..0d9592a 100644 --- a/ecs.php +++ b/ecs.php @@ -21,9 +21,9 @@ 'syntax' => 'short', ]]); - $ecsConfig->import(SetList::SPACES); - $ecsConfig->import(SetList::ARRAY); - $ecsConfig->import(SetList::DOCBLOCK); - $ecsConfig->import(SetList::PSR_12); - $ecsConfig->import(SetList::CLEAN_CODE); + $ecsConfig->import(SetList::SPACES); + $ecsConfig->import(SetList::ARRAY); + $ecsConfig->import(SetList::DOCBLOCK); + $ecsConfig->import(SetList::PSR_12); + $ecsConfig->import(SetList::CLEAN_CODE); }; diff --git a/src/Gateway.php b/src/Gateway.php index 1550911..6d7b103 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -11,6 +11,7 @@ use Omnipay\Przelewy24\Message\MethodsRequest; use Omnipay\Przelewy24\Message\PurchaseInfoRequest; use Omnipay\Przelewy24\Message\PurchaseRequest; +use Omnipay\Przelewy24\Message\RefundsRequest; use Omnipay\Przelewy24\Message\TestAccessRequest; class Gateway extends AbstractGateway @@ -162,4 +163,13 @@ public function cardInfo(string $transactionId): CardInfoRequest 'transactionId' => $transactionId, ]); } + + /** + * @param string[] $options + * @return AbstractRequest|RefundsRequest + */ + public function refund(array $options = []): RefundsRequest + { + return $this->createRequest(RefundsRequest::class, $options); + } } diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index 9acbca5..996ec7d 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -104,7 +104,7 @@ protected function sendRequest(string $method, string $endpoint, $data): Respons base64_encode(sprintf('%s:%s', $this->getMerchantId(), $this->getReportKey())) ), ], - empty($data) ? null : json_encode($data) + empty($data) ? null : json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ); } diff --git a/src/Message/AbstractResponse.php b/src/Message/AbstractResponse.php index fc55dbd..0d65ea5 100644 --- a/src/Message/AbstractResponse.php +++ b/src/Message/AbstractResponse.php @@ -6,15 +6,10 @@ use Omnipay\Common\Message\AbstractResponse as BaseAbstractResponse; use Omnipay\Common\Message\RequestInterface; +use Symfony\Component\HttpFoundation\Response; abstract class AbstractResponse extends BaseAbstractResponse { - public const HTTP_OK = 200; - - public const HTTP_BAD_REQUEST = 400; - - public const HTTP_UNAUTHORIZED = 401; - /** * @param string[] $data */ @@ -26,13 +21,16 @@ public function __construct(RequestInterface $request, $data) public function getCode(): int { if (isset($this->data['code'])) { - return $this->data['code']; + return (int) $this->data['code']; } - return self::HTTP_OK; + return Response::HTTP_OK; } - public function getMessage(): string + /** + * @return array|string|null + */ + public function getMessage() { if (isset($this->data['error'])) { return $this->data['error']; @@ -43,7 +41,9 @@ public function getMessage(): string public function isSuccessful(): bool { - return self::HTTP_OK === $this->getCode(); + $code = $this->getCode(); + + return in_array($code, [Response::HTTP_CREATED, Response::HTTP_OK]); } protected function getAmountFromInternal(int $amount): string diff --git a/src/Message/PurchaseInfoResponse.php b/src/Message/PurchaseInfoResponse.php index 4c331d1..1168cbf 100644 --- a/src/Message/PurchaseInfoResponse.php +++ b/src/Message/PurchaseInfoResponse.php @@ -40,7 +40,7 @@ public function getCode(): int return $this->data['code']; } - return self::HTTP_OK; + return Response::HTTP_OK; } /** diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index 78c5e79..976ac9d 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -133,7 +133,7 @@ public function getShipping() public function setShipping($value): self { - return $this->setParameter('regulationAccept', $value); + return $this->setParameter('shipping', $value); } public function getTransactionLabel(): ?string diff --git a/src/Message/RefundsRequest.php b/src/Message/RefundsRequest.php new file mode 100644 index 0000000..a9921ce --- /dev/null +++ b/src/Message/RefundsRequest.php @@ -0,0 +1,115 @@ +setParameter('requestId', $requestId); + } + + public function getRequestId(): string + { + return $this->getParameter('requestId'); + } + + public function setRefunds(array $refunds): self + { + return $this->setParameter('refunds', $refunds); + } + + public function getRefunds(): array + { + return $this->getParameter('refunds'); + } + + public function setRefundsUuid(string $refundsUuid): self + { + return $this->setParameter('refundsUuid', $refundsUuid); + } + + public function getRefundsUuid(): string + { + return $this->getParameter('refundsUuid'); + } + + public function setUrlStatus(?string $urlStatus): self + { + return $this->setParameter('urlStatus', $urlStatus); + } + + public function getUrlStatus(): ?string + { + return $this->getParameter('urlStatus'); + } + + public function getData(): array + { + $this->validate('requestId', 'refunds', 'refundsUuid'); + $this->validateRefundsArray(); + $this->transformRefundsAmount(); + + $data = [ + 'requestId' => $this->getRequestId(), + 'refunds' => $this->getRefunds(), + 'refundsUuid' => $this->getRefundsUuid(), + 'urlStatus' => $this->getUrlStatus(), + ]; + + return array_filter($data); + } + + /** + * @param array $data + * @return ResponseInterface|MethodsResponse + */ + public function sendData($data): ResponseInterface + { + $httpResponse = $this->sendRequest('GET', 'transaction/refund', $data); + + $responseData = json_decode($httpResponse->getBody()->getContents(), true); + + return $this->response = new RefundsResponse($this, $responseData, $this->getEndpoint()); + } + + /** + * @throws InvalidRequestException + */ + private function validateRefundsArray(): void + { + $refunds = $this->getParameter('refunds'); + if (is_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"); + } + foreach ($requiredFields as $requiredField) { + if (! array_key_exists($requiredField, $refund)) { + throw new InvalidRequestException("The $requiredField parameter is required in index $key of `refunds` array"); + } + } + } + } + + /** + * @throws InvalidRequestException + */ + private function transformRefundsAmount(): void + { + $refunds = $this->getParameter('refunds'); + foreach ($refunds as $key => $refund) { + $refunds[$key]['amount'] = $this->internalAmountValue($refund['amount']); + } + + $this->setParameter('refunds', $refunds); + } +} diff --git a/src/Message/RefundsResponse.php b/src/Message/RefundsResponse.php new file mode 100644 index 0000000..90da4b2 --- /dev/null +++ b/src/Message/RefundsResponse.php @@ -0,0 +1,42 @@ +refunds = $data['data'] ?? null; + if (isset($data['responseCode'])) { + $this->responseCode = (int) $data['responseCode']; + } + } + + public function getRefunds(): array + { + return $this->refunds; + } + + public function getResponseCode(): ?int + { + return $this->responseCode; + } + + public function getCode(): int + { + if (! is_null($this->getResponseCode())) { + return $this->getResponseCode(); + } + + return parent::getCode(); + } +} diff --git a/tests-api/GatewayTest.php b/tests-api/GatewayTest.php index a54030b..092a88c 100644 --- a/tests-api/GatewayTest.php +++ b/tests-api/GatewayTest.php @@ -5,7 +5,6 @@ namespace API; use Omnipay\Omnipay; -use Omnipay\Przelewy24\Message\AbstractResponse; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\VarDumper\VarDumper; @@ -32,7 +31,7 @@ public function setUp() public function testAccess(): void { $response = $this->gateway->testAccess()->send(); - $this->assertSame(AbstractResponse::HTTP_OK, $response->getCode()); + $this->assertSame(Response::HTTP_OK, $response->getCode()); $this->assertSame('', $response->getMessage()); $this->assertTrue($response->isSuccessful()); @@ -40,14 +39,14 @@ public function testAccess(): void $response = $this->gateway->testAccess()->send(); $this->assertFalse($response->isSuccessful()); - $this->assertSame(AbstractResponse::HTTP_UNAUTHORIZED, $response->getCode()); + $this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getCode()); $this->assertSame("Incorrect authentication", $response->getMessage()); } public function testMethods(): void { $response = $this->gateway->methods()->send(); - $this->assertSame(AbstractResponse::HTTP_OK, $response->getCode()); + $this->assertSame(Response::HTTP_OK, $response->getCode()); $this->assertSame('', $response->getMessage()); $this->assertTrue($response->isSuccessful()); $this->assertGreaterThan(0, count($response->getMethods())); @@ -72,7 +71,7 @@ public function testPurchase(): void VarDumper::dump($response->getRedirectUrl()); VarDumper::dump($response->getMessage()); - $this->assertSame(AbstractResponse::HTTP_OK, $response->getCode()); + $this->assertSame(Response::HTTP_OK, $response->getCode()); $this->assertSame('', $response->getMessage()); $this->assertTrue($response->isSuccessful()); $this->assertContains('https://sandbox.przelewy24.pl/trnRequest/', $response->getRedirectUrl()); diff --git a/tests/GatewayTest.php b/tests/GatewayTest.php index 3b45980..3efe35e 100644 --- a/tests/GatewayTest.php +++ b/tests/GatewayTest.php @@ -8,6 +8,7 @@ use Omnipay\Przelewy24\Message\MethodsRequest; use Omnipay\Przelewy24\Message\PurchaseInfoRequest; use Omnipay\Przelewy24\Message\PurchaseRequest; +use Omnipay\Przelewy24\Message\RefundsRequest; use Omnipay\Przelewy24\Message\TestAccessRequest; use Omnipay\Tests\GatewayTestCase; @@ -142,6 +143,9 @@ public function it_should_create_a_purchase() $this->assertSame('10.00', $request->getAmount()); } + /** + * @test + */ public function it_should_set_and_get_amount_on_purchase() { $request = $this->gateway->purchase([ @@ -151,6 +155,9 @@ public function it_should_set_and_get_amount_on_purchase() $this->assertSame('10.00', $request->getAmount()); } + /** + * @test + */ public function it_should_set_and_get_shipping_on_purchase() { $request = $this->gateway->purchase([ @@ -172,6 +179,33 @@ public function it_should_create_a_complete_purchase() $this->assertSame('10.00', $request->getAmount()); } + /** + * @test + * @dataProvider refund_data_provider + */ + public function it_should_create_a_refund( + string $requestId, + array $refunds, + string $refundsUuid, + ?string $urlStatus + ) { + $data = [ + 'requestId' => $requestId, + 'refunds' => $refunds, + 'refundsUuid' => $refundsUuid, + 'urlStatus' => $urlStatus, + ]; + + $request = $this->gateway->refund($data); + + $this->assertInstanceOf(RefundsRequest::class, $request); + + $this->assertSame($requestId, $request->getRequestId()); + $this->assertSame($refunds, $request->getRefunds()); + $this->assertSame($refundsUuid, $request->getRefundsUuid()); + $this->assertSame($urlStatus, $request->getUrlStatus()); + } + /** * @test */ @@ -182,9 +216,41 @@ public function it_should_create_a_purchase_info() $this->assertSame('session-id', $request->getSessionId()); } + /** + * @test + */ public function it_should_create_card_info() { $request = $this->gateway->cardInfo('transaction-id'); $this->assertInstanceOf(CardInfoRequest::class, $request); } + + public function refund_data_provider(): array + { + return [ + [ + 'requestId' => '123', + 'refunds' => [ + [ + 'orderId' => '123', + 'sessionId' => '123', + 'amount' => '123', + ], + ], + 'refundsUuid' => '321', + 'urlStatus' => 'status', + ], + [ + 'requestId' => 'gsa', + 'refunds' => [ + [ + 'orderId' => 'dfsa', + 'amount' => 'dsa', + ], + ], + 'refundsUuid' => '512', + 'urlStatus' => '15215215', + ], + ]; + } } diff --git a/tests/Message/CompletePurchaseRequestTest.php b/tests/Message/CompletePurchaseRequestTest.php index 94c4cb9..4648d0e 100644 --- a/tests/Message/CompletePurchaseRequestTest.php +++ b/tests/Message/CompletePurchaseRequestTest.php @@ -4,10 +4,10 @@ namespace Message; -use Omnipay\Przelewy24\Message\AbstractResponse; use Omnipay\Przelewy24\Message\CompletePurchaseRequest; use Omnipay\Przelewy24\Message\CompletePurchaseResponse; use Omnipay\Tests\TestCase; +use Symfony\Component\HttpFoundation\Response; class CompletePurchaseRequestTest extends TestCase { @@ -51,7 +51,7 @@ public function testSendSuccess() $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('', $response->getMessage()); - $this->assertSame(AbstractResponse::HTTP_OK, $response->getCode()); + $this->assertSame(Response::HTTP_OK, $response->getCode()); } public function testSendFailure() @@ -61,7 +61,7 @@ public function testSendFailure() $this->assertInstanceOf(CompletePurchaseResponse::class, $response); $this->assertFalse($response->isSuccessful()); - $this->assertSame(AbstractResponse::HTTP_BAD_REQUEST, $response->getCode()); + $this->assertSame(Response::HTTP_BAD_REQUEST, $response->getCode()); $this->assertSame('Incorrect CRC value', $response->getMessage()); } } diff --git a/tests/Message/PurchaseRequestTest.php b/tests/Message/PurchaseRequestTest.php index 3a03952..fd9492e 100644 --- a/tests/Message/PurchaseRequestTest.php +++ b/tests/Message/PurchaseRequestTest.php @@ -6,10 +6,10 @@ use Omnipay\Common\CreditCard; use Omnipay\Przelewy24\Gateway; -use Omnipay\Przelewy24\Message\AbstractResponse; use Omnipay\Przelewy24\Message\PurchaseRequest; use Omnipay\Przelewy24\Message\PurchaseResponse; use Omnipay\Tests\TestCase; +use Symfony\Component\HttpFoundation\Response; class PurchaseRequestTest extends TestCase { @@ -111,7 +111,7 @@ public function testSendSuccess() ); $this->assertNull($response->getRedirectData()); $this->assertNull($response->getTransactionReference()); - $this->assertSame(AbstractResponse::HTTP_OK, $response->getCode()); + $this->assertSame(Response::HTTP_OK, $response->getCode()); $this->assertSame('', $response->getMessage()); } @@ -123,7 +123,7 @@ public function testSendSignatureFailure() $this->assertInstanceOf(PurchaseResponse::class, $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); - $this->assertSame(AbstractResponse::HTTP_BAD_REQUEST, $response->getCode()); + $this->assertSame(Response::HTTP_BAD_REQUEST, $response->getCode()); $this->assertSame('Incorrect CRC value', $response->getMessage()); } } diff --git a/tests/Message/RefundsRequestTest.php b/tests/Message/RefundsRequestTest.php new file mode 100644 index 0000000..4fac2ce --- /dev/null +++ b/tests/Message/RefundsRequestTest.php @@ -0,0 +1,211 @@ + '123', + 'refunds' => [ + [ + 'orderId' => '123', + 'sessionId' => '123', + 'amount' => '123', + ], + ], + 'refundsUuid' => '321', + ]; + + /** + * @var RefundsRequest + */ + private $request; + + public function setUp(): void + { + $this->request = new RefundsRequest($this->getHttpClient(), $this->getHttpRequest()); + } + + /** + * @dataProvider refundDataProvider + */ + public function testGetData( + ?string $requestId, + array $refunds, + ?string $refundsUuid, + ?string $urlStatus, + ?string $expectedExceptionMessage + ): void { + $data = []; + + if (! is_null($requestId)) { + $data['requestId'] = $requestId; + } + + $data['refunds'] = $refunds; + + if (! is_null($refundsUuid)) { + $data['refundsUuid'] = $refundsUuid; + } + + if (! is_null($urlStatus)) { + $data['urlStatus'] = $urlStatus; + } + + $this->request->initialize($data); + + if (! is_null($expectedExceptionMessage)) { + $this->expectException(InvalidRequestException::class); + $this->expectExceptionMessage($expectedExceptionMessage); + } + + $data = $this->request->getData(); + $this->assertSame($requestId, $data['requestId']); + foreach ($refunds as $key => $refund) { + $this->assertSame($refund['orderId'], $data['refunds'][$key]['orderId']); + $this->assertSame($refund['sessionId'], $data['refunds'][$key]['sessionId']); + $this->assertNotSame($refund['amount'], $data['refunds'][$key]['amount']); + } + $this->assertSame($refundsUuid, $data['refundsUuid']); + $this->assertSame($urlStatus, $data['urlStatus']); + } + + public function testSendSuccess(): void + { + $this->setMockHttpResponse('RefundsRequestSuccess.txt'); + $this->request->initialize(self::REQUEST_DATA); + $response = $this->request->send(); + + $this->assertInstanceOf(RefundsResponse::class, $response); + $this->assertTrue($response->isSuccessful()); + $this->assertNotNull($response->getRefunds()); + $this->assertNotNull($response->getResponseCode()); + $this->assertSame(1, count($response->getRefunds())); + } + + /** + * @dataProvider failureResponseDataProvider + */ + public function testSendFailure(string $fileName): void + { + $this->setMockHttpResponse($fileName); + $this->request->initialize(self::REQUEST_DATA); + $response = $this->request->send(); + + $this->assertInstanceOf(RefundsResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertNotNull($response->getCode()); + $this->assertNotNull($response->getMessage()); + $this->assertNull($response->getResponseCode()); + } + + public function failureResponseDataProvider(): array + { + return [ + ['RefundsRequestFailure.txt'], + ['RefundsRequestFailedConflict.txt'], + ['RefundsRequestFailedAuthorization.txt'], + ]; + } + + public function refundDataProvider(): array + { + return [ + [ + 'requestId' => '123', + 'refunds' => [ + [ + 'orderId' => '123', + 'sessionId' => '123', + 'amount' => '123', + ], + ], + 'refundsUuid' => '321', + 'urlStatus' => 'status', + 'expectedExceptionMessage' => null, + ], + [ + 'requestId' => 'gsa', + 'refunds' => [ + [ + 'orderId' => 'dfsa', + 'amount' => 'dsa', + ], + ], + 'refundsUuid' => '512', + 'urlStatus' => '15215215', + 'expectedExceptionMessage' => 'The sessionId parameter is required in index 0 of `refunds` array', + ], + [ + 'requestId' => 'gsa', + 'refunds' => [ + [ + 'amount' => 'dsa', + ], + ], + 'refundsUuid' => '512', + 'urlStatus' => '15215215', + 'expectedExceptionMessage' => 'The orderId parameter is required in index 0 of `refunds` array', + ], + [ + 'requestId' => 'gsa', + 'refunds' => [], + 'refundsUuid' => '512', + 'urlStatus' => '15215215', + 'expectedExceptionMessage' => 'The parameter `refunds` can not be empty', + ], + [ + 'requestId' => 'gsa', + 'refunds' => [1, 23], + 'refundsUuid' => '512', + 'urlStatus' => '15215215', + 'expectedExceptionMessage' => 'Values in `refunds` need to be an array', + ], + [ + 'requestId' => null, + 'refunds' => [1, 23], + 'refundsUuid' => null, + 'urlStatus' => '', + 'expectedExceptionMessage' => 'The requestId parameter is required', + ], + [ + 'requestId' => '123', + 'refunds' => [ + [ + 'orderId' => '123', + 'sessionId' => '123', + 'amount' => '123', + ], + ], + 'refundsUuid' => null, + 'urlStatus' => '', + 'expectedExceptionMessage' => 'The refundsUuid parameter is required', + ], + [ + 'requestId' => '123', + 'refunds' => [ + [ + 'orderId' => '123', + 'sessionId' => '123', + 'amount' => '123', + ], + [ + 'sessionId' => '123', + 'amount' => '123', + ], + ], + 'refundsUuid' => '123', + 'urlStatus' => null, + 'expectedExceptionMessage' => 'The orderId parameter is required in index 1 of `refunds` array', + ], + ]; + } +} diff --git a/tests/Mock/RefundsRequestFailedAuthorization.txt b/tests/Mock/RefundsRequestFailedAuthorization.txt new file mode 100644 index 0000000..8fdd928 --- /dev/null +++ b/tests/Mock/RefundsRequestFailedAuthorization.txt @@ -0,0 +1,9 @@ +HTTP/1.1 401 Created +Server: nginx/1.4.4 +Date: Sat, 14 May 2022 14:00: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 + +{"code": "401", "error": "Incorrect authentication"} diff --git a/tests/Mock/RefundsRequestFailedConflict.txt b/tests/Mock/RefundsRequestFailedConflict.txt new file mode 100644 index 0000000..0f97e70 --- /dev/null +++ b/tests/Mock/RefundsRequestFailedConflict.txt @@ -0,0 +1,9 @@ +HTTP/1.1 401 Created +Server: nginx/1.4.4 +Date: Sat, 14 May 2022 14:00: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 + +{"code": "409", "error": []} diff --git a/tests/Mock/RefundsRequestFailure.txt b/tests/Mock/RefundsRequestFailure.txt new file mode 100644 index 0000000..a4e5cc6 --- /dev/null +++ b/tests/Mock/RefundsRequestFailure.txt @@ -0,0 +1,9 @@ +HTTP/1.1 400 Created +Server: nginx/1.4.4 +Date: Sat, 14 May 2022 14:00: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 + +{"code": "400", "error": "Invalid input parameters"} diff --git a/tests/Mock/RefundsRequestSuccess.txt b/tests/Mock/RefundsRequestSuccess.txt new file mode 100644 index 0000000..ce85ce6 --- /dev/null +++ b/tests/Mock/RefundsRequestSuccess.txt @@ -0,0 +1,9 @@ +HTTP/1.1 201 Created +Server: nginx/1.4.4 +Date: Sat, 14 May 2022 14:00: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 + +{"responseCode": "201", "data": [ {"orderId": 1, "sessionId": 2, "amount": 2, "description": "test", "status": 1, "message": "test-message" } ]}