From 06be0f850ee5548d690eff684513301c5e21f5f0 Mon Sep 17 00:00:00 2001 From: Tigran <62335544+tikohov20@users.noreply.github.com> Date: Wed, 24 May 2023 13:39:05 +0400 Subject: [PATCH] Removed unused files. (#76) * Removed unused files. * Removed unused files. --- Gateway/Http/Client/ClientMock.php | 83 ------------------- Gateway/Http/TransferFactory.php | 29 ------- Gateway/Request/AuthorizationRequest.php | 50 ----------- Gateway/Request/MockDataRequest.php | 32 ------- Gateway/Response/FraudHandler.php | 38 --------- Gateway/Response/TxnIdHandler.php | 29 ------- Model/Request/Transactions.php | 22 ++--- Model/Ui/ConfigProvider.php | 4 - .../js/view/payment/method-renderer/mondu.js | 18 ---- 9 files changed, 12 insertions(+), 293 deletions(-) delete mode 100644 Gateway/Http/Client/ClientMock.php delete mode 100644 Gateway/Http/TransferFactory.php delete mode 100644 Gateway/Request/AuthorizationRequest.php delete mode 100644 Gateway/Request/MockDataRequest.php delete mode 100644 Gateway/Response/FraudHandler.php delete mode 100644 Gateway/Response/TxnIdHandler.php diff --git a/Gateway/Http/Client/ClientMock.php b/Gateway/Http/Client/ClientMock.php deleted file mode 100644 index cf030d4..0000000 --- a/Gateway/Http/Client/ClientMock.php +++ /dev/null @@ -1,83 +0,0 @@ -logger = $logger; - } - - public function placeRequest(TransferInterface $transferObject) - { - $response = $this->generateResponseForCode( - $this->getResultCode( - $transferObject - ) - ); - - $this->logger->debug( - [ - 'request' => $transferObject->getBody(), - 'response' => $response - ] - ); - - return $response; - } - - protected function generateResponseForCode($resultCode) - { - - return array_merge( - [ - 'RESULT_CODE' => $resultCode, - 'TXN_ID' => $this->generateTxnId() - ], - $this->getFieldsBasedOnResponseType($resultCode) - ); - } - - protected function generateTxnId() - { - return md5(mt_rand(0, 1000)); - } - - private function getResultCode(TransferInterface $transfer) - { - $headers = $transfer->getHeaders(); - - if (isset($headers['force_result'])) { - return (int)$headers['force_result']; - } - - return $this->results[mt_rand(0, 1)]; - } - - private function getFieldsBasedOnResponseType($resultCode) - { - switch ($resultCode) { - case self::FAILURE: - return [ - 'FRAUD_MSG_LIST' => [ - 'Stolen card', - 'Customer location differs' - ] - ]; - } - - return []; - } -} diff --git a/Gateway/Http/TransferFactory.php b/Gateway/Http/TransferFactory.php deleted file mode 100644 index 9bdd520..0000000 --- a/Gateway/Http/TransferFactory.php +++ /dev/null @@ -1,29 +0,0 @@ -transferBuilder = $transferBuilder; - } - - public function create(array $request) - { - return $this->transferBuilder - ->setBody($request) - ->setMethod('POST') - ->setHeaders( - [ - 'force_result' => $request[MockDataRequest::FORCE_RESULT] ?? null - ] - ) - ->build(); - } -} diff --git a/Gateway/Request/AuthorizationRequest.php b/Gateway/Request/AuthorizationRequest.php deleted file mode 100644 index 02fd3ae..0000000 --- a/Gateway/Request/AuthorizationRequest.php +++ /dev/null @@ -1,50 +0,0 @@ -config = $config; - } - - /** - * @inheritDoc - */ - public function build(array $buildSubject) - { - if (!isset($buildSubject['payment']) - || !$buildSubject['payment'] instanceof PaymentDataObjectInterface - ) { - throw new \InvalidArgumentException('Payment data object should be provided'); - } - - $payment = $buildSubject['payment']; - $order = $payment->getOrder(); - $address = $order->getShippingAddress(); - - return [ - 'TXN_TYPE' => 'A', - 'INVOICE' => $order->getOrderIncrementId(), - 'AMOUNT' => $order->getGrandTotalAmount(), - 'CURRENCY' => $order->getCurrencyCode(), - 'EMAIL' => $address->getEmail(), - 'MERCHANT_KEY' => $this->config->getValue( - 'merchant_gateway_key', - $order->getStoreId() - ) - ]; - } -} diff --git a/Gateway/Request/MockDataRequest.php b/Gateway/Request/MockDataRequest.php deleted file mode 100644 index 3fddf7b..0000000 --- a/Gateway/Request/MockDataRequest.php +++ /dev/null @@ -1,32 +0,0 @@ -getPayment(); - - $transactionResult = $payment->getAdditionalInformation('transaction_result'); - return [ - self::FORCE_RESULT => $transactionResult === null - ? ClientMock::SUCCESS - : $transactionResult - ]; - } -} diff --git a/Gateway/Response/FraudHandler.php b/Gateway/Response/FraudHandler.php deleted file mode 100644 index 8ab769b..0000000 --- a/Gateway/Response/FraudHandler.php +++ /dev/null @@ -1,38 +0,0 @@ -getPayment(); - - $payment->setAdditionalInformation( - self::FRAUD_MSG_LIST, - (array)$response[self::FRAUD_MSG_LIST] - ); - - /** @var $payment Payment */ - $payment->setIsTransactionPending(true); - $payment->setIsFraudDetected(true); - } -} diff --git a/Gateway/Response/TxnIdHandler.php b/Gateway/Response/TxnIdHandler.php deleted file mode 100644 index 45cf3db..0000000 --- a/Gateway/Response/TxnIdHandler.php +++ /dev/null @@ -1,29 +0,0 @@ -getPayment(); - - /** @var $payment Payment */ - $payment->setTransactionId($response[self::TXN_ID]); - $payment->setIsTransactionClosed(false); - } -} diff --git a/Model/Request/Transactions.php b/Model/Request/Transactions.php index f7afc27..d338fb8 100644 --- a/Model/Request/Transactions.php +++ b/Model/Request/Transactions.php @@ -43,12 +43,12 @@ public function __construct( public function request($_params = []): array { try { - if(@$_params['email']) { + if (@$_params['email']) { $this->fallbackEmail = $_params['email']; } $params = $this->getRequestParams(); - if($_params['payment_method'] === 'direct_debit' || $_params['payment_method'] === 'installment') { + if ($_params['payment_method'] === 'direct_debit' || $_params['payment_method'] === 'installment') { $params['payment_method'] = $_params['payment_method']; } @@ -62,7 +62,7 @@ public function request($_params = []): array $data = json_decode($result, true); $this->_checkoutSession->setMonduid(@$data['order']['uuid']); - if(!@$data['order']['uuid']) { + if (!@$data['order']['uuid']) { return [ 'error' => 1, 'body' => json_decode($result, true), @@ -75,7 +75,7 @@ public function request($_params = []): array 'message' => __('Success') ]; } - } catch(\Exception $e) { + } catch (\Exception $e) { return [ 'error' => 1, 'body' => null, @@ -84,7 +84,8 @@ public function request($_params = []): array } } - protected function getRequestParams() { + protected function getRequestParams() + { $quote = $this->_checkoutSession->getQuote(); $quote->collectTotals(); $requiresShipping = $quote->getShippingAddress() !== null ? 1 : 0; @@ -129,7 +130,7 @@ private function getBillingAddressParams(Quote $quote): array if (($billing = $quote->getBillingAddress()) !== null) { $address = (array) $billing->getStreet(); $line1 = (string) array_shift($address); - if($billing->getStreetNumber()) { + if ($billing->getStreetNumber()) { $line1 .= ', '. $billing->getStreetNumber(); } $line2 = (string) implode(' ', $address); @@ -140,7 +141,7 @@ private function getBillingAddressParams(Quote $quote): array 'address_line1' => $line1, 'address_line2' => $line2, ]; - if($billing->getRegion()) { + if ($billing->getRegion()) { $params['state'] = (string) $billing->getRegion(); } } @@ -155,7 +156,7 @@ private function getShippingAddressParams(Quote $quote): array if (($shipping = $quote->getShippingAddress()) !== null) { $address = (array) $shipping->getStreet(); $line1 = (string) array_shift($address); - if($shipping->getStreetNumber()) { + if ($shipping->getStreetNumber()) { $line1 .= ', '. $shipping->getStreetNumber(); } $line2 = (string) implode(' ', $address); @@ -167,7 +168,7 @@ private function getShippingAddressParams(Quote $quote): array 'address_line2' => $line2, ]; - if($shipping->getRegion()) { + if ($shipping->getRegion()) { $params['state'] = (string) $shipping->getRegion(); } } @@ -180,7 +181,8 @@ private function getShippingAddressParams(Quote $quote): array * @return mixed|string|null * @throws \Exception */ - public function getExternalReferenceId(Quote $quote) { + public function getExternalReferenceId(Quote $quote) + { $reservedOrderId = $quote->getReservedOrderId(); if (!$reservedOrderId) { $quote->reserveOrderId()->save(); diff --git a/Model/Ui/ConfigProvider.php b/Model/Ui/ConfigProvider.php index dc1c6ba..25f37ca 100644 --- a/Model/Ui/ConfigProvider.php +++ b/Model/Ui/ConfigProvider.php @@ -128,10 +128,6 @@ public function getConfig() 'payment' => [ self::CODE => [ 'sdkUrl' => $this->getSdkUrl(), - 'transactionResults' => [ - ClientMock::SUCCESS => __('Success'), - ClientMock::FAILURE => __('Fraud'), - ], 'monduCheckoutTokenUrl' => $this->urlBuilder->getUrl('mondu/payment_checkout/token'), 'description' => $descriptionMondu, 'title' => __($this->scopeConfig->getValue('payment/mondu/title', ScopeInterface::SCOPE_STORE)) diff --git a/view/frontend/web/js/view/payment/method-renderer/mondu.js b/view/frontend/web/js/view/payment/method-renderer/mondu.js index e48c57e..d15f1b1 100644 --- a/view/frontend/web/js/view/payment/method-renderer/mondu.js +++ b/view/frontend/web/js/view/payment/method-renderer/mondu.js @@ -21,14 +21,12 @@ define([ return Component.extend({ defaults: { template: "Mondu_Mondu/payment/form", - transactionResult: "", monduSkdLoaded: false, }, isBillingSameAsShipping: true, initObservable: function () { var self = this; - self._super().observe(["transactionResult"]); billingAddress().isAddressSameAsShipping.subscribe(function ( isSame ) { @@ -53,25 +51,9 @@ define([ getData: function () { return { method: this.item.method, - additional_data: { - transaction_result: this.transactionResult(), - }, }; }, - getTransactionResults: function () { - var self = this; - return _.map( - window.checkoutConfig.payment[self.getCode()].transactionResults, - function (value, key) { - return { - value: key, - transaction_result: value, - }; - } - ); - }, - getMonduCheckoutTokenUrl: function () { var self = this; return window.checkoutConfig.payment[self.getCode()]