diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..ed4c8c3 Binary files /dev/null and b/.DS_Store differ diff --git a/iyzico.ocmod.zip b/iyzico.ocmod.zip new file mode 100644 index 0000000..fc34915 Binary files /dev/null and b/iyzico.ocmod.zip differ diff --git a/iyzico/.DS_Store b/iyzico/.DS_Store new file mode 100644 index 0000000..533e957 Binary files /dev/null and b/iyzico/.DS_Store differ diff --git a/iyzico/admin/.DS_Store b/iyzico/admin/.DS_Store new file mode 100644 index 0000000..eee835f Binary files /dev/null and b/iyzico/admin/.DS_Store differ diff --git a/iyzico/admin/controller/.DS_Store b/iyzico/admin/controller/.DS_Store new file mode 100644 index 0000000..a0d8f30 Binary files /dev/null and b/iyzico/admin/controller/.DS_Store differ diff --git a/iyzico/admin/controller/payment/.DS_Store b/iyzico/admin/controller/payment/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/iyzico/admin/controller/payment/.DS_Store differ diff --git a/iyzico/admin/controller/payment/iyzico.php b/iyzico/admin/controller/payment/iyzico.php new file mode 100644 index 0000000..f0c78dd --- /dev/null +++ b/iyzico/admin/controller/payment/iyzico.php @@ -0,0 +1,416 @@ + 'error_api_channel', + 'name' => 'payment_iyzico_api_channel', + ), + array( + 'validateField' => 'blank', + 'name' => 'payment_iyzico_api_url', + ), + array( + 'validateField' => 'error_api_key', + 'name' => 'payment_iyzico_api_key', + ), + array( + 'validateField' => 'error_secret_key', + 'name' => 'payment_iyzico_secret_key', + ), + array( + 'validateField' => 'error_design', + 'name' => 'payment_iyzico_design', + ), + array( + 'validateField' => 'error_language', + 'name' => 'payment_iyzico_language', + ), + array( + 'validateField' => 'error_order_status', + 'name' => 'payment_iyzico_order_status', + ), + array( + 'validateField' => 'error_cancel_order_status', + 'name' => 'payment_iyzico_order_cancel_status', + ), + array( + 'validateField' => 'blank', + 'name' => 'payment_iyzico_status', + ), + array( + 'validateField' => 'blank', + 'name' => 'payment_iyzico_sort_order', + ), + array( + 'validateField' => 'error_title', + 'name' => 'payment_iyzico_title', + ), + array( + 'validateField' => 'blank', + 'name' => 'payment_iyzico_order_status_id', + ), + array( + 'validateField' => 'blank', + 'name' => 'payment_iyzico_webhook_text', + ), + array( + 'validateField' => 'blank', + 'name' => 'payment_iyzico_overlay_token', + ), + array( + 'validateField' => 'blank', + 'name' => 'payment_iyzico_overlay_status', + ), + array( + 'validateField' => 'blank', + 'name' => 'webhook_iyzico_webhook_url_key', + ) + ); + + + /** + * iyzico extension: index methods + * + * @return void + */ + public function index(): void + { + # Load Language + $this->load->language('extension/iyzico/payment/iyzico'); + + # Load Settings Model + $this->load->model('setting/setting'); + + # Load User Model + $this->load->model('user/user'); + + # Load Order Status Model + $this->load->model('localisation/order_status'); + + # Load Model + $this->load->model('extension/iyzico/payment/iyzico'); + + # Set Webhook Url + $this->setWebookUrl(); + + # Set Webhook Button + $this->setWebookButton(); + + # Set Webhook Update + $this->setWebhookUpdate(); + + foreach ($this->fields as $key => $field) { + if (isset($this->error[$field['validateField']])) + $data[$field['validateField']] = $this->error[$field['validateField']]; + else + $data[$field['validateField']] = ''; + + if (isset($this->request->post[$field['name']])) + $data[$field['name']] = $this->request->post[$field['name']]; + else + $data[$field['name']] = $this->config->get($field['name']); + + } + + # Get Title + $title = $this->language->get('heading_title'); + + # Set Title + $this->document->setTitle($title); + + # Install Status + $data['install_status'] = $this->installStatus(); + + # Set Order Statues + $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); + + # Button Links + $data['action'] = $this->url->link('extension/iyzico/payment/iyzico.save', 'user_token=' . $this->session->data['user_token'], true); + $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment'); + + # Admin Page Options + $data['heading_title'] = $title; + $data['header'] = $this->load->controller('common/header'); + $data['column_left'] = $this->load->controller('common/column_left'); + $data['footer'] = $this->load->controller('common/footer'); + $data['locale'] = $this->language->get('code'); + $data['breadcrumbs'] = $this->createBreadcrumbs(); + + # iyzico Options + $data['iyzico_webhook_url'] = HTTP_CATALOG . 'index.php?route=extension/iyzico/payment/iyzico.webhook&key=' . $this->config->get('webhook_iyzico_webhook_url_key'); + $data['module_version'] = $this->module_product_name; + $data['copy_clipboard_text'] = $this->language->get('copy_clipboard_text'); + + $this->response->setOutput($this->load->view('extension/iyzico/payment/iyzico', $data)); + } + + /** + * iyzico extension: save methods + * + * @return void + */ + public function save(): void + { + # Load Language + $this->load->language('extension/iyzico/payment/iyzico'); + + # Load Model + $this->load->model('extension/iyzico/payment/iyzico'); + + # Check Permission + if (!$this->user->hasPermission('modify', 'extension/iyzico/payment/iyzico')) + $this->error['warning'] = $this->language->get('error_permission'); + + # Validate + $this->validate(); + + $formRequest = $this->request->post; + + # Check payment_iyzico_api_channel + if($formRequest['payment_iyzico_api_channel'] == 'sandbox') + $formRequest['payment_iyzico_api_url'] = 'https://sandbox-api.iyzipay.com'; + else + $formRequest['payment_iyzico_api_url'] = 'https://api.iyzipay.com'; + + $json = []; + if (!$this->error) { + $this->load->model('setting/setting'); + $this->model_setting_setting->editSetting('payment_iyzico', $formRequest); + $json['success'] = $this->language->get('text_success'); + } else { + $json['error'] = $this->error; + } + + $data['test_Error'] = "test hata"; + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($json)); + } + + + /** + * iyzico extension: install methods + * + * @return void + */ + public function install(): void + { + # Load Model + $this->load->model('setting/setting'); + + # Load Model + $this->load->model('extension/iyzico/payment/iyzico'); + + + foreach ($this->fields as $key => $field) { + if (isset($this->error[$field['validateField']])) + $data[$field['validateField']] = $this->error[$field['validateField']]; + else + $data[$field['validateField']] = ''; + + if (isset($this->request->post[$field['name']])) + $data[$field['name']] = $this->request->post[$field['name']]; + else + $data[$field['name']] = $this->config->get($field['name']); + } + + # Set Webhook Url + $this->setWebhookUpdate(); + + # Install + $this->model_extension_iyzico_payment_iyzico->install(); + + # Install Events + $this->__registerEvents(); + + # Set Settings + $this->model_setting_setting->editSetting('payment_iyzico', $data); + } + + /** + * iyzico extension: uninstall methods + * + * @return void + */ + public function uninstall(): void + { + # Load Model + $this->load->model('setting/setting'); + + # Load Model + $this->load->model('extension/iyzico/payment/iyzico'); + + # Delete Settings + $this->db->query("DELETE FROM " . DB_PREFIX . "setting WHERE store_id = '0' AND code = 'payment_iyzico_webhook'"); + + # Uninstall + $this->model_extension_iyzico_payment_iyzico->uninstall(); + + # Delete Settings + $this->model_setting_setting->deleteSetting('payment_iyzico'); + } + + /** + * iyzico extension: validate methods + * + * @return bool + */ + protected function validate() + { + foreach ($this->fields as $field) { + if ($field['validateField'] != 'blank') { + if (!$this->request->post[$field['name']]) { + $this->error[$field['validateField']] = $this->language->get($field['validateField']); + } + } + } + + return !$this->error; + } + + + /** + * iyzico extension: setWebookUrl methods + * + * @return bool + */ + private function setWebookUrl(): bool + { + + $getWebhookUrlKey = $this->config->get('webhook_iyzico_webhook_url_key'); + $generateUrlId = substr(base64_encode(time() . mt_rand()), 15, 6); + + if (!$getWebhookUrlKey) + $this->model_setting_setting->editSetting('webhook_iyzico', array("webhook_iyzico_webhook_url_key" => $generateUrlId)); + + return true; + } + + /** + * iyzico extension: installStatus methods + * + * @return int + */ + private function installStatus(): int + { + $counter = 0; + foreach ($this->fields as $key => $field) { + $data[$field['name']] = $this->config->get($field['name']); + if (!empty($this->config->get($field['name']))) + $counter++; + } + return $counter; + } + + /** + * iyzico extension: setWebookButton methods + * + * @return void + */ + private function setWebookButton(): void + { + $webhookActive = $this->config->get('payment_iyzico_webhook_active_button'); + if (empty($webhookActive)) + $this->db->query("INSERT INTO `" . DB_PREFIX . "setting` (`code`, `key`, `value`, `serialized`) VALUES ('payment_iyzico_webhook','payment_iyzico_webhook_active_button', '1' ,'0');"); + } + + /** + * iyzico extension: setWebhookUpdate methods + * + * @return void + */ + private function setWebhookUpdate(): void + { + + $configWebhookStatus = $this->config->get('payment_iyzico_webhook_active_button'); + $configApikey = $this->config->get('payment_iyzico_api_key'); + $configSecretKey = $this->config->get('payment_iyzico_secret_key'); + + if (isset($configApikey) && isset($configSecretKey)) { + if ($configWebhookStatus == 1) { + $webhookPost = new stdClass(); + $webhookPost->webhookUrl = HTTP_CATALOG . 'index.php?route=extension/payment/iyzico.webhook&key=' . $this->config->get('webhook_iyzico_webhook_url_key'); + + $webhookPki = $this->model_extension_iyzico_payment_iyzico->pkiStringGenerate($webhookPost); + $authorizationData = $this->model_extension_iyzico_payment_iyzico->authorizationGenerate($configApikey, $configSecretKey, $webhookPki); + $requestResponseWebhook = $this->model_extension_iyzico_payment_iyzico->iyzicoPostWebhookUrlKey($authorizationData, $webhookPost); + + if(isset($requestResponseWebhook->merchantNotificationUpdateStatus)){ + if ($requestResponseWebhook->merchantNotificationUpdateStatus == 'UPDATED' || $requestResponseWebhook->merchantNotificationUpdateStatus == 'CREATED') + $this->model_setting_setting->editSetting('payment_iyzico_webhook', array("payment_iyzico_webhook_active_button" => 2)); + else + $this->model_setting_setting->editSetting('payment_iyzico_webhook', array("payment_iyzico_webhook_active_button" => 3)); + } + } + } + } + + /** + * iyzico extension: createBreadcrumbs methods + * + * @return array + */ + protected function createBreadcrumbs(): array + { + return array( + array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) + ), + array( + 'text' => $this->language->get('text_extension'), + 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) + ), + array( + 'text' => $this->language->get('heading_title'), + 'href' => $this->url->link('extension/iyzico/payment/iyzico', 'user_token=' . $this->session->data['user_token'], true) + ) + ); + } + + /** + * iyzico extension: __registerEvents methods + * + * @return void + */ + protected function __registerEvents(): void + { + + // events array + $events = array(); + + $events[] = array( + 'code' => "overlay_script", + 'trigger' => "catalog/controller/common/footer/after", + 'action' => "extension/iyzico/payment/iyzico.injectOverlayScript", + 'description' => "Injecting overlay script", + 'status' => 1, + 'sort_order' => 1, + ); + + $events[] = array( + 'code' => "module_notification", + 'trigger' => "admin/controller/common/footer/after", + 'action' => "extension/iyzico/payment/iyzico.injectModuleNotification", + 'description' => "Injecting module notification", + 'status' => 1, + 'sort_order' => 1, + ); + + $this->load->model('setting/event'); + foreach ($events as $event) { + $this->model_setting_event->addEvent($event); + } + } +} diff --git a/iyzico/admin/language/.DS_Store b/iyzico/admin/language/.DS_Store new file mode 100644 index 0000000..6dfe615 Binary files /dev/null and b/iyzico/admin/language/.DS_Store differ diff --git a/iyzico/admin/language/en-gb/.DS_Store b/iyzico/admin/language/en-gb/.DS_Store new file mode 100644 index 0000000..9839ef8 Binary files /dev/null and b/iyzico/admin/language/en-gb/.DS_Store differ diff --git a/iyzico/admin/language/en-gb/payment/.DS_Store b/iyzico/admin/language/en-gb/payment/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/iyzico/admin/language/en-gb/payment/.DS_Store differ diff --git a/iyzico/admin/language/en-gb/payment/iyzico.php b/iyzico/admin/language/en-gb/payment/iyzico.php new file mode 100644 index 0000000..addb5e7 --- /dev/null +++ b/iyzico/admin/language/en-gb/payment/iyzico.php @@ -0,0 +1,75 @@ +iyzico'; +$_['general_select'] = 'Select'; +$_['live'] = 'Live'; +$_['sandbox'] = 'Sandbox / Test'; +$_['api_field'] = 'API Type'; +$_['api_field_tooltip'] = 'API Type Live or Sandbox'; +$_['api_key'] = 'API Key'; +$_['secret_key'] = 'Secret Key'; +$_['apikey_field_tooltip'] = 'Your API key with including 32 digit letter and number.'; +$_['secretkey_field_tooltip'] = 'Your Secret Key with including 32 digit letter and number.'; +$_['view_select'] = 'Design'; +$_['payment_iyzico_language_name'] = 'Checkout language'; +$_['order_status'] = 'Order Status'; +$_['cancel_order_status'] = 'Cancel Order Status'; +$_['order_status_tooltip'] = 'New ordering status info'; +$_['cancel_order_status_tooltip'] = 'Cancel ordering status info'; +$_['extension_status'] = 'Extension Status'; +$_['sort_order'] = 'Order'; +$_['error_api_channel'] = 'Api Channel Required!'; +$_['error_api_key'] = 'Api Key Required!'; +$_['error_secret_key'] = 'Secret Key Required!'; +$_['text_success'] = 'Iyzico Payment Extension: Updated Success!'; +$_['valid_live'] = 'Sandbox API key information is unusable for Live API'; +$_['valid_sandbox'] = 'Live API key information is unusable for Sandbox API'; +$_['install'] = 'Install'; +$_['help'] = 'Help'; +$_['settings'] = 'Settings'; +$_['settings_content'] = 'I Hope everything is okay'; +$_['install_title'] = 'Install Title'; +$_['install_hello'] = 'Hello'; +$_['support'] = 'Support'; +$_['install_content'] = 'Welcome to iyzico Opencart install screen.
Live:         https://merchant.iyzipay.com
+ Sandbox:   https://sandbox-merchant.iyzipay.com

+ Help detail Help is click.'; +$_['payment_title'] = 'Payment Value'; +$_['api_connection'] = 'Api Connection:'; +$_['api_connection_success'] = 'Success'; +$_['api_connection_failed'] = 'Failed'; +$_['api_connection_failed_content'] = 'Opss.. Help detail Help is click.'; +$_['buyer_protection'] = 'Buyer Protection'; +$_['overlay_design'] = 'Design:'; +$_['overlay_bottom_left'] = 'Bottom Left'; +$_['overlay_bottom_left_val'] = 'bottomLeft'; +$_['overlay_bottom_right'] = 'Bottom Right'; +$_['overlay_bottom_right_val'] = 'bottomRight'; +$_['overlay_closed'] = 'Hidden'; +$_['overlay_closed_val'] = 'hidden'; +$_['iyzico_update_screen'] = 'IYZICO UPDATE SCREEN'; +$_['current_version_name'] = 'Old Version:'; +$_['new_version_name'] = 'New Version:'; +$_['description_name'] = 'Description:'; +$_['iyzico_webhook'] = 'Webhook Integration'; +$_['webhook_url_description'] = "Don't forget to do webhook Integration."; +$_['iyzico_webhook_url_key_error'] = "Webhook URL Error! Please, try these steps respectively. 1- Refresh web page 1-2 times. 2- If webhook url doesn't create , Please, after delete the iyzico plugin, re-install the iyzico plugin and save module settings. 3- Send an email to entegrasyon@iyzico.com"; + +$_['pwi_status_error'] = "Pay with iyzico module is not enable!"; +$_['pwi_status_error_detail'] = "You can not access Settings of iyzico Checkout Form Module without installing the pay with iyzico module."; +$_['dev_iyzipay_opencart_link'] = "https://dev.iyzipay.com/tr/acik-kaynak/opencart"; +$_['dev_iyzipay_detail'] = "Complete the installation of the Opencart 4.x - Pay with iyzico module via dev.iyzipay:"; + +$_['checkout_language_automatic'] = 'Automatic'; +$_['checkout_language_turkish'] = 'Turkish'; +$_['checkout_language_english'] = 'English'; + +$_['admin_active_button'] = 'Active'; +$_['text_extension'] = 'Extensions'; +$_['breadcrumb_heading_title'] = 'iyzico Module Settings'; +$_['copy_clipboard_text'] = 'Copy to Clipboard: '; +$_['error_design'] = 'Design Required!'; + +$_['text_info_label'] = '  If you have problems, please contact.  entegrasyon@iyzico.com'; diff --git a/iyzico/admin/language/tr-tr/.DS_Store b/iyzico/admin/language/tr-tr/.DS_Store new file mode 100644 index 0000000..942b022 Binary files /dev/null and b/iyzico/admin/language/tr-tr/.DS_Store differ diff --git a/iyzico/admin/language/tr-tr/payment/.DS_Store b/iyzico/admin/language/tr-tr/payment/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/iyzico/admin/language/tr-tr/payment/.DS_Store differ diff --git a/upload/admin/language/tr-tr/extension/payment/iyzico.php b/iyzico/admin/language/tr-tr/payment/iyzico.php old mode 100755 new mode 100644 similarity index 67% rename from upload/admin/language/tr-tr/extension/payment/iyzico.php rename to iyzico/admin/language/tr-tr/payment/iyzico.php index bead9b6..16370e2 --- a/upload/admin/language/tr-tr/extension/payment/iyzico.php +++ b/iyzico/admin/language/tr-tr/payment/iyzico.php @@ -1,8 +1,8 @@ iyzico'; +$_['heading_title'] = 'iyzico Ödeme Formu'; +$_['text_iyzico'] = 'iyzico'; $_['general_select'] = 'Seçiniz'; $_['live'] = 'Live'; $_['sandbox'] = 'Sandbox / Test'; @@ -13,6 +13,7 @@ $_['apikey_field_tooltip'] = 'iyzico panelinizin ayarlar bölümünden erişebileceğiniz api anahtarı'; $_['secretkey_field_tooltip'] = 'iyzico panelinizin ayarlar bölümünden erişebileceğiniz güvenlik api anahtarı'; $_['view_select'] = 'Görünüm'; +$_['payment_iyzico_language_name'] = 'Ödeme Formu Dili'; $_['design_field_tooltip'] = 'Ödeme formunuzun görünümü'; $_['order_status'] = 'Sipariş Durumu'; $_['order_status_tooltip'] = 'Sipariş alındığında müşteriye gösterilecek durum bilgisi'; @@ -53,4 +54,23 @@ $_['iyzico_update_screen'] = 'İYZİCO GÜNCELLEME EKRANI'; $_['current_version_name'] = 'Mevcur Sürümünüz:'; $_['new_version_name'] = 'Yeni Sürümünüz:'; -$_['description_name'] = 'Açıklama:'; \ No newline at end of file +$_['description_name'] = 'Açıklama:'; +$_['iyzico_webhook'] = 'Webhook Entegrasyonu'; +$_['webhook_url_description'] = "Webhook entegrasyonunu yapmayı unutmayınız."; +$_['iyzico_webhook_url_key_error'] = "Webhook URL üretilemedi. Lütfen sırasıyla bu adımları deneyin. 1- Web sayfasını 1-2 defa yenileyin. 2- Webhook URL üretilmediyse lütfen plugini kaldırıp, yeniden kurun ve ayarları kaydedin. 3- Sorun devam ederse entegrasyon@iyzico.com'a mail atınız."; + +$_['pwi_status_error'] = "iyzico İle Öde modülü aktif değil!"; +$_['pwi_status_error_detail'] = "iyzico ile Öde modülünü kurmadan iyzico Ödeme Formu ayarlarına erişemezsiniz."; +$_['dev_iyzipay_opencart_link'] = "https://dev.iyzipay.com/tr/acik-kaynak/opencart"; +$_['dev_iyzipay_detail'] = "Opencart 4.x - iyzico ile Öde modülünün kurulumunu tamamlayınız: "; +$_['checkout_language_automatic'] = 'Otomatik'; +$_['checkout_language_turkish'] = 'Türkçe'; +$_['checkout_language_english'] = 'İngilizce'; + +$_['admin_active_button'] = 'Aktifleştir'; +$_['text_extension'] = 'Eklentiler'; +$_['breadcrumb_heading_title'] = 'iyzico Modül Ayarları'; +$_['copy_clipboard_text'] = 'Panoya Kopyalandı: '; +$_['error_design'] = 'Görünüm Gerekli!'; + +$_['text_info_label'] = '  Problem yaşıyorsanız iletişime geçiniz.  entegrasyon@iyzico.com'; diff --git a/iyzico/admin/model/.DS_Store b/iyzico/admin/model/.DS_Store new file mode 100644 index 0000000..942b022 Binary files /dev/null and b/iyzico/admin/model/.DS_Store differ diff --git a/iyzico/admin/model/payment/.DS_Store b/iyzico/admin/model/payment/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/iyzico/admin/model/payment/.DS_Store differ diff --git a/iyzico/admin/model/payment/iyzico.php b/iyzico/admin/model/payment/iyzico.php new file mode 100644 index 0000000..c2ea0b7 --- /dev/null +++ b/iyzico/admin/model/payment/iyzico.php @@ -0,0 +1,183 @@ +db->query(" + CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "iyzico_order` ( + `iyzico_order_id` INT(11) NOT NULL AUTO_INCREMENT, + `payment_id` INT(11) NOT NULL, + `order_id` INT(11) NOT NULL, + `total_amount` DECIMAL( 10, 2 ) NOT NULL, + `status` VARCHAR(20) NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`iyzico_order_id`) + ) ENGINE=MyISAM DEFAULT COLLATE=utf8_general_ci;"); + + $this->db->query(" + CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "iyzico_card` ( + `iyzico_card_id` INT(11) NOT NULL AUTO_INCREMENT, + `customer_id` INT(11) NOT NULL, + `card_user_key` VARCHAR(50), + `api_key` VARCHAR(50), + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`iyzico_card_id`) + ) ENGINE=MyISAM DEFAULT COLLATE=utf8_general_ci;"); + } + + public function uninstall() + { + $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "iyzico_order`;"); + $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "iyzico_card`;"); + } + + public function pkiStringGenerate($objectData) + { + $pki_value = "["; + foreach ($objectData as $key => $data) { + if (is_object($data)) { + $name = var_export($key, true); + $name = str_replace("'", "", $name); + $pki_value .= $name . "=["; + $end_key = count(get_object_vars($data)); + $count = 0; + foreach ($data as $key => $value) { + $count++; + $name = var_export($key, true); + $name = str_replace("'", "", $name); + $pki_value .= $name . "=" . "" . $value; + if ($end_key != $count) + $pki_value .= ","; + } + $pki_value .= "]"; + } else if (is_array($data)) { + $name = var_export($key, true); + $name = str_replace("'", "", $name); + $pki_value .= $name . "=["; + $end_key = count($data); + $count = 0; + foreach ($data as $key => $result) { + $count++; + $pki_value .= "["; + + foreach ($result as $key => $item) { + $name = var_export($key, true); + $name = str_replace("'", "", $name); + + $pki_value .= $name . "=" . "" . $item; + $reResult = (array) $result; + $newResult = $reResult[array_key_last($reResult)]; + + if ($newResult != $item) { + $pki_value .= ","; + } + + if ($newResult == $item) { + + if ($end_key != $count) { + $pki_value .= "], "; + } else { + $pki_value .= "]"; + } + } + } + } + + $reData = (array) $data; + $newData = $reData[array_key_last($reData)]; + if ($newData == $result) + $pki_value .= "]"; + } else { + $name = var_export($key, true); + $name = str_replace("'", "", $name); + + $pki_value .= $name . "=" . "" . $data . ""; + } + + $reObjectData = (array) $objectData; + $newobjectData = $reObjectData[array_key_last($reObjectData)]; + + if ($newobjectData != $data) + $pki_value .= ","; + } + $pki_value .= "]"; + return $pki_value; + } + + public function authorizationGenerate($api_key, $secret_key, $pki) + { + + $rand_value = rand(100000, 99999999); + $hash_value = $api_key . $rand_value . $secret_key . $pki; + $hash = base64_encode(sha1($hash_value, true)); + + $authorization = 'IYZWS ' . $api_key . ':' . $hash; + + $authorization_data = array( + 'authorization' => $authorization, + 'rand_value' => $rand_value + ); + + return $authorization_data; + } + + public function apiConnection($authorization_data, $api_connection_object) + { + + $url = $this->config->get('payment_iyzico_api_url'); + $url = $url . '/payment/bin/check'; + + $api_connection_object = json_encode($api_connection_object); + + return $this->curlPost($api_connection_object, $authorization_data, $url); + + } + + public function iyzicoPostWebhookUrlKey($authorization_data, $webhook_active_post) + { + + $url = $this->config->get('payment_iyzico_api_url'); + $url = $url . '/payment/notification/update'; + + $webhook_active_post = json_encode($webhook_active_post); + + return $this->curlPost($webhook_active_post, $authorization_data, $url); + + } + + public function curlPost($json, $authorizationData, $url) + { + + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + if ($json) { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); + curl_setopt($curl, CURLOPT_POSTFIELDS, $json); + } + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); + curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE); + curl_setopt($curl, CURLOPT_TIMEOUT, 10); + + curl_setopt( + $curl, + CURLOPT_HTTPHEADER, + array( + "Authorization: " . $authorizationData['authorization'], + "x-iyzi-rnd:" . $authorizationData['rand_value'], + "Content-Type: application/json", + ) + ); + + $result = json_decode(curl_exec($curl)); + curl_close($curl); + + + return $result; + } + +} diff --git a/iyzico/admin/view/.DS_Store b/iyzico/admin/view/.DS_Store new file mode 100644 index 0000000..cfa567f Binary files /dev/null and b/iyzico/admin/view/.DS_Store differ diff --git a/iyzico/admin/view/image/.DS_Store b/iyzico/admin/view/image/.DS_Store new file mode 100644 index 0000000..ba8286f Binary files /dev/null and b/iyzico/admin/view/image/.DS_Store differ diff --git a/iyzico/admin/view/image/payment/iyzico_cards.png b/iyzico/admin/view/image/payment/iyzico_cards.png new file mode 100644 index 0000000..bc64854 Binary files /dev/null and b/iyzico/admin/view/image/payment/iyzico_cards.png differ diff --git a/iyzico/admin/view/image/payment/iyzico_logo.png b/iyzico/admin/view/image/payment/iyzico_logo.png new file mode 100644 index 0000000..e9d57a7 Binary files /dev/null and b/iyzico/admin/view/image/payment/iyzico_logo.png differ diff --git a/iyzico/admin/view/javascript/.DS_Store b/iyzico/admin/view/javascript/.DS_Store new file mode 100644 index 0000000..a8ce148 Binary files /dev/null and b/iyzico/admin/view/javascript/.DS_Store differ diff --git a/iyzico/admin/view/javascript/iyzico/.DS_Store b/iyzico/admin/view/javascript/iyzico/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/iyzico/admin/view/javascript/iyzico/.DS_Store differ diff --git a/upload/admin/view/javascript/iyzico/accordion_iyzico.js b/iyzico/admin/view/javascript/iyzico/accordion_iyzico.js old mode 100755 new mode 100644 similarity index 100% rename from upload/admin/view/javascript/iyzico/accordion_iyzico.js rename to iyzico/admin/view/javascript/iyzico/accordion_iyzico.js diff --git a/iyzico/admin/view/javascript/iyzico/validation_iyzico.js b/iyzico/admin/view/javascript/iyzico/validation_iyzico.js new file mode 100644 index 0000000..91b2163 --- /dev/null +++ b/iyzico/admin/view/javascript/iyzico/validation_iyzico.js @@ -0,0 +1 @@ +function getApiValid(){var e,n,t;return event.preventDefault(),e=document.getElementById("api_channel").value,n=document.getElementById("api_key").value,t=document.getElementById("api_key").value,"live"==e?l(n,t):"sandbox"==e?s(n,t):(alert("Geçersiz istek."),!1)}function l(e,n){if("sandbox-"==e.substring(0,8)||"sandbox-"==n.substring(0,8))return alert("{{valid_live}}"),!1}function s(e,n){if("sandbox-"!=e.substring(0,8)||"sandbox-"!=n.substring(0,8))return alert("{{valid_sandbox}}"),!1} diff --git a/iyzico/admin/view/stylesheet/.DS_Store b/iyzico/admin/view/stylesheet/.DS_Store new file mode 100644 index 0000000..a8ce148 Binary files /dev/null and b/iyzico/admin/view/stylesheet/.DS_Store differ diff --git a/upload/admin/view/stylesheet/iyzico/iyzico.css b/iyzico/admin/view/stylesheet/iyzico/iyzico.css old mode 100755 new mode 100644 similarity index 100% rename from upload/admin/view/stylesheet/iyzico/iyzico.css rename to iyzico/admin/view/stylesheet/iyzico/iyzico.css diff --git a/iyzico/admin/view/template/.DS_Store b/iyzico/admin/view/template/.DS_Store new file mode 100644 index 0000000..7147f7f Binary files /dev/null and b/iyzico/admin/view/template/.DS_Store differ diff --git a/iyzico/admin/view/template/payment/.DS_Store b/iyzico/admin/view/template/payment/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/iyzico/admin/view/template/payment/.DS_Store differ diff --git a/iyzico/admin/view/template/payment/iyzico.twig b/iyzico/admin/view/template/payment/iyzico.twig new file mode 100644 index 0000000..f35ad43 --- /dev/null +++ b/iyzico/admin/view/template/payment/iyzico.twig @@ -0,0 +1,301 @@ +{{ header }} +{{ column_left }} +
+ +
+
+
+ + {{heading_title}} + - v{{module_version}} +
+
+
+ +
+
+ {% if payment_iyzico_status != 1 %} +
+
+ {{text_info_label}} +
+
+ {% endif %} +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ {% if payment_iyzico_title %} + + {% else %} + + {% endif %} +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + +
+
+
+ +
+ +
+ +
+
+ +
+ + + +
+
+
+
+
+
+ +{{ footer }} diff --git a/iyzico/catalog/.DS_Store b/iyzico/catalog/.DS_Store new file mode 100644 index 0000000..2a57a4b Binary files /dev/null and b/iyzico/catalog/.DS_Store differ diff --git a/iyzico/catalog/controller/.DS_Store b/iyzico/catalog/controller/.DS_Store new file mode 100644 index 0000000..9839ef8 Binary files /dev/null and b/iyzico/catalog/controller/.DS_Store differ diff --git a/iyzico/catalog/controller/payment/.DS_Store b/iyzico/catalog/controller/payment/.DS_Store new file mode 100644 index 0000000..22f7a4b Binary files /dev/null and b/iyzico/catalog/controller/payment/.DS_Store differ diff --git a/iyzico/catalog/controller/payment/iyzico.php b/iyzico/catalog/controller/payment/iyzico.php new file mode 100644 index 0000000..2f2108c --- /dev/null +++ b/iyzico/catalog/controller/payment/iyzico.php @@ -0,0 +1,701 @@ +load->language('extension/iyzico/payment/iyzico'); + return $this->getCheckoutFormToken(); + } + + private function setcookieSameSite($name, $value, $expire, $path, $domain, $secure, $httponly) + { + + if (PHP_VERSION_ID < 70300) { + + setcookie($name, $value, $expire, "$path; samesite=None", $domain, $secure, $httponly); + } else { + setcookie($name, $value, [ + 'expires' => $expire, + 'path' => $path, + 'domain' => $domain, + 'samesite' => 'None', + 'secure' => $secure, + 'httponly' => $httponly + ]); + + + } + } + + private function checkAndSetCookieSameSite() + { + + $checkCookieNames = array('PHPSESSID', 'OCSESSID', 'default', 'PrestaShop-', 'wp_woocommerce_session_'); + + foreach ($_COOKIE as $cookieName => $value) { + foreach ($checkCookieNames as $checkCookieName) { + if (stripos($cookieName, $checkCookieName) === 0) { + $this->setcookieSameSite($cookieName, $_COOKIE[$cookieName], time() + 86400, "/", $_SERVER['SERVER_NAME'], true, true); + } + } + } + } + + public function getCheckoutFormToken() + { + + $this->checkAndSetCookieSameSite(); + + $this->load->model('checkout/order'); + $this->load->model('setting/setting'); + $this->load->model('extension/iyzico/payment/iyzico'); + + $order_id = (int) $this->session->data['order_id']; + $customer_id = (int) isset($this->session->data['customer_id']) ? $this->session->data['customer_id'] : 0; + $user_id = (int) isset($this->session->data['user_id']) ? $this->session->data['user_id'] : 0; + $order_info = $this->model_checkout_order->getOrder($order_id); + $products = $this->cart->getProducts(); + + $api_key = $this->config->get('payment_iyzico_api_key'); + $secret_key = $this->config->get('payment_iyzico_secret_key'); + $payment_source = "OPENCART-4x-" . $this->moduleVersion . "|" . $this->moduleProductName; + + $user_create_date = $this->model_extension_iyzico_payment_iyzico->getUserCreateDate($user_id); + + $this->session->data['conversation_id'] = $order_id; + + + $order_info['payment_address'] = $order_info['payment_address_1'] . " " . $order_info['payment_address_2']; + $order_info['shipping_address'] = $order_info['shipping_address_1'] . " " . $order_info['shipping_address_2']; + + + + $iyzico = new stdClass(); + + $iyzico->locale = $this->language->get('code'); + $iyzico->conversationId = $order_id; + $iyzico->price = $this->priceParser($this->itemPriceSubTotal($products) * $order_info['currency_value']); + $iyzico->paidPrice = $this->priceParser($order_info['total'] * $order_info['currency_value']); + $iyzico->currency = $order_info['currency_code']; + $iyzico->basketId = $order_id; + $iyzico->paymentGroup = "PRODUCT"; + $iyzico->forceThreeDS = "0"; + $iyzico->callbackUrl = $this->url->link('extension/iyzico/payment/iyzico.getCallBack', '', true); + $iyzico->cardUserKey = $this->model_extension_iyzico_payment_iyzico->findUserCardKey($customer_id, $api_key); + $iyzico->paymentSource = $payment_source; + + if ($iyzico->paidPrice === 0) { + return false; + } + + $iyzico->buyer = new stdClass; + $iyzico->buyer->id = $order_info['customer_id']; + $iyzico->buyer->name = $this->dataCheck($order_info['firstname']); + $iyzico->buyer->surname = $this->dataCheck($order_info['lastname']); + $iyzico->buyer->identityNumber = '11111111111'; + $iyzico->buyer->email = $this->dataCheck($order_info['email']); + $iyzico->buyer->gsmNumber = $this->dataCheck($order_info['telephone']); + $iyzico->buyer->registrationDate = $user_create_date; + $iyzico->buyer->lastLoginDate = date('Y-m-d H:i:s'); + $iyzico->buyer->registrationAddress = $this->dataCheck($order_info['payment_address']); + $iyzico->buyer->city = $this->dataCheck($order_info['payment_zone']); + $iyzico->buyer->country = $this->dataCheck($order_info['payment_country']); + $iyzico->buyer->zipCode = $this->dataCheck($order_info['payment_postcode']); + $iyzico->buyer->ip = $this->dataCheck($this->getIpAdress()); + + $iyzico->shippingAddress = new stdClass; + $iyzico->shippingAddress->address = $this->dataCheck($order_info['shipping_address']); + $iyzico->shippingAddress->zipCode = $this->dataCheck($order_info['shipping_postcode']); + $iyzico->shippingAddress->contactName = $this->dataCheck($order_info['shipping_firstname']); + $iyzico->shippingAddress->city = $this->dataCheck($order_info['shipping_zone']); + $iyzico->shippingAddress->country = $this->dataCheck($order_info['shipping_country']); + + + $iyzico->billingAddress = new stdClass; + $iyzico->billingAddress->address = $this->dataCheck($order_info['payment_address']); + $iyzico->billingAddress->zipCode = $this->dataCheck($order_info['payment_postcode']); + $iyzico->billingAddress->contactName = $this->dataCheck($order_info['payment_firstname']); + $iyzico->billingAddress->city = $this->dataCheck($order_info['payment_zone']); + $iyzico->billingAddress->country = $this->dataCheck($order_info['payment_country']); + + $iyzico->basketItems = array(); + + foreach ($products as $product) { + $price = $product['total'] * $order_info['currency_value']; + + if ($price) { + $item = new stdClass(); + $item->id = $product['product_id']; + $item->price = $this->priceParser($price); + $item->name = $product['name']; + $item->category1 = $this->model_extension_iyzico_payment_iyzico->getCategoryName($product['product_id']); + $item->itemType = "PHYSICAL"; + $iyzico->basketItems[] = $item; + } + } + + + $shipping = $this->shippingInfo(); + + + if (!empty($shipping) && $shipping['cost'] && $shipping['cost'] != '0.00') { + + $shippigKey = count($iyzico->basketItems); + + $iyzico->basketItems[$shippigKey] = new stdClass(); + + $iyzico->basketItems[$shippigKey]->id = 'Kargo'; + $iyzico->basketItems[$shippigKey]->price = $this->priceParser($shipping['cost'] * $order_info['currency_value']); + $iyzico->basketItems[$shippigKey]->name = $shipping['name']; + $iyzico->basketItems[$shippigKey]->category1 = "Kargo"; + $iyzico->basketItems[$shippigKey]->itemType = "VIRTUAL"; + } + + + $rand_value = rand(100000, 99999999); + $order_object = $this->model_extension_iyzico_payment_iyzico->createFormInitializObjectSort($iyzico); + $pki_generate = $this->model_extension_iyzico_payment_iyzico->pkiStringGenerate($order_object); + $authorization_data = $this->model_extension_iyzico_payment_iyzico->authorizationGenerate($pki_generate, $api_key, $secret_key, $rand_value); + + $iyzico_json = json_encode($iyzico, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + + $response = $this->model_extension_iyzico_payment_iyzico->createFormInitializeRequest($iyzico_json, $authorization_data); + + $data['checkoutFormType'] = $this->config->get('payment_iyzico_design'); + $data['checkoutFormContent'] = $response->checkoutFormContent; + + return $this->load->view('extension/iyzico/payment/iyzico_form', $data); + + + + } + + + public function getCallBack($webhook = null, $webhookPaymentConversationId = null, $webhookToken = null, $webhookIyziEventType = null) + { + + + try { + + $this->load->language('extension/iyzico/payment/iyzico'); + + if ((!isset($this->request->post['token']) || !isset($this->session->data['order_id']) || empty($this->request->post['token'])) && $webhook != "webhook") { + + $errorMessage = 'invalid token'; + throw new \Exception($errorMessage); + + } + + $this->load->model('checkout/order'); + $this->load->model('extension/iyzico/payment/iyzico'); + + $api_key = $this->config->get('payment_iyzico_api_key'); + $secret_key = $this->config->get('payment_iyzico_secret_key'); + + if ($webhook == 'webhook') { + $conversation_id = $webhookPaymentConversationId; + $token = $webhookToken; + } else { + $conversation_id = (int) $this->session->data['conversation_id']; + $order_id = (int) $this->session->data['order_id']; + $token = $this->request->post['token']; + } + + $customer_id = isset($this->session->data['customer_id']) ? (int) $this->session->data['customer_id'] : 0; + + $detail_object = new stdClass(); + $language = $this->config->get('payment_iyzico_language'); + if (empty($language) or $language == 'null') { + $detail_object->locale = $this->language->get('code'); + } elseif ($language == 'TR' or $language == 'tr') { + $detail_object->locale = 'tr'; + } else { + $detail_object->locale = 'en'; + } + + $detail_object->conversationId = $conversation_id; + $detail_object->token = $this->db->escape($token); + + $rand_value = rand(100000, 99999999); + $pki_generate = $this->model_extension_iyzico_payment_iyzico->pkiStringGenerate($detail_object); + $authorization_data = $this->model_extension_iyzico_payment_iyzico->authorizationGenerate($pki_generate, $api_key, $secret_key, $rand_value); + + $iyzico_json = json_encode($detail_object); + $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); + } + + + if ($webhook == "webhook") { + + $order_id = $request_response->basketId; + $order_info = $this->model_checkout_order->getOrder($order_id); + + if ($webhookIyziEventType == 'CREDIT_PAYMENT_AUTH' && $request_response->paymentStatus == 'PENDING_CREDIT') { + $orderMessage = 'Alışveriş kredisi başvurusu sürecindedir.'; + $this->model_checkout_order->addHistory($request_response->basketId, 1, $orderMessage); + return $this->webhookHttpResponse("Order Exist - Alışveriş kredisi başvurusu sürecindedir.", 200); + + } + if ($webhookIyziEventType == 'CREDIT_PAYMENT_AUTH' && $request_response->status == 'success') { + $orderMessage = 'Alışveriş kredisi işlemi başarıyla tamamlandı.'; + $this->model_checkout_order->addHistory($request_response->basketId, 2, $orderMessage); + return $this->webhookHttpResponse("Order Exist - Alışveriş kredisi işlemi başarıyla tamamlandı.", 200); + } + if ($webhookIyziEventType == 'CREDIT_PAYMENT_INIT' && $request_response->status == 'INIT_CREDIT') { + $orderMessage = 'Alışveriş kredisi işlemi başlatıldı.'; + $this->model_checkout_order->addHistory($request_response->basketId, 1, $orderMessage); + return $this->webhookHttpResponse("Order Exist - Alışveriş kredisi işlemi başlatıldı.", 200); + } + + if ($webhookIyziEventType == 'CREDIT_PAYMENT_AUTH' && $request_response->status == 'FAILURE') { + $orderMessage = 'Alışveriş kredisi işlemi başarısız sonuçlandı.'; + $this->model_checkout_order->addHistory($request_response->basketId, 7, $orderMessage); + return $this->webhookHttpResponse("Order Exist - Alışveriş kredisi işlemi başarısız sonuçlandı.", 200); + } + + if ($request_response->paymentStatus == 'BANK_TRANSFER_AUTH' && $request_response->status == 'success') { + $orderMessage = 'iyzico Banka Havale/EFT ödemesi tamamlandı.'; + $this->setWebhookText(0); + $this->model_checkout_order->addHistory($request_response->order_id, 5, $orderMessage); + return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico.successpage')); + } + + } + + + if ($webhook == "webhook") { + $order_id = $request_response->basketId; + $order_info = $this->model_checkout_order->getOrder($order_id); + + if (isset($order_info) & $order_info['order_status_id'] == '5') { + return $this->webhookHttpResponse("Order Exist - Sipariş zaten var.", 200); + + } + } + + $iyzico_local_order = new stdClass; + $iyzico_local_order->payment_id = !empty($request_response->paymentId) ? (int) $request_response->paymentId : ''; + $iyzico_local_order->order_id = $order_id; + $iyzico_local_order->total_amount = !empty($request_response->paidPrice) ? (float) $request_response->paidPrice : ''; + $iyzico_local_order->status = $request_response->paymentStatus; + + $this->model_extension_iyzico_payment_iyzico->insertIyzicoOrder($iyzico_local_order); + + $this->setWebhookText(0); + + if ($request_response->paymentStatus == 'INIT_BANK_TRANSFER' && $request_response->status == 'success') { + $orderMessage = 'iyzico Banka Havale/EFT ödemesi bekleniyor.'; + $this->setWebhookText(0); + $this->model_checkout_order->addHistory($iyzico_local_order->order_id, 1, $orderMessage); + return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico.successpage')); + } + + if ($webhook != 'webhook' && $request_response->paymentStatus == 'PENDING_CREDIT' && $request_response->status == 'success') { + $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')); + } + $this->setWebhookText(0); + + if ($request_response->paymentStatus != 'SUCCESS' || $request_response->status != 'success' || $order_id != $request_response->basketId) { + echo '
Ödemeniz alınamadı.Anasayfaya yönlendirliyorsunuz.
'; + return $this->response->redirect($this->url->link('checkout/checkout')); + } + + /* Save Card */ + if (isset($request_response->cardUserKey)) { + if ($customer_id) { + $cardUserKey = $this->model_extension_iyzico_payment_iyzico->findUserCardKey($customer_id, $api_key); + if ($request_response->cardUserKey != $cardUserKey) { + $this->model_extension_iyzico_payment_iyzico->insertCardUserKey($customer_id, $request_response->cardUserKey, $api_key); + } + } + + } + + $payment_id = $this->db->escape($request_response->paymentId); + $payment_field_desc = $this->language->get('payment_field_desc'); + if (!empty($payment_id)) { + $message = $payment_field_desc . $payment_id . "\n"; + } + + $installment = $request_response->installment; + + if ($installment > 1) { + $installement_field_desc = $this->language->get('installement_field_desc'); + $this->model_extension_iyzico_payment_iyzico->orderUpdateByInstallement($iyzico_local_order->order_id, $request_response->paidPrice); + $messageInstallement = $request_response->cardFamily . ' - ' . $request_response->installment . $installement_field_desc; + $this->model_checkout_order->addHistory($iyzico_local_order->order_id, $this->config->get('payment_iyzico_order_status'), $messageInstallement); + } else { + $this->model_checkout_order->addHistory($iyzico_local_order->order_id, $this->config->get('payment_iyzico_order_status'), $message); + } + + if ($webhook == 'webhook') { + 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')); + + } catch (\Exception $e) { + + + if ($webhook == 'webhook') { + return $this->webhookHttpResponse("errorCode: " . $request_response->errorCode . " - " . $request_response->errorMessage, 404); + } + + $errorMessage = isset($request_response->errorMessage) ? $request_response->errorMessage : $e->getMessage(); + + $this->session->data['iyzico_error_message'] = $errorMessage; + + return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico.errorpage')); + + } + + + } + + public function errorPage() + { + + $data['continue'] = $this->url->link('common/home'); + $data['column_left'] = $this->load->controller('common/column_left'); + $data['column_right'] = $this->load->controller('common/column_right'); + $data['content_top'] = $this->load->controller('common/content_top'); + $data['content_bottom'] = $this->load->controller('common/content_bottom'); + $data['footer'] = $this->load->controller('common/footer'); + $data['header'] = $this->load->controller('common/header'); + $data['error_title'] = 'Ödemeniz Alınamadı.'; + $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)); + + } + + public function successPage() + { + + if (!isset($this->session->data['order_id'])) { + return $this->response->redirect($this->url->link('common/home')); + } + + $this->load->language('account/order'); + + $order_id = $this->session->data['order_id']; + + if (isset($this->session->data['order_id'])) { + $this->cart->clear(); + + unset($this->session->data['shipping_method']); + unset($this->session->data['shipping_methods']); + unset($this->session->data['payment_method']); + unset($this->session->data['payment_methods']); + unset($this->session->data['guest']); + unset($this->session->data['comment']); + unset($this->session->data['coupon']); + unset($this->session->data['reward']); + unset($this->session->data['voucher']); + unset($this->session->data['vouchers']); + unset($this->session->data['totals']); + } + + $this->load->model('account/order'); + $this->load->model('catalog/product'); + $this->load->model('checkout/order'); + $this->load->model('tool/upload'); + + $order_info = $this->model_checkout_order->getOrder($order_id); + + // Products + $data['products'] = array(); + + $products = $this->model_account_order->getProducts($order_id); + + foreach ($products as $product) { + $option_data = array(); + + $options = $this->model_account_order->getOptions($order_id, $product['order_product_id']); + + foreach ($options as $option) { + if ($option['type'] != 'file') { + $value = $option['value']; + } else { + $upload_info = $this->model_tool_upload->getUploadByCode($option['value']); + + if ($upload_info) { + $value = $upload_info['name']; + } else { + $value = ''; + } + } + + $option_data[] = array( + 'name' => $option['name'], + 'value' => (strlen($value) > 20 ? mb_substr($value, 0, 20) . '..' : $value) + ); + } + + $product_info = $this->model_catalog_product->getProduct($product['product_id']); + + if ($product_info) { + $reorder = $this->url->link('account/order/reorder', 'order_id=' . $order_id . '&order_product_id=' . $product['order_product_id'], true); + } else { + $reorder = ''; + } + + $data['products'][] = array( + 'name' => $product['name'], + 'model' => $product['model'], + 'option' => $option_data, + 'quantity' => $product['quantity'], + 'price' => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']), + 'total' => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value']), + 'reorder' => $reorder, + 'return' => $this->url->link('account/return/add', 'order_id=' . $order_info['order_id'] . '&product_id=' . $product['product_id'], true) + ); + } + + // Voucher + $data['vouchers'] = array(); + + $vouchers = $this->model_account_order->getVouchers($order_id); + + foreach ($vouchers as $voucher) { + $data['vouchers'][] = array( + 'description' => $voucher['description'], + 'amount' => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']) + ); + } + + // Totals + $data['totals'] = array(); + + $totals = $this->model_account_order->getTotals($order_id); + + foreach ($totals as $total) { + $data['totals'][] = array( + 'title' => $total['title'], + 'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), + ); + } + + $data['comment'] = nl2br($order_info['comment']); + + // History + $data['histories'] = array(); + + $results = $this->model_account_order->getHistories($order_id); + + foreach ($results as $result) { + $data['histories'][] = array( + 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])), + 'status' => $result['status'], + 'comment' => $result['notify'] ? nl2br($result['comment']) : '' + ); + } + + $this->document->addStyle('view/javascript/iyzico/iyzico_success.css'); + + $language = $this->config->get('payment_iyzico_language'); + $str_language = mb_strtolower($language); + + if (empty($str_language) or $str_language == 'null') { + $locale = $this->language->get('code'); + } else { + $locale = $str_language; + } + + $data['locale'] = $locale; + $thankyouText = $this->config->get('payment_iyzico_webhook_text'); + $data['credit_pending'] = $thankyouText; + + $data['continue'] = $this->url->link('account/order', '', true); + + $data['column_left'] = $this->load->controller('common/column_left'); + $data['column_right'] = $this->load->controller('common/column_right'); + $data['content_top'] = $this->load->controller('common/content_top'); + $data['content_bottom'] = $this->load->controller('common/content_bottom'); + $data['footer'] = $this->load->controller('common/footer'); + $data['header'] = $this->load->controller('common/header'); + $data['success_icon'] = 'catalog/view/theme/default/image/iyzico/payment/iyzico_success_icon.png'; + + /* Remove Order */ + unset($this->session->data['order_id']); + + return $this->response->setOutput($this->load->view('extension/iyzico/payment/iyzico_success', $data)); + } + + private function dataCheck($data) + { + + if (!$data || $data == ' ') { + + $data = "NOT PROVIDED"; + } + + return $data; + + } + + + private function shippingInfo(): bool|array + { + if (isset($this->session->data['shipping_method']) && $this->session->data['shipping_method'] != 'flat.flat') + $shipping_info = $this->session->data['shipping_method']; + else + $shipping_info = false; + + if ($shipping_info != false) + if (isset($shipping_info['tax_class_id'])) + $shipping_info['tax'] = $this->tax->getRates($shipping_info['cost'], $shipping_info['tax_class_id']); + else + $shipping_info['tax'] = false; + + return $shipping_info; + } + + private function itemPriceSubTotal($products) + { + $price = 0; + foreach ($products as $key => $product) { + $price += (float) $product['total']; + } + + $shippingInfo = $this->shippingInfo(); + if (is_object($shippingInfo) || is_array($shippingInfo)) + $price += (float) $shippingInfo['cost']; + + return $price; + } + + private function priceParser($price) + { + + if (strpos($price, ".") === false) + return $price . ".0"; + + $subStrIndex = 0; + $priceReversed = strrev($price); + for ($i = 0; $i < strlen($priceReversed); $i++) { + if (strcmp($priceReversed[$i], "0") == 0) { + $subStrIndex = $i + 1; + } else if (strcmp($priceReversed[$i], ".") == 0) { + $priceReversed = "0" . $priceReversed; + break; + } else { + break; + } + } + + return strrev(substr($priceReversed, $subStrIndex)); + } + + private function getIpAdress(): string + { + return $_SERVER['REMOTE_ADDR']; + } + + + public function setWebhookText($thankyouTextValue) + { + return $this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `value` = '" . $thankyouTextValue . "' , `serialized` = 0 WHERE `code` = 'payment_iyzico' AND `key` = 'payment_iyzico_webhook_text' AND `store_id` = '0'"); + } + + + + public function webhook() + { + + if (isset($this->request->get['key']) && $this->request->get['key'] == $this->config->get('webhook_iyzico_webhook_url_key')) { + + $post = file_get_contents("php://input"); + $params = json_decode($post, true); + + if (isset(getallheaders()['x-iyz-signature'])) + $this->iyziSignature = getallheaders()['x-iyz-signature']; + + + if (isset($params['iyziEventType']) && isset($params['token']) && isset($params['paymentConversationId'])) { + $this->paymentConversationId = $params['paymentConversationId']; + $this->webhookToken = $params['token']; + $this->iyziEventType = $params['iyziEventType']; + + if ($this->iyziSignature) { + $secretKey = $this->config->get('payment_iyzico_secret_key'); + $createIyzicoSignature = base64_encode(sha1($secretKey . $this->iyziEventType . $this->webhookToken, true)); + + if ($this->iyziSignature == $createIyzicoSignature) { + $this->getCallBack('webhook', $params['paymentConversationId'], $params['token'], $params['iyziEventType']); + } else { + $this->webhookHttpResponse("signature_not_valid - X-IYZ-SIGNATURE geçersiz", 404); + } + } else { + $this->getCallBack('webhook', $params['paymentConversationId'], $params['token'], $params['iyziEventType']); + } + } else { + $this->webhookHttpResponse("invalid_parameters - Gönderilen parametreler geçersiz", 404); + } + } else { + $this->webhookHttpResponse("invalid_key - key geçersiz", 404); + } + } + + public function webhookHttpResponse($message, $status) + { + $httpMessage = array('message' => $message); + header('Content-Type: application/json, Status: ' . $status, true, $status); + echo json_encode($httpMessage); + exit(); + } + + public function injectOverlayScript($route, &$data = false, &$output = null) + { + $this->load->model('setting/setting'); + + $token = $this->config->get('payment_iyzico_overlay_token'); + $overlayStatus = $this->config->get('payment_iyzico_overlay_status'); + $apiChannel = $this->config->get('payment_iyzico_api_channel'); + + if ($overlayStatus != 'hidden' && $overlayStatus != '' || $apiChannel == 'sandbox') { + + $hook = ""; + $js = " + + + "; + + $output = str_replace($hook, $js, $output); + } + } +} diff --git a/iyzico/catalog/language/.DS_Store b/iyzico/catalog/language/.DS_Store new file mode 100644 index 0000000..6dfe615 Binary files /dev/null and b/iyzico/catalog/language/.DS_Store differ diff --git a/iyzico/catalog/language/en-gb/.DS_Store b/iyzico/catalog/language/en-gb/.DS_Store new file mode 100644 index 0000000..9bba3e1 Binary files /dev/null and b/iyzico/catalog/language/en-gb/.DS_Store differ diff --git a/iyzico/catalog/language/en-gb/payment/.DS_Store b/iyzico/catalog/language/en-gb/payment/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/iyzico/catalog/language/en-gb/payment/.DS_Store differ diff --git a/iyzico/catalog/language/en-gb/payment/iyzico.php b/iyzico/catalog/language/en-gb/payment/iyzico.php new file mode 100644 index 0000000..5894c0a --- /dev/null +++ b/iyzico/catalog/language/en-gb/payment/iyzico.php @@ -0,0 +1,10 @@ +'; +$_['payment_failed'] = 'Payment Failed'; +$_['text_title'] = 'iyzico'; +$_['payment_field_desc'] = 'Payment ID: '; +$_['installement_field_desc'] = ' Installment Commission'; +$_['iyzico_onepage_desc'] = 'The payment form will be active when you fill in your information and confirm the complete order button.'; +$_['iyzico_checkout_form_title'] = 'Payment Form'; +$_['iyzico_checkout_form_desc'] = 'This payment form will be used to complete your order.'; \ No newline at end of file diff --git a/iyzico/catalog/language/tr-tr/.DS_Store b/iyzico/catalog/language/tr-tr/.DS_Store new file mode 100644 index 0000000..9839ef8 Binary files /dev/null and b/iyzico/catalog/language/tr-tr/.DS_Store differ diff --git a/iyzico/catalog/language/tr-tr/payment/.DS_Store b/iyzico/catalog/language/tr-tr/payment/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/iyzico/catalog/language/tr-tr/payment/.DS_Store differ diff --git a/iyzico/catalog/language/tr-tr/payment/iyzico.php b/iyzico/catalog/language/tr-tr/payment/iyzico.php new file mode 100644 index 0000000..0148d6b --- /dev/null +++ b/iyzico/catalog/language/tr-tr/payment/iyzico.php @@ -0,0 +1,10 @@ +'; +$_['payment_failed'] = 'Ödeme Başarısız'; +$_['text_title'] = 'iyzico'; +$_['payment_field_desc'] = 'Ödeme Numarası: '; +$_['installement_field_desc'] = 'Taksit Vade Komisyonu'; +$_['iyzico_onepage_desc'] = 'Ödeme formu, bilgilerinizi doldurup siparişi tamamla butonuna bastığınız zaman aktif olacaktır.'; +$_['iyzico_checkout_form_title'] = 'Ödeme Formu'; +$_['iyzico_checkout_form_desc'] = 'Bu ödeme formu, siparişinizi tamamlamak için kullanılacaktır.'; \ No newline at end of file diff --git a/iyzico/catalog/model/.DS_Store b/iyzico/catalog/model/.DS_Store new file mode 100644 index 0000000..94268bd Binary files /dev/null and b/iyzico/catalog/model/.DS_Store differ diff --git a/iyzico/catalog/model/payment/.DS_Store b/iyzico/catalog/model/payment/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/iyzico/catalog/model/payment/.DS_Store differ diff --git a/iyzico/catalog/model/payment/iyzico.php b/iyzico/catalog/model/payment/iyzico.php new file mode 100644 index 0000000..83209ed --- /dev/null +++ b/iyzico/catalog/model/payment/iyzico.php @@ -0,0 +1,370 @@ +load->language('extension/iyzico/payment/iyzico'); + + if ($this->cart->hasSubscription()) { + $status = false; + } elseif ($this->cart->hasShipping()) { + $status = true; + } elseif (!$this->config->get('config_checkout_payment_address')) { + $status = true; + } elseif (!$this->config->get('payment_iyzico_geo_zone_id')) { + $status = true; + } else { + $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE `geo_zone_id` = '" . (int) $this->config->get('payment_iyzico_geo_zone_id') . "' AND `country_id` = '" . (int) $address['country_id'] . "' AND (`zone_id` = '" . (int) $address['zone_id'] . "' OR `zone_id` = '0')"); + if ($query->num_rows) { + $status = true; + } else { + $status = false; + } + } + + $method_data = []; + + if ($status) { + $option_data['iyzico'] = [ + 'code' => 'iyzico.iyzico', + 'name' => $this->iyzicoMultipLangTitle($this->config->get('payment_iyzico_title')), + ]; + + $method_data = [ + 'code' => 'iyzico', + 'name' => $this->iyzicoMultipLangTitle($this->config->get('payment_iyzico_title')), + 'option' => $option_data, + 'sort_order' => $this->config->get('payment_iyzico_sort_order') + ]; + } + + return $method_data; + } + + private function iyzicoMultipLangTitle($title) + { + + $this->load->language('extension/iyzico/payment/iyzico'); + $language = $this->config->get('payment_iyzico_language'); + $str_language = mb_strtolower($language); + + if (empty($str_language) or $str_language == 'null') + $title_language = $this->language->get('code'); + else + $title_language = $str_language; + + if ($title) { + $parser = explode('|', $title); + if (is_array($parser) && count($parser)) { + foreach ($parser as $key => $parse) { + $result = explode('=', $parse); + if ($title_language == $result[0]) { + $new_title = $result[1]; + break; + } + } + } + } + + if (!isset($new_title)) { + $new_title = $this->language->get('iyzico'); + } + + return $new_title; + } + + public function authorizationGenerate($pkiString, $apiKey, $secretKey, $randValue): array + { + $hashValue = $apiKey . $randValue . $secretKey . $pkiString; + $hashed = base64_encode(sha1($hashValue, true)); + + $authorization = 'IYZWS ' . $apiKey . ':' . $hashed; + + return array( + 'authorization' => $authorization, + 'rand_value' => $randValue + ); + } + + public function createFormInitializObjectSort($data) + { + + $form = new stdClass(); + + $form->locale = $data->locale; + $form->conversationId = $data->conversationId; + $form->price = $data->price; + $form->basketId = $data->basketId; + $form->paymentGroup = $data->paymentGroup; + + $form->buyer = new stdClass(); + $form->buyer = $data->buyer; + + $form->shippingAddress = new stdClass(); + $form->shippingAddress = $data->shippingAddress; + + $form->billingAddress = new stdClass(); + $form->billingAddress = $data->billingAddress; + + foreach ($data->basketItems as $key => $item) { + $form->basketItems[$key] = new stdClass(); + $form->basketItems[$key] = $item; + } + + $form->callbackUrl = $data->callbackUrl; + $form->paymentSource = $data->paymentSource; + $form->currency = $data->currency; + $form->paidPrice = $data->paidPrice; + $form->forceThreeDS = $data->forceThreeDS; + $form->cardUserKey = $data->cardUserKey; + + return $form; + } + + public function pkiStringGenerate($objectData) + { + $pki_value = "["; + foreach ($objectData as $key => $data) { + if (is_object($data)) { + $name = var_export($key, true); + $name = str_replace("'", "", $name); + $pki_value .= $name . "=["; + $end_key = count(get_object_vars($data)); + $count = 0; + foreach ($data as $key => $value) { + $count++; + $name = var_export($key, true); + $name = str_replace("'", "", $name); + $pki_value .= $name . "=" . "" . $value; + if ($end_key != $count) + $pki_value .= ","; + } + $pki_value .= "]"; + } else if (is_array($data)) { + $name = var_export($key, true); + $name = str_replace("'", "", $name); + $pki_value .= $name . "=["; + $end_key = count($data); + $count = 0; + foreach ($data as $key => $result) { + $count++; + $pki_value .= "["; + + foreach ($result as $key => $item) { + $name = var_export($key, true); + $name = str_replace("'", "", $name); + + $pki_value .= $name . "=" . "" . $item; + $reResult = (array) $result; + $newResult = $reResult[array_key_last($reResult)]; + + if ($newResult != $item) { + $pki_value .= ","; + } + + if ($newResult == $item) { + + if ($end_key != $count) { + $pki_value .= "], "; + } else { + $pki_value .= "]"; + } + } + } + } + + $reData = (array) $data; + $newData = $reData[array_key_last($reData)]; + if ($newData == $result) + $pki_value .= "]"; + } else { + $name = var_export($key, true); + $name = str_replace("'", "", $name); + + $pki_value .= $name . "=" . "" . $data . ""; + } + + $reObjectData = (array) $objectData; + $newobjectData = $reObjectData[array_key_last($reObjectData)]; + + if ($newobjectData != $data) + $pki_value .= ","; + } + $pki_value .= "]"; + return $pki_value; + } + + + public function hashGenerate($pkiString, $apiKey, $secretKey, $randValue) + { + $hash = $apiKey . $randValue . $secretKey . $pkiString; + return base64_encode(sha1($hash, true)); + + } + + public function createFormInitializeDetailRequest($json, $authorization_data) + { + $url = $this->config->get('payment_iyzico_api_url'); + $url = $url . '/payment/iyzipos/checkoutform/auth/ecom/detail'; + + return $this->curlPost($json, $authorization_data, $url); + } + + + public function createFormInitializeRequest($json, $authorizationData) + { + $url = $this->config->get('payment_iyzico_api_url'); + $url = $url . '/payment/iyzipos/checkoutform/initialize/auth/ecom'; + + return $this->curlPost($json, $authorizationData, $url); + } + + + public function curlPost($json, $authorization_data, $url) + { + + $phpVersion = phpversion(); + + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + + if ($json) { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); + curl_setopt($curl, CURLOPT_POSTFIELDS, $json); + } + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); + curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE); + curl_setopt($curl, CURLOPT_TIMEOUT, 150); + + curl_setopt( + $curl, + CURLOPT_HTTPHEADER, + array( + "Authorization: " . $authorization_data['authorization'], + "x-iyzi-rnd:" . $authorization_data['rand_value'], + "opencart-php-version:" . $phpVersion, + "Content-Type: application/json", + ) + ); + + $result = json_decode(curl_exec($curl)); + curl_close($curl); + + + + return $result; + } + + public function insertCardUserKey($customerId, $cardUserKey, $apiKey) + { + return $this->db->query("INSERT INTO `" . DB_PREFIX . "iyzico_card` SET + `customer_id` = '" . $this->db->escape($customerId) . "', + `card_user_key` = '" . $this->db->escape($cardUserKey) . "', + `api_key` = '" . $this->db->escape($apiKey) . "'"); + } + + public function findUserCardKey($customerId, $apiKey): int|string + { + $customerId = $this->db->escape($customerId); + $apiKey = $this->db->escape($apiKey); + $cardUserKey = (object) $this->db->query("SELECT card_user_key FROM " . DB_PREFIX . "iyzico_card WHERE customer_id = '" . $customerId . "' and api_key = '" . $apiKey . "' ORDER BY iyzico_card_id DESC"); + + return count($cardUserKey->rows) ? $cardUserKey->rows[0]['card_user_key'] : ""; + } + + public function insertIyzicoOrder($order) + { + return $this->db->query("INSERT INTO `" . DB_PREFIX . "iyzico_order` SET + `payment_id` = '" . $this->db->escape($order->payment_id) . "', + `order_id` = '" . $this->db->escape($order->order_id) . "', + `total_amount` = '" . $this->db->escape($order->total_amount) . "', + `status` = '" . $this->db->escape($order->status) . "'"); + } + + public function orderUpdateByInstallement($orderId, $paidPrice) + { + + $orderId = $this->db->escape($orderId); + $orderInfo = $this->model_checkout_order->getOrder($orderId); + + $this->load->language('extension/iyzico/payment/iyzico'); + + $orderTotal = (array) $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . $orderId . "' AND code = 'total' "); + $lastSortValue = $this->db->escape($orderTotal['row']['sort_order'] - 1); + + $exchange_rate = $this->currency->getValue($orderInfo['currency_code']); + + $new_amount = str_replace(',', '', $paidPrice); + $old_amount = str_replace(',', '', $orderInfo['total'] * $orderInfo['currency_value']); + $installment_fee_variation = (float) ($new_amount - $old_amount) / $exchange_rate; + $installment_fee_variation = $this->db->escape($installment_fee_variation); + $installment_fee_desc = $this->language->get('installement_field_desc'); + + $this->db->query("INSERT INTO " . DB_PREFIX . "order_total SET order_id = '" . + $orderId . "',code = 'iyzico_fee', extension='iyzico', title = '" . $installment_fee_desc . "', `value` = '" . + $installment_fee_variation . "', sort_order = '" . $lastSortValue . "'"); + + + $orderTotalData = (array) $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . $orderId . "' AND code != 'total' "); + $calculateTotal = 0; + + foreach ($orderTotalData['rows'] as $row) { + $calculateTotal += $row['value']; + } + + $calculateTotal = $this->db->escape($calculateTotal); + + $this->db->query("UPDATE " . DB_PREFIX . "order_total SET `value` = '" . $calculateTotal . "' WHERE order_id = '$orderId' AND code = 'total' "); + $this->db->query("UPDATE `" . DB_PREFIX . "order` SET total = '" . $calculateTotal . "' WHERE order_id = '" . $orderId . "'"); + + } + + public function getCategoryName($productId) + { + + $productId = $this->db->escape($productId); + $query = $this->db->query("SELECT category_id FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . $productId . "' LIMIT 1"); + + + if (count($query->rows)) { + $categoryId = $this->db->escape($query->rows[0]['category_id']); + $category = $this->db->query("SELECT name FROM " . DB_PREFIX . "category_description WHERE category_id = '" . $categoryId . "' LIMIT 1"); + if ($category->rows[0]['name']) + $categoryName = $category->rows[0]['name']; + else + $categoryName = 'NO CATEGORIES'; + } else { + $categoryName = 'NO CATEGORIES'; + } + + $categoryName = html_entity_decode($categoryName); + $categoryName = trim($categoryName); + + return $categoryName; + } + + + public function getUserCreateDate($userId) + { + + $userId = $this->db->escape($userId); + + $user_create_date = (object) $this->db->query("SELECT date_added FROM " . DB_PREFIX . "user WHERE user_id = '" . $userId . "'"); + + if (count($user_create_date->rows)) { + return $user_create_date->rows[0]['date_added']; + } + + return date('Y-m-d H:i:s'); + } + + + +} diff --git a/iyzico/catalog/model/total/iyzico_fee.php b/iyzico/catalog/model/total/iyzico_fee.php new file mode 100644 index 0000000..ffd5fa0 --- /dev/null +++ b/iyzico/catalog/model/total/iyzico_fee.php @@ -0,0 +1,15 @@ + - +
{{ column_left }} {% if column_left and column_right %} {% set class = 'col-sm-6' %} @@ -12,7 +12,7 @@
{{ content_top }}

