From 2720906bb166922f1dc3ac7e08c5ed22f6c81c0b Mon Sep 17 00:00:00 2001 From: feyzullah Demir <101548542+feyzullahdemir@users.noreply.github.com> Date: Tue, 16 May 2023 09:46:04 +0300 Subject: [PATCH] +new version --- .DS_Store | Bin 6148 -> 6148 bytes iyzico/.DS_Store | Bin 0 -> 6148 bytes iyzico/admin/controller/payment/iyzico.php | 4 +- iyzico/catalog/controller/payment/iyzico.php | 48 +++--- .../view/template/payment/iyzico_error.twig | 2 +- .../view/template/payment/iyzico_form.twig | 144 +----------------- iyzico/install.json | 2 +- 7 files changed, 27 insertions(+), 173 deletions(-) create mode 100644 iyzico/.DS_Store diff --git a/.DS_Store b/.DS_Store index fc6e0e19933e531eaf211d235ce70cba134a9042..d56cb8ce2e908803b86e4925d08ed7836c1bcb1a 100644 GIT binary patch delta 34 pcmZoMXffDe$;ikt*@`impOZ6QK%%S5Z-O8O({YS3Oz1(E!ajWh?fxS3mDOZN=;0u!I&*gY7eE5v%Zi|;`2DO zy8){?coMNQF#FB!%8hDvM6TvYm}HZ1kxj#- zVxqq|gx}s|_bgyJ=%??OA$Z=xX%c67ulLSt^~TnA(`s66>(+me3qKF?dFBPPYwTS} znS`YsgqQJnF|v10WtswpHY&**O;qJWKW2}EJgHCSi_ z4+z((fI5|%CkEH)FfL4-Yp~F$(-~JQ!#rl?^6|pe>M$-;IODEHYKZ}2V4Z=w?%H_% zpTRFv`N&^Sp&l_n4E!?&cw^`fJt)eYt>4PSvsQrKfudksfd&ZJYnK4%;6Bn(PVEload->controller('common/footer'); $data['locale'] = $this->language->get('code'); $data['iyzico_webhook_url_key'] = $this->config->get('webhook_iyzico_webhook_url_key'); - $data['iyzico_webhook_url'] = HTTP_CATALOG.'index.php?route=extension/iyzico/payment/iyzico|webhook&key=' .$this->config->get('webhook_iyzico_webhook_url_key'); + $data['iyzico_webhook_url'] = HTTP_CATALOG.'index.php?route=extension/iyzico/payment/iyzico%7Cwebhook&key=' .$this->config->get('webhook_iyzico_webhook_url_key'); $data['module_version'] = $this->module_product_name; $data['iyzico_webhook_button'] = $this->config->get('payment_iyzico_webhook_active_button'); diff --git a/iyzico/catalog/controller/payment/iyzico.php b/iyzico/catalog/controller/payment/iyzico.php index 879a5f4..91e3cb5 100644 --- a/iyzico/catalog/controller/payment/iyzico.php +++ b/iyzico/catalog/controller/payment/iyzico.php @@ -4,7 +4,7 @@ class iyzico extends \Opencart\System\Engine\Controller { private $module_version = VERSION; - private $module_product_name = '1.6'; + private $module_product_name = '2.0'; private $paymentConversationId; private $webhookToken; @@ -16,18 +16,15 @@ public function index() { $this->load->language('extension/iyzico/payment/iyzico'); - $data['form_class'] = $this->config->get('payment_iyzico_design'); - $data['form_type'] = $this->config->get('payment_iyzico_design'); - $data['config_theme'] = $this->config->get('config_theme'); - $data['onepage_desc'] = $this->language->get('iyzico_onepage_desc'); - - if($data['form_type'] == 'onepage') - $data['form_class'] = 'responsive'; + if (isset($this->session->data['order_id'])) { + //$this->cart->clear(); - $data['user_login_check'] = $this->customer->isLogged(); + unset($this->session->data['payment_method']); + unset($this->session->data['payment_methods']); + } - return $this->load->view('extension/iyzico/payment/iyzico_form',$data); + return $this->getCheckoutFormToken(); } @@ -85,7 +82,7 @@ public function getCheckoutFormToken() { $api_key = $this->config->get('payment_iyzico_api_key'); $secret_key = $this->config->get('payment_iyzico_secret_key'); - $payment_source = "OPENCART-4x-".$this->module_version."|".$this->module_product_name."|".$this->config->get('payment_iyzico_design'); + $payment_source = "OPENCART-4x-".$this->module_version."|".$this->module_product_name; $user_create_date = $this->model_extension_iyzico_payment_iyzico->getUserCreateDate($user_id); @@ -110,7 +107,7 @@ public function getCheckoutFormToken() { $iyzico->basketId = $order_id; $iyzico->paymentGroup = "PRODUCT"; $iyzico->forceThreeDS = "0"; - $iyzico->callbackUrl = $this->url->link('extension/iyzico/payment/iyzico|getCallBack', '', true); + $iyzico->callbackUrl = $this->url->link('extension/iyzico/payment/iyzico%7CgetCallBack', '', true); $iyzico->cardUserKey = $this->model_extension_iyzico_payment_iyzico->findUserCardKey($customer_id,$api_key); $iyzico->paymentSource = $payment_source; @@ -189,18 +186,16 @@ public function getCheckoutFormToken() { $form_response = $this->model_extension_iyzico_payment_iyzico->createFormInitializeRequest($iyzico_json,$authorization_data); - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($form_response)); + + $data['iyzico_redirect'] = $form_response->paymentPageUrl; + return $this->load->view('extension/iyzico/payment/iyzico_form',$data); + } public function getCallBack($webhook = null, $webhookPaymentConversationId = null ,$webhookToken = null) { - if(!isset($webhook) or !isset($webhookPaymentConversationId) or !isset($webhookToken)) - { - exit; - } try { @@ -254,6 +249,7 @@ public function getCallBack($webhook = null, $webhookPaymentConversationId = nul $request_response = $this->model_extension_iyzico_payment_iyzico->createFormInitializeDetailRequest($iyzico_json,$authorization_data); + if ($webhook == "webhook" && $webhookIyziEventType != 'CREDIT_PAYMENT_AUTH' && $request_response->status == 'failure'){ return $this->webhookHttpResponse("errorCode: ".$request_response->errorCode ." - " . $request_response->errorMessage, 404); } @@ -319,7 +315,7 @@ public function getCallBack($webhook = null, $webhookPaymentConversationId = nul $orderMessage = 'iyzico Banka Havale/EFT ödemesi bekleniyor.'; $this->setWebhookText(0); $this->model_checkout_order->addHistory($iyzico_local_order->order_id, $this->config->get('payment_iyzico_order_status'), $orderMessage); - return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico|successpage')); + return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico%7Csuccesspage')); } if($webhook != 'webhook' && $request_response->paymentStatus == 'PENDING_CREDIT' && $request_response->status == 'success') @@ -327,15 +323,13 @@ public function getCallBack($webhook = null, $webhookPaymentConversationId = nul $orderMessage = 'Alışveriş kredisi işlemi başlatıldı.'; $this->setWebhookText(1); $this->model_checkout_order->addHistory($iyzico_local_order->order_id, 1,$orderMessage); - return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico|successpage')); + return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico%7Csuccesspage')); } $this->setWebhookText(0); if($request_response->paymentStatus != 'SUCCESS' || $request_response->status != 'success' || $order_id != $request_response->basketId ) { - - /* Redirect Error */ - $errorMessage = isset($request_response->errorMessage) ? $request_response->errorMessage : $this->language->get('payment_failed'); - throw new \Exception($errorMessage); + echo '
Ödemeniz alınamadı.Anasayfaya yönlendirliyorsunuz.
'; + return $this->response->redirect($this->url->link('checkout/checkout')); } /* Save Card */ @@ -377,7 +371,7 @@ public function getCallBack($webhook = null, $webhookPaymentConversationId = nul return $this->webhookHttpResponse("Order Created by Webhook - Sipariş webhook tarafından oluşturuldu.", 200); } - return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico|successpage')); + return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico%7Csuccesspage')); } catch (Exception $e) { @@ -390,7 +384,7 @@ public function getCallBack($webhook = null, $webhookPaymentConversationId = nul $this->session->data['iyzico_error_message'] = $errorMessage; - return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico|errorpage')); + return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico%7Cerrorpage')); } @@ -410,7 +404,7 @@ public function errorPage() { $data['error_message'] = $this->session->data['iyzico_error_message']; $data['error_icon'] = 'catalog/view/theme/default/image/iyzico/payment/iyzico_error_icon.png'; - return $this->response->setOutput($this->load->view('extension/iyzico/payment/iyzico|iyzico_error', $data)); + return $this->response->setOutput($this->load->view('extension/iyzico/payment/iyzico%7Ciyzico_error', $data)); } diff --git a/iyzico/catalog/view/template/payment/iyzico_error.twig b/iyzico/catalog/view/template/payment/iyzico_error.twig index 0d2302a..723ceb2 100644 --- a/iyzico/catalog/view/template/payment/iyzico_error.twig +++ b/iyzico/catalog/view/template/payment/iyzico_error.twig @@ -1,6 +1,6 @@ {{ header }}
- +
{{ column_left }} {% if column_left and column_right %} {% set class = 'col-sm-6' %} diff --git a/iyzico/catalog/view/template/payment/iyzico_form.twig b/iyzico/catalog/view/template/payment/iyzico_form.twig index c284b1f..643f8d6 100644 --- a/iyzico/catalog/view/template/payment/iyzico_form.twig +++ b/iyzico/catalog/view/template/payment/iyzico_form.twig @@ -1,144 +1,4 @@ - -
-
-
-

iyzico

- {% if form_type == 'onepage' %} -
-

{{ onepage_desc }}

- {% endif %} - -
-
- - - + - -{% if form_type != 'onepage' %} - -{% elseif form_type == 'onepage' %} - - -{% endif %} diff --git a/iyzico/install.json b/iyzico/install.json index 77222c6..67baf4e 100644 --- a/iyzico/install.json +++ b/iyzico/install.json @@ -2,7 +2,7 @@ "name": "iyzico", "code": "iyzico", "license": "GPL", - "version": "1.6.0", + "version": "2.0.0", "author": "iyzico", "link": "https://www.iyzico.com/" }