From e14986b802b52a1dd793a2848845d66171675c22 Mon Sep 17 00:00:00 2001 From: Piotr Synowiec Date: Wed, 18 May 2022 10:48:13 +0200 Subject: [PATCH 1/2] transaction-register-more-params: updated PurchaseRequest with most of the P24 params (#7) --- src/Message/AbstractRequest.php | 10 +- src/Message/PurchaseRequest.php | 159 +++++++++++++++++++++++++- src/Message/PurchaseResponse.php | 6 +- tests-api/GatewayTest.php | 31 +++++ tests/GatewayTest.php | 11 +- tests/Message/PurchaseRequestTest.php | 4 +- 6 files changed, 207 insertions(+), 14 deletions(-) diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index 51f489d..9acbca5 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -108,8 +108,14 @@ protected function sendRequest(string $method, string $endpoint, $data): Respons ); } - protected function internalAmountValue(): int + /** + * @param mixed $value + * @throws + */ + protected function internalAmountValue($value = null): int { - return (int) bcmul($this->getAmount(), '100', 2); + $amount = $value ?? $this->getAmount(); + + return (int) bcmul((string) $amount, '100', 2); } } diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index c69e88a..78c5e79 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -36,6 +36,136 @@ public function setCountry(string $value): self return $this->setParameter('country', $value); } + public function getCardNotifyUrl(): ?string + { + return $this->getParameter('cardNotifyUrl'); + } + + public function setCardNotifyUrl(string $value): self + { + return $this->setParameter('cardNotifyUrl', $value); + } + + public function getName(): ?string + { + return $this->getParameter('name'); + } + + public function setName(string $value): self + { + return $this->setParameter('name', $value); + } + + public function getAddress(): ?string + { + return $this->getParameter('address'); + } + + public function setAddress(string $value): self + { + return $this->setParameter('address', $value); + } + + public function getPostcode(): ?string + { + return $this->getParameter('postcode'); + } + + public function setPostcode(string $value): self + { + return $this->setParameter('postcode', $value); + } + + public function getCity(): ?string + { + return $this->getParameter('city'); + } + + public function setCity(string $value): self + { + return $this->setParameter('city', $value); + } + + public function getPhone(): ?string + { + return $this->getParameter('phone'); + } + + public function setPhone(string $value): self + { + return $this->setParameter('phone', $value); + } + + public function getTimeLimit(): ?int + { + return $this->getParameter('timeLimit'); + } + + public function setTimeLimit(int $value): self + { + return $this->setParameter('timeLimit', $value); + } + + public function getWaitForResult(): ?bool + { + return $this->getParameter('waitForResult'); + } + + public function setWaitForResult(bool $value): self + { + return $this->setParameter('waitForResult', $value); + } + + public function getRegulationAccept(): ?bool + { + return $this->getParameter('regulationAccept'); + } + + public function setRegulationAccept(bool $value): self + { + return $this->setParameter('regulationAccept', $value); + } + + public function getShipping() + { + return $this->getParameter('shipping'); + } + + public function setShipping($value): self + { + return $this->setParameter('regulationAccept', $value); + } + + public function getTransactionLabel(): ?string + { + return $this->getParameter('transactionLabel'); + } + + public function setTransactionLabel(string $value): self + { + return $this->setParameter('transactionLabel', $value); + } + + public function getEncoding(): ?string + { + return $this->getParameter('encoding'); + } + + public function setEncoding(string $value): self + { + return $this->setParameter('encoding', $value); + } + + public function getMethodRefId(): ?string + { + return $this->getParameter('methodRefId'); + } + + public function setMethodRefId(string $value): self + { + return $this->setParameter('methodRefId', $value); + } + public function getData() { $this->validate( @@ -57,21 +187,38 @@ public function getData() 'currency' => $this->getCurrency(), 'description' => $this->getDescription(), 'email' => $this->getEmail(), + 'client' => $this->getName(), + 'address' => $this->getAddress(), + 'zip' => $this->getPostcode(), + 'city' => $this->getCity(), 'country' => $this->getCountry(), + 'phone' => $this->getPhone(), 'language' => $this->getLanguage(), + 'method' => $this->getPaymentMethod() ? (int) $this->getPaymentMethod() : null, 'urlReturn' => $this->getReturnUrl(), 'urlStatus' => $this->getNotifyUrl(), + 'urlCardPaymentNotification' => $this->getCardNotifyUrl(), + 'timeLimit' => $this->getTimeLimit(), + 'channel' => $this->getChannel(), + 'waitForResult' => $this->getWaitForResult(), + 'regulationAccept' => $this->getRegulationAccept(), + 'shipping' => $this->getShipping() ? $this->internalAmountValue($this->getShipping()) : null, + 'transferLabel' => $this->getTransactionLabel(), + 'encoding' => $this->getEncoding(), + 'methodRefId' => $this->getMethodRefId(), + // alias for credit card + // TODO + // 'cart' => ??? + // 'additional' => ??? 'sign' => $this->generateSignature(), ]; - if (null !== $this->getChannel()) { - $data['channel'] = $this->getChannel(); - } - - return $data; + return array_filter($data, function ($val) { + return ! is_null($val); + }); } - public function sendData($data) + public function sendData($data): PurchaseResponse { $httpResponse = $this->sendRequest('POST', 'transaction/register', $data); diff --git a/src/Message/PurchaseResponse.php b/src/Message/PurchaseResponse.php index 8cdf898..8236298 100644 --- a/src/Message/PurchaseResponse.php +++ b/src/Message/PurchaseResponse.php @@ -6,7 +6,7 @@ class PurchaseResponse extends AbstractResponse { - public function getToken() + public function getToken(): string { if (isset($this->data['data'])) { return trim($this->data['data']['token']); @@ -15,12 +15,12 @@ public function getToken() return ''; } - public function getRedirectUrl() + public function getRedirectUrl(): string { return $this->request->getRedirectEndpoint() . 'trnRequest/' . $this->getToken(); } - public function getRedirectMethod() + public function getRedirectMethod(): string { return 'GET'; } diff --git a/tests-api/GatewayTest.php b/tests-api/GatewayTest.php index 510bff9..60e236b 100644 --- a/tests-api/GatewayTest.php +++ b/tests-api/GatewayTest.php @@ -101,6 +101,37 @@ public function testComplete(): void VarDumper::dump($response->getMessage()); } + public function testPurchaseCard(): void + { + $sessionId = $this->randomString(); + + $request = $this->gateway->purchase([ + 'sessionId' => $sessionId, + 'amount' => '10.66', + 'currency' => 'PLN', + 'description' => 'Transaction description - card', + 'email' => 'franek@dolas.com', + 'name' => 'Franek Dolas', + 'country' => 'PL', + 'returnUrl' => 'https://omnipay-przelewy24v1.requestcatcher.com/return', + 'notifyUrl' => 'https://omnipay-przelewy24v1.requestcatcher.com/notify', + 'cardNotifyUrl' => 'https://omnipay-przelewy24v1.requestcatcher.com/notifyCard', + 'channel' => 218, + ]); + + $response = $request->send(); + + VarDumper::dump($sessionId); + VarDumper::dump($response->getRedirectUrl()); + VarDumper::dump($response->getMessage()); + + $this->assertSame(AbstractResponse::HTTP_OK, $response->getCode()); + $this->assertSame('', $response->getMessage()); + $this->assertTrue($response->isSuccessful()); + $this->assertContains('https://sandbox.przelewy24.pl/trnRequest/', $response->getRedirectUrl()); + $this->assertSame(35, strlen($response->getToken())); + } + private function randomString(int $length = 15): string { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; diff --git a/tests/GatewayTest.php b/tests/GatewayTest.php index 740b8f4..9a01417 100644 --- a/tests/GatewayTest.php +++ b/tests/GatewayTest.php @@ -111,7 +111,7 @@ public function it_should_set_and_get_language() } /** - * @test VarDumper::dump($data); + * @test */ public function it_should_create_a_test_access() { @@ -149,6 +149,15 @@ public function it_should_set_and_get_amount_on_purchase() $this->assertSame('10.00', $request->getAmount()); } + public function it_should_set_and_get_shipping_on_purchase() + { + $request = $this->gateway->purchase([ + 'amount' => '1000', + ]); + $request->setShipping('12.34'); + $this->assertSame('12.34', $request->getShipping()); + } + /** * @test */ diff --git a/tests/Message/PurchaseRequestTest.php b/tests/Message/PurchaseRequestTest.php index 04bd7ad..3a03952 100644 --- a/tests/Message/PurchaseRequestTest.php +++ b/tests/Message/PurchaseRequestTest.php @@ -89,10 +89,10 @@ public function testGetData($channel) $this->assertSame('15276e08cc84868619e1054ccf15d638337cae2bced6cb5a48bb799a3b52144692bce63408db85c84a6ca0461a999885', $data['sign']); if (null === $channel) { - $this->assertCount(12, $data); + $this->assertCount(11, $data); } else { $this->assertSame($channel, $data['channel']); - $this->assertCount(13, $data); + $this->assertCount(12, $data); } } From 7a03232add04010f82a7222e0ecfc8eff21aa825 Mon Sep 17 00:00:00 2001 From: Piotr Synowiec Date: Wed, 18 May 2022 10:48:34 +0200 Subject: [PATCH 2/2] [Transaction by session] (#8) * transaction-by-session-id: update README * transaction-by-session-id: endpoint method, request, response & api test * transaction-by-session-id: tests in progress * transaction-by-session-id: PurchaseInfoRequest success test * transaction-by-session-id: finished PurchaseInfoRequest tests --- README.md | 13 +-- src/Gateway.php | 11 +++ src/Message/AbstractResponse.php | 5 + src/Message/PurchaseInfoRequest.php | 36 +++++++ src/Message/PurchaseInfoResponse.php | 82 ++++++++++++++++ tests-api/GatewayTest.php | 20 ++++ tests/GatewayTest.php | 11 +++ tests/Message/PurchaseInfoRequestTest.php | 95 +++++++++++++++++++ tests/Mock/PurchaseInfoAuthFailure.txt | 12 +++ tests/Mock/PurchaseInfoInvalidDataFailure.txt | 12 +++ tests/Mock/PurchaseInfoNotFound.txt | 12 +++ tests/Mock/PurchaseInfoNotFoundFailure.txt | 12 +++ tests/Mock/PurchaseInfoSuccess.txt | 32 +++++++ 13 files changed, 347 insertions(+), 6 deletions(-) create mode 100644 src/Message/PurchaseInfoRequest.php create mode 100644 src/Message/PurchaseInfoResponse.php create mode 100644 tests/Message/PurchaseInfoRequestTest.php create mode 100644 tests/Mock/PurchaseInfoAuthFailure.txt create mode 100644 tests/Mock/PurchaseInfoInvalidDataFailure.txt create mode 100644 tests/Mock/PurchaseInfoNotFound.txt create mode 100644 tests/Mock/PurchaseInfoNotFoundFailure.txt create mode 100644 tests/Mock/PurchaseInfoSuccess.txt diff --git a/README.md b/README.md index 568126d..1eacba6 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,13 @@ ## 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 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/by/sessionId | purchaseInfo | ## Install diff --git a/src/Gateway.php b/src/Gateway.php index 9790153..ff22882 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -8,6 +8,7 @@ use Omnipay\Common\Message\AbstractRequest; use Omnipay\Przelewy24\Message\CompletePurchaseRequest; use Omnipay\Przelewy24\Message\MethodsRequest; +use Omnipay\Przelewy24\Message\PurchaseInfoRequest; use Omnipay\Przelewy24\Message\PurchaseRequest; use Omnipay\Przelewy24\Message\TestAccessRequest; @@ -140,4 +141,14 @@ public function completePurchase(array $options = []): CompletePurchaseRequest { return $this->createRequest(CompletePurchaseRequest::class, $options); } + + /** + * @return AbstractRequest|PurchaseInfoRequest + */ + public function purchaseInfo(string $sessionId): PurchaseInfoRequest + { + return $this->createRequest(PurchaseInfoRequest::class, [ + 'sessionId' => $sessionId, + ]); + } } diff --git a/src/Message/AbstractResponse.php b/src/Message/AbstractResponse.php index 70f9038..bf9a3c6 100644 --- a/src/Message/AbstractResponse.php +++ b/src/Message/AbstractResponse.php @@ -45,4 +45,9 @@ public function isSuccessful(): bool { return self::HTTP_OK === $this->getCode(); } + + protected function getAmountFromInternal(int $amount): string + { + return bcdiv((string) $amount, '100', 2); + } } diff --git a/src/Message/PurchaseInfoRequest.php b/src/Message/PurchaseInfoRequest.php new file mode 100644 index 0000000..900b7c3 --- /dev/null +++ b/src/Message/PurchaseInfoRequest.php @@ -0,0 +1,36 @@ +getParameter('sessionId'); + } + + public function setSessionId(string $value): self + { + return $this->setParameter('sessionId', $value); + } + + public function getData(): array + { + $this->validate('sessionId'); + + return [ + 'sessionId' => $this->getSessionId(), + ]; + } + + public function sendData($data) + { + $httpResponse = $this->sendRequest('GET', sprintf('transaction/by/sessionId/%s', $data['sessionId']), []); + + $responseData = json_decode($httpResponse->getBody()->getContents(), true); + + return $this->response = new PurchaseInfoResponse($this, $responseData); + } +} diff --git a/src/Message/PurchaseInfoResponse.php b/src/Message/PurchaseInfoResponse.php new file mode 100644 index 0000000..684525d --- /dev/null +++ b/src/Message/PurchaseInfoResponse.php @@ -0,0 +1,82 @@ +info = $this->formatInfo($data['data']); + } + } + + /** + * @return string[] + */ + public function getInfo(): array + { + return $this->info; + } + + public function getCode(): int + { + if (isset($this->data['responseCode']) && isset($this->data['error']) && strlen($this->data['error']) > 0) { + return Response::HTTP_NOT_FOUND; + } + + if (isset($this->data['code'])) { + return $this->data['code']; + } + + return self::HTTP_OK; + } + + /** + * @param string[] $data + * @return string[] + */ + private function formatInfo(array $data): array + { + $formatted = $data; + + // format + if (isset($formatted['amount'])) { + $formatted['amount'] = $this->getAmountFromInternal((int) $formatted['amount']); + } + + // replace keys + $formatted = $this->replaceInfoKeys($formatted, 'clientEmail', 'email'); + $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; + } + + /** + * @param string[] $data + * @return string[] + */ + private function replaceInfoKeys(array $data, string $oldKey, string $newKey): array + { + if (isset($data[$oldKey])) { + $data[$newKey] = $data[$oldKey]; + unset($data[$oldKey]); + } + + return $data; + } +} diff --git a/tests-api/GatewayTest.php b/tests-api/GatewayTest.php index 60e236b..a54030b 100644 --- a/tests-api/GatewayTest.php +++ b/tests-api/GatewayTest.php @@ -7,6 +7,7 @@ use Omnipay\Omnipay; use Omnipay\Przelewy24\Message\AbstractResponse; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\VarDumper\VarDumper; class GatewayTest extends TestCase @@ -99,6 +100,25 @@ public function testComplete(): void VarDumper::dump($response->getCode()); VarDumper::dump($response->getMessage()); + + $this->assertSame(Response::HTTP_OK, $response->getCode()); + $this->assertTrue($response->isSuccessful()); + } + + public function testPurchaseInfo(): void + { + $sessionId = '20c62d6b-5ff0-46a0-97eb-eea0dd5b4a93'; // real existing session + $response = $this->gateway->purchaseInfo($sessionId)->send(); + + VarDumper::dump($response->getCode()); + VarDumper::dump($response->getInfo()); + + $this->assertSame(Response::HTTP_OK, $response->getCode()); + $this->assertTrue($response->isSuccessful()); + $this->assertCount(18, $response->getInfo()); + + $response = $this->gateway->purchaseInfo('not-existing')->send(); + $this->assertSame(Response::HTTP_NOT_FOUND, $response->getCode()); } public function testPurchaseCard(): void diff --git a/tests/GatewayTest.php b/tests/GatewayTest.php index 9a01417..8426c04 100644 --- a/tests/GatewayTest.php +++ b/tests/GatewayTest.php @@ -5,6 +5,7 @@ use Omnipay\Przelewy24\Gateway; use Omnipay\Przelewy24\Message\CompletePurchaseRequest; use Omnipay\Przelewy24\Message\MethodsRequest; +use Omnipay\Przelewy24\Message\PurchaseInfoRequest; use Omnipay\Przelewy24\Message\PurchaseRequest; use Omnipay\Przelewy24\Message\TestAccessRequest; use Omnipay\Tests\GatewayTestCase; @@ -169,4 +170,14 @@ public function it_should_create_a_complete_purchase() $this->assertInstanceOf(CompletePurchaseRequest::class, $request); $this->assertSame('10.00', $request->getAmount()); } + + /** + * @test + */ + public function it_should_create_a_purchase_info() + { + $request = $this->gateway->purchaseInfo('session-id'); + $this->assertInstanceOf(PurchaseInfoRequest::class, $request); + $this->assertSame('session-id', $request->getSessionId()); + } } diff --git a/tests/Message/PurchaseInfoRequestTest.php b/tests/Message/PurchaseInfoRequestTest.php new file mode 100644 index 0000000..f009e58 --- /dev/null +++ b/tests/Message/PurchaseInfoRequestTest.php @@ -0,0 +1,95 @@ +request = new PurchaseInfoRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize([ + 'sessionId' => '1234567890', + ]); + } + + public function testGetData(): void + { + $data = $this->request->getData(); + + $this->assertSame('1234567890', $data['sessionId']); + } + + public function testSendSuccess() + { + $this->setMockHttpResponse('PurchaseInfoSuccess.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(PurchaseInfoResponse::class, $response); + $this->assertTrue($response->isSuccessful()); + $this->assertSame(Response::HTTP_OK, $response->getCode()); + $this->assertCount(18, $response->getInfo()); + + $this->assertSame(1234567890, $response->getInfo()['orderId']); + $this->assertSame('20c62d6b-5ff0-46a0-97eb-eea0dd5b4a93', $response->getInfo()['sessionId']); + $this->assertSame(1, $response->getInfo()['status']); + $this->assertSame('12.34', $response->getInfo()['amount']); + $this->assertSame('PLN', $response->getInfo()['currency']); + $this->assertSame('202205161730', $response->getInfo()['date']); + $this->assertSame('202205161730', $response->getInfo()['dateOfTransaction']); + $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('franek@dolas.com', $response->getInfo()['email']); + $this->assertSame('Franek Dolas', $response->getInfo()['name']); + $this->assertSame('Kościuszki 12', $response->getInfo()['address']); + $this->assertSame('Kraków', $response->getInfo()['city']); + $this->assertSame('30-611', $response->getInfo()['postcode']); + } + + public function testSendAuthFailure() + { + $this->setMockHttpResponse('PurchaseInfoAuthFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(PurchaseInfoResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getCode()); + $this->assertSame('Incorrect authentication', $response->getMessage()); + } + + public function testSendInvalidDataFailure() + { + $this->setMockHttpResponse('PurchaseInfoInvalidDataFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(PurchaseInfoResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertSame(Response::HTTP_BAD_REQUEST, $response->getCode()); + $this->assertSame('Invalid input data', $response->getMessage()); + } + + public function testSendNotFoundFailure() + { + $this->setMockHttpResponse('PurchaseInfoNotFoundFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf(PurchaseInfoResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertSame(Response::HTTP_NOT_FOUND, $response->getCode()); + $this->assertSame('Transaction not found', $response->getMessage()); + } +} diff --git a/tests/Mock/PurchaseInfoAuthFailure.txt b/tests/Mock/PurchaseInfoAuthFailure.txt new file mode 100644 index 0000000..dcd3fbf --- /dev/null +++ b/tests/Mock/PurchaseInfoAuthFailure.txt @@ -0,0 +1,12 @@ +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 + +{ + "error": "Incorrect authentication", + "code": 401 +} diff --git a/tests/Mock/PurchaseInfoInvalidDataFailure.txt b/tests/Mock/PurchaseInfoInvalidDataFailure.txt new file mode 100644 index 0000000..4383bc8 --- /dev/null +++ b/tests/Mock/PurchaseInfoInvalidDataFailure.txt @@ -0,0 +1,12 @@ +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 + +{ + "error": "Invalid input data", + "code": 400 +} diff --git a/tests/Mock/PurchaseInfoNotFound.txt b/tests/Mock/PurchaseInfoNotFound.txt new file mode 100644 index 0000000..32b458e --- /dev/null +++ b/tests/Mock/PurchaseInfoNotFound.txt @@ -0,0 +1,12 @@ +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 + +{ + "error": "Transaction not found", + "responseCode": 0 +} diff --git a/tests/Mock/PurchaseInfoNotFoundFailure.txt b/tests/Mock/PurchaseInfoNotFoundFailure.txt new file mode 100644 index 0000000..32b458e --- /dev/null +++ b/tests/Mock/PurchaseInfoNotFoundFailure.txt @@ -0,0 +1,12 @@ +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 + +{ + "error": "Transaction not found", + "responseCode": 0 +} diff --git a/tests/Mock/PurchaseInfoSuccess.txt b/tests/Mock/PurchaseInfoSuccess.txt new file mode 100644 index 0000000..9f21937 --- /dev/null +++ b/tests/Mock/PurchaseInfoSuccess.txt @@ -0,0 +1,32 @@ +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 + +{ + "error": "", + "data": { + "orderId": 1234567890, + "sessionId": "20c62d6b-5ff0-46a0-97eb-eea0dd5b4a93", + "status": 1, + "amount": "1234", + "currency": "PLN", + "date": "202205161730", + "dateOfTransaction": "202205161730", + "clientEmail": "franek@dolas.com", + "accountMD5": "", + "paymentMethod": 154, + "description": "transaction description", + "clientName": "Franek Dolas", + "clientAddress": "Kościuszki 12", + "clientCity": "Kraków", + "clientPostcode": "30-611", + "batchId": 0, + "fee": "12", + "statement": "P24-K12-B34-H56" + }, + "responseCode": 0 +}