{{ error_title }}

-

{{ error_message }}

+

{{ errorMessage }}

diff --git a/iyzico/catalog/view/template/payment/iyzico_form.twig b/iyzico/catalog/view/template/payment/iyzico_form.twig new file mode 100644 index 0000000..23b6b14 --- /dev/null +++ b/iyzico/catalog/view/template/payment/iyzico_form.twig @@ -0,0 +1,23 @@ + +{% if checkoutFormType == 'responsive' %} +
+ {{ iyzico_checkout_form_title }} +

+ {{ iyzico_checkout_form_desc }} +

+
+
+
+
+{% endif %} +{% if checkoutFormType == 'popup' %} +
+
+ +
+
+{% endif %} +{{ checkoutFormContent }} diff --git a/iyzico/catalog/view/template/payment/iyzico_success.twig b/iyzico/catalog/view/template/payment/iyzico_success.twig new file mode 100644 index 0000000..d8a6902 --- /dev/null +++ b/iyzico/catalog/view/template/payment/iyzico_success.twig @@ -0,0 +1,88 @@ +{{ header }} +
+ +
{{ column_left }} + {% if column_left and column_right %} + {% set class = 'col-sm-6' %} + {% elseif column_left or column_right %} + {% set class = 'col-sm-9' %} + {% else %} + {% set class = 'col-sm-12' %} + {% endif %} +
{{ content_top }} +
+ +
+ {% if locale == 'tr'%} + {% if credit_pending == '1'%} +

