From 28102ed240bdc642e6eaabc061390fd6c663b8b6 Mon Sep 17 00:00:00 2001 From: leon-zhang-awx Date: Mon, 23 Dec 2024 10:18:28 +0800 Subject: [PATCH] remove connection flow to release a bug fix --- .DS_Store | Bin 0 -> 6148 bytes Controller/.DS_Store | Bin 0 -> 6148 bytes Controller/Settings/Index.php | 125 --------------------------------- etc/adminhtml/system/basic.xml | 4 +- 4 files changed, 2 insertions(+), 127 deletions(-) create mode 100644 .DS_Store create mode 100644 Controller/.DS_Store delete mode 100644 Controller/Settings/Index.php diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d9844a7b2baf7a5d22bdc3d401849928688e139a GIT binary patch literal 6148 zcmeHK%}T>S5Z-O8O)NqW3Oz1(Em&>+!%Il(3mDOZN^NM+V9b^@HHT8jSzpK}@p+ut z-4sge!HbBU3A5ks{AAg0!%mhl#@)&AfU!Db%mPI$+0d*I^rJ3G$ygA%dPl+}i{J@Z zvJ_2*zsLaY-4^S@zQrtsU7PQppN&U;Bz^FI_@gKsr>)i}FO@4Bn^mi7)vSB(NoHO; zNGD@=klf>CP(J`27R7VFi`1^?d3L*;h z@h*WV3_1pLjo<;{Iu%f-a&yJtIvwo7#5o3YjXIriH8Z@&%*@RVg{#@YE>t+0^$ss!u;JAjVCTq9UO=tn@&Kn*eQs|^ z=Lt=r)dH~H>+uHI02t_wc=xb0zwf@VtI8OW&NJ>Y;e_Y6@o8FAUrso8z=%7%@cPDo zc$`jo?q#B~Qa}nw0VyB_q`xb^G)pQmsa7L~C7tlkp|1kfbleCipQs7@HVC((3-|>~Iw=Q1Jdu^j1=w9(T=(C fcD#+EtZTmJ{a!dH2A%n!6ZJFTy2zx!Un}ql{3R8e literal 0 HcmV?d00001 diff --git a/Controller/Settings/Index.php b/Controller/Settings/Index.php deleted file mode 100644 index 15523bb..0000000 --- a/Controller/Settings/Index.php +++ /dev/null @@ -1,125 +0,0 @@ -response = $response; - $this->configWriter = $configWriter; - $this->request = $request; - $this->cache = $cache; - $this->configuration = $configuration; - $this->cacheManager = $cacheManager; - } - - /** - * @return ResponseHttp - * @throws Exception - */ - public function execute(): ResponseHttp - { - $data = json_decode($this->request->getContent(), true); - $tokenFromCache = $this->cache->load(SetUpdateSettingsMessage::CACHE_NAME); - $this->cache->remove(SetUpdateSettingsMessage::CACHE_NAME); - - $signature = $this->request->getHeader('x-signature'); - if (!$signature) { - return $this->error('Signature id is required.'); - } - $ts = $this->request->getHeader('x-timestamp') . $this->request->getContent(); - if (hash_hmac('sha256', $ts, $tokenFromCache) !== $signature) { - return $this->error('Signature id is invalid.'); - } - - $clientId = $data['client_id']; - $apiKey = $data['api_key']; - $webhookKey = $data['webhook_secret']; - $accountId = $data['account_id']; - $accountName = $data['account_name']; - if (empty($clientId)) { - return $this->error('Client ID is required.'); - } - if (empty($apiKey)) { - return $this->error('API Key is required.'); - } - if (empty($webhookKey)) { - return $this->error('Webhook Key is required.'); - } - if (empty($accountId)) { - return $this->error('Account id is required.'); - } - if (empty($accountName)) { - return $this->error('Account name is required.'); - } - $encryptor = ObjectManager::getInstance()->get(EncryptorInterface::class); - $mode = substr($tokenFromCache, 0, 4) === 'demo' ? 'demo' : 'prod'; - $account = $this->configuration->getAccount(); - $arrAccount = $account ? json_decode($account, true) : []; - $arrAccount[$mode . '_account_id'] = $accountId; - $arrAccount[$mode . '_account_name'] = $accountName; - $this->configWriter->save('airwallex/general/' . 'account', json_encode($arrAccount)); - $this->configWriter->save('airwallex/general/' . $mode . '_account_name', $accountName); - $this->configWriter->save('airwallex/general/' . $mode . '_client_id', $clientId); - $this->configWriter->save('airwallex/general/' . $mode . '_api_key', $encryptor->encrypt($apiKey)); - $this->configWriter->save('airwallex/general/webhook_' . $mode . '_secret_key', $encryptor->encrypt($webhookKey)); - $this->configWriter->save('airwallex/general/mode', $mode); - $this->cacheManager->flush(['config']); - $this->response->setBody(json_encode(['success' => true])); - return $this->response->setStatusCode(self::HTTP_OK); - } - - /** - * @throws Exception - */ - public function error(string $message) - { - throw new Exception($message); - } - - public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException - { - return null; - } - - /** - * @param RequestInterface $request - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * - * @return bool|null - */ - public function validateForCsrf(RequestInterface $request): ?bool - { - return true; - } -} diff --git a/etc/adminhtml/system/basic.xml b/etc/adminhtml/system/basic.xml index 5f5dfc9..2a02748 100644 --- a/etc/adminhtml/system/basic.xml +++ b/etc/adminhtml/system/basic.xml @@ -7,9 +7,9 @@ Airwallex\Payments\Model\Config\Source\Mode airwallex/general/mode - + airwallex/general/demo_client_id