From a09dabab28da4eb25ea667ff58255c738ba1f2fa Mon Sep 17 00:00:00 2001 From: Mauricio Astudillo Toledo Date: Wed, 5 Jun 2024 10:40:52 -0400 Subject: [PATCH] feat: remove webpay modal --- .../Exceptions/TransactionCommitException.php | 9 - .../Exceptions/TransactionCreateException.php | 9 - .../Exceptions/TransactionRefundException.php | 9 - .../Exceptions/TransactionStatusException.php | 9 - .../Responses/TransactionCommitResponse.php | 7 - .../Responses/TransactionCreateResponse.php | 26 --- .../Responses/TransactionRefundResponse.php | 7 - .../Responses/TransactionStatusResponse.php | 40 ----- src/Webpay/Modal/Transaction.php | 155 ------------------ src/Webpay/Modal/WebpayModal.php | 19 --- 10 files changed, 290 deletions(-) delete mode 100644 src/Webpay/Modal/Exceptions/TransactionCommitException.php delete mode 100644 src/Webpay/Modal/Exceptions/TransactionCreateException.php delete mode 100644 src/Webpay/Modal/Exceptions/TransactionRefundException.php delete mode 100644 src/Webpay/Modal/Exceptions/TransactionStatusException.php delete mode 100644 src/Webpay/Modal/Responses/TransactionCommitResponse.php delete mode 100644 src/Webpay/Modal/Responses/TransactionCreateResponse.php delete mode 100644 src/Webpay/Modal/Responses/TransactionRefundResponse.php delete mode 100644 src/Webpay/Modal/Responses/TransactionStatusResponse.php delete mode 100644 src/Webpay/Modal/Transaction.php delete mode 100644 src/Webpay/Modal/WebpayModal.php diff --git a/src/Webpay/Modal/Exceptions/TransactionCommitException.php b/src/Webpay/Modal/Exceptions/TransactionCommitException.php deleted file mode 100644 index dc0c5322..00000000 --- a/src/Webpay/Modal/Exceptions/TransactionCommitException.php +++ /dev/null @@ -1,9 +0,0 @@ -token = Utils::returnValueIfExists($json, 'token'); - } - - /** - * @return string|null - */ - public function getToken() - { - return $this->token; - } -} diff --git a/src/Webpay/Modal/Responses/TransactionRefundResponse.php b/src/Webpay/Modal/Responses/TransactionRefundResponse.php deleted file mode 100644 index 83167986..00000000 --- a/src/Webpay/Modal/Responses/TransactionRefundResponse.php +++ /dev/null @@ -1,7 +0,0 @@ -setTransactionStatusFields($json); - } - - public function isApproved() - { - if($this->getResponseCode() !== ResponseCodesEnum::RESPONSE_CODE_APPROVED) { - return false; - } - - switch($this->getStatus()) { - case TransactionStatusEnum::STATUS_CAPTURED: - case TransactionStatusEnum::STATUS_REVERSED: - case TransactionStatusEnum::STATUS_NULLIFIED: - case TransactionStatusEnum::STATUS_AUTHORIZED: - case TransactionStatusEnum::STATUS_PARTIALLY_NULLIFIED: - return true; - default : - return false; - } - } -} diff --git a/src/Webpay/Modal/Transaction.php b/src/Webpay/Modal/Transaction.php deleted file mode 100644 index a125d2f2..00000000 --- a/src/Webpay/Modal/Transaction.php +++ /dev/null @@ -1,155 +0,0 @@ - $buyOrder, - 'session_id' => $sessionId, - 'amount' => $amount, - ]; - - try { - $response = $this->sendRequest('POST', static::CREATE_TRANSACTION_ENDPOINT, $payload); - } catch (WebpayRequestException $exception) { - throw new TransactionCreateException($exception->getMessage(), - $exception->getTransbankErrorMessage(), - $exception->getHttpCode(), - $exception->getFailedRequest(), - $exception - ); - } - - return new TransactionCreateResponse($response); - } - - /** - * @param string $token - * - * @throws TransactionCommitException|GuzzleHttp\Exception\GuzzleException - * - * @return TransactionCommitResponse - ** - */ - public function commit($token) - { - $endpoint = str_replace('{token}', $token, static::COMMIT_TRANSACTION_ENDPOINT); - - try { - $response = $this->sendRequest('PUT', $endpoint, []); - } catch (WebpayRequestException $exception) { - throw new TransactionCommitException($exception->getMessage(), - $exception->getTransbankErrorMessage(), - $exception->getHttpCode(), - $exception->getFailedRequest(), - $exception - ); - } - - return new TransactionCommitResponse($response); - } - - /** - * @param $token - * - * @throws GuzzleHttp\Exception\GuzzleException - * @throws TransactionStatusException - * - * @return TransactionStatusResponse - */ - public function status($token) - { - $endpoint = str_replace('{token}', $token, static::STATUS_TRANSACTION_ENDPOINT); - - try { - $response = $this->sendRequest('GET', $endpoint, []); - } catch (WebpayRequestException $exception) { - throw new TransactionStatusException($exception->getMessage(), - $exception->getTransbankErrorMessage(), - $exception->getHttpCode(), - $exception->getFailedRequest(), - $exception - ); - } - - return new TransactionStatusResponse($response); - } - - /** - * @param $token - * @param $amount - * @param Options|null $options - * - * @throws GuzzleHttp\Exception\GuzzleException|TransactionRefundException - * - * @return TransactionRefundResponse - */ - public function refund($token, $amount) - { - $endpoint = str_replace('{token}', $token, static::REFUND_TRANSACTION_ENDPOINT); - - try { - $response = $this->sendRequest( - 'POST', - $endpoint, - ['amount' => $amount] - ); - } catch (WebpayRequestException $exception) { - throw new TransactionRefundException($exception->getMessage(), - $exception->getTransbankErrorMessage(), - $exception->getHttpCode(), - $exception->getFailedRequest(), - $exception - ); - } - - return new TransactionRefundResponse($response); - } - - public static function getDefaultOptions() - { - return Options::forIntegration(WebpayModal::DEFAULT_COMMERCE_CODE, WebpayModal::DEFAULT_API_KEY); - } - - public static function getGlobalOptions() - { - return WebpayModal::getOptions(); - } -} diff --git a/src/Webpay/Modal/WebpayModal.php b/src/Webpay/Modal/WebpayModal.php deleted file mode 100644 index a1910786..00000000 --- a/src/Webpay/Modal/WebpayModal.php +++ /dev/null @@ -1,19 +0,0 @@ -