diff --git a/Help.doc b/Help.doc new file mode 100644 index 0000000..17d5f41 Binary files /dev/null and b/Help.doc differ diff --git a/admin/controller/payment/zarinpalZg.php b/admin/controller/payment/zarinpalZg.php index f9654f3..6555700 100644 --- a/admin/controller/payment/zarinpalZg.php +++ b/admin/controller/payment/zarinpalZg.php @@ -1,9 +1,10 @@ load->language('payment/zarinpalZg'); + $this->load->language('payment/zarinpalzg'); $this->document->setTitle = $this->language->get('heading_title'); @@ -13,7 +14,7 @@ public function index() { if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validate())) { $this->load->model('setting/setting'); - $this->model_setting_setting->editSetting('zarinpalZg', $this->request->post); + $this->model_setting_setting->editSetting('zarinpalzg', $this->request->post); $this->session->data['success'] = $this->language->get('text_success'); @@ -70,46 +71,46 @@ public function index() { $this->document->breadcrumbs[] = array( //'href' => $this->url->https('payment/sb24'), - 'href' => $this->url->link('payment/zarinpalZg', 'token=' . $this->session->data['token'], 'SSL'), + 'href' => $this->url->link('payment/zarinpalzg', 'token=' . $this->session->data['token'], 'SSL'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ' ); - $this->data['action'] = $this->url->link('payment/zarinpalZg', 'token=' . $this->session->data['token'], 'SSL'); + $this->data['action'] = $this->url->link('payment/zarinpalzg', 'token=' . $this->session->data['token'], 'SSL'); $this->data['cancel'] = $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'); - if (isset($this->request->post['zarinpal_PIN'])) { - $this->data['zarinpal_PIN'] = $this->request->post['zarinpal_PIN']; + if (isset($this->request->post['zarinpalzg_PIN'])) { + $this->data['zarinpalzg_PIN'] = $this->request->post['zarinpalzg_PIN']; } else { - $this->data['zarinpal_PIN'] = $this->config->get('zarinpal_PIN'); + $this->data['zarinpalzg_PIN'] = $this->config->get('zarinpalzg_PIN'); } - if (isset($this->request->post['zarinpal_order_status_id'])) { - $this->data['zarinpal_order_status_id'] = $this->request->post['zarinpal_order_status_id']; + if (isset($this->request->post['zarinpalzg_order_status_id'])) { + $this->data['zarinpalzg_order_status_id'] = $this->request->post['zarinpalzg_order_status_id']; } else { - $this->data['zarinpal_order_status_id'] = $this->config->get('zarinpal_order_status_id'); + $this->data['zarinpalzg_order_status_id'] = $this->config->get('zarinpalzg_order_status_id'); } $this->load->model('localisation/order_status'); $this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); - if (isset($this->request->post['zarinpal_status'])) { - $this->data['zarinpal_status'] = $this->request->post['zarinpal_status']; + if (isset($this->request->post['zarinpalzg_status'])) { + $this->data['zarinpalzg_status'] = $this->request->post['zarinpalzg_status']; } else { - $this->data['zarinpal_status'] = $this->config->get('zarinpal_status'); + $this->data['zarinpalzg_status'] = $this->config->get('zarinpalzg_status'); } - if (isset($this->request->post['zarinpal_sort_order'])) { - $this->data['zarinpal_sort_order'] = $this->request->post['zarinpal_sort_order']; + if (isset($this->request->post['zarinpalzg_sort_order'])) { + $this->data['zarinpalzg_sort_order'] = $this->request->post['zarinpalzg_sort_order']; } else { - $this->data['zarinpal_sort_order'] = $this->config->get('zarinpal_sort_order'); + $this->data['zarinpalzg_sort_order'] = $this->config->get('zarinpalzg_sort_order'); } - $this->template = 'payment/zarinpalZg.tpl'; + $this->template = 'payment/zarinpalzg.tpl'; $this->children = array( 'common/header', 'common/footer' @@ -121,11 +122,11 @@ public function index() { private function validate() { - if (!$this->user->hasPermission('modify', 'payment/zarinpalZg')) { + if (!$this->user->hasPermission('modify', 'payment/zarinpalzg')) { $this->error['warning'] = $this->language->get('error_permission'); } - if (!$this->request->post['zarinpal_PIN']) { + if (!$this->request->post['zarinpalzg_PIN']) { $this->error['PIN'] = $this->language->get('error_PIN'); } diff --git a/admin/language/persian/payment/zarinpalZg.php b/admin/language/persian/payment/zarinpalZg.php index 365191c..0225a2e 100644 --- a/admin/language/persian/payment/zarinpalZg.php +++ b/admin/language/persian/payment/zarinpalZg.php @@ -2,13 +2,13 @@ // Heading -$_['heading_title'] = ' زرين پال- زرین گیت'; +$_['heading_title'] = 'زرين پال-زرین گیت'; // Text $_['text_payment'] = 'پرداخت'; $_['text_success'] = 'موفق: ویرایش شد!'; $_['text_development'] = 'آماده'; -$_['text_zarinpal'] = 'ZarinPal'; +$_['text_zarinpalzg'] = 'ZarinPal'; // Entry $_['entry_PIN'] = 'کد دروازه پرداخت:
'; @@ -19,4 +19,4 @@ // Error $_['error_permission'] = 'اخطار: اجازه ویرایش ندارید!'; $_['error_PIN'] = 'PIN ضروریست!'; -?> +?> \ No newline at end of file diff --git a/admin/view/image/payment/zarinpalzg.gif b/admin/view/image/payment/zarinpalzg.gif new file mode 100644 index 0000000..62875f5 Binary files /dev/null and b/admin/view/image/payment/zarinpalzg.gif differ diff --git a/admin/view/template/payment/zarinpalZg.tpl b/admin/view/template/payment/zarinpalZg.tpl index 43f4bab..9b745fb 100644 --- a/admin/view/template/payment/zarinpalZg.tpl +++ b/admin/view/template/payment/zarinpalZg.tpl @@ -25,7 +25,7 @@ * - +
@@ -33,9 +33,9 @@ - - + @@ -45,8 +45,8 @@ - + @@ -57,7 +57,7 @@ - + @@ -65,4 +65,4 @@ - + \ No newline at end of file diff --git a/catalog/controller/payment/zarinpalZg.php b/catalog/controller/payment/zarinpalZg.php index e2f2ab1..e46db9b 100644 --- a/catalog/controller/payment/zarinpalZg.php +++ b/catalog/controller/payment/zarinpalZg.php @@ -1,56 +1,34 @@ language->load('payment/zarinpalZg'); - $this->data['button_confirm'] = $this->language->get('button_confirm'); + $this->language->load('payment/zarinpalzg'); + $this->data['button_confirm'] = $this->language->get('button_confirm'); $this->data['text_wait'] = $this->language->get('text_wait'); $this->data['text_ersal'] = $this->language->get('text_ersal'); - if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/zarinpalZg.tpl')) { - $this->template = $this->config->get('config_template') . '/template/payment/zarinpalZg.tpl'; + if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/zarinpalzg.tpl')) { + $this->template = $this->config->get('config_template') . '/template/payment/zarinpalzg.tpl'; } else { - $this->template = 'default/template/payment/zarinpalZg.tpl'; + $this->template = 'default/template/payment/zarinpalzg.tpl'; } $this->render(); } - public function confirm() { - - $this->load->model('checkout/order'); + $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - $this->load->library('encryption'); - $encryption = new Encryption($this->config->get('config_encryption')); - - //$this->data['Amount'] = $this->currency->format($order_info['total'], 'TMN', $order_info['value'], FALSE); - $this->data['Amount'] = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false); - - //$this->data['Amount']=$this->data['Amount']\10; - - $this->data['PIN']=$this->config->get('zarinpal_PIN'); - + $this->data['PIN']=$this->config->get('zarinpalzg_PIN'); $this->data['ResNum'] = $this->session->data['order_id']; - $this->data['return'] = $this->url->link('checkout/success', '', 'SSL'); - //$this->data['return'] = HTTPS_SERVER . 'index.php?route=checkout/success'; - $this->data['cancel_return'] = $this->url->link('checkout/payment', '', 'SSL'); - //$this->data['cancel_return'] = HTTPS_SERVER . 'index.php?route=checkout/payment'; - $this->data['back'] = $this->url->link('checkout/payment', '', 'SSL'); - //$client = new SoapClient("https://www.zarinpal.com/pg/services/WebGate/wsdl"); - $client = new nusoap_client('https://de.zarinpal.com/pg/services/WebGate/wsdl', 'wsdl'); - $client->soap_defencoding = 'UTF-8'; + $client = new SoapClient('https://www.zarinpal.com/pg/services/WebGate/wsdl', array('encoding' => 'UTF-8')); - if((!$client)){ + if ((!$client)) { $json = array(); $json['error']= "Can not connect to ZarinPal.
"; @@ -58,43 +36,34 @@ public function confirm() { } $amount = intval($this->data['Amount'])/$order_info['currency_value']; - if($this->currency->getCode()=='RLS') { - $amount = $amount/10; + if ($this->currency->getCode()=='RLS') { + $amount = $amount / 10; } - //$callbackUrl = $this->url->https('payment/zarinpal/callback&order_id=' . $encryption->encrypt($this->session->data['order_id'])); - //$callbackUrl = HTTPS_SERVER . 'index.php?route=payment/zarinpal/callback&order_id=' . $encryption->encrypt($this->session->data['order_id']); - $this->data['order_id'] = $encryption->encrypt($this->session->data['order_id']); - //$callbackUrl = $this->url->link('payment/zarinpal/callback&order_id=' . $encryption->encrypt($this->session->data['order_id'])); - $callbackUrl = $this->url->link('payment/zarinpalZg/callback', 'order_id='. $this->data['order_id'], 'SSL'); - - //$res=$client->PaymentRequest($this->data['PIN'], $amount, $callbackUrl, urlencode(' خريد شماره: '.$order_info['order_id']) ); - $parameters = array( - array( - 'MerchantID' => $this->data['PIN'], - 'Amount' => $amount, - 'Description' => 'خريد شماره: '.$order_info['order_id'], - 'Email' => '', - 'Mobile' => '', - 'CallbackURL' => $callbackUrl - ) - ); - $res = $client->call('PaymentRequest', $parameters); - if($res['Status'] == 100){ - $this->data['action'] = 'https://www.zarinpal.com/pg/StartPay/' . $res['Authority']; + + $this->data['order_id'] = $this->session->data['order_id']; + $callbackUrl = $this->url->link('payment/zarinpalzg/callback&order_id=' . $this->data['order_id']); + + $result = $client->PaymentRequest(array( + 'MerchantID' => $this->data['PIN'], + 'Amount' => $amount, + 'Description' => 'خريد شماره: ' . $order_info['order_id'], + 'Email' => '', + 'Mobile' => '', + 'CallbackURL' => $callbackUrl + )); + if ($result->Status == 100) { + $this->data['action'] = 'https://www.zarinpal.com/pg/StartPay/'. $result->Authority .'/ZarinGate'; $json = array(); - $json['success']= $this->data['action']; + $json['success']= $this->data['action']; $this->response->setOutput(json_encode($json)); } else { - echo 'ERR: '. $res['Status']; - $this->CheckState($res['Status']); - //die(); + $this->CheckState($result->Status); } } public function CheckState($status) { $json = array(); - switch($status){ - + switch ($status) { case "-1" : $json['error']="اطلاعات ارسالی ناقص می باشند"; break; @@ -115,70 +84,58 @@ public function CheckState($status) { break; default : - $json['error']= "خطای نامشخص;"; + $json['error']= "خطای نامشخص. کد خطا: " ; break; - } + } $this->response->setOutput(json_encode($json)); } function verify_payment($authority, $amount){ - - if($authority){ - //$client = new SoapClient("http://pg.zarinpal.com/services/WebGate/wsdl"); - $client = new nusoap_client('https://de.zarinpal.com/pg/services/WebGate/wsdl', 'wsdl'); - $client->soap_defencoding = 'UTF-8'; - if ((!$client)){ - echo 'Error: can not connect to ZarinPal.
';return false; + if ($authority) { + //$client = new SoapClient("http://www.zarinpalzg.com/WebserviceGateway/wsdl"); + $client = new SoapClient('https://www.zarinpal.com/pg/services/WebGate/wsdl', array('encoding' => 'UTF-8')); + if ((!$client)) { + echo "Error: can not connect to ZarinPal.
"; + return false; } else { - $this->data['PIN'] = $this->config->get('zarinpal_PIN'); - //$res = $client->PaymentVerification($this->data['PIN'], $authority ,$amount); - $parameters = array( - array( - 'MerchantID' => $this->data['PIN'], - 'Authority' => $authority, - 'Amount' => $amount - ) - ); - $res = $client->call('PaymentVerification', $parameters); + $this->data['PIN'] = $this->config->get('zarinpalzg_PIN'); + $result = $client->PaymentVerification(array( + 'MerchantID' => $this->data['PIN'], + 'Authority' => $authority, + 'Amount' => $amount + )); - $this->CheckState($res['Status']); + $this->CheckState($result); - if($res['Status']==100){ - $this->RefId = $res['RefId']; + if ($result->Status==100) { return true; } else { - echo 'ERR: '. $res['Status']; return false; } } } else { return false; } + return false; } public function callback() { - $this->load->library('encryption'); - - $encryption = new Encryption($this->config->get('config_encryption')); - $au = $this->request->get['Authority']; - $status = $this->request->get['Status']; - $order_id = $encryption->decrypt($this->request->get['order_id']); - $MerchantID=$this->config->get('zarinpal_PIN'); + $authority = $this->request->get['Authority']; + $order_id = $this->request->get['order_id']; + $MerchantID = $this->config->get('zarinpalzg_PIN'); + $debugmod = false; $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); - //$Amount = $this->currency->format($order_info['total'], 'RLS', $order_info['value'], FALSE); - - $Amount = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false); //echo $this->data['Amount']; - $amount = $Amount/$order_info['currency_value']; - if ($order_info && $status == "OK") { - if(($this->verify_payment($au, $amount))) { - $this->model_checkout_order->confirm($order_id, $this->config->get('zarinpal_order_status_id'), 'شماره سند تراکنش: '. $this->RefId); + $amount = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false); //echo $this->data['Amount']; + if ($order_info) { + if (($this->verify_payment($authority, $amount)) or ($debugmod==true)) { + $this->model_checkout_order->confirm($order_id, $this->config->get('zarinpalzg_order_status_id'),'شماره رسيد ديجيتالي; Authority: '.$authority); - $this->response->setOutput('
 با تشکر پرداخت شما با شماره تراکنش '. $this->RefId .' تکمیل شد.لطفا چند لحظه صبر کنید و یا اینجا کلیک نمایید 
'); + $this->response->setOutput('
 با تشکر پرداخت تکمیل شد.لطفا چند لحظه صبر کنید و یا اینجا کلیک نمایید 
'); } } else { $this->response->setOutput('
 .

بازگشت به فروشگاه
 
'); diff --git a/catalog/model/payment/zarinpalZg.php b/catalog/model/payment/zarinpalZg.php index aa6c37e..5225bd6 100644 --- a/catalog/model/payment/zarinpalZg.php +++ b/catalog/model/payment/zarinpalZg.php @@ -1,9 +1,10 @@ load->language('payment/zarinpalZg'); + $this->load->language('payment/zarinpalzg'); - if ($this->config->get('zarinpal_status')) { + if ($this->config->get('zarinpalzg_status')) { $status = TRUE; } else { $status = FALSE; @@ -13,13 +14,13 @@ public function getMethod() { if ($status) { $method_data = array( - 'code' => 'zarinpalZg', + 'code' => 'zarinpalzg', 'title' => $this->language->get('text_title'), - 'sort_order' => $this->config->get('zarinpal_sort_order') + 'sort_order' => $this->config->get('zarinpalzg_sort_order') ); } return $method_data; } } -?> \ No newline at end of file +?> diff --git a/catalog/view/theme/default/template/payment/zarinpalZg.tpl b/catalog/view/theme/default/template/payment/zarinpalZg.tpl index e7a54a2..a7d57e7 100644 --- a/catalog/view/theme/default/template/payment/zarinpalZg.tpl +++ b/catalog/view/theme/default/template/payment/zarinpalZg.tpl @@ -9,7 +9,7 @@ $('#button-confirm').bind('click', function() { $.ajax({ type: 'GET', - url: 'index.php?route=payment/zarinpal/confirm', + url: 'index.php?route=payment/zarinpalzg/confirm', dataType: 'json', beforeSend: function() { $('#button-confirm').attr('disabled', true);