Alışveriş Kredisi için başvurunuz alınmıştır. Başvurunuz, en kısa sürede sonuçlandırılacaktır.

+ {% else %} +

Ödemeniz Alındı.

+ {% endif %} + {% else %} + {% if credit_pending == '1'%} +

Your Shopping Loan application has been received. Your application will be finalized as soon as possible.

+ {% else %} +

Your Payment Received.

+ {% endif %} + {% endif %} +
+ +
+
+
+
+
+ + + + + + + + + + + + + {% for product in products %} + + + + + + + + {% endfor %} + {% for voucher in vouchers %} + + + + + + + + {% endfor %} + + + + + {% for total in totals %} + + + + + {% endfor %} + + +
{{ column_name }}{{ column_model }}{{ column_quantity }}{{ column_price }}{{ column_total }}
{{ product.name }} {% for option in product.option %}
+   - {{ option.name }}: {{ option.value }} {% endfor %} + {% if product.recurring %}
+ {{ text_recurring_item }} {{ product.recurring }} {% endif %}
{{ product.model }}{{ product.quantity }}{{ product.price }}{{ product.total }}
{{ voucher.description }}1{{ voucher.amount }}{{ voucher.amount }}
{{ total.title }}:{{ total.text }}
+
+ +
+ {{ content_bottom }}
+ {{ column_right }}
+
+{{ footer }} diff --git a/iyzico/catalog/view/theme/.DS_Store b/iyzico/catalog/view/theme/.DS_Store new file mode 100644 index 0000000..08d8f5c Binary files /dev/null and b/iyzico/catalog/view/theme/.DS_Store differ diff --git a/iyzico/catalog/view/theme/default/.DS_Store b/iyzico/catalog/view/theme/default/.DS_Store new file mode 100644 index 0000000..0f26d7c Binary files /dev/null and b/iyzico/catalog/view/theme/default/.DS_Store differ diff --git a/iyzico/catalog/view/theme/default/image/.DS_Store b/iyzico/catalog/view/theme/default/image/.DS_Store new file mode 100644 index 0000000..bf309fc Binary files /dev/null and b/iyzico/catalog/view/theme/default/image/.DS_Store differ diff --git a/upload/catalog/view/theme/default/image/payment/iyzico_error_icon.png b/iyzico/catalog/view/theme/default/image/payment/iyzico_error_icon.png old mode 100755 new mode 100644 similarity index 100% rename from upload/catalog/view/theme/default/image/payment/iyzico_error_icon.png rename to iyzico/catalog/view/theme/default/image/payment/iyzico_error_icon.png diff --git a/upload/catalog/view/theme/default/image/payment/iyzico_success_icon.png b/iyzico/catalog/view/theme/default/image/payment/iyzico_success_icon.png old mode 100755 new mode 100644 similarity index 100% rename from upload/catalog/view/theme/default/image/payment/iyzico_success_icon.png rename to iyzico/catalog/view/theme/default/image/payment/iyzico_success_icon.png diff --git a/iyzico/install.json b/iyzico/install.json new file mode 100644 index 0000000..8966ba8 --- /dev/null +++ b/iyzico/install.json @@ -0,0 +1,6 @@ +{ + "name": "iyzico Payment Gateway", + "version": "2.2.0", + "author": "iyzico", + "link": "https://iyzico.com/" +} \ No newline at end of file diff --git a/iyzico_opencart4_iyzico_odeme_formu_kurulum.pdf b/iyzico_opencart4_iyzico_odeme_formu_kurulum.pdf new file mode 100644 index 0000000..3b854ab Binary files /dev/null and b/iyzico_opencart4_iyzico_odeme_formu_kurulum.pdf differ diff --git a/opencart-test-suite/tests/admin/SampleAdminTest.php b/opencart-test-suite/tests/admin/SampleAdminTest.php deleted file mode 100644 index 4575e32..0000000 --- a/opencart-test-suite/tests/admin/SampleAdminTest.php +++ /dev/null @@ -1,138 +0,0 @@ -load->model('extension/payment/iyzico'); - - $api_con_object = new stdClass(); - $api_con_object->locale = $this->language->get('code'); - $api_con_object->conversationId = rand(100000,99999999); - $api_con_object->binNumber = '454671'; - - $result_pki = $this->model_extension_payment_iyzico->pkiStringGenerate($api_con_object); - $result_pki = (string) $result_pki; - - $default_pki = "[locale=en,conversationId=".$api_con_object->conversationId.",binNumber=454671]"; - - - $this->assertEquals($result_pki,$default_pki); - - } - - public function testAuthorizationGenerate() { - - $this->load->model('extension/payment/iyzico'); - - $api_key = 'xxxx'; - $secret_key = 'xxxx'; - $default_pki_string = "[locale=en,conversationId=21763770,binNumber=454671]"; - - $authorization = $this->model_extension_payment_iyzico->authorizationGenerate($api_key,$secret_key,$default_pki_string); - - $default_hash = $api_key.$authorization['rand_value'].$secret_key.$default_pki_string; - $default_hash = base64_encode(sha1($default_hash,true)); - - $default_authorization = "IYZWS ".$api_key.":".$default_hash; - - $this->assertEquals($authorization['authorization'],$default_authorization); - } - - - public function testOverlayScript() { - - $authorization_data = array( - 'authorization' => 'test', - 'rand_value' => '123456' - ); - $overlay_script_object = '[locale=en,conversationId=21763770,binNumber=454671]'; - - $this->load->model('extension/payment/iyzico'); - $result = $this->model_extension_payment_iyzico->overlayScript($authorization_data,$overlay_script_object); - - $this->assertEquals($result->status,'failure'); - - } - - - public function testCurlPost() { - - $this->load->model('extension/payment/iyzico'); - - $json = '{"test": "test", "test": "test"}'; - - $authorization_data = array( - 'authorization' => 'test', - 'rand_value' => '123456' - ); - $url = 'https://sandbox-api.iyzipay.com'; - - $result = $this->model_extension_payment_iyzico->curlPost($json,$authorization_data,$url); - - $this->assertEquals($result->status,'failure'); - - } - /* - public function testInstallIyzicoExtensionPayment() { - - /* - $client = new Client(); - $url = "http://localhost/opencart/opencart-test-suite/www/admin/index.php"; - - - $request = $client->get($url,[ 'query' => - [ - 'route' => 'extension/extension/payment/install', - 'user_token' => 'Tok0c3ykLFbxWVEqjcxqAOsChyOs0CvM', - 'extension' => 'iyzico' - ] - ]); - - - $request = $client->post($url."?route=common/login", - ['body' => - [ - 'username' => 'int', - 'password' => 'aA070849', - 'redirect' => '', - ] - ]); - - var_dump($request->getBody()->getContents()); - exit; - - $data = json_decode($response->getBody(), true); - echo $data; - - exit; - - - //'route=extension/extension/payment/install&user_token=U1UfypL8FtGZhMzDSh3djz7NfnfWndGr&extension=iyzico' - - - $result = $this->load->controller('extension/payment/iyzico/install'); - - $this->assertEquals(NULL, $result); - - } - - public function testIndexIyzicoExtensionPayment() { - - - $result = $this->load->controller('extension/payment/iyzico/index'); - - $this->assertEquals(NULL, $result); - - - } - */ - -} - diff --git a/opencart-test-suite/tests/catalog/Sample2Test.php b/opencart-test-suite/tests/catalog/Sample2Test.php deleted file mode 100644 index cf607f2..0000000 --- a/opencart-test-suite/tests/catalog/Sample2Test.php +++ /dev/null @@ -1,28 +0,0 @@ -db->query("INSERT INTO " . DB_PREFIX . "customer SET customer_group_id = '1', store_id = '" . (int)$this->config->get('config_store_id') . "', firstname = 'Test', lastname = 'Customer', email = 'somebody@test.com', telephone = '123456789', fax = '123456789', custom_field = '', salt = '" . $this->db->escape($salt = token(9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1('password')))) . "', newsletter = '0', ip = '127.0.0.1', status = '1', date_added = NOW()"); - $customer_id = $this->db->getLastId(); - - $this->assertTrue($this->login('somebody@test.com', 'password')); - $this->assertTrue(!!$this->customer->isLogged()); - - $response = $this->dispatchAction('account/edit'); - $this->assertRegExp('/Your Personal Details/', $response->getOutput()); - - $this->logout(); - $this->assertFalse(!!$this->customer->isLogged()); - } - - public function testAnExamplaryModel() - { - $model = $this->loadModel("catalog/manufacturer"); - $manufacturer = $model->getManufacturer(5); - $this->assertEquals('HTC', $manufacturer['name']); - } -} diff --git a/opencart-test-suite/tests/catalog/SampleTest.php b/opencart-test-suite/tests/catalog/SampleTest.php deleted file mode 100644 index d277192..0000000 --- a/opencart-test-suite/tests/catalog/SampleTest.php +++ /dev/null @@ -1,25 +0,0 @@ -assertFalse($this->isAdmin()); - } - - public function testDispatchingToExamplaryAction() - { - $response = $this->dispatchAction('account/login'); - $this->assertRegExp('/I am a returning customer/', $response->getOutput()); - } - - public function testDispatchingToAnotherExamplaryAction() - { - $response = $this->dispatchAction('checkout/cart/add', 'POST', ['product_id' => 28]); - $output = json_decode($response->getOutput(), true); - $this->assertTrue(isset($output['success']) && isset($output['total'])); - $this->assertRegExp('/HTC Touch HD/', $output['success']); - } -} diff --git a/README.md b/readme.md old mode 100755 new mode 100644 similarity index 93% rename from README.md rename to readme.md index 83206fc..4e58162 --- a/README.md +++ b/readme.md @@ -6,9 +6,9 @@ # Requirements ------------ -* PHP 5.6 and later. +* PHP 8.0 and later. * cURL -* Opencart 3.x +* Opencart 4.x # Installation --------------- @@ -23,4 +23,3 @@ # Notes --------------- * Developed and Tested on vanilla OpenCart Installation - diff --git a/upload/admin/controller/extension/payment/iyzico.php b/upload/admin/controller/extension/payment/iyzico.php deleted file mode 100755 index 890dc29..0000000 --- a/upload/admin/controller/extension/payment/iyzico.php +++ /dev/null @@ -1,316 +0,0 @@ - 'error_api_channel', - 'name' => 'payment_iyzico_api_channel', - ), - array( - 'validateField' => 'blank', - 'name' => 'payment_iyzico_api_url', - ), - array( - 'validateField' => 'error_api_key', - 'name' => 'payment_iyzico_api_key', - ), - array( - 'validateField' => 'error_secret_key', - 'name' => 'payment_iyzico_secret_key', - ), - array( - 'validateField' => 'error_design', - 'name' => 'payment_iyzico_design', - ), - array( - 'validateField' => 'error_order_status', - 'name' => 'payment_iyzico_order_status', - ), - array( - 'validateField' => 'error_cancel_order_status', - 'name' => 'payment_iyzico_order_cancel_status', - ), - array( - 'validateField' => 'blank', - 'name' => 'payment_iyzico_status', - ), - array( - 'validateField' => 'blank', - 'name' => 'payment_iyzico_sort_order', - ), - array( - 'validateField' => 'error_title', - 'name' => 'payment_iyzico_title', - ), - array( - 'validateField' => 'blank', - 'name' => 'payment_iyzico_order_status_id', - ), - array( - 'validateField' => 'blank', - 'name' => 'payment_iyzico_overlay_token', - ), - array( - 'validateField' => 'blank', - 'name' => 'payment_iyzico_overlay_position', - ), - array( - 'validateField' => 'blank', - 'name' => 'payment_iyzico_overlay_status', - ) - - ); - - public function index() { - - $this->load->language('extension/payment/iyzico'); - $this->load->model('setting/setting'); - $this->load->model('user/user'); - $this->load->model('extension/payment/iyzico'); - - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { - - $request = $this->requestIyzico($this->request->post,'add',''); - - $overlay_result = $this->getOverlayScript($request['payment_iyzico_overlay_status'], - $request['payment_iyzico_api_key'], - $request['payment_iyzico_secret_key']); - - - $request_overlay = $this->requestIyzico($request,'edit',$overlay_result); - - $request = array_merge($request,$request_overlay); - - $this->model_setting_setting->editSetting('payment_iyzico',$request); - - $this->getApiConnection($request['payment_iyzico_api_key'],$request['payment_iyzico_secret_key']); - - - $this->response->redirect($this->url->link('extension/payment/iyzico', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)); - } - - foreach ($this->fields as $key => $field) { - - if (isset($this->error[$field['validateField']])) { - $data[$field['validateField']] = $this->error[$field['validateField']]; - } else { - $data[$field['validateField']] = ''; - } - - if (isset($this->request->post[$field['name']])) { - $data[$field['name']] = $this->request->post[$field['name']]; - } else { - $data[$field['name']] = $this->config->get($field['name']); - } - } - - $this->document->setTitle($this->language->get('heading_title')); - $this->document->addStyle('view/stylesheet/iyzico/iyzico.css'); - $this->document->addScript('view/javascript/iyzico/accordion_iyzico.js','footer'); - - - - /* Extension Install Completed Status */ - $data['install_status'] = $this->installStatus(); - - /* User Info Get*/ - $user_info = $this->model_user_user->getUser($this->user->getId()); - $data['firstname'] = $user_info['firstname']; - $data['lastname'] = $user_info['lastname']; - - /* Get Api Status */ - $data['api_status'] = $this->getApiStatus($data['install_status']); - - /* Get Order Status */ - $this->load->model('localisation/order_status'); - $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); - - - $data['action'] = $this->url->link('extension/payment/iyzico', 'user_token=' . $this->session->data['user_token'], true); - $data['heading_title'] = $this->language->get('heading_title'); - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - $data['locale'] = $this->language->get('code'); - - $this->response->setOutput($this->load->view('extension/payment/iyzico', $data)); - } - - private function getApiConnection($api_key,$secret_key) { - - $api_con_object = new stdClass(); - $api_con_object->locale = $this->language->get('code'); - $api_con_object->conversationId = rand(100000,99999999); - $api_con_object->binNumber = '454671'; - - $api_con_pki = $this->model_extension_payment_iyzico->pkiStringGenerate($api_con_object); - $authorization_data = $this->model_extension_payment_iyzico->authorizationGenerate($api_key,$secret_key,$api_con_pki); - $test_api_con = $this->model_extension_payment_iyzico->apiConnection($authorization_data,$api_con_object); - - if(isset($test_api_con->status) && $test_api_con->status == 'success') { - $api_status = true; - - } else { - - $api_status = false; - } - - $this->session->data['api_status'] = $api_status; - - return $api_status; - } - - private function getOverlayScript($position,$api_key,$secret_key) { - - $overlay_script_object = new stdClass(); - $overlay_script_object->locale = $this->language->get('code'); - $overlay_script_object->conversationId = rand(100000,99999999); - $overlay_script_object->position = $position; - - $overlay_pki = $this->model_extension_payment_iyzico->pkiStringGenerate($overlay_script_object); - $authorization_data = $this->model_extension_payment_iyzico->authorizationGenerate($api_key,$secret_key,$overlay_pki); - $overlay_script = $this->model_extension_payment_iyzico->overlayScript($authorization_data,$overlay_script_object); - - return $overlay_script; - } - - private function getApiStatus($install_status) { - - $api_status = false; - - if($install_status >= 6 ) { - - if(isset($this->session->data['api_status']) && !empty($this->session->data['api_status'])) { - - $api_status = $this->session->data['api_status']; - - } else { - $api_key = $this->config->get('payment_iyzico_api_key'); - $secret_key = $this->config->get('payment_iyzico_secret_key'); - - return $this->getApiConnection($api_key,$secret_key); - } - - } else { - - $api_status = false; - } - - - return $api_status; - - } - - private function installStatus() { - - $counter = 0; - - foreach ($this->fields as $key => $field) { - - $data[$field['name']] = $this->config->get($field['name']); - if(!empty($this->config->get($field['name']))) - $counter++; - } - - - return $counter; - } - - - public function install() { - - $this->load->model('extension/payment/iyzico'); - $this->model_extension_payment_iyzico->install(); - $this->model_setting_event->addEvent('overlay_script', 'catalog/controller/common/footer/after', 'extension/payment/iyzico/injectOverlayScript'); - $this->model_setting_event->addEvent('module_notification', 'admin/controller/common/footer/after', 'extension/payment/iyzico/injectModuleNotification'); - } - - public function uninstall() { - - $this->load->model('extension/payment/iyzico'); - $this->model_extension_payment_iyzico->uninstall(); - $this->model_setting_event->deleteEventByCode('overlay_script'); - $this->model_setting_event->deleteEventByCode('module_notification'); - } - - protected function validate() { - - if (!$this->user->hasPermission('modify', 'extension/payment/iyzico')) { - $this->error['warning'] = $this->language->get('error_permission'); - } - - foreach ($this->fields as $key => $field) { - - if($field['validateField'] != 'blank') { - - if (!$this->request->post[$field['name']]){ - $this->error[$field['validateField']] = $this->language->get($field['validateField']); - } - } - - } - - return !$this->error; - } - - public function requestIyzico($request,$method_type,$extra_request = false) { - - $request_modify = array(); - - if ($method_type == 'add') { - - - foreach ($this->fields as $key => $field) { - - if(isset($request[$field['name']])) { - - if($field['name'] == 'payment_iyzico_api_key' || $field['name'] == 'payment_iyzico_secret_key') - $request[$field['name']] = str_replace(' ','',$request[$field['name']]); - - $request_modify[$field['name']] = $request[$field['name']]; - - } - - } - - if($request_modify['payment_iyzico_api_channel'] == 'live') { - - $request_modify['payment_iyzico_api_url'] = 'https://api.iyzipay.com'; - - } else if($request_modify['payment_iyzico_api_channel'] == 'sandbox') { - - $request_modify['payment_iyzico_api_url'] = 'https://sandbox-api.iyzipay.com'; - $request_modify['payment_iyzico_overlay_status'] = 'hidden'; - - } - - - if(!$request_modify['payment_iyzico_overlay_status']) { - - - $request_modify['payment_iyzico_overlay_status'] = 'bottomLeft'; - } - - } - - if ($method_type == 'edit') { - - if(isset($extra_request->status)) { - - if($extra_request->status == 'success') { - - $request_modify['payment_iyzico_overlay_token'] = $extra_request->protectedShopId; - } - } - } - - return $request_modify; - } - - - -} diff --git a/upload/admin/language/en-gb/extension/payment/iyzico.php b/upload/admin/language/en-gb/extension/payment/iyzico.php deleted file mode 100755 index ef19cd2..0000000 --- a/upload/admin/language/en-gb/extension/payment/iyzico.php +++ /dev/null @@ -1,61 +0,0 @@ -iyzico'; -$_['general_select'] = 'Select'; -$_['live'] = 'Live'; -$_['sandbox'] = 'Sandbox / Test'; -$_['api_field'] = 'API Type'; -$_['api_field_tooltip'] = 'API Type Live or Sandbox'; -$_['api_key'] = 'API Key'; -$_['secret_key'] = 'Secret Key'; -$_['apikey_field_tooltip'] = 'Your API key with including 32 digit letter and number.'; -$_['secretkey_field_tooltip'] = 'Your Secret Key with including 32 digit letter and number.'; -$_['view_select'] = 'Design'; -$_['order_status'] = 'Order Status'; -$_['cancel_order_status'] = 'Cancel Order Status'; -$_['order_status_tooltip'] = 'New ordering status info'; -$_['cancel_order_status_tooltip'] = 'Cancel ordering status info'; -$_['extension_status'] = 'Extension Status'; -$_['sort_order'] = 'Order'; -$_['error_api_channel'] = 'Api Channel Required!'; -$_['error_api_key'] = 'Api Key Required!'; -$_['error_secret_key'] = 'Secret Key Required!'; -$_['text_success'] = 'Iyzico Payment Extension: Updated Success!'; -$_['valid_live'] = 'Sandbox API key information is unusable for Live API'; -$_['valid_sandbox'] = 'Live API key information is unusable for Sandbox API'; -$_['install'] = 'Install'; -$_['help'] = 'Help'; -$_['settings'] = 'Settings'; -$_['settings_content'] = 'I Hope everything is okay'; -$_['install_title'] = 'Install Title'; -$_['install_hello'] = 'Hello'; -$_['support'] = 'Support'; -$_['install_content'] = 'Welcome to iyzico Opencart install screen.
Live:         https://merchant.iyzipay.com
- Sandbox:   https://sandbox-merchant.iyzipay.com

