From f4b5005b1d339131d7d1d00a0bf5c9066a322c16 Mon Sep 17 00:00:00 2001 From: Jakub Menzel Date: Wed, 11 Mar 2026 08:51:27 +0100 Subject: [PATCH 1/7] Terminal client - CloudPOS --- README.md | 38 +++++ src/ClientTerminal.php | 122 ++++++++++++++++ src/Comgate.php | 16 +++ src/Config.php | 1 + .../Codes/TerminalPaymentStatusCode.php | 20 +++ src/Entity/Codes/TerminalStatusCode.php | 21 +++ src/Entity/Request/TerminalClosingRequest.php | 19 +++ .../Request/TerminalPaymentCancelRequest.php | 40 ++++++ .../Request/TerminalPaymentCreateRequest.php | 33 +++++ .../Request/TerminalPaymentStatusRequest.php | 40 ++++++ .../Request/TerminalRefundCancelRequest.php | 40 ++++++ .../Request/TerminalRefundCreateRequest.php | 33 +++++ .../Request/TerminalRefundStatusRequest.php | 40 ++++++ src/Entity/Request/TerminalStatusRequest.php | 19 +++ .../Response/TerminalClosingResponse.php | 79 +++++++++++ .../TerminalPaymentCancelResponse.php | 53 +++++++ .../TerminalPaymentCreateResponse.php | 107 ++++++++++++++ .../TerminalPaymentStatusResponse.php | 130 ++++++++++++++++++ .../Response/TerminalRefundCancelResponse.php | 53 +++++++ .../Response/TerminalRefundCreateResponse.php | 60 ++++++++ .../Response/TerminalRefundStatusResponse.php | 102 ++++++++++++++ .../Response/TerminalStatusResponse.php | 49 +++++++ src/Entity/TerminalPayment.php | 69 ++++++++++ src/Entity/TerminalRefund.php | 69 ++++++++++ src/Http/ITransport.php | 16 +++ src/Http/Transport.php | 100 +++++++++++++- 26 files changed, 1368 insertions(+), 1 deletion(-) create mode 100644 src/ClientTerminal.php create mode 100644 src/Entity/Codes/TerminalPaymentStatusCode.php create mode 100644 src/Entity/Codes/TerminalStatusCode.php create mode 100644 src/Entity/Request/TerminalClosingRequest.php create mode 100644 src/Entity/Request/TerminalPaymentCancelRequest.php create mode 100644 src/Entity/Request/TerminalPaymentCreateRequest.php create mode 100644 src/Entity/Request/TerminalPaymentStatusRequest.php create mode 100644 src/Entity/Request/TerminalRefundCancelRequest.php create mode 100644 src/Entity/Request/TerminalRefundCreateRequest.php create mode 100644 src/Entity/Request/TerminalRefundStatusRequest.php create mode 100644 src/Entity/Request/TerminalStatusRequest.php create mode 100644 src/Entity/Response/TerminalClosingResponse.php create mode 100644 src/Entity/Response/TerminalPaymentCancelResponse.php create mode 100644 src/Entity/Response/TerminalPaymentCreateResponse.php create mode 100644 src/Entity/Response/TerminalPaymentStatusResponse.php create mode 100644 src/Entity/Response/TerminalRefundCancelResponse.php create mode 100644 src/Entity/Response/TerminalRefundCreateResponse.php create mode 100644 src/Entity/Response/TerminalRefundStatusResponse.php create mode 100644 src/Entity/Response/TerminalStatusResponse.php create mode 100644 src/Entity/TerminalPayment.php create mode 100644 src/Entity/TerminalRefund.php diff --git a/README.md b/README.md index 50ae0ff..36442a9 100644 --- a/README.md +++ b/README.md @@ -265,6 +265,44 @@ try{ ``` +### Create terminal CloudPOS payment +#### API Documentation +https://apidoc.comgate.cz/api/rest-terminal +```php +use Comgate\SDK\Comgate; +use Comgate\SDK\Entity\Codes\CurrencyCode; +use Comgate\SDK\Entity\Codes\RequestCode; +use Comgate\SDK\Entity\Money; +use Comgate\SDK\Entity\TerminalPayment; +use Comgate\SDK\Entity\TerminalRefund; +use Comgate\SDK\Exception\ApiException; + +$clientTerminal = Comgate::defaultsRest() + ->setMerchant('123456') // get on portal.comgate.cz + ->setSecret('foobarbaz') // get on portal.comgate.cz + ->createTerminalClient(); + +$terminalPayment = new TerminalPayment(); +$terminalPayment + ->setPrice(Money::ofInt(4)) + ->setCurr(CurrencyCode::CZK) + ->setRefId('123456'); + +try { + $createTerminalPaymentResponse = $clientTerminal->createPayment($terminalPayment); + if ($createTerminalPaymentResponse->getCode() === RequestCode::OK) { + + // save ID of terminal payment in your system + echo 'created terminal payment: ' . $createTerminalPaymentResponse->getTransId(); + + } else { + var_dump($createTerminalPaymentResponse->getMessage()); + } +} catch (ApiException $e) { + var_dump($e->getMessage()); +} +``` + ### Debugging #### Logging diff --git a/src/ClientTerminal.php b/src/ClientTerminal.php new file mode 100644 index 0000000..5b04f93 --- /dev/null +++ b/src/ClientTerminal.php @@ -0,0 +1,122 @@ +transport = $transport; + } + + /** + * Vytvoří novou platbu na terminálu + */ + public function createPayment(TerminalPayment $terminalPayment): TerminalPaymentCreateResponse + { + $request = new TerminalPaymentCreateRequest($terminalPayment); + $response = $this->transport->postJson($request->getUrn(), $request->toArray()); + return new TerminalPaymentCreateResponse($response); + } + + /** + * Zjistí stav platby na terminálu + */ + public function getPaymentStatus(string $transId): TerminalPaymentStatusResponse + { + $request = new TerminalPaymentStatusRequest($transId); + $response = $this->transport->get($this->replacePathParam($request->getUrn(), $transId)); + return new TerminalPaymentStatusResponse($response); + } + + /** + * Zruší platbu na terminálu + */ + public function cancelPayment(string $transId): TerminalPaymentCancelResponse + { + $request = new TerminalPaymentCancelRequest($transId); + $response = $this->transport->delete($this->replacePathParam($request->getUrn(), $transId)); + return new TerminalPaymentCancelResponse($response); + } + + /** + * Provede uzávěrku na terminálu + */ + public function createClosing(): TerminalClosingResponse + { + $request = new TerminalClosingRequest(); + $response = $this->transport->postJson($request->getUrn(), $request->toArray()); + return new TerminalClosingResponse($response); + } + + /** + * Vytvoří nový návrat (refund) na terminálu + */ + public function createRefund(TerminalRefund $terminalRefund): TerminalRefundCreateResponse + { + $request = new TerminalRefundCreateRequest($terminalRefund); + $response = $this->transport->postJson($request->getUrn(), $request->toArray()); + return new TerminalRefundCreateResponse($response); + } + + /** + * Zjistí stav návratu na terminálu + */ + public function getRefundStatus(string $transId): TerminalRefundStatusResponse + { + $request = new TerminalRefundStatusRequest($transId); + $response = $this->transport->get($this->replacePathParam($request->getUrn(), $transId)); + return new TerminalRefundStatusResponse($response); + } + + /** + * Zruší návrat na terminálu + */ + public function cancelRefund(string $transId): TerminalRefundCancelResponse + { + $request = new TerminalRefundCancelRequest($transId); + $response = $this->transport->delete($this->replacePathParam($request->getUrn(), $transId)); + return new TerminalRefundCancelResponse($response); + } + + /** + * Zjistí stav terminálu + */ + public function getTerminalStatus(): TerminalStatusResponse + { + $request = new TerminalStatusRequest(); + $response = $this->transport->get($request->getUrn()); + return new TerminalStatusResponse($response); + } + + /** + * Nahradí {transId} v URN skutečným transId + */ + private function replacePathParam(string $urn, string $transId): string + { + return str_replace('{transId}', $transId, $urn); + } +} diff --git a/src/Comgate.php b/src/Comgate.php index 035f660..8ef554b 100644 --- a/src/Comgate.php +++ b/src/Comgate.php @@ -36,6 +36,17 @@ public static function defaults(): self return $self; } + /** + * @return static + */ + public static function defaultsRest(): self + { + $self = new static(); + $self->url = Config::URL_REST; + + return $self; + } + /** * @return static */ @@ -81,6 +92,11 @@ public function createClient(): Client return new Client($this->createTransport()); } + public function createTerminalClient(): ClientTerminal + { + return new ClientTerminal($this->createTransport()); + } + protected function createConfig(): Config { return new Config($this->merchant, $this->secret, $this->url); diff --git a/src/Config.php b/src/Config.php index e42c31a..57ad3ac 100644 --- a/src/Config.php +++ b/src/Config.php @@ -5,6 +5,7 @@ class Config { public const URL = 'https://payments.comgate.cz/v1.0/'; + public const URL_REST = 'https://payments.comgate.cz/v2.0/'; /** @var string */ private $merchant; diff --git a/src/Entity/Codes/TerminalPaymentStatusCode.php b/src/Entity/Codes/TerminalPaymentStatusCode.php new file mode 100644 index 0000000..a9e36d1 --- /dev/null +++ b/src/Entity/Codes/TerminalPaymentStatusCode.php @@ -0,0 +1,20 @@ + + */ + public function toArray(): array + { + return []; + } +} diff --git a/src/Entity/Request/TerminalPaymentCancelRequest.php b/src/Entity/Request/TerminalPaymentCancelRequest.php new file mode 100644 index 0000000..43c724b --- /dev/null +++ b/src/Entity/Request/TerminalPaymentCancelRequest.php @@ -0,0 +1,40 @@ +transId = $transId; + } + + public function getUrn(): string + { + return 'terminalPayment/transId/{transId}.json'; + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'transId' => $this->transId, + ]; + } + + public function getTransId(): string + { + return $this->transId; + } + + public function setTransId(string $transId): self + { + $this->transId = $transId; + return $this; + } +} diff --git a/src/Entity/Request/TerminalPaymentCreateRequest.php b/src/Entity/Request/TerminalPaymentCreateRequest.php new file mode 100644 index 0000000..e1b79a4 --- /dev/null +++ b/src/Entity/Request/TerminalPaymentCreateRequest.php @@ -0,0 +1,33 @@ +terminalPayment = $terminalPayment; + } + + public function getUrn(): string + { + return 'terminalPayment.json'; + } + + /** + * @return array + */ + public function toArray(): array + { + return array_filter([ + 'price' => $this->terminalPayment->getPrice()->get(), + 'curr' => $this->terminalPayment->getCurr(), + 'refId' => $this->terminalPayment->getRefId(), + ], function ($v) { return $v !== null; }); + } +} diff --git a/src/Entity/Request/TerminalPaymentStatusRequest.php b/src/Entity/Request/TerminalPaymentStatusRequest.php new file mode 100644 index 0000000..cbb6240 --- /dev/null +++ b/src/Entity/Request/TerminalPaymentStatusRequest.php @@ -0,0 +1,40 @@ +transId = $transId; + } + + public function getUrn(): string + { + return 'terminalPayment/transId/{transId}.json'; + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'transId' => $this->transId, + ]; + } + + public function getTransId(): string + { + return $this->transId; + } + + public function setTransId(string $transId): self + { + $this->transId = $transId; + return $this; + } +} diff --git a/src/Entity/Request/TerminalRefundCancelRequest.php b/src/Entity/Request/TerminalRefundCancelRequest.php new file mode 100644 index 0000000..c2c5147 --- /dev/null +++ b/src/Entity/Request/TerminalRefundCancelRequest.php @@ -0,0 +1,40 @@ +transId = $transId; + } + + public function getUrn(): string + { + return 'terminalRefund/transId/{transId}.json'; + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'transId' => $this->transId, + ]; + } + + public function getTransId(): string + { + return $this->transId; + } + + public function setTransId(string $transId): self + { + $this->transId = $transId; + return $this; + } +} diff --git a/src/Entity/Request/TerminalRefundCreateRequest.php b/src/Entity/Request/TerminalRefundCreateRequest.php new file mode 100644 index 0000000..6f370b5 --- /dev/null +++ b/src/Entity/Request/TerminalRefundCreateRequest.php @@ -0,0 +1,33 @@ +terminalRefund = $terminalRefund; + } + + public function getUrn(): string + { + return 'terminalRefund.json'; + } + + /** + * @return array + */ + public function toArray(): array + { + return array_filter([ + 'price' => $this->terminalRefund->getPrice()->get(), + 'curr' => $this->terminalRefund->getCurr(), + 'refId' => $this->terminalRefund->getRefId(), + ], function ($v) { return $v !== null; }); + } +} diff --git a/src/Entity/Request/TerminalRefundStatusRequest.php b/src/Entity/Request/TerminalRefundStatusRequest.php new file mode 100644 index 0000000..af4ce1a --- /dev/null +++ b/src/Entity/Request/TerminalRefundStatusRequest.php @@ -0,0 +1,40 @@ +transId = $transId; + } + + public function getUrn(): string + { + return 'terminalRefund/transId/{transId}.json'; + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'transId' => $this->transId, + ]; + } + + public function getTransId(): string + { + return $this->transId; + } + + public function setTransId(string $transId): self + { + $this->transId = $transId; + return $this; + } +} diff --git a/src/Entity/Request/TerminalStatusRequest.php b/src/Entity/Request/TerminalStatusRequest.php new file mode 100644 index 0000000..0645b99 --- /dev/null +++ b/src/Entity/Request/TerminalStatusRequest.php @@ -0,0 +1,19 @@ + + */ + public function toArray(): array + { + return []; + } +} diff --git a/src/Entity/Response/TerminalClosingResponse.php b/src/Entity/Response/TerminalClosingResponse.php new file mode 100644 index 0000000..1d61163 --- /dev/null +++ b/src/Entity/Response/TerminalClosingResponse.php @@ -0,0 +1,79 @@ +> */ + protected $batchData = []; + + /** + * @param Response $response + * @throws ApiException + */ + public function __construct(Response $response) + { + $data = json_decode($response->getContent(), true); + + $code = (int) ($data['code'] ?? 1500); + $message = $data['message'] ?? ''; + + switch ($code) { + case 0: + $this->setCode($code) + ->setMessage($message) + ->setBatchNumber((int) ($data['batchNumber'] ?? 0)); + + if (isset($data['batchData']) && is_array($data['batchData'])) { + $this->setBatchData($data['batchData']); + } + break; + + default: + throw new ApiException($message, $code); + } + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'code' => $this->getCode(), + 'message' => $this->getMessage(), + 'batchNumber' => $this->getBatchNumber(), + 'batchData' => $this->getBatchData(), + ]; + } + + public function getCode(): int { return $this->code; } + public function setCode(int $code): self { $this->code = $code; return $this; } + public function getMessage(): string { return $this->message; } + public function setMessage(string $message): self { $this->message = $message; return $this; } + public function getBatchNumber(): int { return $this->batchNumber; } + public function setBatchNumber(int $batchNumber): self { $this->batchNumber = $batchNumber; return $this; } + + /** + * @return array> + */ + public function getBatchData(): array { return $this->batchData; } + + /** + * @param array> $batchData + * @return self + */ + public function setBatchData(array $batchData): self { $this->batchData = $batchData; return $this; } +} diff --git a/src/Entity/Response/TerminalPaymentCancelResponse.php b/src/Entity/Response/TerminalPaymentCancelResponse.php new file mode 100644 index 0000000..1607df6 --- /dev/null +++ b/src/Entity/Response/TerminalPaymentCancelResponse.php @@ -0,0 +1,53 @@ +getContent(), true); + + $code = (int) ($data['code'] ?? 1500); + $message = $data['message'] ?? ''; + + switch ($code) { + case 0: + $this->setCode($code) + ->setMessage($message); + break; + + default: + throw new ApiException($message, $code); + } + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'code' => $this->getCode(), + 'message' => $this->getMessage(), + ]; + } + + public function getCode(): int { return $this->code; } + public function setCode(int $code): self { $this->code = $code; return $this; } + public function getMessage(): string { return $this->message; } + public function setMessage(string $message): self { $this->message = $message; return $this; } +} diff --git a/src/Entity/Response/TerminalPaymentCreateResponse.php b/src/Entity/Response/TerminalPaymentCreateResponse.php new file mode 100644 index 0000000..87c1fe3 --- /dev/null +++ b/src/Entity/Response/TerminalPaymentCreateResponse.php @@ -0,0 +1,107 @@ +getContent(), true); + + $code = (int) ($data['code'] ?? 1500); + $message = $data['message'] ?? ''; + + switch ($code) { + case 0: + $this->setCode($code) + ->setMessage($message) + ->setTransId($data['transId'] ?? ''); + break; + + default: + throw new ApiException($message, $code); + } + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'code' => $this->getCode(), + 'message' => $this->getMessage(), + 'transId' => $this->getTransId(), + ]; + } + + /** + * @return int + */ + public function getCode(): int + { + return $this->code; + } + + /** + * @param int $code + * @return self + */ + public function setCode(int $code): self + { + $this->code = $code; + return $this; + } + + /** + * @return string + */ + public function getMessage(): string + { + return $this->message; + } + + /** + * @param string $message + * @return self + */ + public function setMessage(string $message): self + { + $this->message = $message; + return $this; + } + + /** + * @return string + */ + public function getTransId(): string + { + return $this->transId; + } + + /** + * @param string $transId + * @return self + */ + public function setTransId(string $transId): self + { + $this->transId = $transId; + return $this; + } +} diff --git a/src/Entity/Response/TerminalPaymentStatusResponse.php b/src/Entity/Response/TerminalPaymentStatusResponse.php new file mode 100644 index 0000000..e681966 --- /dev/null +++ b/src/Entity/Response/TerminalPaymentStatusResponse.php @@ -0,0 +1,130 @@ +getContent(), true); + + $code = (int) ($data['code'] ?? 1500); + $message = $data['message'] ?? ''; + + switch ($code) { + case 0: + $this->setCode($code) + ->setMessage($message) + ->setPrice((int) ($data['price'] ?? 0)) + ->setCurr($data['curr'] ?? '') + ->setRefId($data['refId'] ?? '') + ->setTransId($data['transId'] ?? '') + ->setStatus($data['status'] ?? '') + ->setFee($data['fee'] ?? '') + ->setCardValid($data['cardValid'] ?? '') + ->setCardNumber($data['cardNumber'] ?? '') + ->setPaymentErrorReason($data['paymentErrorReason'] ?? '') + ->setReversed((bool) ($data['reversed'] ?? false)) + ->setAmountRefunded($data['amountRefunded'] ?? ''); + break; + + default: + throw new ApiException($message, $code); + } + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'code' => $this->getCode(), + 'message' => $this->getMessage(), + 'price' => $this->getPrice(), + 'curr' => $this->getCurr(), + 'refId' => $this->getRefId(), + 'transId' => $this->getTransId(), + 'status' => $this->getStatus(), + 'fee' => $this->getFee(), + 'cardValid' => $this->getCardValid(), + 'cardNumber' => $this->getCardNumber(), + 'paymentErrorReason' => $this->getPaymentErrorReason(), + 'reversed' => $this->isReversed(), + 'amountRefunded' => $this->getAmountRefunded(), + ]; + } + + public function getCode(): int { return $this->code; } + public function setCode(int $code): self { $this->code = $code; return $this; } + public function getMessage(): string { return $this->message; } + public function setMessage(string $message): self { $this->message = $message; return $this; } + public function getPrice(): int { return $this->price; } + public function setPrice(int $price): self { $this->price = $price; return $this; } + public function getCurr(): string { return $this->curr; } + public function setCurr(string $curr): self { $this->curr = $curr; return $this; } + public function getRefId(): string { return $this->refId; } + public function setRefId(string $refId): self { $this->refId = $refId; return $this; } + public function getTransId(): string { return $this->transId; } + public function setTransId(string $transId): self { $this->transId = $transId; return $this; } + public function getStatus(): string { return $this->status; } + public function setStatus(string $status): self { $this->status = $status; return $this; } + public function getFee(): string { return $this->fee; } + public function setFee(string $fee): self { $this->fee = $fee; return $this; } + public function getCardValid(): string { return $this->cardValid; } + public function setCardValid(string $cardValid): self { $this->cardValid = $cardValid; return $this; } + public function getCardNumber(): string { return $this->cardNumber; } + public function setCardNumber(string $cardNumber): self { $this->cardNumber = $cardNumber; return $this; } + public function getPaymentErrorReason(): string { return $this->paymentErrorReason; } + public function setPaymentErrorReason(string $paymentErrorReason): self { $this->paymentErrorReason = $paymentErrorReason; return $this; } + public function isReversed(): bool { return $this->reversed; } + public function setReversed(bool $reversed): self { $this->reversed = $reversed; return $this; } + public function getAmountRefunded(): string { return $this->amountRefunded; } + public function setAmountRefunded(string $amountRefunded): self { $this->amountRefunded = $amountRefunded; return $this; } +} diff --git a/src/Entity/Response/TerminalRefundCancelResponse.php b/src/Entity/Response/TerminalRefundCancelResponse.php new file mode 100644 index 0000000..f5aecaf --- /dev/null +++ b/src/Entity/Response/TerminalRefundCancelResponse.php @@ -0,0 +1,53 @@ +getContent(), true); + + $code = (int) ($data['code'] ?? 1500); + $message = $data['message'] ?? ''; + + switch ($code) { + case 0: + $this->setCode($code) + ->setMessage($message); + break; + + default: + throw new ApiException($message, $code); + } + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'code' => $this->getCode(), + 'message' => $this->getMessage(), + ]; + } + + public function getCode(): int { return $this->code; } + public function setCode(int $code): self { $this->code = $code; return $this; } + public function getMessage(): string { return $this->message; } + public function setMessage(string $message): self { $this->message = $message; return $this; } +} diff --git a/src/Entity/Response/TerminalRefundCreateResponse.php b/src/Entity/Response/TerminalRefundCreateResponse.php new file mode 100644 index 0000000..60dc5f8 --- /dev/null +++ b/src/Entity/Response/TerminalRefundCreateResponse.php @@ -0,0 +1,60 @@ +getContent(), true); + + $code = (int) ($data['code'] ?? 1500); + $message = $data['message'] ?? ''; + + switch ($code) { + case 0: + $this->setCode($code) + ->setMessage($message) + ->setTransId($data['transId'] ?? ''); + break; + + default: + throw new ApiException($message, $code); + } + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'code' => $this->getCode(), + 'message' => $this->getMessage(), + 'transId' => $this->getTransId(), + ]; + } + + public function getCode(): int { return $this->code; } + public function setCode(int $code): self { $this->code = $code; return $this; } + public function getMessage(): string { return $this->message; } + public function setMessage(string $message): self { $this->message = $message; return $this; } + public function getTransId(): string { return $this->transId; } + public function setTransId(string $transId): self { $this->transId = $transId; return $this; } +} diff --git a/src/Entity/Response/TerminalRefundStatusResponse.php b/src/Entity/Response/TerminalRefundStatusResponse.php new file mode 100644 index 0000000..27d36f7 --- /dev/null +++ b/src/Entity/Response/TerminalRefundStatusResponse.php @@ -0,0 +1,102 @@ +getContent(), true); + + $code = (int) ($data['code'] ?? 1500); + $message = $data['message'] ?? ''; + + switch ($code) { + case 0: + $this->setCode($code) + ->setMessage($message) + ->setPrice((int) ($data['price'] ?? 0)) + ->setCurr($data['curr'] ?? '') + ->setRefId($data['refId'] ?? '') + ->setTransId($data['transId'] ?? '') + ->setStatus($data['status'] ?? '') + ->setCardNumber($data['cardNumber'] ?? '') + ->setReversed((bool) ($data['reversed'] ?? false)); + break; + + default: + throw new ApiException($message, $code); + } + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'code' => $this->getCode(), + 'message' => $this->getMessage(), + 'price' => $this->getPrice(), + 'curr' => $this->getCurr(), + 'refId' => $this->getRefId(), + 'transId' => $this->getTransId(), + 'status' => $this->getStatus(), + 'cardNumber' => $this->getCardNumber(), + 'reversed' => $this->isReversed(), + ]; + } + + public function getCode(): int { return $this->code; } + public function setCode(int $code): self { $this->code = $code; return $this; } + public function getMessage(): string { return $this->message; } + public function setMessage(string $message): self { $this->message = $message; return $this; } + public function getPrice(): int { return $this->price; } + public function setPrice(int $price): self { $this->price = $price; return $this; } + public function getCurr(): string { return $this->curr; } + public function setCurr(string $curr): self { $this->curr = $curr; return $this; } + public function getRefId(): string { return $this->refId; } + public function setRefId(string $refId): self { $this->refId = $refId; return $this; } + public function getTransId(): string { return $this->transId; } + public function setTransId(string $transId): self { $this->transId = $transId; return $this; } + public function getStatus(): string { return $this->status; } + public function setStatus(string $status): self { $this->status = $status; return $this; } + public function getCardNumber(): string { return $this->cardNumber; } + public function setCardNumber(string $cardNumber): self { $this->cardNumber = $cardNumber; return $this; } + public function isReversed(): bool { return $this->reversed; } + public function setReversed(bool $reversed): self { $this->reversed = $reversed; return $this; } +} diff --git a/src/Entity/Response/TerminalStatusResponse.php b/src/Entity/Response/TerminalStatusResponse.php new file mode 100644 index 0000000..5aa1d17 --- /dev/null +++ b/src/Entity/Response/TerminalStatusResponse.php @@ -0,0 +1,49 @@ +getContent(), true); + + $this->setStatus($data['status'] ?? 'UNKNOWN'); + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'status' => $this->getStatus(), + ]; + } + + /** + * @return string + */ + public function getStatus(): string + { + return $this->status; + } + + /** + * @param string $status + * @return self + */ + public function setStatus(string $status): self + { + $this->status = $status; + return $this; + } +} diff --git a/src/Entity/TerminalPayment.php b/src/Entity/TerminalPayment.php new file mode 100644 index 0000000..092cf5d --- /dev/null +++ b/src/Entity/TerminalPayment.php @@ -0,0 +1,69 @@ +price; + } + + /** + * @param int|float|Money $price + * @return self + */ + public function setPrice($price): self + { + $this->price = Money::of($price); + return $this; + } + + /** + * @return string + */ + public function getCurr(): string + { + return $this->curr; + } + + /** + * @param string $curr Kód měny dle ISO 4217 (CZK, EUR) + * @return self + */ + public function setCurr(string $curr): self + { + $this->curr = $curr; + return $this; + } + + /** + * @return string|null + */ + public function getRefId(): ?string + { + return $this->refId; + } + + /** + * @param string|null $refId Variabilní symbol nebo číslo objednávky na straně klienta + * @return self + */ + public function setRefId(?string $refId): self + { + $this->refId = $refId; + return $this; + } +} diff --git a/src/Entity/TerminalRefund.php b/src/Entity/TerminalRefund.php new file mode 100644 index 0000000..553d220 --- /dev/null +++ b/src/Entity/TerminalRefund.php @@ -0,0 +1,69 @@ +price; + } + + /** + * @param int|float|Money $price + * @return self + */ + public function setPrice($price): self + { + $this->price = Money::of($price); + return $this; + } + + /** + * @return string + */ + public function getCurr(): string + { + return $this->curr; + } + + /** + * @param string $curr Kód měny dle ISO 4217 (CZK, EUR) + * @return self + */ + public function setCurr(string $curr): self + { + $this->curr = $curr; + return $this; + } + + /** + * @return string|null + */ + public function getRefId(): ?string + { + return $this->refId; + } + + /** + * @param string|null $refId Variabilní symbol nebo číslo objednávky na straně klienta + * @return self + */ + public function setRefId(?string $refId): self + { + $this->refId = $refId; + return $this; + } +} diff --git a/src/Http/ITransport.php b/src/Http/ITransport.php index 5a05411..047e0d4 100644 --- a/src/Http/ITransport.php +++ b/src/Http/ITransport.php @@ -9,4 +9,20 @@ interface ITransport * @param mixed[] $options */ public function post(string $uri, array $data, array $options = []): Response; + + /** + * @param mixed[] $data + * @param mixed[] $options + */ + public function postJson(string $uri, array $data, array $options = []): Response; + + /** + * @param mixed[] $options + */ + public function get(string $uri, array $options = []): Response; + + /** + * @param mixed[] $options + */ + public function delete(string $uri, array $options = []): Response; } diff --git a/src/Http/Transport.php b/src/Http/Transport.php index 17da99e..edd9784 100644 --- a/src/Http/Transport.php +++ b/src/Http/Transport.php @@ -87,7 +87,105 @@ public function post(string $urn, array $data, array $options = []): Response throw new ComgateException("Request failed: {$e}", 0); } - return new Response(self::createResponse($response)); + return new Response($this->createResponse($response)); + } + + /** + * @param mixed[] $options + */ + public function get(string $urn, array $options = []): Response + { + return $this->makeRestRequest('GET', $urn, [], $options); + } + + /** + * @param mixed[] $data + * @param mixed[] $options + */ + public function postJson(string $urn, array $data, array $options = []): Response + { + return $this->makeRestRequest('POST', $urn, $data, $options); + } + + /** + * @param mixed[] $options + */ + public function delete(string $urn, array $options = []): Response + { + return $this->makeRestRequest('DELETE', $urn, [], $options); + } + + /** + * @param mixed[] $data + * @param mixed[] $options + */ + private function makeRestRequest(string $method, string $urn, array $data = [], array $options = []): Response + { + $curl = curl_init(); + + // Příprava URL s Basic Auth + $url = $this->config->getUrl() . $urn; + $auth = base64_encode($this->config->getMerchant() . ':' . $this->config->getSecret()); + + $headers = [ + 'Authorization: Basic ' . $auth, + 'Content-Type: application/json', + ]; + + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_HEADER, true); + + if ($method === 'POST' && !empty($data)) { + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); + } + + if (isset($_ENV['APPLICATION_ENV']) && $_ENV['APPLICATION_ENV'] === 'sdk-github') { + curl_setopt($curl, CURLOPT_HTTPHEADER, array_merge($headers, [ + 'CF-Access-Client-Id: ' . $_ENV['CF_ACCESS_CLIENT_ID'], + 'CF-Access-Client-Secret: ' . $_ENV['CF_ACCESS_CLIENT_SECRET'], + ])); + } + + $response = curl_exec($curl); + $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + $e = curl_error($curl); + + if ($this->logger !== null) { + $this->logger->log(LogLevel::INFO, 'REST Request to "' . $url . '" sent'); + $this->logger->log(LogLevel::DEBUG, 'Response: ' . $response); + $this->logger->log(LogLevel::DEBUG, 'cURL info: ' . json_encode(curl_getinfo($curl))); + + switch (true){ + case ($response === false): + $log = [LogLevel::ERROR, 'cURL request failed: ' . $e]; + break; + case ($httpCode >= 500): + $log = [LogLevel::CRITICAL, 'Server error: HTTP code ' . $httpCode]; + break; + case ($httpCode >= 400): + $log = [LogLevel::ERROR, 'Client error: HTTP code ' . $httpCode]; + break; + default: + $log = [LogLevel::INFO, 'cURL request completed successfully.']; + break; + } + $this->logger->log(...$log); + } + + // PHP 8.5+ automatically closes the handle + // for lower versions we need to close it manually + if(PHP_VERSION_ID < 80500){ + curl_close($curl); + }; + + if ($e != '') { + throw new ComgateException("Request failed: {$e}", 0); + } + + return new Response($this->createResponse($response)); } /** From e1f77f2cfef0796db3f12327e2ef6dd88628d2d1 Mon Sep 17 00:00:00 2001 From: Jakub Menzel Date: Wed, 11 Mar 2026 09:00:01 +0100 Subject: [PATCH 2/7] Terminal client - CloudPOS --- src/Entity/Request/TerminalClosingRequest.php | 2 +- src/Entity/Request/TerminalStatusRequest.php | 2 +- src/Http/Transport.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Entity/Request/TerminalClosingRequest.php b/src/Entity/Request/TerminalClosingRequest.php index 8fa2e63..82983ff 100644 --- a/src/Entity/Request/TerminalClosingRequest.php +++ b/src/Entity/Request/TerminalClosingRequest.php @@ -10,7 +10,7 @@ public function getUrn(): string } /** - * @return array + * @return array */ public function toArray(): array { diff --git a/src/Entity/Request/TerminalStatusRequest.php b/src/Entity/Request/TerminalStatusRequest.php index 0645b99..bfd3757 100644 --- a/src/Entity/Request/TerminalStatusRequest.php +++ b/src/Entity/Request/TerminalStatusRequest.php @@ -10,7 +10,7 @@ public function getUrn(): string } /** - * @return array + * @return array */ public function toArray(): array { diff --git a/src/Http/Transport.php b/src/Http/Transport.php index edd9784..c6dc507 100644 --- a/src/Http/Transport.php +++ b/src/Http/Transport.php @@ -138,7 +138,7 @@ private function makeRestRequest(string $method, string $urn, array $data = [], curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); - if ($method === 'POST' && !empty($data)) { + if ($method === 'POST' && count($data) != 0) { curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); } From 73d3caf6dd3eef7ac708510005c45ad451ab6ee3 Mon Sep 17 00:00:00 2001 From: Jakub Menzel Date: Tue, 24 Mar 2026 13:12:41 +0100 Subject: [PATCH 3/7] Comgate REST (protokol v2.0) --- README.md | 2 +- src/Client.php | 44 ++++++++----------- src/Comgate.php | 11 ----- src/Config.php | 4 +- src/Entity/Request/AboDownloadRequest.php | 10 ++++- .../Request/AboSingleTransferRequest.php | 8 +++- .../Request/AppleDomainAssociationRequest.php | 10 ++++- src/Entity/Request/CsvDownloadRequest.php | 4 +- .../Request/CsvSingleTransferRequest.php | 4 +- src/Entity/Request/MethodsRequest.php | 19 ++++++-- .../Request/MotoPaymentCreateRequest.php | 2 +- src/Entity/Request/PaymentCancelRequest.php | 2 +- src/Entity/Request/PaymentCreateRequest.php | 2 +- src/Entity/Request/PaymentRefundRequest.php | 2 +- src/Entity/Request/PaymentStatusRequest.php | 2 +- src/Entity/Request/PreauthCancelRequest.php | 2 +- src/Entity/Request/PreauthCaptureRequest.php | 8 +--- src/Entity/Request/PublicCryptoKeyRequest.php | 2 +- .../Request/RecurringPaymentRequest.php | 2 +- src/Entity/Request/SimulationRequest.php | 2 +- src/Entity/Request/SingleTransferRequest.php | 4 +- src/Entity/Request/TransferListRequest.php | 4 +- .../AppleDomainAssociationResponse.php | 3 +- .../Response/MotoPaymentCreateResponse.php | 3 +- src/Entity/Response/PaymentCancelResponse.php | 3 +- src/Entity/Response/PaymentCreateResponse.php | 3 +- src/Entity/Response/PaymentStatusResponse.php | 25 +++++------ src/Entity/Response/PreauthCancelResponse.php | 3 +- .../Response/PreauthCaptureResponse.php | 3 +- .../Response/PublicCryptoKeyResponse.php | 3 +- .../Response/RecurringPaymentResponse.php | 3 +- src/Entity/Response/RefundResponse.php | 3 +- src/Entity/Response/SimulationResponse.php | 3 +- src/Http/ITransport.php | 6 +++ src/Http/Transport.php | 11 ++++- 35 files changed, 122 insertions(+), 100 deletions(-) diff --git a/README.md b/README.md index 36442a9..764f349 100644 --- a/README.md +++ b/README.md @@ -277,7 +277,7 @@ use Comgate\SDK\Entity\TerminalPayment; use Comgate\SDK\Entity\TerminalRefund; use Comgate\SDK\Exception\ApiException; -$clientTerminal = Comgate::defaultsRest() +$clientTerminal = Comgate::defaults() ->setMerchant('123456') // get on portal.comgate.cz ->setSecret('foobarbaz') // get on portal.comgate.cz ->createTerminalClient(); diff --git a/src/Client.php b/src/Client.php index 2e0c89f..d6628e1 100644 --- a/src/Client.php +++ b/src/Client.php @@ -62,7 +62,7 @@ public function __construct(ITransport $transport) public function createPayment(Payment $payment): PaymentCreateResponse { $paymentCreateRequest = new PaymentCreateRequest($payment); - $paymentCreateResponse = $this->transport->post($paymentCreateRequest->getUrn(), + $paymentCreateResponse = $this->transport->postJson($paymentCreateRequest->getUrn(), $paymentCreateRequest->toArray()); return new PaymentCreateResponse($paymentCreateResponse); } @@ -70,7 +70,7 @@ public function createPayment(Payment $payment): PaymentCreateResponse public function getStatus(string $transId): PaymentStatusResponse { $paymentStatusRequest = new PaymentStatusRequest($transId); - $statusResponse = $this->transport->post($paymentStatusRequest->getUrn(), $paymentStatusRequest->toArray()); + $statusResponse = $this->transport->get($paymentStatusRequest->getUrn()); return new PaymentStatusResponse($statusResponse); } @@ -80,7 +80,7 @@ public function getMethods(?MethodsRequest $methodsRequest = null): MethodsRespo $methodsRequest = new MethodsRequest(); } - $methodsResponse = $this->transport->post($methodsRequest->getUrn(), $methodsRequest->toArray()); + $methodsResponse = $this->transport->get($methodsRequest->getUrn()); return new MethodsResponse($methodsResponse); } @@ -88,37 +88,35 @@ public function getMethods(?MethodsRequest $methodsRequest = null): MethodsRespo public function cancelPayment(string $transId): PaymentCancelResponse { $cancelPaymentRequest = new PaymentCancelRequest($transId); - $cancelResponse = $this->transport->post($cancelPaymentRequest->getUrn(), $cancelPaymentRequest->toArray()); + $cancelResponse = $this->transport->delete($cancelPaymentRequest->getUrn()); return new PaymentCancelResponse($cancelResponse); } public function capturePreauth(string $transId, Money $amount): PreauthCaptureResponse { $capturePreauthRequest = new PreauthCaptureRequest($transId, $amount); - $captureResponse = $this->transport->post($capturePreauthRequest->getUrn(), $capturePreauthRequest->toArray()); + $captureResponse = $this->transport->putJson($capturePreauthRequest->getUrn(), $capturePreauthRequest->toArray()); return new PreauthCaptureResponse($captureResponse); } public function cancelPreauth(string $transId): PreauthCancelResponse { $cancelPreauthRequest = new PreauthCancelRequest($transId); - $cancelResponse = $this->transport->post($cancelPreauthRequest->getUrn(), $cancelPreauthRequest->toArray()); + $cancelResponse = $this->transport->delete($cancelPreauthRequest->getUrn()); return new PreauthCancelResponse($cancelResponse); } public function refundPayment(Refund $refund): RefundResponse { $refundRequest = new PaymentRefundRequest($refund); - $refundResponse = $this->transport->post($refundRequest->getUrn(), $refundRequest->toArray()); + $refundResponse = $this->transport->postJson($refundRequest->getUrn(), $refundRequest->toArray()); return new RefundResponse($refundResponse); } public function initRecurringPayment(Payment $payment): RecurringPaymentResponse { $recurringRequest = new RecurringPaymentRequest($payment); - echo $recurringRequest->getUrn(); - $recurringResponse = $this->transport->post($recurringRequest->getUrn(), $recurringRequest->toArray()); - echo $recurringResponse->getContent(); + $recurringResponse = $this->transport->postJson($recurringRequest->getUrn(), $recurringRequest->toArray()); return new RecurringPaymentResponse($recurringResponse); } @@ -130,7 +128,7 @@ public function initRecurringPayment(Payment $payment): RecurringPaymentResponse public function simulation(array $params): SimulationResponse { $simulationRequest = new SimulationRequest($params); - $simulationResponse = $this->transport->post($simulationRequest->getUrn(), $simulationRequest->toArray()); + $simulationResponse = $this->transport->postJson($simulationRequest->getUrn(), $simulationRequest->toArray()); return new SimulationResponse($simulationResponse); } @@ -143,52 +141,46 @@ public function simulation(array $params): SimulationResponse public function transferList(DateTimeInterface $date, bool $test): TransferListResponse { $transferListRequest = new TransferListRequest($date, $test); - $transferListResponse = $this->transport->post($transferListRequest->getUrn(), $transferListRequest->toArray()); + $transferListResponse = $this->transport->get($transferListRequest->getUrn()); return new TransferListResponse($transferListResponse); } public function singleTransfer(int $transferId, bool $test): SingleTransferResponse { $singleTransferRequest = new SingleTransferRequest($transferId, $test); - $singleTransferResponse = $this->transport->post($singleTransferRequest->getUrn(), - $singleTransferRequest->toArray()); + $singleTransferResponse = $this->transport->get($singleTransferRequest->getUrn()); return new SingleTransferResponse($singleTransferResponse); } public function csvSingleTransfer(string $transferId, bool $test): CsvSingleTransferResponse { $csvSingleTransferRequest = new CsvSingleTransferRequest($transferId, $test); - $csvSingleTransferResponse = $this->transport->post($csvSingleTransferRequest->getUrn(), - $csvSingleTransferRequest->toArray()); + $csvSingleTransferResponse = $this->transport->get($csvSingleTransferRequest->getUrn()); return new CsvSingleTransferResponse($csvSingleTransferResponse); } public function aboSingleTransfer(string $transferId, bool $test, string $type, string $encoding): AboSingleTransferResponse { $aboSingleTransferRequest = new AboSingleTransferRequest($transferId, $test, $type, $encoding); - $aboSingleTransferResponse = $this->transport->post($aboSingleTransferRequest->getUrn(), - $aboSingleTransferRequest->toArray()); + $aboSingleTransferResponse = $this->transport->get($aboSingleTransferRequest->getUrn()); return new AboSingleTransferResponse($aboSingleTransferResponse); } public function getAppleDomainAssociation(string $method = '', string $currency = ''): AppleDomainAssociationResponse{ $appleDomainAssociationRequest = new AppleDomainAssociationRequest($method, $currency); - $appleDomainAssociationResponse = $this->transport->post($appleDomainAssociationRequest->getUrn(), - $appleDomainAssociationRequest->toArray()); + $appleDomainAssociationResponse = $this->transport->get($appleDomainAssociationRequest->getUrn()); return new AppleDomainAssociationResponse($appleDomainAssociationResponse); } public function getCsvDownload(string $date, bool $test = false): void{ $csvDownloadRequest = new CsvDownloadRequest($date, $test); - $csvDownloadResponse = $this->transport->post($csvDownloadRequest->getUrn(), - $csvDownloadRequest->toArray()); + $csvDownloadResponse = $this->transport->get($csvDownloadRequest->getUrn()); new CsvDownloadResponse($csvDownloadResponse); } public function getAboDownload(string $date, string $type = '', bool $test = false, string $encoding = 'utf8'): void{ $aboDownloadRequest = new AboDownloadRequest($date, $type, $test, $encoding); - $aboDownloadResponse = $this->transport->post($aboDownloadRequest->getUrn(), - $aboDownloadRequest->toArray()); + $aboDownloadResponse = $this->transport->get($aboDownloadRequest->getUrn()); new AboDownloadResponse($aboDownloadResponse); } @@ -203,7 +195,7 @@ public function getAboDownload(string $date, string $type = '', bool $test = fa public function createMotoPayment(Payment $payment, PaymentCard $paymentCard): ?MotoPaymentCreateResponse { $publicCryptoKeyRequest = new PublicCryptoKeyRequest(); - $publicCryptoKeyResponse = new PublicCryptoKeyResponse($this->transport->post($publicCryptoKeyRequest->getUrn(), $publicCryptoKeyRequest->toArray())); + $publicCryptoKeyResponse = new PublicCryptoKeyResponse($this->transport->get($publicCryptoKeyRequest->getUrn())); $publicJkwKey = null; $jwkData = json_decode(base64_decode($publicCryptoKeyResponse->getKey(), true), true); @@ -237,7 +229,7 @@ public function createMotoPayment(Payment $payment, PaymentCard $paymentCard): ? } $motoPaymentCreateRequest = new MotoPaymentCreateRequest($motoPayment); - $motoPaymentCreateResponse = $this->transport->post($motoPaymentCreateRequest->getUrn(), $motoPaymentCreateRequest->toArray()); + $motoPaymentCreateResponse = $this->transport->postJson($motoPaymentCreateRequest->getUrn(), $motoPaymentCreateRequest->toArray()); return new MotoPaymentCreateResponse($motoPaymentCreateResponse); } diff --git a/src/Comgate.php b/src/Comgate.php index 8ef554b..d946dd4 100644 --- a/src/Comgate.php +++ b/src/Comgate.php @@ -36,17 +36,6 @@ public static function defaults(): self return $self; } - /** - * @return static - */ - public static function defaultsRest(): self - { - $self = new static(); - $self->url = Config::URL_REST; - - return $self; - } - /** * @return static */ diff --git a/src/Config.php b/src/Config.php index 57ad3ac..3bab14b 100644 --- a/src/Config.php +++ b/src/Config.php @@ -4,8 +4,8 @@ class Config { - public const URL = 'https://payments.comgate.cz/v1.0/'; - public const URL_REST = 'https://payments.comgate.cz/v2.0/'; + public const URL = 'https://payments.comgate.cz/v2.0/'; + /** @var string */ private $merchant; diff --git a/src/Entity/Request/AboDownloadRequest.php b/src/Entity/Request/AboDownloadRequest.php index f9d54ca..b73ba21 100644 --- a/src/Entity/Request/AboDownloadRequest.php +++ b/src/Entity/Request/AboDownloadRequest.php @@ -34,7 +34,15 @@ public function __construct(string $date, string $type, bool $test, string $enco */ public function getUrn(): string { - return 'aboDownload'; + $urn = 'aboDownload/date/' . urlencode($this->getDate()); + $params = [ + 'test' => $this->isTest() ? 'true' : 'false', + 'encoding' => $this->getEncoding(), + ]; + if ($this->getType() !== '') { + $params['type'] = $this->getType(); + } + return $urn . '?' . http_build_query($params); } /** diff --git a/src/Entity/Request/AboSingleTransferRequest.php b/src/Entity/Request/AboSingleTransferRequest.php index d0a9c3c..6894cde 100644 --- a/src/Entity/Request/AboSingleTransferRequest.php +++ b/src/Entity/Request/AboSingleTransferRequest.php @@ -44,7 +44,13 @@ public function __construct(string $transferId, bool $test, string $type, string */ public function getUrn(): string { - return 'aboSingleTransfer'; + $urn = 'aboSingleTransfer/transferId/' . urlencode($this->getTransferId()) . '.json'; + $params = [ + 'type' => $this->getType(), + 'encoding' => $this->getEncoding(), + 'test' => $this->isTest() ? 'true' : 'false', + ]; + return $urn . '?' . http_build_query($params); } /** diff --git a/src/Entity/Request/AppleDomainAssociationRequest.php b/src/Entity/Request/AppleDomainAssociationRequest.php index 4d4baca..513fcff 100644 --- a/src/Entity/Request/AppleDomainAssociationRequest.php +++ b/src/Entity/Request/AppleDomainAssociationRequest.php @@ -18,7 +18,15 @@ public function __construct(string $method, string $currency) public function getUrn(): string { - return 'appleDomainAssociation'; + $params = []; + if ($this->getCurrency() !== '') { + $params['currency'] = $this->getCurrency(); + } + $urn = 'appleDomainAssociation.json'; + if (!empty($params)) { + $urn .= '?' . http_build_query($params); + } + return $urn; } public function toArray(): array diff --git a/src/Entity/Request/CsvDownloadRequest.php b/src/Entity/Request/CsvDownloadRequest.php index d9b583e..e179316 100644 --- a/src/Entity/Request/CsvDownloadRequest.php +++ b/src/Entity/Request/CsvDownloadRequest.php @@ -25,7 +25,9 @@ public function __construct(string $date, bool $test) */ public function getUrn(): string { - return 'csvDownload'; + $urn = 'csvDownload/date/' . urlencode($this->getDate()); + $params = ['test' => $this->isTest() ? 'true' : 'false']; + return $urn . '?' . http_build_query($params); } /** diff --git a/src/Entity/Request/CsvSingleTransferRequest.php b/src/Entity/Request/CsvSingleTransferRequest.php index 70b9d25..2e1866c 100644 --- a/src/Entity/Request/CsvSingleTransferRequest.php +++ b/src/Entity/Request/CsvSingleTransferRequest.php @@ -26,7 +26,9 @@ public function __construct(string $transferId, bool $test) */ public function getUrn(): string { - return 'csvSingleTransfer'; + $urn = 'csvSingleTransfer/transferId/' . urlencode($this->getTransferId()) . '.json'; + $params = ['test' => $this->isTest() ? 'true' : 'false']; + return $urn . '?' . http_build_query($params); } /** diff --git a/src/Entity/Request/MethodsRequest.php b/src/Entity/Request/MethodsRequest.php index 93c3003..66692b6 100644 --- a/src/Entity/Request/MethodsRequest.php +++ b/src/Entity/Request/MethodsRequest.php @@ -61,7 +61,14 @@ class MethodsRequest implements IRequest public function getUrn(): string { - return 'methods'; + $params = $this->toArray(); + unset($params['type']); + + $urn = 'method.json'; + if (!empty($params)) { + $urn .= '?' . http_build_query($params); + } + return $urn; } /** @@ -198,12 +205,16 @@ public function getPrice(): ?string } /** - * @param string|null $price + * @param string|int|float|null $price * @return void */ - public function setPrice(?string $price): void + public function setPrice($price): void { - $this->price = $price; + if ($price === null) { + $this->price = null; + } else { + $this->price = (string) $price; + } } /** diff --git a/src/Entity/Request/MotoPaymentCreateRequest.php b/src/Entity/Request/MotoPaymentCreateRequest.php index 8bfaa29..107fb91 100644 --- a/src/Entity/Request/MotoPaymentCreateRequest.php +++ b/src/Entity/Request/MotoPaymentCreateRequest.php @@ -19,7 +19,7 @@ public function __construct(MotoPayment $payment) */ public function getUrn(): string { - return 'moto'; + return 'moto.json'; } /** diff --git a/src/Entity/Request/PaymentCancelRequest.php b/src/Entity/Request/PaymentCancelRequest.php index a012df1..959c0b0 100644 --- a/src/Entity/Request/PaymentCancelRequest.php +++ b/src/Entity/Request/PaymentCancelRequest.php @@ -20,7 +20,7 @@ public function __construct(string $transId) */ public function getUrn(): string { - return 'cancel'; + return 'payment/transId/' . urlencode($this->getTransId()) . '.json'; } /** diff --git a/src/Entity/Request/PaymentCreateRequest.php b/src/Entity/Request/PaymentCreateRequest.php index 89c2fdf..a5f7c3b 100644 --- a/src/Entity/Request/PaymentCreateRequest.php +++ b/src/Entity/Request/PaymentCreateRequest.php @@ -20,7 +20,7 @@ public function __construct(Payment $payment) */ public function getUrn(): string { - return 'create'; + return 'payment.json'; } /** diff --git a/src/Entity/Request/PaymentRefundRequest.php b/src/Entity/Request/PaymentRefundRequest.php index 2cec5a9..2da2874 100644 --- a/src/Entity/Request/PaymentRefundRequest.php +++ b/src/Entity/Request/PaymentRefundRequest.php @@ -23,7 +23,7 @@ public function __construct(Refund $refund) */ public function getUrn(): string { - return 'refund'; + return 'refund.json'; } /** diff --git a/src/Entity/Request/PaymentStatusRequest.php b/src/Entity/Request/PaymentStatusRequest.php index 68df928..5f160c0 100644 --- a/src/Entity/Request/PaymentStatusRequest.php +++ b/src/Entity/Request/PaymentStatusRequest.php @@ -20,7 +20,7 @@ public function __construct(string $transId) */ public function getUrn(): string { - return 'status'; + return 'payment/transId/' . urlencode($this->getTransId()) . '.json'; } /** diff --git a/src/Entity/Request/PreauthCancelRequest.php b/src/Entity/Request/PreauthCancelRequest.php index c78ef9d..d2e98ff 100644 --- a/src/Entity/Request/PreauthCancelRequest.php +++ b/src/Entity/Request/PreauthCancelRequest.php @@ -22,7 +22,7 @@ public function __construct(string $transId){ */ public function getUrn(): string { - return 'cancelPreauth'; + return 'preauth/transId/' . urlencode($this->getTransId()) . '.json'; } /** diff --git a/src/Entity/Request/PreauthCaptureRequest.php b/src/Entity/Request/PreauthCaptureRequest.php index fc38009..4f82a1e 100644 --- a/src/Entity/Request/PreauthCaptureRequest.php +++ b/src/Entity/Request/PreauthCaptureRequest.php @@ -27,7 +27,7 @@ public function __construct(string $transId, Money $amount){ */ public function getUrn(): string { - return 'capturePreauth'; + return 'preauth/transId/' . urlencode($this->getTransId()) . '.json'; } /** @@ -35,13 +35,9 @@ public function getUrn(): string */ public function toArray(): array { - // Required - $output = [ - 'transId' => $this->getTransId(), + return [ 'amount' => $this->getAmount()->get(), ]; - - return $output; } /** diff --git a/src/Entity/Request/PublicCryptoKeyRequest.php b/src/Entity/Request/PublicCryptoKeyRequest.php index ab52fea..5f6367e 100644 --- a/src/Entity/Request/PublicCryptoKeyRequest.php +++ b/src/Entity/Request/PublicCryptoKeyRequest.php @@ -11,7 +11,7 @@ class PublicCryptoKeyRequest implements IRequest */ public function getUrn(): string { - return 'pubCryptoKey'; + return 'pubCryptoKey.json'; } /** diff --git a/src/Entity/Request/RecurringPaymentRequest.php b/src/Entity/Request/RecurringPaymentRequest.php index f711571..ddb27ec 100644 --- a/src/Entity/Request/RecurringPaymentRequest.php +++ b/src/Entity/Request/RecurringPaymentRequest.php @@ -22,7 +22,7 @@ public function __construct(Payment $payment){ */ public function getUrn(): string { - return 'recurring'; + return 'recurring.json'; } /** diff --git a/src/Entity/Request/SimulationRequest.php b/src/Entity/Request/SimulationRequest.php index cad76c2..ca83691 100644 --- a/src/Entity/Request/SimulationRequest.php +++ b/src/Entity/Request/SimulationRequest.php @@ -22,7 +22,7 @@ public function __construct(array $params) public function getUrn(): string { - return 'simulation'; + return 'simulation.json'; } /** diff --git a/src/Entity/Request/SingleTransferRequest.php b/src/Entity/Request/SingleTransferRequest.php index cec8b1c..76ebbcf 100644 --- a/src/Entity/Request/SingleTransferRequest.php +++ b/src/Entity/Request/SingleTransferRequest.php @@ -24,7 +24,9 @@ public function __construct(int $transferId, bool $test = false) */ public function getUrn(): string { - return 'singleTransfer'; + $urn = 'singleTransfer/transferId/' . $this->getTransferId() . '.json'; + $params = ['test' => $this->isTest() ? 'true' : 'false']; + return $urn . '?' . http_build_query($params); } /** diff --git a/src/Entity/Request/TransferListRequest.php b/src/Entity/Request/TransferListRequest.php index 5a83649..9196eca 100644 --- a/src/Entity/Request/TransferListRequest.php +++ b/src/Entity/Request/TransferListRequest.php @@ -28,7 +28,9 @@ public function __construct(DateTimeInterface $date, bool $test = false) */ public function getUrn(): string { - return 'transferList'; + $urn = 'transferList/date/' . urlencode($this->getDate()->format(self::DATE_FORMAT)) . '.json'; + $params = ['test' => $this->isTest() ? 'true' : 'false']; + return $urn . '?' . http_build_query($params); } /** diff --git a/src/Entity/Response/AppleDomainAssociationResponse.php b/src/Entity/Response/AppleDomainAssociationResponse.php index f99fa7b..f9984bc 100644 --- a/src/Entity/Response/AppleDomainAssociationResponse.php +++ b/src/Entity/Response/AppleDomainAssociationResponse.php @@ -4,7 +4,6 @@ use Comgate\SDK\Exception\Api\MissingParamException; use Comgate\SDK\Exception\ApiException; -use Comgate\SDK\Http\Query; use Comgate\SDK\Http\Response; class AppleDomainAssociationResponse @@ -16,7 +15,7 @@ class AppleDomainAssociationResponse */ public function __construct(Response $appleDomainAssociationResponse) { - $parsedResponse = Query::parse($appleDomainAssociationResponse->getContent()); + $parsedResponse = json_decode($appleDomainAssociationResponse->getContent(), true); if (isset($parsedResponse['code']) && isset($parsedResponse['message'])) { $code = (int) $parsedResponse['code']; diff --git a/src/Entity/Response/MotoPaymentCreateResponse.php b/src/Entity/Response/MotoPaymentCreateResponse.php index c2126ea..e8c9957 100644 --- a/src/Entity/Response/MotoPaymentCreateResponse.php +++ b/src/Entity/Response/MotoPaymentCreateResponse.php @@ -5,7 +5,6 @@ use Comgate\SDK\Exception\Api\MissingParamException; use Comgate\SDK\Exception\ApiException; use Comgate\SDK\Http\Response; -use Comgate\SDK\Http\Query; class MotoPaymentCreateResponse { @@ -34,7 +33,7 @@ class MotoPaymentCreateResponse */ public function __construct(Response $motoPaymentsCreateResponse) { - $parsedResponse = Query::parse($motoPaymentsCreateResponse->getContent()); + $parsedResponse = json_decode($motoPaymentsCreateResponse->getContent(), true); $code = (int) $parsedResponse['code']; $message = $parsedResponse['message']; diff --git a/src/Entity/Response/PaymentCancelResponse.php b/src/Entity/Response/PaymentCancelResponse.php index d3f38a5..4c04bde 100644 --- a/src/Entity/Response/PaymentCancelResponse.php +++ b/src/Entity/Response/PaymentCancelResponse.php @@ -5,7 +5,6 @@ use Comgate\SDK\Exception\Api\MissingParamException; use Comgate\SDK\Exception\ApiException; use Comgate\SDK\Http\Response; -use Comgate\SDK\Http\Query; class PaymentCancelResponse { @@ -25,7 +24,7 @@ class PaymentCancelResponse */ public function __construct(Response $cancelPreauthResponse) { - $parsedResponse = Query::parse($cancelPreauthResponse->getContent()); + $parsedResponse = json_decode($cancelPreauthResponse->getContent(), true); $code = (int) $parsedResponse['code']; $message = $parsedResponse['message']; diff --git a/src/Entity/Response/PaymentCreateResponse.php b/src/Entity/Response/PaymentCreateResponse.php index 47ae148..d06b6ba 100644 --- a/src/Entity/Response/PaymentCreateResponse.php +++ b/src/Entity/Response/PaymentCreateResponse.php @@ -5,7 +5,6 @@ use Comgate\SDK\Exception\Api\MissingParamException; use Comgate\SDK\Exception\ApiException; use Comgate\SDK\Http\Response; -use Comgate\SDK\Http\Query; class PaymentCreateResponse { @@ -33,7 +32,7 @@ class PaymentCreateResponse */ public function __construct(Response $paymentsCreateResponse) { - $parsedResponse = Query::parse($paymentsCreateResponse->getContent()); + $parsedResponse = json_decode($paymentsCreateResponse->getContent(), true); $code = (int) $parsedResponse['code']; $message = $parsedResponse['message']; diff --git a/src/Entity/Response/PaymentStatusResponse.php b/src/Entity/Response/PaymentStatusResponse.php index 9269fce..b3024e3 100644 --- a/src/Entity/Response/PaymentStatusResponse.php +++ b/src/Entity/Response/PaymentStatusResponse.php @@ -6,7 +6,6 @@ use Comgate\SDK\Entity\Method; use Comgate\SDK\Entity\Money; use Comgate\SDK\Http\Response; -use Comgate\SDK\Http\Query; use Comgate\SDK\Exception\Api\PaymentNotFoundException; use Comgate\SDK\Exception\ApiException; @@ -123,7 +122,7 @@ class PaymentStatusResponse */ public function __construct(Response $paymentStatusResponse) { - $parsedResponse = Query::parse($paymentStatusResponse->getContent()); + $parsedResponse = json_decode($paymentStatusResponse->getContent(), true); $code = (int) $parsedResponse['code']; $message = $parsedResponse['message']; @@ -132,22 +131,22 @@ public function __construct(Response $paymentStatusResponse) case 0: $this->setCode($code) ->setMessage($message) - ->setMerchant($parsedResponse['merchant']) - ->setSecret($parsedResponse['secret']) + ->setMerchant($parsedResponse['merchant'] ?? '') + ->setSecret($parsedResponse['secret'] ?? '') ->setTransId($parsedResponse['transId']) - ->setTest($parsedResponse['test'] === 'true') - ->setPrice(Money::ofCents((int) $parsedResponse['price'])) - ->setCurrency($parsedResponse['curr']) - ->setLabel($parsedResponse['label']) - ->setRefId($parsedResponse['refId']) + ->setTest(($parsedResponse['test'] ?? 'false') === 'true') + ->setPrice(Money::ofCents((int) ($parsedResponse['price'] ?? 0))) + ->setCurrency($parsedResponse['curr'] ?? '') + ->setLabel($parsedResponse['label'] ?? '') + ->setRefId($parsedResponse['refId'] ?? '') ->setPayerId($parsedResponse['payerId'] ?? '') - ->setMethod($parsedResponse['method']) + ->setMethod($parsedResponse['method'] ?? '') ->setAccount($parsedResponse['account'] ?? '') ->setEmail($parsedResponse['email'] ?? '') - ->setName($parsedResponse['name']) + ->setName($parsedResponse['name'] ?? '') ->setPhone($parsedResponse['phone'] ?? '') - ->setStatus($parsedResponse['status']) - ->setPayerName($parsedResponse['payerName']) + ->setStatus($parsedResponse['status'] ?? '') + ->setPayerName($parsedResponse['payerName'] ?? '') ->setPayerAcc($parsedResponse['payerAcc'] ?? '') ->setFee($parsedResponse['fee'] ?? '') ->setVs($parsedResponse['vs'] ?? '') diff --git a/src/Entity/Response/PreauthCancelResponse.php b/src/Entity/Response/PreauthCancelResponse.php index 3935a99..739f56c 100644 --- a/src/Entity/Response/PreauthCancelResponse.php +++ b/src/Entity/Response/PreauthCancelResponse.php @@ -6,7 +6,6 @@ use Comgate\SDK\Exception\Api\PreauthException; use Comgate\SDK\Exception\ApiException; use Comgate\SDK\Http\Response; -use Comgate\SDK\Http\Query; class PreauthCancelResponse { @@ -27,7 +26,7 @@ class PreauthCancelResponse */ public function __construct(Response $cancelPreauthResponse) { - $parsedResponse = Query::parse($cancelPreauthResponse->getContent()); + $parsedResponse = json_decode($cancelPreauthResponse->getContent(), true); $code = (int) $parsedResponse['code']; $message = $parsedResponse['message']; diff --git a/src/Entity/Response/PreauthCaptureResponse.php b/src/Entity/Response/PreauthCaptureResponse.php index 0466cfa..00719e9 100644 --- a/src/Entity/Response/PreauthCaptureResponse.php +++ b/src/Entity/Response/PreauthCaptureResponse.php @@ -6,7 +6,6 @@ use Comgate\SDK\Exception\Api\PreauthException; use Comgate\SDK\Exception\ApiException; use Comgate\SDK\Http\Response; -use Comgate\SDK\Http\Query; class PreauthCaptureResponse { @@ -27,7 +26,7 @@ class PreauthCaptureResponse */ public function __construct(Response $capturePreauthResponse) { - $parsedResponse = Query::parse($capturePreauthResponse->getContent()); + $parsedResponse = json_decode($capturePreauthResponse->getContent(), true); $code = (int) $parsedResponse['code']; $message = $parsedResponse['message']; diff --git a/src/Entity/Response/PublicCryptoKeyResponse.php b/src/Entity/Response/PublicCryptoKeyResponse.php index 1d64269..001ae40 100644 --- a/src/Entity/Response/PublicCryptoKeyResponse.php +++ b/src/Entity/Response/PublicCryptoKeyResponse.php @@ -4,7 +4,6 @@ namespace Comgate\SDK\Entity\Response; use Comgate\SDK\Http\Response; -use Comgate\SDK\Http\Query; use Comgate\SDK\Exception\ApiException; class PublicCryptoKeyResponse @@ -27,7 +26,7 @@ class PublicCryptoKeyResponse */ public function __construct(Response $publicCryptoKeyResponse) { - $parsedResponse = Query::parse($publicCryptoKeyResponse->getContent()); + $parsedResponse = json_decode($publicCryptoKeyResponse->getContent(), true); $code = (int) $parsedResponse['code']; $message = $parsedResponse['message'] ?? ''; diff --git a/src/Entity/Response/RecurringPaymentResponse.php b/src/Entity/Response/RecurringPaymentResponse.php index dad4464..74f1c41 100644 --- a/src/Entity/Response/RecurringPaymentResponse.php +++ b/src/Entity/Response/RecurringPaymentResponse.php @@ -5,7 +5,6 @@ use Comgate\SDK\Exception\Api\MissingParamException; use Comgate\SDK\Exception\ApiException; use Comgate\SDK\Http\Response; -use Comgate\SDK\Http\Query; class RecurringPaymentResponse { @@ -29,7 +28,7 @@ class RecurringPaymentResponse */ public function __construct(Response $recurringPaymentResponse) { - $parsedResponse = Query::parse($recurringPaymentResponse->getContent()); + $parsedResponse = json_decode($recurringPaymentResponse->getContent(), true); $code = (int) $parsedResponse['code']; $message = $parsedResponse['message']; diff --git a/src/Entity/Response/RefundResponse.php b/src/Entity/Response/RefundResponse.php index d34f1fe..95e96a9 100644 --- a/src/Entity/Response/RefundResponse.php +++ b/src/Entity/Response/RefundResponse.php @@ -6,7 +6,6 @@ use Comgate\SDK\Exception\Api\PreauthException; use Comgate\SDK\Exception\ApiException; use Comgate\SDK\Http\Response; -use Comgate\SDK\Http\Query; class RefundResponse { @@ -26,7 +25,7 @@ class RefundResponse */ public function __construct(Response $refundResponse) { - $parsedResponse = Query::parse($refundResponse->getContent()); + $parsedResponse = json_decode($refundResponse->getContent(), true); $code = (int) $parsedResponse['code']; $message = $parsedResponse['message']; diff --git a/src/Entity/Response/SimulationResponse.php b/src/Entity/Response/SimulationResponse.php index 33b97fc..e5aa1e0 100644 --- a/src/Entity/Response/SimulationResponse.php +++ b/src/Entity/Response/SimulationResponse.php @@ -6,7 +6,6 @@ use Comgate\SDK\Exception\Api\PreauthException; use Comgate\SDK\Exception\ApiException; use Comgate\SDK\Http\Response; -use Comgate\SDK\Http\Query; class SimulationResponse { @@ -25,7 +24,7 @@ class SimulationResponse */ public function __construct(Response $simulationResponse) { - $parsedResponse = Query::parse($simulationResponse->getContent()); + $parsedResponse = json_decode($simulationResponse->getContent(), true); $code = (int) $parsedResponse['code']; $message = $parsedResponse['message']; diff --git a/src/Http/ITransport.php b/src/Http/ITransport.php index 047e0d4..cdde888 100644 --- a/src/Http/ITransport.php +++ b/src/Http/ITransport.php @@ -25,4 +25,10 @@ public function get(string $uri, array $options = []): Response; * @param mixed[] $options */ public function delete(string $uri, array $options = []): Response; + + /** + * @param mixed[] $data + * @param mixed[] $options + */ + public function putJson(string $uri, array $data, array $options = []): Response; } diff --git a/src/Http/Transport.php b/src/Http/Transport.php index c6dc507..f2ea022 100644 --- a/src/Http/Transport.php +++ b/src/Http/Transport.php @@ -115,6 +115,15 @@ public function delete(string $urn, array $options = []): Response return $this->makeRestRequest('DELETE', $urn, [], $options); } + /** + * @param mixed[] $data + * @param mixed[] $options + */ + public function putJson(string $urn, array $data, array $options = []): Response + { + return $this->makeRestRequest('PUT', $urn, $data, $options); + } + /** * @param mixed[] $data * @param mixed[] $options @@ -138,7 +147,7 @@ private function makeRestRequest(string $method, string $urn, array $data = [], curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); - if ($method === 'POST' && count($data) != 0) { + if (in_array($method, ['POST', 'PUT']) && count($data) != 0) { curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); } From fa3b5f17439cf5a5078908d7a2dd88ac871df559 Mon Sep 17 00:00:00 2001 From: Jakub Menzel Date: Tue, 24 Mar 2026 14:13:23 +0100 Subject: [PATCH 4/7] Comgate REST (protokol v2.0) --- src/Entity/Request/AppleDomainAssociationRequest.php | 2 +- src/Entity/Request/MethodsRequest.php | 2 +- src/Http/Transport.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Entity/Request/AppleDomainAssociationRequest.php b/src/Entity/Request/AppleDomainAssociationRequest.php index 513fcff..3af4180 100644 --- a/src/Entity/Request/AppleDomainAssociationRequest.php +++ b/src/Entity/Request/AppleDomainAssociationRequest.php @@ -23,7 +23,7 @@ public function getUrn(): string $params['currency'] = $this->getCurrency(); } $urn = 'appleDomainAssociation.json'; - if (!empty($params)) { + if (count($params) > 0) { $urn .= '?' . http_build_query($params); } return $urn; diff --git a/src/Entity/Request/MethodsRequest.php b/src/Entity/Request/MethodsRequest.php index 66692b6..71dad35 100644 --- a/src/Entity/Request/MethodsRequest.php +++ b/src/Entity/Request/MethodsRequest.php @@ -65,7 +65,7 @@ public function getUrn(): string unset($params['type']); $urn = 'method.json'; - if (!empty($params)) { + if (count($params) > 0) { $urn .= '?' . http_build_query($params); } return $urn; diff --git a/src/Http/Transport.php b/src/Http/Transport.php index f2ea022..08f15b4 100644 --- a/src/Http/Transport.php +++ b/src/Http/Transport.php @@ -147,7 +147,7 @@ private function makeRestRequest(string $method, string $urn, array $data = [], curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); - if (in_array($method, ['POST', 'PUT']) && count($data) != 0) { + if (in_array($method, ['POST', 'PUT'], true) && count($data) != 0) { curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); } From 507882aaf585a09401c7717b4509be42bcab51dd Mon Sep 17 00:00:00 2001 From: Jakub Menzel Date: Mon, 30 Mar 2026 11:34:48 +0200 Subject: [PATCH 5/7] Comgate REST (protokol v2.0) --- .env.example | 2 +- .github/workflows/tests.yml | 2 +- tests/Integration/ClientCest.php | 2 +- tests/Unit/Http/TransportCest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index c428f81..c1420e0 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ API_MERCHANT=112233 API_SECRET=foobarfoobaz -API_URL=https://payments.comgate.cz/v1.0/ +API_URL_REST=https://payments.comgate.cz/v2.0/ APPLICATION_ENV=dev diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4c5d731..7bfddd0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -75,7 +75,7 @@ jobs: run: | echo "API_MERCHANT=${{ secrets.API_MERCHANT }}" >> .env echo "API_SECRET=${{ secrets.API_SECRET }}" >> .env - echo "API_URL=${{ secrets.API_URL }}" >> .env + echo "API_URL_REST=${{ secrets.API_URL_REST }}" >> .env echo "APPLICATION_ENV='sdk-github'" >> .env echo "CF_ACCESS_CLIENT_ID=${{ secrets.CF_ACCESS_CLIENT_ID }}" >> .env echo "CF_ACCESS_CLIENT_SECRET=${{ secrets.CF_ACCESS_CLIENT_SECRET }}" >> .env diff --git a/tests/Integration/ClientCest.php b/tests/Integration/ClientCest.php index f746949..64ea1c0 100644 --- a/tests/Integration/ClientCest.php +++ b/tests/Integration/ClientCest.php @@ -509,7 +509,7 @@ private function getClient(): Client $client = Comgate::defaults() ->setMerchant($_ENV['API_MERCHANT']) ->setSecret($_ENV['API_SECRET']) - ->setUrl($_ENV['API_URL']) + ->setUrl($_ENV['API_URL_REST']) ->createClient(); return $client; } diff --git a/tests/Unit/Http/TransportCest.php b/tests/Unit/Http/TransportCest.php index b1ddc95..5e56737 100644 --- a/tests/Unit/Http/TransportCest.php +++ b/tests/Unit/Http/TransportCest.php @@ -16,7 +16,7 @@ public function testPostException(UnitTester $I) $client = Comgate::defaults() ->setMerchant($_ENV['API_MERCHANT']) ->setSecret($_ENV['API_SECRET']) - ->setUrl($_ENV['API_URL']) + ->setUrl($_ENV['API_URL_REST']) ->createClient(); $config = new Config('merchant', 'secret'); From 1d71d6c526524cb4227af7c8a628f0956f6a976f Mon Sep 17 00:00:00 2001 From: Jakub Menzel Date: Tue, 7 Apr 2026 10:24:55 +0200 Subject: [PATCH 6/7] trigger CI From 29bfa10d2cfd670013f59bd468a4b3f90c80ac36 Mon Sep 17 00:00:00 2001 From: Jakub Menzel Date: Tue, 7 Apr 2026 12:51:49 +0200 Subject: [PATCH 7/7] Comgate REST (protokol v2.0) --- src/Entity/Request/AboSingleTransferRequest.php | 3 ++- src/Entity/Request/AppleDomainAssociationRequest.php | 3 ++- src/Entity/Request/CsvSingleTransferRequest.php | 3 ++- src/Entity/Response/AppleDomainAssociationResponse.php | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Entity/Request/AboSingleTransferRequest.php b/src/Entity/Request/AboSingleTransferRequest.php index 6894cde..44abfab 100644 --- a/src/Entity/Request/AboSingleTransferRequest.php +++ b/src/Entity/Request/AboSingleTransferRequest.php @@ -29,7 +29,8 @@ class AboSingleTransferRequest implements IRequest * @var string */ protected $encoding; - private bool $download = false; // just for method sync Cest to pass, should be always false + /** @var bool */ + private $download = false; // just for method sync Cest to pass, should be always false public function __construct(string $transferId, bool $test, string $type, string $encoding) { diff --git a/src/Entity/Request/AppleDomainAssociationRequest.php b/src/Entity/Request/AppleDomainAssociationRequest.php index 3af4180..7e93b88 100644 --- a/src/Entity/Request/AppleDomainAssociationRequest.php +++ b/src/Entity/Request/AppleDomainAssociationRequest.php @@ -8,7 +8,8 @@ class AppleDomainAssociationRequest implements IRequest * @var string */ protected $method; - protected string $currency; + /** @var string */ + protected $currency; public function __construct(string $method, string $currency) { diff --git a/src/Entity/Request/CsvSingleTransferRequest.php b/src/Entity/Request/CsvSingleTransferRequest.php index 2e1866c..9528466 100644 --- a/src/Entity/Request/CsvSingleTransferRequest.php +++ b/src/Entity/Request/CsvSingleTransferRequest.php @@ -13,7 +13,8 @@ class CsvSingleTransferRequest implements IRequest * @var bool */ protected $test; - private bool $download = false; // just for method sync Cest to pass, should be always false + /** @var bool */ + private $download = false; // just for method sync Cest to pass, should be always false public function __construct(string $transferId, bool $test) { diff --git a/src/Entity/Response/AppleDomainAssociationResponse.php b/src/Entity/Response/AppleDomainAssociationResponse.php index f9984bc..10c28cf 100644 --- a/src/Entity/Response/AppleDomainAssociationResponse.php +++ b/src/Entity/Response/AppleDomainAssociationResponse.php @@ -8,7 +8,8 @@ class AppleDomainAssociationResponse { - protected string $fileContent; + /** @var string */ + protected $fileContent; /** * @param Response $appleDomainAssociationResponse * @throws ApiException