From 2eb0077a83fa6ad6b62c5bc98530da5461a28786 Mon Sep 17 00:00:00 2001 From: Petr Knap <8299754+petrknap@users.noreply.github.com> Date: Fri, 17 Jul 2026 15:16:06 +0200 Subject: [PATCH 1/2] 7029 - improved exceptions Part 1/2 - refactoring + 404 --- src/Exception/ApiException.php | 4 +- src/Exception/ApiServiceException.php | 14 ++ src/Exception/NotFoundApiServiceException.php | 9 ++ src/Service/ApiService.php | 133 ++--------------- src/Service/ApiServiceInterface.php | 135 ++++++++++++++---- src/Service/GateService.php | 5 + src/TheClient.php | 78 ++++++---- 7 files changed, 203 insertions(+), 175 deletions(-) create mode 100644 src/Exception/ApiServiceException.php create mode 100644 src/Exception/NotFoundApiServiceException.php diff --git a/src/Exception/ApiException.php b/src/Exception/ApiException.php index 9978d5f..4fa7d44 100644 --- a/src/Exception/ApiException.php +++ b/src/Exception/ApiException.php @@ -3,8 +3,8 @@ namespace ThePay\ApiClient\Exception; /** - * represents error on api side or network communication error + * Exception representing a server-side error or a network communication failure */ -class ApiException extends \Exception +class ApiException extends \Exception implements ApiServiceException { } diff --git a/src/Exception/ApiServiceException.php b/src/Exception/ApiServiceException.php new file mode 100644 index 0000000..42ec7a3 --- /dev/null +++ b/src/Exception/ApiServiceException.php @@ -0,0 +1,14 @@ +streamFactory = $streamFactory; } - /** - * Fetch all projects for merchant set in TheConfig - * - * @see https://thepay.docs.apiary.io/#reference/data-retrieval/project-info/get-projects - * - * @return array - */ public function getProjects(): array { $url = $this->config->getApiUrl() . 'projects?merchant_id=' . $this->config->getMerchantId(); @@ -103,15 +98,6 @@ public function getProjects(): array return $projects; } - /** - * Fetch all active payment methods. - * - * @see https://thepay.docs.apiary.io/#reference/data-retrieval/project-info/get-payment-methods - * - * @param LanguageCode|null $languageCode language for payment method titles, null value language from TheConfig used - * - * @throws ApiException - */ public function getActivePaymentMethods(?LanguageCode $languageCode = null): PaymentMethodCollection { $arguments = []; @@ -129,13 +115,6 @@ public function getActivePaymentMethods(?LanguageCode $languageCode = null): Pay return new PaymentMethodCollection($response->getBody()->getContents()); } - /** - * @see https://thepay.docs.apiary.io/#reference/data-retrieval/transactions/get-balance-history - * - * @param int|null $projectId - * - * @return array - */ public function getAccountsBalances(?StringValue $accountIban = null, $projectId = null, ?\DateTime $balanceAt = null) { $arguments = []; @@ -170,16 +149,6 @@ static function (array $accountBalance) { ); } - /** - * @see https://thepay.docs.apiary.io/#reference/data-retrieval/transactions/get-account-transaction-history - * - * @param int<1, max> $page - * @param int<1, 1000> $limit - * - * @return TransactionCollection - * - * @throws \Exception - */ public function getAccountTransactionHistory(TransactionFilter $filter, int $page = 1, int $limit = 100): TransactionCollection { $paginatedCollectionParams = new PaginatedCollectionParams($filter, $page, $limit); @@ -217,13 +186,6 @@ public function getAccountStatementGPC(TransactionFilter $filter, ?GPCPaymentIde return $response->getBody(); } - /** - * Get complete information about the specified payment. - * - * @see https://thepay.docs.apiary.io/#reference/data-retrieval/payments/get-payment-detail - * - * @throws ApiException - */ public function getPayment(Identifier $paymentUid): Payment { $url = $this->url(['payments', $paymentUid]); @@ -236,13 +198,6 @@ public function getPayment(Identifier $paymentUid): Payment return new Payment($response->getBody()->getContents()); } - /** - * Invalidates the specified payment. - * - * @see https://thepay.docs.apiary.io/#reference/payment-management/general-payment-management/invalidate-payment - * - * @throws ApiException - */ public function invalidatePayment(Identifier $paymentUid): void { $url = $this->url(['payments', $paymentUid, 'invalidate']); @@ -253,16 +208,6 @@ public function invalidatePayment(Identifier $paymentUid): void } } - /** - * Fetch information about payments by filter. - * - * @see https://thepay.docs.apiary.io/#reference/data-retrieval/payments/project-get-payments - * - * @param int<1, max> $page - * @param int<1, 1000> $limit - * - * @throws ApiException - */ public function getPayments(PaymentsFilter $filter, int $page = 1, int $limit = 25): PaymentCollection { $paginatedCollectionParams = new PaginatedCollectionParams($filter, $page, $limit); @@ -277,11 +222,6 @@ public function getPayments(PaymentsFilter $filter, int $page = 1, int $limit = return new PaymentCollection($response->getBody()->getContents(), $page, $limit, (int) $response->getHeaderLine('X-Total-Count')); } - /** - * @param Identifier $parentPaymentUid UID of payment which initialized this subscription. - * - * @throws ApiException - */ public function realizeRegularSubscriptionPayment(Identifier $parentPaymentUid, RealizeRegularSubscriptionPaymentParams $params): RecurringPaymentResult { $jsonParams = $params->toArray(); @@ -296,11 +236,6 @@ public function realizeRegularSubscriptionPayment(Identifier $parentPaymentUid, return new RecurringPaymentResult($response->getBody()->getContents()); } - /** - * @param Identifier $parentPaymentUid UID of payment which initialized this subscription. - * - * @throws ApiException - */ public function realizeIrregularSubscriptionPayment(Identifier $parentPaymentUid, RealizeIrregularSubscriptionPaymentParams $params): RecurringPaymentResult { $jsonParams = $params->toArray(); @@ -315,11 +250,6 @@ public function realizeIrregularSubscriptionPayment(Identifier $parentPaymentUid return new RecurringPaymentResult($response->getBody()->getContents()); } - /** - * @param Identifier $parentPaymentUid UID of payment which initialized this subscription. - * - * @throws ApiException - */ public function realizeUsageBasedSubscriptionPayment(Identifier $parentPaymentUid, RealizeUsageBasedSubscriptionPaymentParams $params): RecurringPaymentResult { $jsonParams = $params->toArray(); @@ -334,11 +264,6 @@ public function realizeUsageBasedSubscriptionPayment(Identifier $parentPaymentUi return new RecurringPaymentResult($response->getBody()->getContents()); } - /** - * @param Identifier $parentPaymentUid UID of first payment created with save_authorization=true. - * - * @throws ApiException - */ public function realizePaymentBySavedAuthorization(Identifier $parentPaymentUid, RealizePaymentBySavedAuthorizationParams $params): RecurringPaymentResult { $jsonParams = $params->toArray(); @@ -353,12 +278,6 @@ public function realizePaymentBySavedAuthorization(Identifier $parentPaymentUid, return new RecurringPaymentResult($response->getBody()->getContents()); } - - /** - * @param non-empty-string|null $methodCode - * - * @throws ApiException - */ public function createPayment(CreatePaymentParams $createPaymentParams, ?string $methodCode = null): CreatePaymentResponse { $jsonParams = $createPaymentParams->toArray(); @@ -376,11 +295,6 @@ public function createPayment(CreatePaymentParams $createPaymentParams, ?string return new CreatePaymentResponse($response->getBody()->getContents(), $response->getStatusCode() === 201); } - /** - * @param non-empty-string $methodCode - * - * @throws ApiException - */ public function changePaymentMethod(Identifier $uid, string $methodCode): void { $url = $this->url(['payments', $uid, 'method']); @@ -395,9 +309,6 @@ public function changePaymentMethod(Identifier $uid, string $methodCode): void } } - /** - * @throws ApiException - */ public function realizePreauthorizedPayment(RealizePreauthorizedPaymentParams $params): RealizePreauthorizedPaymentResult { $url = $this->url([ @@ -416,9 +327,6 @@ public function realizePreauthorizedPayment(RealizePreauthorizedPaymentParams $p return new RealizePreauthorizedPaymentResult($response->getBody()->getContents()); } - /** - * @throws ApiException - */ public function cancelPreauthorizedPayment(Identifier $uid): void { $url = $this->url(['payments', $uid, 'preauthorized']); @@ -429,9 +337,6 @@ public function cancelPreauthorizedPayment(Identifier $uid): void } } - /** - * Returns information about payment refund. - */ public function getPaymentRefund(Identifier $uid): PaymentRefundInfo { $url = $this->url(['payments', $uid->getValue(), 'refund']); @@ -450,11 +355,6 @@ public function getPaymentRefund(Identifier $uid): PaymentRefundInfo return new PaymentRefundInfo($responseData->available_amount, $responseData->currency, $refunds); } - /** - * Will create request for automatic refund of payment. - * - * @param Amount $amount amount which should be refunded in cents (currency used for refunding is same as payment currency) - */ public function createPaymentRefund(Identifier $uid, Amount $amount, string $reason): void { $url = $this->url(['payments', $uid->getValue(), 'refund']); @@ -472,11 +372,6 @@ public function createPaymentRefund(Identifier $uid, Amount $amount, string $rea } } - /** - * Returns an array of available payment methods with pay URLs for certain payment. - * - * @return array - */ public function getPaymentUrlsForPayment(Identifier $uid, ?LanguageCode $languageCode = null): array { $arguments = []; @@ -501,15 +396,6 @@ public function getPaymentUrlsForPayment(Identifier $uid, ?LanguageCode $languag return $paymentMethods; } - /** - * Method will generate PDF file as confirmation for paid payment - * - * @see https://thepay.docs.apiary.io/#reference/data-retrieval/payments/get-payment-confirmation - * - * @return string with binary content of PDF file - * - * @throws ApiException if payment is not paid yet - */ public function generatePaymentConfirmationPdf(Identifier $uid, ?LanguageCode $languageCode = null): string { $arguments = []; @@ -590,17 +476,22 @@ private function sendRequest(string $method, string $uri, ?array $jsonBody = nul return $this->httpClient->sendRequest($request); } - private function buildException(string $requestUrl, ResponseInterface $response): \Exception + private function buildException(string $requestUrl, ResponseInterface $response): ApiServiceException { $responseCode = $response->getStatusCode(); $message = 'TheApi call "' . $requestUrl . '" failed, status code: ' . $responseCode . ' ' . $response->getReasonPhrase(); $message .= $this->getErrorResponseMessage($response->getBody()->getContents()); - if ($responseCode == 0 || $responseCode >= 500) { - return new ApiException($message, $responseCode); + switch (true) { + case $responseCode == 404: + return new NotFoundApiServiceException($message, $responseCode); + case $responseCode >= 500: + case $responseCode == 0: // network communication failure + return new ApiException($message, $responseCode); + default: + return new class ($message, $responseCode) extends \RuntimeException implements ApiServiceException { + }; } - - return new \RuntimeException($message, $responseCode); } /** diff --git a/src/Service/ApiServiceInterface.php b/src/Service/ApiServiceInterface.php index 7ee8aef..4967bd2 100644 --- a/src/Service/ApiServiceInterface.php +++ b/src/Service/ApiServiceInterface.php @@ -3,7 +3,8 @@ namespace ThePay\ApiClient\Service; use Psr\Http\Message\StreamInterface; -use ThePay\ApiClient\Exception\ApiException; +use ThePay\ApiClient\Exception\ApiServiceException; +use ThePay\ApiClient\Exception\NotFoundApiServiceException; use ThePay\ApiClient\Filter\PaymentsFilter; use ThePay\ApiClient\Filter\TransactionFilter; use ThePay\ApiClient\Model\AccountBalance; @@ -32,140 +33,218 @@ interface ApiServiceInterface { /** - * Fetch all projects for merchant set in TheConfig + * Returns an array of project instances for your merchant account. + * + * @see https://docs.thepay.eu/#tag/Project-Info/paths/~1v1~1projects/get * * @return Project[] + * + * @throws ApiServiceException */ public function getProjects(); /** - * Fetch all active payment methods. + * Returns a list of all available payment methods for your project. + * + * @see https://docs.thepay.eu/#tag/Project-Info/paths/~1v1~1projects~1%7Bproject_id%7D~1methods/get * * @param LanguageCode|null $languageCode language for payment method titles, null value language from TheConfig used + * * @return PaymentMethodCollection - * @throws ApiException + * + * @throws ApiServiceException */ public function getActivePaymentMethods(?LanguageCode $languageCode = null); /** - * @param Identifier $paymentUid + * This resource represents one particular payment identified by its payment_uid. + * + * @see https://docs.thepay.eu/#tag/Payments/paths/~1v1~1projects~1%7Bproject_id%7D~1payments~1%7Bpayment_uid%7D/get + * * @return Payment - * @throws ApiException + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function getPayment(Identifier $paymentUid); /** - * @param Identifier $paymentUid + * This endpoint will invalidate a payment if it is in `waiting_for_payment` state. + * + * @see https://docs.thepay.eu/#tag/General-Payment-Management/paths/~1v1~1projects~1%7Bproject_id%7D~1payments~1%7Bpayment_uid%7D~1invalidate/put + * * @return void - * @throws ApiException + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function invalidatePayment(Identifier $paymentUid); /** + * This endpoint will realize new payment for the same subscription as its parent payment. + * + * @see https://docs.thepay.eu/#tag/Subscriptions/paths/~1v2~1projects~1%7Bproject_id%7D~1payments~1%7Bparent_payment_uid%7D~1subscription~1regular/post + * * @param Identifier $parentPaymentUid UID of payment which initialized this subscription. - * @param RealizeRegularSubscriptionPaymentParams $params - * @return RecurringPaymentResult - * @throws ApiException + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function realizeRegularSubscriptionPayment(Identifier $parentPaymentUid, RealizeRegularSubscriptionPaymentParams $params): RecurringPaymentResult; /** + * This endpoint will realize new payment for the same subscription as its parent payment. + * + * @see https://docs.thepay.eu/#tag/Subscriptions/paths/~1v2~1projects~1%7Bproject_id%7D~1payments~1%7Bparent_payment_uid%7D~1subscription~1irregular/post + * * @param Identifier $parentPaymentUid UID of payment which initialized this subscription. - * @param RealizeIrregularSubscriptionPaymentParams $params - * @return RecurringPaymentResult - * @throws ApiException + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function realizeIrregularSubscriptionPayment(Identifier $parentPaymentUid, RealizeIrregularSubscriptionPaymentParams $params): RecurringPaymentResult; /** + * This endpoint will realize new payment for the same subscription as its parent payment with changeable price for different amount of shipped products or provided services. + * + * @see https://docs.thepay.eu/#tag/Subscriptions/paths/~1v2~1projects~1%7Bproject_id%7D~1payments~1%7Bparent_payment_uid%7D~1subscription~1usagebased/post + * * @param Identifier $parentPaymentUid UID of payment which initialized this subscription. - * @param RealizeUsageBasedSubscriptionPaymentParams $params - * @return RecurringPaymentResult - * @throws ApiException + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function realizeUsageBasedSubscriptionPayment(Identifier $parentPaymentUid, RealizeUsageBasedSubscriptionPaymentParams $params): RecurringPaymentResult; /** + * This endpoint will realize a new payment by the same authorization which is saved in the parent payment. + * + * @see https://docs.thepay.eu/#tag/Saved-Card-Authorization/paths/~1v2~1projects~1%7Bproject_id%7D~1payments~1%7Bparent_payment_uid%7D~1savedauthorization/post + * * @param Identifier $parentPaymentUid UID of first payment created with save_authorization=true. - * @param RealizePaymentBySavedAuthorizationParams $params - * @return RecurringPaymentResult - * @throws ApiException + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function realizePaymentBySavedAuthorization(Identifier $parentPaymentUid, RealizePaymentBySavedAuthorizationParams $params): RecurringPaymentResult; /** + * Returns a list of payments belonging to a particular project. + * + * @see https://docs.thepay.eu/#tag/Payments/paths/~1v1~1projects~1%7Bproject_id%7D~1payments/get + * * @param int<1, max> $page * @param int<1, 1000> $limit + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function getPayments(PaymentsFilter $filter, int $page = 1, int $limit = 25): PaymentCollection; /** - * @see https://thepay.docs.apiary.io/#reference/data-retrieval/transactions/get-balance-history + * @see https://docs.thepay.eu/#tag/Transactions/paths/~1v1~1balances/get * * @param int|null $projectId * * @return array + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function getAccountsBalances(?StringValue $accountIban = null, $projectId = null, ?\DateTime $balanceAt = null); /** + * @see https://docs.thepay.eu/#tag/Transactions/paths/~1v1~1transactions~1%7Baccount_iban%7D~1/get + * * @param int<1, max> $page * @param int<1, 1000> $limit + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function getAccountTransactionHistory(TransactionFilter $filter, int $page = 1, int $limit = 100): TransactionCollection; + /** + * Returns an account statement for the specified account and time period in GPC format. + * + * @see https://docs.thepay.eu/#tag/Transactions/paths/~1v1~1transactions~1%7Baccount_iban%7D~1account_statement~1gpc/get + * + * @throws NotFoundApiServiceException|ApiServiceException + */ public function getAccountStatementGPC(TransactionFilter $filter, ?GPCPaymentIdentifier $paymentIdentifier = null): StreamInterface; /** + * Creates new payment instance and returns URL to the payment process and URL to the payment detail page. + * + * @see https://docs.thepay.eu/#tag/Payment-Creation/paths/~1v1~1projects~1%7Bproject_id%7D~1payments/post + * * @param non-empty-string|null $methodCode * - * @throws ApiException + * @throws ApiServiceException */ public function createPayment(CreatePaymentParams $createPaymentParams, ?string $methodCode = null): CreatePaymentResponse; /** - * @throws ApiException + * This endpoint will create request for realization of preauthorized payment. + * + * @see https://docs.thepay.eu/#tag/Preauthorized-Payments/paths/~1v2~1projects~1%7Bproject_id%7D~1payments~1%7Bpayment_uid%7D~1preauthorized/post + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function realizePreauthorizedPayment(RealizePreauthorizedPaymentParams $params): RealizePreauthorizedPaymentResult; + /** + * This endpoint will cancel preauthorized payment. + * + * @see https://docs.thepay.eu/#tag/Preauthorized-Payments/paths/~1v1~1projects~1%7Bproject_id%7D~1payments~1%7Bpayment_uid%7D~1preauthorized/delete + * + * @throws NotFoundApiServiceException|ApiServiceException + */ public function cancelPreauthorizedPayment(Identifier $uid): void; /** + * This endpoint will change the current payment method, with which the payment can be paid. + * + * @see https://docs.thepay.eu/#tag/General-Payment-Management/paths/~1v1~1projects~1%7Bproject_id%7D~1payments~1%7Bpayment_uid%7D~1method/put + * * @param non-empty-string $methodCode * - * @throws ApiException + * @throws NotFoundApiServiceException|ApiServiceException */ public function changePaymentMethod(Identifier $uid, string $methodCode): void; /** * Returns information about payment refund. * + * @see https://docs.thepay.eu/#tag/Refunds/paths/~1v1~1projects~1%7Bproject_id%7D~1payments~1%7Bpayment_uid%7D~1refund/get + * * @return PaymentRefundInfo + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function getPaymentRefund(Identifier $uid); /** - * Will create request for automatic refund of payment. + * This endpoint will create a request for automatic refund of a payment. + * + * @see https://docs.thepay.eu/#tag/Refunds/paths/~1v1~1projects~1%7Bproject_id%7D~1payments~1%7Bpayment_uid%7D~1refund/post * * @param Amount $amount amount which should be refunded in cents (currency used for refunding is same as payment currency) + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function createPaymentRefund(Identifier $uid, Amount $amount, string $reason): void; /** * Returns an array of available payment methods with pay URLs for certain payment. * + * @see https://docs.thepay.eu/#tag/General-Payment-Management/paths/~1v1~1projects~1%7Bproject_id%7D~1payments~1%7Bpayment_uid%7D~1payment_urls/get + * * @return array + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function getPaymentUrlsForPayment(Identifier $uid, ?LanguageCode $languageCode = null); /** - * Method will generate PDF file as confirmation for paid payment + * This endpoint will generate a PDF confirmation of paid payment specified by payment_uid. * - * @see https://thepay.docs.apiary.io/#reference/data-retrieval/payments/get-payment-confirmation + * @see https://docs.thepay.eu/#tag/Payments/paths/~1v1~1projects~1%7Bproject_id%7D~1payments~1%7Bpayment_uid%7D~1generate_confirmation/get * * @return string with binary content of PDF file * - * @throws ApiException if payment is not paid yet + * @throws NotFoundApiServiceException|ApiServiceException throws if payment is not paid yet */ public function generatePaymentConfirmationPdf(Identifier $uid, ?LanguageCode $languageCode = null): string; } diff --git a/src/Service/GateService.php b/src/Service/GateService.php index 04df458..e855ad7 100644 --- a/src/Service/GateService.php +++ b/src/Service/GateService.php @@ -2,6 +2,8 @@ namespace ThePay\ApiClient\Service; +use ThePay\ApiClient\Exception\ApiServiceException; +use ThePay\ApiClient\Exception\NotFoundApiServiceException; use ThePay\ApiClient\Model\IPaymentMethod; use ThePay\ApiClient\ValueObject\Identifier; use ThePay\ApiClient\ValueObject\LanguageCode; @@ -28,7 +30,10 @@ public function __construct(ApiServiceInterface $api) /** * @param Identifier $uid UID of payment + * * @return string HTML + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function getPaymentButtonsForPayment(Identifier $uid, ?LanguageCode $languageCode = null) { diff --git a/src/TheClient.php b/src/TheClient.php index ea42aa9..f1cd568 100644 --- a/src/TheClient.php +++ b/src/TheClient.php @@ -2,10 +2,10 @@ namespace ThePay\ApiClient; -use Exception; use InvalidArgumentException; use Psr\Http\Message\StreamInterface; -use ThePay\ApiClient\Exception\ApiException; +use ThePay\ApiClient\Exception\ApiServiceException; +use ThePay\ApiClient\Exception\NotFoundApiServiceException; use ThePay\ApiClient\Filter\PaymentMethodFilter; use ThePay\ApiClient\Filter\PaymentsFilter; use ThePay\ApiClient\Filter\TransactionFilter; @@ -60,10 +60,11 @@ public function __construct( /** * Fetch all projects for merchant set in TheConfig * - * @see https://thepay.docs.apiary.io/#reference/0/merchant-level-resources/get-projects + * @see ApiServiceInterface::getProjects() * * @return Project[] - * @throws ApiException + * + * @throws ApiServiceException */ public function getProjects() { @@ -71,12 +72,14 @@ public function getProjects() } /** - * @see https://thepay.docs.apiary.io/#reference/data-retrieval/transactions/get-balance-history + * @see ApiServiceInterface::getAccountsBalances() * * @param string|null $accountIban * @param int|null $projectId * * @return array + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function getAccountsBalances($accountIban = null, $projectId = null, ?\DateTime $balanceAt = null) { @@ -91,8 +94,10 @@ public function getAccountsBalances($accountIban = null, $projectId = null, ?\Da * @param TransactionFilter $filter * @param int $page * @param int $limit + * * @return Model\Collection\TransactionCollection - * @throws Exception + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function getAccountTransactionHistory(TransactionFilter $filter, $page = 1, $limit = 100) { @@ -102,11 +107,13 @@ public function getAccountTransactionHistory(TransactionFilter $filter, $page = } /** - * @see https://docs.thepay.cz/#tag/Transactions/paths/~1v1~1transactions~1%7Baccount_iban%7D~1account_statement~1gpc/get + * @see ApiServiceInterface::getAccountStatementGPC() * @see ../doc/download-account-transaction-GPC.md * * @return StreamInterface MUST return real PSR-7 network stream, make sure you have your PSR-18 HTTP client correctly configured, GPC format is not paginated! * @return StreamInterface content is windows-1250 encoded + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function getAccountStatementGPC(TransactionFilter $filter, ?GPCPaymentIdentifier $paymentIdentifier = null): StreamInterface { @@ -120,8 +127,10 @@ public function getAccountStatementGPC(TransactionFilter $filter, ?GPCPaymentIde * @param LanguageCode|null $languageCode language for payment method titles, null value language from TheConfig used * @param bool $isRecurring * @param bool $isDeposit + * * @return PaymentMethodCollection - * @throws ApiException + * + * @throws ApiServiceException */ public function getActivePaymentMethods(?PaymentMethodFilter $filter = null, ?LanguageCode $languageCode = null, $isRecurring = false, $isDeposit = true) { @@ -138,8 +147,10 @@ public function getActivePaymentMethods(?PaymentMethodFilter $filter = null, ?La /** * @param string $paymentUid + * * @return Model\Payment - * @throws ApiException|InvalidArgumentException + * + * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException */ public function getPayment($paymentUid) { @@ -151,8 +162,10 @@ public function getPayment($paymentUid) /** * @param string $paymentUid + * * @return void - * @throws ApiException|InvalidArgumentException + * + * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException */ public function invalidatePayment($paymentUid) { @@ -164,7 +177,7 @@ public function invalidatePayment($paymentUid) * @param string $parentPaymentUid UID of payment which initialized this subscription. * @param RealizeRegularSubscriptionPaymentParams $params * @return RecurringPaymentResult - * @throws ApiException|InvalidArgumentException + * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException */ public function realizeRegularSubscriptionPayment($parentPaymentUid, RealizeRegularSubscriptionPaymentParams $params): RecurringPaymentResult { @@ -175,8 +188,10 @@ public function realizeRegularSubscriptionPayment($parentPaymentUid, RealizeRegu /** * @param string $parentPaymentUid UID of payment which initialized this subscription. * @param RealizeIrregularSubscriptionPaymentParams $params + * * @return RecurringPaymentResult - * @throws ApiException|InvalidArgumentException + * + * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException */ public function realizeIrregularSubscriptionPayment($parentPaymentUid, RealizeIrregularSubscriptionPaymentParams $params): RecurringPaymentResult { @@ -187,8 +202,10 @@ public function realizeIrregularSubscriptionPayment($parentPaymentUid, RealizeIr /** * @param string $parentPaymentUid UID of payment which initialized this subscription. * @param RealizeUsageBasedSubscriptionPaymentParams $params + * * @return RecurringPaymentResult - * @throws ApiException|InvalidArgumentException + * + * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException */ public function realizeUsageBasedSubscriptionPayment($parentPaymentUid, RealizeUsageBasedSubscriptionPaymentParams $params): RecurringPaymentResult { @@ -199,8 +216,10 @@ public function realizeUsageBasedSubscriptionPayment($parentPaymentUid, RealizeU /** * @param string $parentPaymentUid UID of first payment created with save_authorization=true. * @param RealizePaymentBySavedAuthorizationParams $params + * * @return RecurringPaymentResult - * @throws ApiException|InvalidArgumentException + * + * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException */ public function realizePaymentBySavedAuthorization($parentPaymentUid, RealizePaymentBySavedAuthorizationParams $params): RecurringPaymentResult { @@ -210,11 +229,13 @@ public function realizePaymentBySavedAuthorization($parentPaymentUid, RealizePay /** - * @param PaymentsFilter $filter Associative array of filters + * @param PaymentsFilter|null $filter Associative array of filters * @param int $page * @param null|int $limit + * * @return PaymentCollection - * @throws ApiException + * + * @throws NotFoundApiServiceException|ApiServiceException */ public function getPayments(?PaymentsFilter $filter = null, $page = 1, $limit = 25) { @@ -232,7 +253,10 @@ public function getPayments(?PaymentsFilter $filter = null, $page = 1, $limit = * * @param string $uid UID of payment, * @param string|null $languageCode language code in ISO 6391 format + * * @return array + * + * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException */ public function getPaymentUrlsForPayment($uid, $languageCode = null) { @@ -271,7 +295,7 @@ public function getPaymentButtonsForPayment($uid, $languageCode = null, $useInli /** * @param non-empty-string|null $methodCode * - * @throws ApiException + * @throws ApiServiceException */ public function createPayment(CreatePaymentParams $params, ?string $methodCode = null): CreatePaymentResponse { @@ -288,7 +312,7 @@ public function createPayment(CreatePaymentParams $params, ?string $methodCode = * @param non-empty-string $paymentUid * @param non-empty-string $methodCode * - * @throws ApiException|InvalidArgumentException + * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException */ public function changePaymentMethod(string $paymentUid, string $methodCode): void { @@ -300,8 +324,10 @@ public function changePaymentMethod(string $paymentUid, string $methodCode): voi /** * @param RealizePreauthorizedPaymentParams $params + * * @return RealizePreauthorizedPaymentResult - * @throws ApiException|InvalidArgumentException + * + * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException */ public function realizePreauthorizedPayment(RealizePreauthorizedPaymentParams $params): RealizePreauthorizedPaymentResult { @@ -314,7 +340,7 @@ public function realizePreauthorizedPayment(RealizePreauthorizedPaymentParams $p /** * @param non-empty-string $paymentUid * - * @throws ApiException|InvalidArgumentException + * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException */ public function cancelPreauthorizedPayment(string $paymentUid): void { @@ -328,8 +354,10 @@ public function cancelPreauthorizedPayment(string $paymentUid): void * Returns information about payment refund. * * @param string $paymentUid + * * @return PaymentRefundInfo - * @throws ApiException|InvalidArgumentException + * + * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException */ public function getPaymentRefund($paymentUid) { @@ -343,8 +371,10 @@ public function getPaymentRefund($paymentUid) * @param string $paymentUid * @param int $amount amount which should be refunded in cents (currency used for refunding is same as payment currency) * @param string $reason + * * @return void - * @throws ApiException|InvalidArgumentException + * + * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException */ public function createPaymentRefund($paymentUid, $amount, $reason) { @@ -355,14 +385,14 @@ public function createPaymentRefund($paymentUid, $amount, $reason) /** * Method will generate PDF file as confirmation for paid payment * - * @see https://thepay.docs.apiary.io/#reference/data-retrieval/payments/get-payment-confirmation + * @see ApiServiceInterface::generatePaymentConfirmationPdf() * * @param non-empty-string $paymentUid * @param non-empty-string|null $languageCode * * @return string with binary content of PDF file * - * @throws ApiException if payment is not paid yet + * @throws NotFoundApiServiceException|ApiServiceException if payment is not paid yet */ public function generatePaymentConfirmationPdf(string $paymentUid, ?string $languageCode = null): string { From 668d499a5aff1fd4d35677223a04d23558b0ffc5 Mon Sep 17 00:00:00 2001 From: Petr Knap <8299754+petrknap@users.noreply.github.com> Date: Thu, 23 Jul 2026 10:21:22 +0200 Subject: [PATCH 2/2] wip --- src/Exception/ApiException.php | 6 ++- src/Exception/ApiExceptionInterface.php | 14 ++++++ src/Exception/ApiServiceException.php | 14 ------ src/Exception/NotFoundApiException.php | 9 ++++ src/Exception/NotFoundApiServiceException.php | 9 ---- .../ServiceUnavailableApiException.php | 14 ++++++ src/Service/ApiService.php | 14 +++--- src/Service/ApiServiceInterface.php | 44 +++++++++---------- src/Service/GateService.php | 6 +-- src/TheClient.php | 44 +++++++++---------- 10 files changed, 95 insertions(+), 79 deletions(-) create mode 100644 src/Exception/ApiExceptionInterface.php delete mode 100644 src/Exception/ApiServiceException.php create mode 100644 src/Exception/NotFoundApiException.php delete mode 100644 src/Exception/NotFoundApiServiceException.php create mode 100644 src/Exception/ServiceUnavailableApiException.php diff --git a/src/Exception/ApiException.php b/src/Exception/ApiException.php index 4fa7d44..916daeb 100644 --- a/src/Exception/ApiException.php +++ b/src/Exception/ApiException.php @@ -3,8 +3,10 @@ namespace ThePay\ApiClient\Exception; /** - * Exception representing a server-side error or a network communication failure + * represents error on api side or network communication error + * + * @deprecated use {@see ServiceUnavailableApiException} */ -class ApiException extends \Exception implements ApiServiceException +class ApiException extends \Exception { } diff --git a/src/Exception/ApiExceptionInterface.php b/src/Exception/ApiExceptionInterface.php new file mode 100644 index 0000000..1dcfaaf --- /dev/null +++ b/src/Exception/ApiExceptionInterface.php @@ -0,0 +1,14 @@ +httpClient->sendRequest($request); } - private function buildException(string $requestUrl, ResponseInterface $response): ApiServiceException + private function buildException(string $requestUrl, ResponseInterface $response): ApiExceptionInterface { $responseCode = $response->getStatusCode(); $message = 'TheApi call "' . $requestUrl . '" failed, status code: ' . $responseCode . ' ' . $response->getReasonPhrase(); @@ -484,12 +484,12 @@ private function buildException(string $requestUrl, ResponseInterface $response) switch (true) { case $responseCode == 404: - return new NotFoundApiServiceException($message, $responseCode); + return new NotFoundApiException($message, $responseCode); case $responseCode >= 500: case $responseCode == 0: // network communication failure - return new ApiException($message, $responseCode); + return new ServiceUnavailableApiException($message, $responseCode); default: - return new class ($message, $responseCode) extends \RuntimeException implements ApiServiceException { + return new class ($message, $responseCode) extends \RuntimeException implements ApiExceptionInterface { }; } } diff --git a/src/Service/ApiServiceInterface.php b/src/Service/ApiServiceInterface.php index 4967bd2..9bb2b2f 100644 --- a/src/Service/ApiServiceInterface.php +++ b/src/Service/ApiServiceInterface.php @@ -3,8 +3,8 @@ namespace ThePay\ApiClient\Service; use Psr\Http\Message\StreamInterface; -use ThePay\ApiClient\Exception\ApiServiceException; -use ThePay\ApiClient\Exception\NotFoundApiServiceException; +use ThePay\ApiClient\Exception\ApiExceptionInterface; +use ThePay\ApiClient\Exception\NotFoundApiException; use ThePay\ApiClient\Filter\PaymentsFilter; use ThePay\ApiClient\Filter\TransactionFilter; use ThePay\ApiClient\Model\AccountBalance; @@ -39,7 +39,7 @@ interface ApiServiceInterface * * @return Project[] * - * @throws ApiServiceException + * @throws ApiExceptionInterface */ public function getProjects(); @@ -52,7 +52,7 @@ public function getProjects(); * * @return PaymentMethodCollection * - * @throws ApiServiceException + * @throws ApiExceptionInterface */ public function getActivePaymentMethods(?LanguageCode $languageCode = null); @@ -63,7 +63,7 @@ public function getActivePaymentMethods(?LanguageCode $languageCode = null); * * @return Payment * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function getPayment(Identifier $paymentUid); @@ -74,7 +74,7 @@ public function getPayment(Identifier $paymentUid); * * @return void * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function invalidatePayment(Identifier $paymentUid); @@ -85,7 +85,7 @@ public function invalidatePayment(Identifier $paymentUid); * * @param Identifier $parentPaymentUid UID of payment which initialized this subscription. * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function realizeRegularSubscriptionPayment(Identifier $parentPaymentUid, RealizeRegularSubscriptionPaymentParams $params): RecurringPaymentResult; @@ -96,7 +96,7 @@ public function realizeRegularSubscriptionPayment(Identifier $parentPaymentUid, * * @param Identifier $parentPaymentUid UID of payment which initialized this subscription. * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function realizeIrregularSubscriptionPayment(Identifier $parentPaymentUid, RealizeIrregularSubscriptionPaymentParams $params): RecurringPaymentResult; @@ -107,7 +107,7 @@ public function realizeIrregularSubscriptionPayment(Identifier $parentPaymentUid * * @param Identifier $parentPaymentUid UID of payment which initialized this subscription. * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function realizeUsageBasedSubscriptionPayment(Identifier $parentPaymentUid, RealizeUsageBasedSubscriptionPaymentParams $params): RecurringPaymentResult; @@ -118,7 +118,7 @@ public function realizeUsageBasedSubscriptionPayment(Identifier $parentPaymentUi * * @param Identifier $parentPaymentUid UID of first payment created with save_authorization=true. * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function realizePaymentBySavedAuthorization(Identifier $parentPaymentUid, RealizePaymentBySavedAuthorizationParams $params): RecurringPaymentResult; @@ -130,7 +130,7 @@ public function realizePaymentBySavedAuthorization(Identifier $parentPaymentUid, * @param int<1, max> $page * @param int<1, 1000> $limit * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function getPayments(PaymentsFilter $filter, int $page = 1, int $limit = 25): PaymentCollection; @@ -141,7 +141,7 @@ public function getPayments(PaymentsFilter $filter, int $page = 1, int $limit = * * @return array * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function getAccountsBalances(?StringValue $accountIban = null, $projectId = null, ?\DateTime $balanceAt = null); @@ -151,7 +151,7 @@ public function getAccountsBalances(?StringValue $accountIban = null, $projectId * @param int<1, max> $page * @param int<1, 1000> $limit * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function getAccountTransactionHistory(TransactionFilter $filter, int $page = 1, int $limit = 100): TransactionCollection; @@ -160,7 +160,7 @@ public function getAccountTransactionHistory(TransactionFilter $filter, int $pag * * @see https://docs.thepay.eu/#tag/Transactions/paths/~1v1~1transactions~1%7Baccount_iban%7D~1account_statement~1gpc/get * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function getAccountStatementGPC(TransactionFilter $filter, ?GPCPaymentIdentifier $paymentIdentifier = null): StreamInterface; @@ -171,7 +171,7 @@ public function getAccountStatementGPC(TransactionFilter $filter, ?GPCPaymentIde * * @param non-empty-string|null $methodCode * - * @throws ApiServiceException + * @throws ApiExceptionInterface */ public function createPayment(CreatePaymentParams $createPaymentParams, ?string $methodCode = null): CreatePaymentResponse; @@ -180,7 +180,7 @@ public function createPayment(CreatePaymentParams $createPaymentParams, ?string * * @see https://docs.thepay.eu/#tag/Preauthorized-Payments/paths/~1v2~1projects~1%7Bproject_id%7D~1payments~1%7Bpayment_uid%7D~1preauthorized/post * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function realizePreauthorizedPayment(RealizePreauthorizedPaymentParams $params): RealizePreauthorizedPaymentResult; @@ -189,7 +189,7 @@ public function realizePreauthorizedPayment(RealizePreauthorizedPaymentParams $p * * @see https://docs.thepay.eu/#tag/Preauthorized-Payments/paths/~1v1~1projects~1%7Bproject_id%7D~1payments~1%7Bpayment_uid%7D~1preauthorized/delete * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function cancelPreauthorizedPayment(Identifier $uid): void; @@ -200,7 +200,7 @@ public function cancelPreauthorizedPayment(Identifier $uid): void; * * @param non-empty-string $methodCode * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function changePaymentMethod(Identifier $uid, string $methodCode): void; @@ -211,7 +211,7 @@ public function changePaymentMethod(Identifier $uid, string $methodCode): void; * * @return PaymentRefundInfo * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function getPaymentRefund(Identifier $uid); @@ -222,7 +222,7 @@ public function getPaymentRefund(Identifier $uid); * * @param Amount $amount amount which should be refunded in cents (currency used for refunding is same as payment currency) * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function createPaymentRefund(Identifier $uid, Amount $amount, string $reason): void; @@ -233,7 +233,7 @@ public function createPaymentRefund(Identifier $uid, Amount $amount, string $rea * * @return array * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function getPaymentUrlsForPayment(Identifier $uid, ?LanguageCode $languageCode = null); @@ -244,7 +244,7 @@ public function getPaymentUrlsForPayment(Identifier $uid, ?LanguageCode $languag * * @return string with binary content of PDF file * - * @throws NotFoundApiServiceException|ApiServiceException throws if payment is not paid yet + * @throws NotFoundApiException|ApiExceptionInterface throws if payment is not paid yet */ public function generatePaymentConfirmationPdf(Identifier $uid, ?LanguageCode $languageCode = null): string; } diff --git a/src/Service/GateService.php b/src/Service/GateService.php index e855ad7..22ac7d2 100644 --- a/src/Service/GateService.php +++ b/src/Service/GateService.php @@ -2,8 +2,8 @@ namespace ThePay\ApiClient\Service; -use ThePay\ApiClient\Exception\ApiServiceException; -use ThePay\ApiClient\Exception\NotFoundApiServiceException; +use ThePay\ApiClient\Exception\ApiExceptionInterface; +use ThePay\ApiClient\Exception\NotFoundApiException; use ThePay\ApiClient\Model\IPaymentMethod; use ThePay\ApiClient\ValueObject\Identifier; use ThePay\ApiClient\ValueObject\LanguageCode; @@ -33,7 +33,7 @@ public function __construct(ApiServiceInterface $api) * * @return string HTML * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function getPaymentButtonsForPayment(Identifier $uid, ?LanguageCode $languageCode = null) { diff --git a/src/TheClient.php b/src/TheClient.php index f1cd568..5283360 100644 --- a/src/TheClient.php +++ b/src/TheClient.php @@ -4,8 +4,8 @@ use InvalidArgumentException; use Psr\Http\Message\StreamInterface; -use ThePay\ApiClient\Exception\ApiServiceException; -use ThePay\ApiClient\Exception\NotFoundApiServiceException; +use ThePay\ApiClient\Exception\ApiExceptionInterface; +use ThePay\ApiClient\Exception\NotFoundApiException; use ThePay\ApiClient\Filter\PaymentMethodFilter; use ThePay\ApiClient\Filter\PaymentsFilter; use ThePay\ApiClient\Filter\TransactionFilter; @@ -64,7 +64,7 @@ public function __construct( * * @return Project[] * - * @throws ApiServiceException + * @throws ApiExceptionInterface */ public function getProjects() { @@ -79,7 +79,7 @@ public function getProjects() * * @return array * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function getAccountsBalances($accountIban = null, $projectId = null, ?\DateTime $balanceAt = null) { @@ -97,7 +97,7 @@ public function getAccountsBalances($accountIban = null, $projectId = null, ?\Da * * @return Model\Collection\TransactionCollection * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function getAccountTransactionHistory(TransactionFilter $filter, $page = 1, $limit = 100) { @@ -113,7 +113,7 @@ public function getAccountTransactionHistory(TransactionFilter $filter, $page = * @return StreamInterface MUST return real PSR-7 network stream, make sure you have your PSR-18 HTTP client correctly configured, GPC format is not paginated! * @return StreamInterface content is windows-1250 encoded * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function getAccountStatementGPC(TransactionFilter $filter, ?GPCPaymentIdentifier $paymentIdentifier = null): StreamInterface { @@ -130,7 +130,7 @@ public function getAccountStatementGPC(TransactionFilter $filter, ?GPCPaymentIde * * @return PaymentMethodCollection * - * @throws ApiServiceException + * @throws ApiExceptionInterface */ public function getActivePaymentMethods(?PaymentMethodFilter $filter = null, ?LanguageCode $languageCode = null, $isRecurring = false, $isDeposit = true) { @@ -150,7 +150,7 @@ public function getActivePaymentMethods(?PaymentMethodFilter $filter = null, ?La * * @return Model\Payment * - * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException + * @throws InvalidArgumentException|NotFoundApiException|ApiExceptionInterface */ public function getPayment($paymentUid) { @@ -165,7 +165,7 @@ public function getPayment($paymentUid) * * @return void * - * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException + * @throws InvalidArgumentException|NotFoundApiException|ApiExceptionInterface */ public function invalidatePayment($paymentUid) { @@ -177,7 +177,7 @@ public function invalidatePayment($paymentUid) * @param string $parentPaymentUid UID of payment which initialized this subscription. * @param RealizeRegularSubscriptionPaymentParams $params * @return RecurringPaymentResult - * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException + * @throws InvalidArgumentException|NotFoundApiException|ApiExceptionInterface */ public function realizeRegularSubscriptionPayment($parentPaymentUid, RealizeRegularSubscriptionPaymentParams $params): RecurringPaymentResult { @@ -191,7 +191,7 @@ public function realizeRegularSubscriptionPayment($parentPaymentUid, RealizeRegu * * @return RecurringPaymentResult * - * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException + * @throws InvalidArgumentException|NotFoundApiException|ApiExceptionInterface */ public function realizeIrregularSubscriptionPayment($parentPaymentUid, RealizeIrregularSubscriptionPaymentParams $params): RecurringPaymentResult { @@ -205,7 +205,7 @@ public function realizeIrregularSubscriptionPayment($parentPaymentUid, RealizeIr * * @return RecurringPaymentResult * - * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException + * @throws InvalidArgumentException|NotFoundApiException|ApiExceptionInterface */ public function realizeUsageBasedSubscriptionPayment($parentPaymentUid, RealizeUsageBasedSubscriptionPaymentParams $params): RecurringPaymentResult { @@ -219,7 +219,7 @@ public function realizeUsageBasedSubscriptionPayment($parentPaymentUid, RealizeU * * @return RecurringPaymentResult * - * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException + * @throws InvalidArgumentException|NotFoundApiException|ApiExceptionInterface */ public function realizePaymentBySavedAuthorization($parentPaymentUid, RealizePaymentBySavedAuthorizationParams $params): RecurringPaymentResult { @@ -235,7 +235,7 @@ public function realizePaymentBySavedAuthorization($parentPaymentUid, RealizePay * * @return PaymentCollection * - * @throws NotFoundApiServiceException|ApiServiceException + * @throws NotFoundApiException|ApiExceptionInterface */ public function getPayments(?PaymentsFilter $filter = null, $page = 1, $limit = 25) { @@ -256,7 +256,7 @@ public function getPayments(?PaymentsFilter $filter = null, $page = 1, $limit = * * @return array * - * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException + * @throws InvalidArgumentException|NotFoundApiException|ApiExceptionInterface */ public function getPaymentUrlsForPayment($uid, $languageCode = null) { @@ -295,7 +295,7 @@ public function getPaymentButtonsForPayment($uid, $languageCode = null, $useInli /** * @param non-empty-string|null $methodCode * - * @throws ApiServiceException + * @throws ApiExceptionInterface */ public function createPayment(CreatePaymentParams $params, ?string $methodCode = null): CreatePaymentResponse { @@ -312,7 +312,7 @@ public function createPayment(CreatePaymentParams $params, ?string $methodCode = * @param non-empty-string $paymentUid * @param non-empty-string $methodCode * - * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException + * @throws InvalidArgumentException|NotFoundApiException|ApiExceptionInterface */ public function changePaymentMethod(string $paymentUid, string $methodCode): void { @@ -327,7 +327,7 @@ public function changePaymentMethod(string $paymentUid, string $methodCode): voi * * @return RealizePreauthorizedPaymentResult * - * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException + * @throws InvalidArgumentException|NotFoundApiException|ApiExceptionInterface */ public function realizePreauthorizedPayment(RealizePreauthorizedPaymentParams $params): RealizePreauthorizedPaymentResult { @@ -340,7 +340,7 @@ public function realizePreauthorizedPayment(RealizePreauthorizedPaymentParams $p /** * @param non-empty-string $paymentUid * - * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException + * @throws InvalidArgumentException|NotFoundApiException|ApiExceptionInterface */ public function cancelPreauthorizedPayment(string $paymentUid): void { @@ -357,7 +357,7 @@ public function cancelPreauthorizedPayment(string $paymentUid): void * * @return PaymentRefundInfo * - * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException + * @throws InvalidArgumentException|NotFoundApiException|ApiExceptionInterface */ public function getPaymentRefund($paymentUid) { @@ -374,7 +374,7 @@ public function getPaymentRefund($paymentUid) * * @return void * - * @throws InvalidArgumentException|NotFoundApiServiceException|ApiServiceException + * @throws InvalidArgumentException|NotFoundApiException|ApiExceptionInterface */ public function createPaymentRefund($paymentUid, $amount, $reason) { @@ -392,7 +392,7 @@ public function createPaymentRefund($paymentUid, $amount, $reason) * * @return string with binary content of PDF file * - * @throws NotFoundApiServiceException|ApiServiceException if payment is not paid yet + * @throws NotFoundApiException|ApiExceptionInterface if payment is not paid yet */ public function generatePaymentConfirmationPdf(string $paymentUid, ?string $languageCode = null): string {