- Help detail Help is click.'; -$_['payment_title'] = 'Payment Value'; -$_['api_connection'] = 'Api Connection:'; -$_['api_connection_success'] = 'Success'; -$_['api_connection_failed'] = 'Failed'; -$_['api_connection_failed_content'] = 'Opss.. Help detail Help is click.'; -$_['buyer_protection'] = 'Buyer Protection'; -$_['overlay_design'] = 'Design:'; -$_['overlay_bottom_left'] = 'Bottom Left'; -$_['overlay_bottom_left_val'] = 'bottomLeft'; -$_['overlay_bottom_right'] = 'Bottom Right'; -$_['overlay_bottom_right_val'] = 'bottomRight'; -$_['overlay_closed'] = 'Hidden'; -$_['overlay_closed_val'] = 'hidden'; -$_['iyzico_update_screen'] = 'IYZICO UPDATE SCREEN'; -$_['current_version_name'] = 'Old Version:'; -$_['new_version_name'] = 'New Version:'; -$_['description_name'] = 'Description:'; - - - - - - - diff --git a/upload/admin/model/extension/payment/iyzico.php b/upload/admin/model/extension/payment/iyzico.php deleted file mode 100755 index b0bcd4b..0000000 --- a/upload/admin/model/extension/payment/iyzico.php +++ /dev/null @@ -1,165 +0,0 @@ -db->query(" - CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "iyzico_order` ( - `iyzico_order_id` INT(11) NOT NULL AUTO_INCREMENT, - `payment_id` INT(11) NOT NULL, - `order_id` INT(11) NOT NULL, - `total_amount` DECIMAL( 10, 2 ) NOT NULL, - `status` VARCHAR(20) NOT NULL, - `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`iyzico_order_id`) - ) ENGINE=MyISAM DEFAULT COLLATE=utf8_general_ci;"); - - $this->db->query(" - CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "iyzico_card` ( - `iyzico_card_id` INT(11) NOT NULL AUTO_INCREMENT, - `customer_id` INT(11) NOT NULL, - `card_user_key` VARCHAR(50), - `api_key` VARCHAR(50), - `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`iyzico_card_id`) - ) ENGINE=MyISAM DEFAULT COLLATE=utf8_general_ci;"); - } - - public function uninstall() { - $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "iyzico_order`;"); - $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "iyzico_card`;"); - } - - public function pkiStringGenerate($object_data) { - - $pki_value = "["; - foreach ($object_data as $key => $data) { - if(is_object($data)) { - $name = var_export($key, true); - $name = str_replace("'", "", $name); - $pki_value .= $name."=["; - $end_key = count(get_object_vars($data)); - $count = 0; - foreach ($data as $key => $value) { - $count++; - $name = var_export($key, true); - $name = str_replace("'", "", $name); - $pki_value .= $name."="."".$value; - if($end_key != $count) - $pki_value .= ","; - } - $pki_value .= "]"; - } else if(is_array($data)) { - $name = var_export($key, true); - $name = str_replace("'", "", $name); - $pki_value .= $name."=["; - $end_key = count($data); - $count = 0; - foreach ($data as $key => $result) { - $count++; - $pki_value .= "["; - - foreach ($result as $key => $item) { - $name = var_export($key, true); - $name = str_replace("'", "", $name); - - $pki_value .= $name."="."".$item; - if(end($result) != $item) { - $pki_value .= ","; - } - if(end($result) == $item) { - if($end_key != $count) { - $pki_value .= "], "; - - } else { - $pki_value .= "]"; - } - } - } - } - if(end($data) == $result) - $pki_value .= "]"; - - } else { - $name = var_export($key, true); - $name = str_replace("'", "", $name); - - $pki_value .= $name."="."".$data.""; - } - if(end($object_data) != $data) - $pki_value .= ","; - } - $pki_value .= "]"; - return $pki_value; - } - - public function authorizationGenerate($api_key,$secret_key,$pki) { - - $rand_value = rand(100000,99999999); - $hash_value = $api_key.$rand_value.$secret_key.$pki; - $hash = base64_encode(sha1($hash_value,true)); - - $authorization = 'IYZWS '.$api_key.':'.$hash; - - $authorization_data = array( - 'authorization' => $authorization, - 'rand_value' => $rand_value - ); - - return $authorization_data; - } - - public function apiConnection($authorization_data,$api_connection_object) { - - $url = $this->config->get('payment_iyzico_api_url'); - $url = $url.'/payment/bin/check'; - - $api_connection_object = json_encode($api_connection_object); - - return $this->curlPost($api_connection_object,$authorization_data,$url); - - } - - public function overlayScript($authorization_data,$overlay_script_object) { - - $url = "https://iyziup.iyzipay.com/"; - $url = $url."v1/iyziup/protected/shop/detail/overlay-script"; - - $overlay_script_object = json_encode($overlay_script_object); - - return $this->curlPost($overlay_script_object,$authorization_data,$url); - - } - - public function curlPost($json,$authorizationData,$url) { - - $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, $url); - $content_length = 0; - if ($json) { - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); - curl_setopt($curl, CURLOPT_POSTFIELDS, $json); - } - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); - curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); - curl_setopt($curl, CURLOPT_TIMEOUT, 10); - - curl_setopt( - $curl, CURLOPT_HTTPHEADER, array( - "Authorization: " .$authorizationData['authorization'], - "x-iyzi-rnd:".$authorizationData['rand_value'], - "Content-Type: application/json", - ) - ); - - $result = json_decode(curl_exec($curl)); - curl_close($curl); - - - return $result; - } - -} \ No newline at end of file diff --git a/upload/admin/view/image/payment/iyzico_logo.png b/upload/admin/view/image/payment/iyzico_logo.png deleted file mode 100644 index d225a86..0000000 Binary files a/upload/admin/view/image/payment/iyzico_logo.png and /dev/null differ diff --git a/upload/admin/view/javascript/iyzico/validation_iyzico.js b/upload/admin/view/javascript/iyzico/validation_iyzico.js deleted file mode 100755 index 2ec4532..0000000 --- a/upload/admin/view/javascript/iyzico/validation_iyzico.js +++ /dev/null @@ -1 +0,0 @@ -function getApiValid(){var e,n,t;return event.preventDefault(),e=document.getElementById("api_channel").value,n=document.getElementById("api_key").value,t=document.getElementById("secret_key").value,"live"==e?l(n,t):"sandbox"==e?s(n,t):(alert("Geçersiz istek."),!1)}function l(e,n){if("sandbox-"==e.substring(0,8)||"sandbox-"==n.substring(0,8))return alert("{{valid_live}}"),!1}function s(e,n){if("sandbox-"!=e.substring(0,8)||"sandbox-"!=n.substring(0,8))return alert("{{valid_sandbox}}"),!1} diff --git a/upload/admin/view/template/extension/payment/iyzico.twig b/upload/admin/view/template/extension/payment/iyzico.twig deleted file mode 100755 index e210cd8..0000000 --- a/upload/admin/view/template/extension/payment/iyzico.twig +++ /dev/null @@ -1,363 +0,0 @@ -{{ header }}{{ column_left }} -
- - -
-
-
- -
-
- {% if install_status >= 6 %} -
-
Iyzico
-
- {{install_hello}} {{ firstname }}, {{settings_content}} -
- {% if api_status %} - {{api_connection}} {{api_connection_success}} -
- {% else %} - {{api_connection}} {{api_connection_failed}} -
- {{api_connection_failed_content}} {{support}} - {% endif %} -
-
- {% else %} -
-
{{install_title}}
-
{{install_hello}} {{ firstname }}, {{install_content}}
-
- {% endif %} - -
- -
- - {% if error_api_channel %} -
{{ error_api_channel }}
- {% endif %} -
-
-
- -
- - {% if error_api_key %} -
{{ error_api_key }}
- {% endif %} -
-
-
- -
- - {% if error_secret_key %} -
{{ error_secret_key }}
- {% endif %} -
-
-
- -
- - {% if error_design %} -
{{ error_design }}
- {% endif %} -
-
-
- -
- {% if payment_iyzico_title %} - - {% else %} - - {% endif %} -
-
-
- -
- - {% if error_order_status %} -
{{ error_order_status }}
- {% endif %} -
-
-
- -
- - {% if error_cancel_order_status %} -
{{ error_cancel_order_status }}
- {% endif %} -
-
-
- -
- -
-
-
- -
- -
-
- -
-
-
-
- -
-

{{ overlay_design }}

-
-
- -
-
-
-
-
-

Korumalı Alışveriş Bilgi Kutucuğu Nedir?

-

Korumalı Alışveriş bilgi kutucuğu, iyzico’nun Korumalı Alışveriş programına dahil olan (ürününü kullanan) e-ticaret sitelerinin kullandığı bir araçtır. Müşterilerin, e-ticaret sitelerinden alışverişle ilgili yaşadığı güven sorununun önüne geçmeyi amaçlayan bu uygulamayı sitenizin sadece ödeme sayfasında değil, sitenizdeki tüm sayfalara ekleyerek ziyaretçilerinizin güvenini kazanabilir, satışlarınıza katkı sağlayabilirsiniz.

- -

E-ticaret müşterilerinin güvenmedikleri bir siteden alışveriş yapma olasılığı oldukça azdır. Bankacılık Düzenleme ve Denetleme Kurulu lisanslı iyzico’nun ‘Korumalı Alışveriş’ bilgi kutucuğu, o sitenin iyzico güvencesi altında olduğuna, ihtiyaç halinde iyzico destek ekibinin olası sorunları çözeceği anlamına gelir. Bu, alışveriş için sitenize gelen müşterilerinize güvenli alışveriş yapabilecekleri mesajı verir.

- -

Hesabınızda korumalı alışveriş aktif değilse destek@iyizco.com mail atabilirsiniz.

- -
-
-
-
- - {% if locale == 'tr' %} -
API bilgileri nedir ?
-
-

API bilgileri şifrelenerek size özel olarak tanımlanmış anahtar bilgileridir. Bu anahtarlar siteniz üzerinden İyzico servisleri ile iletişim kurmanızı sağlar. -

-
-
Live ve Sandbox Nedir ?
-
-

Live ve Sandbox kullanacağınız API türünü yansıtmaktadır.

-
    -
  • Live API
  • -
-

Müşterilerinizden gerçek ödeme almak için Live Api kullanılır. Müşterilerinizin kartları aracılığıyla İyzico üzerinden ödeme alabilmeniz için kullanılır.

-
    -
  • Sandbox API
  • -
-

Web sayfanızı müşterilerinize açmadan önce İyzico Api ile test yapmak için kullanılır. Yapılan istekler gerçek istekler değildir, sadece geliştirme amaçlı kullanılır.

-
-
API bilgilerime nereden ulaşabilirim ?
-
-
    -
  • Live API
  • -
-

https://merchant.iyzipay.com adresi üzerinden müşteri bilgileriniz ile giriş yapınız. Panele eriştiğiniz sırada sağ üst köşede profil bilgilerinizi göreceksiniz. Profil bilgilerinizin üzerine tıkladıktan sonra “Ayarlar” menüsüne tıklayınız. “API Anahtları" alanından “API Anahtarı ve Güvenlik Anahtarı" bilgilerinizi kopyalayıp Opencart iyzico modülü panelinde bulunan “API Anahtarı” ve “Güvenlik Anahtarı” alanlarına yapıştırınız..

-
    -
  • Sandbox API
  • -
-

https://sandbox-merchant.iyzipay.com adresi üzerinden müşteri bilgileriniz ile giriş yapınız. Panele eriştiğiniz sırada sağ üst köşede profil bilgilerinizi göreceksiniz. Profil bilgilerinizin üzerine tıkladıktan sonra “Ayarlar” menüsüne tıklayınız. “API Anahtları" alanından “API Anahtarı ve Güvenlik Anahtarı" bilgilerinizi kopyalayıp Opencart iyzico modülü panelinde bulunan “API Anahtarı” ve “Güvenlik Anahtarı” alanlarına yapıştırınız..

-

Test ortamımız için https://sandbox-merchant.iyzipay.com/login adresinden kayıt olup hemen sonrasında(mail onaysız) login olabiliyorsunuz. Sandbox’ı test ederken https://dev.iyzipay.com/tr/test-kartlari adresindeki test kartlarını kullanabilirsiniz.

-
-
Responsive ve Popup Nedir ?
-
-
    -
  • Responsive
  • -
-

Müşterileriniz ödeme adımına geldiği zaman ödeme formunun Mobil ve Web uyumlu olarak görünmesini sağlar.

-
    -
  • Popup
  • -
-

Müşterileriniz ödeme adımına geldiği zaman tüm ekranı şeffaf olarak kaplayan Mobil ve Web uyumlu İyzico ödeme formunun görünmesini sağlar.

-
-
Korumalı Alışveriş Nedir ?
-
-

Korumalı Alışveriş müşterilerinizin ve sizin İyzico güvencesi altında olduğunuzu belirten bir servistir.

-

Müşterilerinize İyzico Korumalı Alışveriş güvencesi altında olduğunu göstermek için “Korumalı Alışveriş” sekmesinden Korumalı Alışveriş logosunun sayfanızın neresinde gözükmesini istediğinizi seçmeniz yeterlidir.

-
-
Bağlantı durumu: “başarısız” sebebi ne olabilir ?
-
-
    -
  • API bilgilerinizi kontrol ettiniz mi ?
  • -
-

İyzico üzerinden aldığınız "API Anahtarı” ve “Güvenlik Anahtarı” bilgilerinin doğru olduğundan emin olunuz.

-
    -
  • TLS versiyonunuzu kontrol ettiniz mi ?
  • -
-

Sunucu sağlayıcınızla görüşerek OpenSSL versiyonunu minimum 1.0.1’e, curl versiyonunu 7.30.4 yukseltebilirsiniz.

-
    -
  • Sorununuz hala devam ediyor mu ?
  • -
-

Bizimle iletişime geçebilirsiniz. Destek için: destek@iyzico.com -

- {% elseif locale == 'en' %} - - {% endif %} - - -
-
-
-
-
-
-
- - -{{ footer }} \ No newline at end of file diff --git a/upload/catalog/controller/extension/payment/iyzico.php b/upload/catalog/controller/extension/payment/iyzico.php deleted file mode 100755 index ae0ba59..0000000 --- a/upload/catalog/controller/extension/payment/iyzico.php +++ /dev/null @@ -1,503 +0,0 @@ -load->language('extension/payment/iyzico'); - $data['form_class'] = $this->config->get('payment_iyzico_design'); - $data['form_type'] = $this->config->get('payment_iyzico_design'); - - if($data['form_type'] == 'onepage') - $data['form_class'] = 'responsive'; - - - $data['user_login_check'] = $this->customer->isLogged(); - - return $this->load->view('extension/payment/iyzico_form',$data); - } - - public function getCheckoutFormToken() { - - $this->load->model('checkout/order'); - $this->load->model('setting/setting'); - $this->load->model('extension/payment/iyzico'); - - $module_attribute = false; - $order_id = (int) $this->session->data['order_id']; - $customer_id = (int) isset($this->session->data['customer_id']) ? $this->session->data['customer_id'] : 0; - $user_id = (int) isset($this->session->data['user_id']) ? $this->session->data['user_id'] : 0; - $order_info = $this->model_checkout_order->getOrder($order_id); - $products = $this->cart->getProducts(); - - $api_key = $this->config->get('payment_iyzico_api_key'); - $secret_key = $this->config->get('payment_iyzico_secret_key'); - $payment_source = "OPENCART-".$this->module_version."|".$this->module_product_name."|".$this->config->get('payment_iyzico_design'); - - $user_create_date = $this->model_extension_payment_iyzico->getUserCreateDate($user_id); - - $this->session->data['conversation_id'] = $order_id; - - - $order_info['payment_address'] = $order_info['payment_address_1']." ".$order_info['payment_address_2']; - $order_info['shipping_address'] = $order_info['shipping_address_1']." ".$order_info['shipping_address_2']; - - - /* Order Detail */ - $iyzico = new stdClass; - $iyzico->locale = $this->language->get('code'); - $iyzico->conversationId = $order_id; - $iyzico->price = $this->priceParser($this->itemPriceSubTotal($products) * $order_info['currency_value']); - $iyzico->paidPrice = $this->priceParser($order_info['total'] * $order_info['currency_value']); - $iyzico->currency = $order_info['currency_code']; - $iyzico->basketId = $order_id; - $iyzico->paymentGroup = "PRODUCT"; - $iyzico->forceThreeDS = "0"; - $iyzico->callbackUrl = $this->url->link('extension/payment/iyzico/getcallback', '', true); - $iyzico->cardUserKey = $this->model_extension_payment_iyzico->findUserCardKey($customer_id,$api_key); - $iyzico->paymentSource = $payment_source; - - if ($iyzico->paidPrice === 0) { - return false; - } - - $iyzico->buyer = new stdClass; - $iyzico->buyer->id = $order_info['customer_id']; - $iyzico->buyer->name = $this->dataCheck($order_info['firstname']); - $iyzico->buyer->surname = $this->dataCheck($order_info['lastname']); - $iyzico->buyer->identityNumber = '11111111111'; - $iyzico->buyer->email = $this->dataCheck($order_info['email']); - $iyzico->buyer->gsmNumber = $this->dataCheck($order_info['telephone']); - $iyzico->buyer->registrationDate = $user_create_date; - $iyzico->buyer->lastLoginDate = date('Y-m-d H:i:s'); - $iyzico->buyer->registrationAddress = $this->dataCheck($order_info['payment_address']); - $iyzico->buyer->city = $this->dataCheck($order_info['payment_zone']); - $iyzico->buyer->country = $this->dataCheck($order_info['payment_country']); - $iyzico->buyer->zipCode = $this->dataCheck($order_info['payment_postcode']); - $iyzico->buyer->ip = $this->dataCheck($this->getIpAdress()); - - $iyzico->shippingAddress = new stdClass; - $iyzico->shippingAddress->address = $this->dataCheck($order_info['shipping_address']); - $iyzico->shippingAddress->zipCode = $this->dataCheck($order_info['shipping_postcode']); - $iyzico->shippingAddress->contactName = $this->dataCheck($order_info['shipping_firstname']); - $iyzico->shippingAddress->city = $this->dataCheck($order_info['shipping_zone']); - $iyzico->shippingAddress->country = $this->dataCheck($order_info['shipping_country']); - - - $iyzico->billingAddress = new stdClass; - $iyzico->billingAddress->address = $this->dataCheck($order_info['payment_address']); - $iyzico->billingAddress->zipCode = $this->dataCheck($order_info['payment_postcode']); - $iyzico->billingAddress->contactName = $this->dataCheck($order_info['payment_firstname']); - $iyzico->billingAddress->city = $this->dataCheck($order_info['payment_zone']); - $iyzico->billingAddress->country = $this->dataCheck($order_info['payment_country']); - - foreach ($products as $key => $product) { - $price = $product['total'] * $order_info['currency_value']; - - if($price) { - $iyzico->basketItems[$key] = new stdClass(); - - $iyzico->basketItems[$key]->id = $product['model']; - $iyzico->basketItems[$key]->price = $this->priceParser($price); - $iyzico->basketItems[$key]->name = $product['name']; - $iyzico->basketItems[$key]->category1 = $this->model_extension_payment_iyzico->getCategoryName($product['product_id']); - $iyzico->basketItems[$key]->itemType = "PHYSICAL"; - } - } - - $shipping = $this->shippingInfo(); - - if(!empty($shipping) && $shipping['cost'] && $shipping['cost'] != '0.00') { - - $shippigKey = count($iyzico->basketItems); - - $iyzico->basketItems[$shippigKey] = new stdClass(); - - $iyzico->basketItems[$shippigKey]->id = 'Kargo'; - $iyzico->basketItems[$shippigKey]->price = $this->priceParser($shipping['cost'] * $order_info['currency_value']); - $iyzico->basketItems[$shippigKey]->name = $shipping['title']; - $iyzico->basketItems[$shippigKey]->category1 = "Kargo"; - $iyzico->basketItems[$shippigKey]->itemType = "VIRTUAL"; - } - - - $rand_value = rand(100000,99999999); - $order_object = $this->model_extension_payment_iyzico->createFormInitializObjectSort($iyzico); - $pki_generate = $this->model_extension_payment_iyzico->pkiStringGenerate($order_object); - $authorization_data = $this->model_extension_payment_iyzico->authorizationGenerate($pki_generate,$api_key,$secret_key,$rand_value); - - $iyzico_json = json_encode($iyzico,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); - - $form_response = $this->model_extension_payment_iyzico->createFormInitializeRequest($iyzico_json,$authorization_data); - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($form_response)); - } - - public function getCallBack() { - - try { - - $this->load->language('extension/payment/iyzico'); - - if(!isset($this->request->post['token']) || empty($this->request->post['token'])) { - - $errorMessage = 'invalid token'; - throw new \Exception($errorMessage); - - } - - $this->load->model('checkout/order'); - $this->load->model('extension/payment/iyzico'); - - $api_key = $this->config->get('payment_iyzico_api_key'); - $secret_key = $this->config->get('payment_iyzico_secret_key'); - $conversation_id = (int) $this->session->data['conversation_id']; - $order_id = (int) $this->session->data['order_id']; - $customer_id = isset($this->session->data['customer_id']) ? (int) $this->session->data['customer_id'] : 0; - - $detail_object = new stdClass(); - - $detail_object->locale = $this->language->get('code'); - $detail_object->conversationId = $conversation_id; - $detail_object->token = $this->db->escape($this->request->post['token']); - - $rand_value = rand(100000,99999999); - $pki_generate = $this->model_extension_payment_iyzico->pkiStringGenerate($detail_object); - $authorization_data = $this->model_extension_payment_iyzico->authorizationGenerate($pki_generate,$api_key,$secret_key,$rand_value); - - $iyzico_json = json_encode($detail_object); - $request_response = $this->model_extension_payment_iyzico->createFormInitializeDetailRequest($iyzico_json,$authorization_data); - - $iyzico_local_order = new stdClass; - $iyzico_local_order->payment_id = !empty($request_response->paymentId) ? (int) $request_response->paymentId : ''; - $iyzico_local_order->order_id = (int) $this->session->data['order_id']; - $iyzico_local_order->total_amount = !empty($request_response->paidPrice) ? (float) $request_response->paidPrice : ''; - $iyzico_local_order->status = $request_response->paymentStatus; - - $iyzico_order_insert = $this->model_extension_payment_iyzico->insertIyzicoOrder($iyzico_local_order); - - 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); - } - - - /* Save Card */ - if(isset($request_response->cardUserKey)) { - - if($customer_id) { - - $cardUserKey = $this->model_extension_payment_iyzico->findUserCardKey($customer_id,$api_key); - - if($request_response->cardUserKey != $cardUserKey) { - - $this->model_extension_payment_iyzico->insertCardUserKey($customer_id,$request_response->cardUserKey,$api_key); - - } - } - - } - - $payment_id = $this->db->escape($request_response->paymentId); - $payment_field_desc = $this->language->get('payment_field_desc'); - if (!empty($payment_id)) { - $message = $payment_field_desc.$payment_id . "\n"; - } - - $installment = $request_response->installment; - - if ($installment > 1) { - $installement_field_desc = $this->language->get('installement_field_desc'); - $this->model_extension_payment_iyzico->orderUpdateByInstallement($iyzico_local_order->order_id,$request_response->paidPrice); - $this->model_checkout_order->addOrderHistory($iyzico_local_order->order_id, $this->config->get('payment_iyzico_order_status'), $message); - $messageInstallement = $request_response->cardFamily . ' - ' . $request_response->installment .$installement_field_desc; - $this->model_checkout_order->addOrderHistory($iyzico_local_order->order_id, $this->config->get('payment_iyzico_order_status'), $messageInstallement); - } else { - $this->model_checkout_order->addOrderHistory($iyzico_local_order->order_id, $this->config->get('payment_iyzico_order_status'), $message); - } - - return $this->response->redirect($this->url->link('extension/payment/iyzico/successpage')); - - } catch (Exception $e) { - - $errorMessage = isset($request_response->errorMessage) ? $request_response->errorMessage : $e->getMessage(); - - $this->session->data['iyzico_error_message'] = $errorMessage; - - return $this->response->redirect($this->url->link('extension/payment/iyzico/errorpage')); - - } - - - } - - public function errorPage() { - - $data['continue'] = $this->url->link('common/home'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['column_right'] = $this->load->controller('common/column_right'); - $data['content_top'] = $this->load->controller('common/content_top'); - $data['content_bottom'] = $this->load->controller('common/content_bottom'); - $data['footer'] = $this->load->controller('common/footer'); - $data['header'] = $this->load->controller('common/header'); - $data['error_title'] = 'Ödemeniz Alınamadı.'; - $data['error_message'] = $this->session->data['iyzico_error_message']; - $data['error_icon'] = 'catalog/view/theme/default/image/payment/iyzico_error_icon.png'; - - return $this->response->setOutput($this->load->view('extension/payment/iyzico_error', $data)); - - } - - public function successPage() { - - if(!isset($this->session->data['order_id'])) { - return $this->response->redirect($this->url->link('common/home')); - } - - $this->load->language('account/order'); - - $order_id = $this->session->data['order_id']; - - if (isset($this->session->data['order_id'])) { - $this->cart->clear(); - - unset($this->session->data['shipping_method']); - unset($this->session->data['shipping_methods']); - unset($this->session->data['payment_method']); - unset($this->session->data['payment_methods']); - unset($this->session->data['guest']); - unset($this->session->data['comment']); - unset($this->session->data['coupon']); - unset($this->session->data['reward']); - unset($this->session->data['voucher']); - unset($this->session->data['vouchers']); - unset($this->session->data['totals']); - } - - $this->load->model('account/order'); - $this->load->model('catalog/product'); - $this->load->model('tool/upload'); - - $order_info = $this->model_account_order->getOrder($order_id); - - // Products - $data['products'] = array(); - - $products = $this->model_account_order->getOrderProducts($order_id); - - foreach ($products as $product) { - $option_data = array(); - - $options = $this->model_account_order->getOrderOptions($order_id, $product['order_product_id']); - - foreach ($options as $option) { - if ($option['type'] != 'file') { - $value = $option['value']; - } else { - $upload_info = $this->model_tool_upload->getUploadByCode($option['value']); - - if ($upload_info) { - $value = $upload_info['name']; - } else { - $value = ''; - } - } - - $option_data[] = array( - 'name' => $option['name'], - 'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) - ); - } - - $product_info = $this->model_catalog_product->getProduct($product['product_id']); - - if ($product_info) { - $reorder = $this->url->link('account/order/reorder', 'order_id=' . $order_id . '&order_product_id=' . $product['order_product_id'], true); - } else { - $reorder = ''; - } - - $data['products'][] = array( - 'name' => $product['name'], - 'model' => $product['model'], - 'option' => $option_data, - 'quantity' => $product['quantity'], - 'price' => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']), - 'total' => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value']), - 'reorder' => $reorder, - 'return' => $this->url->link('account/return/add', 'order_id=' . $order_info['order_id'] . '&product_id=' . $product['product_id'], true) - ); - } - - // Voucher - $data['vouchers'] = array(); - - $vouchers = $this->model_account_order->getOrderVouchers($order_id); - - foreach ($vouchers as $voucher) { - $data['vouchers'][] = array( - 'description' => $voucher['description'], - 'amount' => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']) - ); - } - - // Totals - $data['totals'] = array(); - - $totals = $this->model_account_order->getOrderTotals($order_id); - - foreach ($totals as $total) { - $data['totals'][] = array( - 'title' => $total['title'], - 'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), - ); - } - - $data['comment'] = nl2br($order_info['comment']); - - // History - $data['histories'] = array(); - - $results = $this->model_account_order->getOrderHistories($order_id); - - foreach ($results as $result) { - $data['histories'][] = array( - 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])), - 'status' => $result['status'], - 'comment' => $result['notify'] ? nl2br($result['comment']) : '' - ); - } - - $this->document->addStyle('catalog/view/javascript/iyzico/iyzico_success.css'); - - $data['continue'] = $this->url->link('account/order', '', true); - - $data['column_left'] = $this->load->controller('common/column_left'); - $data['column_right'] = $this->load->controller('common/column_right'); - $data['content_top'] = $this->load->controller('common/content_top'); - $data['content_bottom'] = $this->load->controller('common/content_bottom'); - $data['footer'] = $this->load->controller('common/footer'); - $data['header'] = $this->load->controller('common/header'); - $data['success_icon'] = 'catalog/view/theme/default/image/payment/iyzico_success_icon.png'; - - /* Remove Order */ - unset($this->session->data['order_id']); - - return $this->response->setOutput($this->load->view('extension/payment/iyzico_success', $data)); - } - - private function dataCheck($data) { - - if(!$data || $data == ' ') { - - $data = "NOT PROVIDED"; - } - - return $data; - - } - - private function shippingInfo() { - - if(isset($this->session->data['shipping_method'])) { - - $shipping_info = $this->session->data['shipping_method']; - - } else { - - $shipping_info = false; - } - - if($shipping_info) { - - if ($shipping_info['tax_class_id']) { - - $shipping_info['tax'] = $this->tax->getRates($shipping_info['cost'], $shipping_info['tax_class_id']); - - } else { - - $shipping_info['tax'] = false; - } - - } - - return $shipping_info; - } - - private function itemPriceSubTotal($products) { - - $price = 0; - - foreach ($products as $key => $product) { - - $price+= (float) $product['total']; - } - - - $shippingInfo = $this->shippingInfo(); - - if(is_object($shippingInfo) || is_array($shippingInfo)) { - - $price+= (float) $shippingInfo['cost']; - - } - - return $price; - - } - - private function priceParser($price) { - - if (strpos($price, ".") === false) { - return $price . ".0"; - } - $subStrIndex = 0; - $priceReversed = strrev($price); - for ($i = 0; $i < strlen($priceReversed); $i++) { - if (strcmp($priceReversed[$i], "0") == 0) { - $subStrIndex = $i + 1; - } else if (strcmp($priceReversed[$i], ".") == 0) { - $priceReversed = "0" . $priceReversed; - break; - } else { - break; - } - } - - return strrev(substr($priceReversed, $subStrIndex)); - } - - public function injectOverlayScript($route, &$data = false, &$output) { - - - $this->load->model('setting/setting'); - - $token = $this->config->get('payment_iyzico_overlay_token'); - $overlay_status = $this->config->get('payment_iyzico_overlay_status'); - $api_channel = $this->config->get('payment_iyzico_api_channel'); - - if($overlay_status != 'hidden' && $overlay_status != '' || $api_channel == 'sandbox') { - - $hook = ''; - $js = " - "; - - $output = str_replace($hook,$js,$output); - - } - } - - - private function getIpAdress() { - - $ip_address = $_SERVER['REMOTE_ADDR']; - - return $ip_address; - } -} diff --git a/upload/catalog/language/en-gb/extension/payment/iyzico.php b/upload/catalog/language/en-gb/extension/payment/iyzico.php deleted file mode 100755 index 6051fe9..0000000 --- a/upload/catalog/language/en-gb/extension/payment/iyzico.php +++ /dev/null @@ -1,7 +0,0 @@ -config->get('payment_iyzico_geo_zone_id'); - $payment_iyzico_geo_zone_id = $this->db->escape($payment_iyzico_geo_zone_id); - $address_country_id = $this->db->escape($address['country_id']); - $address_zone_id = $this->db->escape($address['zone_id']); - - $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE `geo_zone_id` = '" . $payment_iyzico_geo_zone_id . "' AND `country_id` = '" . $address_country_id . "' AND (`zone_id` = '" . $address_zone_id . "' OR `zone_id` = '0')"); - - if ($this->config->get('payment_iyzico_total') > $total) { - $status = false; - } elseif (!$this->config->get('payment_iyzico_geo_zone_id')) { - $status = true; - } elseif ($query->num_rows) { - $status = true; - } else { - $status = false; - } - - $method_data = array(); - - if ($status) { - $method_data = array( - 'code' => 'iyzico', - 'title' => $this->iyzicoMultipLangTitle($this->config->get('payment_iyzico_title')), - 'terms' => '', - 'sort_order' => $this->config->get('payment_iyzico_sort_order') - ); - } - - return $method_data; - } - - private function iyzicoMultipLangTitle($title) { - - $this->load->language('extension/payment/iyzico'); - - if($title) { - - $parser = explode('|',$title); - - if(is_array($parser) && count($parser)) { - - foreach ($parser as $key => $parse) { - $result = explode('=',$parse); - - if($this->language->get('code') == $result[0]) { - $new_title = $result[1]; - break; - } - } - - } - - } - if(!isset($new_title)) { - $new_title = $this->language->get('iyzico'); - } - - return $new_title; - - } - - public function authorizationGenerate($pki,$api_key,$secret_key,$rand_value) { - - $hash_value = $api_key.$rand_value.$secret_key.$pki; - $hash = base64_encode(sha1($hash_value,true)); - - $authorization = 'IYZWS '.$api_key.':'.$hash; - - $authorization_data = array( - 'authorization' => $authorization, - 'rand_value' => $rand_value - ); - - return $authorization_data; - - } - - - public function createFormInitializObjectSort($object_data) { - - $form_object = new stdClass(); - - $form_object->locale = $object_data->locale; - $form_object->conversationId = $object_data->conversationId; - $form_object->price = $object_data->price; - $form_object->basketId = $object_data->basketId; - $form_object->paymentGroup = $object_data->paymentGroup; - - $form_object->buyer = new stdClass(); - $form_object->buyer = $object_data->buyer; - - $form_object->shippingAddress = new stdClass(); - $form_object->shippingAddress = $object_data->shippingAddress; - - $form_object->billingAddress = new stdClass(); - $form_object->billingAddress = $object_data->billingAddress; - - foreach ($object_data->basketItems as $key => $item) { - - $form_object->basketItems[$key] = new stdClass(); - $form_object->basketItems[$key] = $item; - - } - - $form_object->callbackUrl = $object_data->callbackUrl; - $form_object->paymentSource = $object_data->paymentSource; - $form_object->currency = $object_data->currency; - $form_object->paidPrice = $object_data->paidPrice; - $form_object->forceThreeDS = $object_data->forceThreeDS; - $form_object->cardUserKey = $object_data->cardUserKey; - - return $form_object; - } - - public function pkiStringGenerate($object_data) { - - $pki_value = "["; - foreach ($object_data as $key => $data) { - if(is_object($data)) { - $name = var_export($key, true); - $name = str_replace("'", "", $name); - $pki_value .= $name."=["; - $end_key = count(get_object_vars($data)); - $count = 0; - foreach ($data as $key => $value) { - $count++; - $name = var_export($key, true); - $name = str_replace("'", "", $name); - $pki_value .= $name."="."".$value; - if($end_key != $count) - $pki_value .= ","; - } - $pki_value .= "]"; - } else if(is_array($data)) { - $name = var_export($key, true); - $name = str_replace("'", "", $name); - $pki_value .= $name."=["; - $end_key = count($data); - $count = 0; - foreach ($data as $key => $result) { - $count++; - $pki_value .= "["; - - foreach ($result as $key => $item) { - $name = var_export($key, true); - $name = str_replace("'", "", $name); - - $pki_value .= $name."="."".$item; - if(end($result) != $item) { - $pki_value .= ","; - } - if(end($result) == $item) { - if($end_key != $count) { - $pki_value .= "], "; - - } else { - $pki_value .= "]"; - } - } - } - } - if(end($data) == $result) - $pki_value .= "]"; - - } else { - $name = var_export($key, true); - $name = str_replace("'", "", $name); - - $pki_value .= $name."="."".$data.""; - } - if(end($object_data) != $data) - $pki_value .= ","; - } - $pki_value .= "]"; - return $pki_value; - } - - - public function hashGenerate($pki,$api_key,$secret_key,$random_value) { - - $hash = $api_key . $random_value . $secret_key . $pki; - - return base64_encode(sha1($hash, true)); - - } - - public function createFormInitializeDetailRequest($json,$authorization_data) { - - $url = $this->config->get('payment_iyzico_api_url'); - $url = $url.'/payment/iyzipos/checkoutform/auth/ecom/detail'; - - return $this->curlPost($json,$authorization_data,$url); - - } - - - public function createFormInitializeRequest($json,$authorization_data) { - - $url = $this->config->get('payment_iyzico_api_url'); - $url = $url.'/payment/iyzipos/checkoutform/initialize/auth/ecom'; - - return $this->curlPost($json,$authorization_data,$url); - } - - - public function curlPost($json,$authorization_data,$url) { - - - $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, $url); - $content_length = 0; - if ($json) { - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); - curl_setopt($curl, CURLOPT_POSTFIELDS, $json); - } - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); - curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); - curl_setopt($curl, CURLOPT_TIMEOUT, 150); - - curl_setopt( - $curl, CURLOPT_HTTPHEADER, array( - "Authorization: " .$authorization_data['authorization'], - "x-iyzi-rnd:".$authorization_data['rand_value'], - "Content-Type: application/json", - ) - ); - - $result = json_decode(curl_exec($curl)); - curl_close($curl); - - - - return $result; - } - - public function insertCardUserKey($customer_id,$card_user_key,$api_key) { - - $insertCard = $this->db->query("INSERT INTO `" . DB_PREFIX . "iyzico_card` SET - `customer_id` = '" . $this->db->escape($customer_id) . "', - `card_user_key` = '" . $this->db->escape($card_user_key) . "', - `api_key` = '" . $this->db->escape($api_key) . "'"); - - return $insertCard; - } - - public function findUserCardKey($customer_id,$api_key) { - - $customer_id = $this->db->escape($customer_id); - $api_key = $this->db->escape($api_key); - - $card_user_key = (object) $this->db->query("SELECT card_user_key FROM " . DB_PREFIX . "iyzico_card WHERE customer_id = '" . $customer_id ."' and api_key = '".$api_key."' ORDER BY iyzico_card_id DESC"); - - if(count($card_user_key->rows)) { - - return $card_user_key->rows[0]['card_user_key']; - } - - return ''; - } - - public function insertIyzicoOrder($order) { - - $insertOrder = $this->db->query("INSERT INTO `" . DB_PREFIX . "iyzico_order` SET - `payment_id` = '" . $this->db->escape($order->payment_id) . "', - `order_id` = '" . $this->db->escape($order->order_id) . "', - `total_amount` = '" . $this->db->escape($order->total_amount) . "', - `status` = '" . $this->db->escape($order->status) . "'"); - - return $insertOrder; - } - - public function orderUpdateByInstallement($order_id,$paidPrice) { - - $order_id = $this->db->escape($order_id); - - $order_info = $this->model_checkout_order->getOrder($order_id); - - $order_total = (array) $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . $order_id . "' AND code = 'total' "); - - $last_sort_value = $order_total['row']['sort_order'] - 1; - $last_sort_value = $this->db->escape($last_sort_value); - - $exchange_rate = $this->currency->getValue($order_info['currency_code']); - - $new_amount = str_replace(',', '', $paidPrice); - $old_amount = str_replace(',', '', $order_info['total'] * $order_info['currency_value']); - $installment_fee_variation = (float) ($new_amount - $old_amount) / $exchange_rate; - $installment_fee_variation = $this->db->escape($installment_fee_variation); - - $this->db->query("INSERT INTO " . DB_PREFIX . "order_total SET order_id = '" . - $order_id . "',code = 'iyzico_fee', title = 'Taksit Ücreti', `value` = '" . - $installment_fee_variation . "', sort_order = '" . $last_sort_value . "'"); - - - $order_total_data = (array) $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . $order_id . "' AND code != 'total' "); - - $calculate_total = 0; - - foreach ($order_total_data['rows'] as $row) { - $calculate_total += $row['value']; - } - - $calculate_total = $this->db->escape($calculate_total); - - $this->db->query("UPDATE " . DB_PREFIX . "order_total SET `value` = '" . $calculate_total . "' WHERE order_id = '$order_id' AND code = 'total' "); - - $this->db->query("UPDATE `" . DB_PREFIX . "order` SET total = '" . $calculate_total . "' WHERE order_id = '" . $order_id . "'"); - - } - - public function getCategoryName($product_id) { - - $product_id = $this->db->escape($product_id); - - $query = $this->db->query("SELECT category_id FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . $product_id . "' LIMIT 1"); - - - if(count($query->rows)) { - - $category_id = $this->db->escape($query->rows[0]['category_id']); - - $category = $this->db->query("SELECT name FROM " . DB_PREFIX . "category_description WHERE category_id = '" . $category_id . "' LIMIT 1"); - - if($category->rows[0]['name']) { - $category_name = $category->rows[0]['name']; - } else { - $category_name = 'NO CATEGORIES'; - } - - } else { - $category_name = 'NO CATEGORIES'; - } - - return $category_name; - } - - - public function getUserCreateDate($user_id) { - - $user_id = $this->db->escape($user_id); - - $user_create_date = (object) $this->db->query("SELECT date_added FROM " . DB_PREFIX . "user WHERE user_id = '" . $user_id ."'"); - - if(count($user_create_date->rows)) { - - return $user_create_date->rows[0]['date_added']; - } - - return date('Y-m-d H:i:s'); - } - - - -} \ No newline at end of file diff --git a/upload/catalog/model/extension/total/iyzico_fee.php b/upload/catalog/model/extension/total/iyzico_fee.php deleted file mode 100755 index ecce289..0000000 --- a/upload/catalog/model/extension/total/iyzico_fee.php +++ /dev/null @@ -1,9 +0,0 @@ - -.loading{width:40px;height:40px;background-color:#4ec8f1;margin:100px auto;-webkit-animation:sk-rotateplane 1.2s infinite ease-in-out;animation:sk-rotateplane 1.2s infinite ease-in-out}@-webkit-keyframes sk-rotateplane{0%{-webkit-transform:perspective(120px)}50%{-webkit-transform:perspective(120px) rotateY(180deg)}100%{-webkit-transform:perspective(120px) rotateY(180deg) rotateX(180deg)}}@keyframes sk-rotateplane{0%{transform:perspective(120px) rotateX(0) rotateY(0);-webkit-transform:perspective(120px) rotateX(0) rotateY(0)}50%{transform:perspective(120px) rotateX(-180.1deg) rotateY(0);-webkit-transform:perspective(120px) rotateX(-180.1deg) rotateY(0)}100%{transform:perspective(120px) rotateX(-180deg) rotateY(-179.9deg);-webkit-transform:perspective(120px) rotateX(-180deg) rotateY(-179.9deg)}}.brand{margin:auto}.brand p{color:#16a2c5;text-align:center;margin-top:-100px} - -
-
-
-

iyzico

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

Ödeme formu bilgilerinizi doldurup siparişi tamamla butonuna bastığınız zaman aktif olacaktır.

- {% endif %} - -
-
- - - - - -{% if form_type != 'onepage' %} - -{% elseif form_type == 'onepage' %} - -{% endif %} diff --git a/upload/catalog/view/theme/default/template/extension/payment/iyzico_success.twig b/upload/catalog/view/theme/default/template/extension/payment/iyzico_success.twig deleted file mode 100755 index 957e142..0000000 --- a/upload/catalog/view/theme/default/template/extension/payment/iyzico_success.twig +++ /dev/null @@ -1,76 +0,0 @@ -{{ header }} -
- -
{{ column_left }} - {% if column_left and column_right %} - {% set class = 'col-sm-6' %} - {% elseif column_left or column_right %} - {% set class = 'col-sm-9' %} - {% else %} - {% set class = 'col-sm-12' %} - {% endif %} -
{{ content_top }} -
- -
-

Ödemeniz Alındı.

-
- -
-
-
-
-
- - - - - - - - - - - - - {% for product in products %} - - - - - - - - {% endfor %} - {% for voucher in vouchers %} - - - - - - - - {% endfor %} - - - - - {% for total in totals %} - - - - - {% endfor %} - - -
{{ column_name }}{{ column_model }}{{ column_quantity }}{{ column_price }}{{ column_total }}
{{ product.name }} {% for option in product.option %}
-   - {{ option.name }}: {{ option.value }} {% endfor %} - {% if product.recurring %}
- {{ text_recurring_item }} {{ product.recurring }} {% endif %}
{{ product.model }}{{ product.quantity }}{{ product.price }}{{ product.total }}
{{ voucher.description }}1{{ voucher.amount }}{{ voucher.amount }}
{{ total.title }}:{{ total.text }}
-
- -
- {{ content_bottom }}
- {{ column_right }}
-
-{{ footer }}