diff --git a/OpenCart2.0_Seamless_Plugin/admin/controller/payment/molpay.php b/OpenCart2.0_Seamless_Plugin/admin/controller/payment/molpay.php index 3e96ac1..1da8f4e 100644 --- a/OpenCart2.0_Seamless_Plugin/admin/controller/payment/molpay.php +++ b/OpenCart2.0_Seamless_Plugin/admin/controller/payment/molpay.php @@ -36,7 +36,8 @@ public function index() { $data['entry_mid'] = $this->language->get('entry_mid'); $data['entry_vkey'] = $this->language->get('entry_vkey'); - $data['entry_order_status'] = $this->language->get('entry_order_status'); + $data['entry_skey'] = $this->language->get('entry_skey'); + $data['entry_type'] = $this->language->get('entry_type'); $data['entry_completed_status'] = $this->language->get('entry_completed_status'); $data['entry_pending_status'] = $this->language->get('entry_pending_status'); $data['entry_failed_status'] = $this->language->get('entry_failed_status'); @@ -48,7 +49,9 @@ public function index() { $data['channel_list'] = $this->language->get('channel_list'); $data['help_vkey'] = $this->language->get('help_vkey'); - + $data['help_skey'] = $this->language->get('help_skey'); + $data['help_type'] = $this->language->get('help_type'); + $data['button_save'] = $this->language->get('button_save'); $data['button_cancel'] = $this->language->get('button_cancel'); @@ -70,6 +73,18 @@ public function index() { $data['error_vkey'] = ''; } + if (isset($this->error['skey'])) { + $data['error_skey'] = $this->error['skey']; + } else { + $data['error_skey'] = ''; + } + + if (isset($this->error['type'])) { + $data['error_type'] = $this->error['type']; + } else { + $data['error_type'] = ''; + } + $data['breadcrumbs'] = array(); $data['breadcrumbs'][] = array( @@ -102,10 +117,16 @@ public function index() { $data['molpay_vkey'] = $this->config->get('molpay_vkey'); } - if (isset($this->request->post['molpay_order_status_id'])) { - $data['molpay_order_status_id'] = $this->request->post['molpay_order_status_id']; + if (isset($this->request->post['molpay_skey'])) { + $data['molpay_skey'] = $this->request->post['molpay_skey']; + } else { + $data['molpay_skey'] = $this->config->get('molpay_skey'); + } + + if (isset($this->request->post['molpay_type'])) { + $data['molpay_type'] = $this->request->post['molpay_type']; } else { - $data['molpay_order_status_id'] = $this->config->get('molpay_order_status_id'); + $data['molpay_type'] = $this->config->get('molpay_type'); } if (isset($this->request->post['molpay_completed_status_id'])) { @@ -154,15 +175,11 @@ public function index() { //Load the data into variable - foreach($data['channel_list'] as $key=>$val) - { - if (isset($this->request->post['molpay_'.$key.'_status'])) - { - $data['molpay_'.$key.'_status'] = $this->request->post['molpay_'.$key.'_status']; - } - else - { - $data['molpay_'.$key.'_status'] = $this->config->get('molpay_'.$key.'_status'); + foreach ($data['channel_list'] as $key=>$val) { + if (isset($this->request->post['molpay_'.$key.'_status'])) { + $data["dbchannel_list"]['molpay_'.$key.'_status'] = $this->request->post['molpay_'.$key.'_status']; + } else { + $data["dbchannel_list"]['molpay_'.$key.'_status'] = $this->config->get('molpay_'.$key.'_status'); } } @@ -186,6 +203,14 @@ protected function validate() { $this->error['vkey'] = $this->language->get('error_vkey'); } + if (!$this->request->post['molpay_skey']) { + $this->error['skey'] = $this->language->get('error_skey'); + } + + if (!$this->request->post['molpay_type']) { + $this->error['type'] = $this->language->get('error_type'); + } + return !$this->error; } } diff --git a/OpenCart2.0_Seamless_Plugin/admin/language/english/payment/molpay.php b/OpenCart2.0_Seamless_Plugin/admin/language/en-gb/payment/molpay.php similarity index 80% rename from OpenCart2.0_Seamless_Plugin/admin/language/english/payment/molpay.php rename to OpenCart2.0_Seamless_Plugin/admin/language/en-gb/payment/molpay.php index 4f1a70c..b11fc0b 100644 --- a/OpenCart2.0_Seamless_Plugin/admin/language/english/payment/molpay.php +++ b/OpenCart2.0_Seamless_Plugin/admin/language/en-gb/payment/molpay.php @@ -4,12 +4,12 @@ * * @package Payment Gateway * @author MOLPay Technical Team - * @version 2.0 + * @version 2.0.1 */ // Versioning $_['molpay_ptype'] = "OpenCart"; -$_['molpay_pversion'] = "2.0"; +$_['molpay_pversion'] = "2.0.1"; // Heading $_['heading_title'] = 'MOLPay Malaysia Online Payment Gateway'; @@ -23,7 +23,8 @@ // Entry $_['entry_mid'] = 'MOLPay Merchant ID'; $_['entry_vkey'] = 'MOLPay Verify Key'; -$_['entry_order_status'] = 'Order Status'; +$_['entry_skey'] = 'MOLPay Secret Key'; +$_['entry_type'] = 'MOLPay Account Type'; $_['entry_completed_status'] = 'Completed Status'; $_['entry_pending_status'] = 'Pending Status'; $_['entry_failed_status'] = 'Failed Status'; @@ -52,18 +53,23 @@ 'credit3' => 'Multi Currency Credit Card', 'NGANLUONG' => 'NGANLUONG', 'crossborder' => 'Credit Card/ Debit Card (PayVision)', - 'PEXPLUS' => 'PEx+', - 'jompay' => 'JOMPay', + 'PEXPLUS' => 'PEx+', + 'jompay' => 'JOMPay', 'Cash-Esapay' => 'Cash Esapay', - 'alipay' => 'Alipay.com' + 'alipay' => 'Alipay.com' ); // Help $_['help_vkey'] = 'Please refer to your MOLPay Merchant Profile for this key.'; +$_['help_skey'] = 'Please refer to your MOLPay Merchant Profile for this key.'; +$_['help_type'] = 'Please choose your account type (Sandbox/Production)'; +$_['type'] = array(1=> "Production", 2=>"Sandbox"); // Error $_['error_permission'] = 'Warning: You do not have permission to modify MOLPay Malaysia Online Payment Gateway!'; $_['error_mid'] = 'MOLPay Merchant ID Required!'; $_['error_vkey'] = 'MOLPay Verify Key Required!'; +$_['error_skey'] = 'MOLPay Secret Key Required!'; +$_['error_type'] = 'MOLPay Account Type Required!'; $_['error_settings'] = 'MOLPay merchant id and verify key mismatch, contact support@molpay.com to assist.'; $_['error_status'] = 'Unable to connect MOLPay API.'; diff --git a/OpenCart2.0_Seamless_Plugin/admin/view/image/payment/op-alipay.jpg b/OpenCart2.0_Seamless_Plugin/admin/view/image/payment/op-alipay.png similarity index 100% rename from OpenCart2.0_Seamless_Plugin/admin/view/image/payment/op-alipay.jpg rename to OpenCart2.0_Seamless_Plugin/admin/view/image/payment/op-alipay.png diff --git a/OpenCart2.0_Seamless_Plugin/admin/view/template/payment/molpay.tpl b/OpenCart2.0_Seamless_Plugin/admin/view/template/payment/molpay.tpl index 497b8c4..6c1c971 100644 --- a/OpenCart2.0_Seamless_Plugin/admin/view/template/payment/molpay.tpl +++ b/OpenCart2.0_Seamless_Plugin/admin/view/template/payment/molpay.tpl @@ -1,189 +1,198 @@
- -
- -
- -
- -
-
-

-
-
-
-
- -
- -
-
-
- -
- - -
- -
-
-
- -
- - -
- -
-
-
- -
- -
-
-
- -
- + -
-
-
+
diff --git a/OpenCart2.0_Seamless_Plugin/catalog/controller/payment/molpay.php b/OpenCart2.0_Seamless_Plugin/catalog/controller/payment/molpay.php index e3b6430..3e2fd72 100644 --- a/OpenCart2.0_Seamless_Plugin/catalog/controller/payment/molpay.php +++ b/OpenCart2.0_Seamless_Plugin/catalog/controller/payment/molpay.php @@ -4,7 +4,7 @@ * * @package Payment Gateway * @author MOLPay Technical Team - * @version 2.0 + * @version 2.0.1 */ class ControllerPaymentMolpay extends Controller { @@ -15,18 +15,16 @@ public function index() { $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - if (isset($this->session->data['guest'])) - { + if (isset($this->session->data['guest'])) { $email = $this->session->data['guest']['email']; $telephone = $this->session->data['guest']['telephone']; - } - else - { + } else { $email = $this->customer->getEmail(); $telephone = $this->customer->getTelephone(); } - $data['action'] = 'https://www.onlinepayment.com.my/MOLPay/pay/'.$this->config->get('molpay_mid').'/'; + $data['action'] = $this->config->get('molpay_type').'MOLPay/pay/'.$this->config->get('molpay_mid').'/'; + $data['js'] = $this->config->get('molpay_type')."/MOLPay/API/seamless/latest/js/MOLPay_seamless.deco.js"; $data['mid']= $this->config->get('molpay_mid'); $data['amount'] = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false); $data['orderid'] = $this->session->data['order_id']; @@ -41,16 +39,15 @@ public function index() { $this->load->language('payment/molpay'); $channel_list = $this->language->get('channel_list'); - foreach($channel_list as $key=>$val) - { + foreach ($channel_list as $key=>$val) { $inGet = 'molpay_'.$key.'_status'; $data['channel_list'][$key] = $this->config->get($inGet); } $products = $this->cart->getProducts(); - foreach ($products as $product) { - $data['prod_desc'][]= $product['name']." x ".$product['quantity']; - } + foreach ($products as $product) { + $data['prod_desc'][]= $product['name']." x ".$product['quantity']; + } $data['lang'] = $this->session->data['language']; @@ -58,16 +55,13 @@ public function index() { $version_oc = substr(VERSION,0,3); - if($version_oc == "2.2") - { + if ($version_oc == "2.2") { if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/molpay.tpl')) { return $this->load->view($this->config->get('config_template') . '/template/payment/molpay.tpl', $data); } else { return $this->load->view('payment/molpay.tpl', $data); } - } - else - { + } else { if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/molpay.tpl')) { return $this->load->view($this->config->get('config_template') . '/template/payment/molpay.tpl', $data); } else { @@ -76,13 +70,16 @@ public function index() { } } + /***************************************************** + * Return with IPN(Instant Payment Notification) + ******************************************************/ public function return_ipn() { $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($this->request->post['orderid']); // orderid - $vkey = $this->config->get('molpay_vkey'); + $secretkey = $this->config->get('molpay_skey'); $_POST['treq']= 1; @@ -99,11 +96,11 @@ public function return_ipn() { /*********************************************************** * Backend acknowledge method for IPN (DO NOT MODIFY) ************************************************************/ - while ( list($k,$v) = each($_POST) ) { - $postData[]= $k."=".$v; - } + foreach ($_POST as $k => $v) { + $postData[]= $k."=".$v; + } $postdata = implode("&",$postData); - $url = "https://www.onlinepayment.com.my/MOLPay/API/chkstat/returnipn.php"; + $url = $this->config->get('molpay_type')."MOLPay/API/chkstat/returnipn.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_POST , 1); curl_setopt($ch, CURLOPT_POSTFIELDS , $postdata); @@ -112,7 +109,7 @@ public function return_ipn() { curl_setopt($ch, CURLINFO_HEADER_OUT , TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , FALSE); - //curl_setopt($ch, CURLOPT_SSLVERSION , 3); + curl_setopt($ch, CURLOPT_SSLVERSION , 6); $result = curl_exec( $ch ); curl_close( $ch ); /*********************************************************** @@ -120,12 +117,10 @@ public function return_ipn() { ************************************************************/ $key0 = md5($tranID.$orderid.$status.$domain.$amount.$currency); - $key1 = md5($paydate.$domain.$key0.$appcode.$vkey); + $key1 = md5($paydate.$domain.$key0.$appcode.$secretkey); if ( $skey != $key1 ) $status = -1 ; - - $order_status_id = $this->config->get('config_order_status_id'); if ( $status == "00" ) { $order_status_id = $this->config->get('molpay_completed_status_id'); @@ -138,11 +133,12 @@ public function return_ipn() { } - if (!$order_info['order_status_id']) { - $this->model_checkout_order->addOrderHistory($orderid, $order_status_id); - } else { - $this->model_checkout_order->addOrderHistory($orderid, $order_status_id); + $response=array(); + foreach ($_POST as $k => $v) { + $response[] = "[".$k."]=".$v; } + if ($order_info['order_status_id'] != $this->config->get('molpay_completed_status_id')) + $this->model_checkout_order->addOrderHistory($orderid, $order_status_id, "RETURN URL \n".implode("\n ", $response), false, false); $successStatus = array('00','22'); if( in_array($status,$successStatus) ) { @@ -175,7 +171,7 @@ public function return_ipn() { public function callback_ipn() { $this->load->model('checkout/order'); - $vkey = $this->config->get('molpay_vkey'); + $secretkey = $this->config->get('molpay_skey'); $nbcb = (isset($_POST['nbcb']) && !empty($_POST['nbcb'])) ? $_POST['nbcb'] : ''; $tranID = (isset($_POST['tranID']) && !empty($_POST['tranID'])) ? $_POST['tranID'] : ''; @@ -189,35 +185,36 @@ public function callback_ipn() { $skey = (isset($_POST['skey']) && !empty($_POST['skey'])) ? $_POST['skey'] : ''; $key0 = md5($tranID.$orderid.$status.$domain.$amount.$currency); - $key1 = md5($paydate.$domain.$key0.$appcode.$vkey); + $key1 = md5($paydate.$domain.$key0.$appcode.$secretkey); if ( $skey != $key1 ) $status = -1 ; - if ($nbcb == 1) { - echo "CBTOKEN:MPSTATOK"; - $order_info = $this->model_checkout_order->getOrder($this->request->post['orderid']); // orderid - - - $order_status_id = $this->config->get('config_order_status_id'); - - if ( $status == "00" ) { - $order_status_id = $this->config->get('molpay_completed_status_id'); - - } elseif( $status == "22" ) { - $order_status_id = $this->config->get('molpay_pending_status_id'); - - } else { - $order_status_id = $this->config->get('molpay_failed_status_id'); - - } - - if (!$order_info['order_status_id']) { - $this->model_checkout_order->addOrderHistory($orderid, $order_status_id); - } else { - $this->model_checkout_order->addOrderHistory($orderid, $order_status_id); - } - } + $order_info = $this->model_checkout_order->getOrder($this->request->post['orderid']); // orderid + if ( $status == "00" ) { + $order_status_id = $this->config->get('molpay_completed_status_id'); + } elseif( $status == "22" ) { + $order_status_id = $this->config->get('molpay_pending_status_id'); + } else { + $order_status_id = $this->config->get('molpay_failed_status_id'); + } + + $response=array(); + foreach ($_POST as $k => $v) { + $response[] = "[".$k."]=".$v; + } + if ($order_info['order_status_id'] != $this->config->get('molpay_completed_status_id')) + $this->model_checkout_order->addOrderHistory($orderid, $order_status_id, "CALLBACK URL \n".implode("\n ", $response), false, false); + + /*********************************************************** + * Backend acknowledge method for IPN (DO NOT MODIFY) + ************************************************************/ + if ($nbcb == 1) { + echo "CBTOKEN:MPSTATOK";exit; + } + /*********************************************************** + * End of Acknowledge method for IPN + ************************************************************/ } /***************************************************** @@ -226,7 +223,7 @@ public function callback_ipn() { public function notification_ipn() { $this->load->model('checkout/order'); - $vkey = $this->config->get('molpay_vkey'); + $secretkey = $this->config->get('molpay_skey'); $nbcb = (isset($_POST['nbcb']) && !empty($_POST['nbcb'])) ? $_POST['nbcb'] : ''; $tranID = (isset($_POST['tranID']) && !empty($_POST['tranID'])) ? $_POST['tranID'] : ''; @@ -238,35 +235,54 @@ public function notification_ipn() { $appcode = (isset($_POST['appcode']) && !empty($_POST['appcode'])) ? $_POST['appcode'] : ''; $paydate = (isset($_POST['paydate']) && !empty($_POST['paydate'])) ? $_POST['paydate'] : ''; $skey = (isset($_POST['skey']) && !empty($_POST['skey'])) ? $_POST['skey'] : ''; + + /*********************************************************** + * Backend acknowledge method for IPN (DO NOT MODIFY) + ************************************************************/ + if ($nbcb == 2) { + foreach ($_POST as $k => $v) { + $postData[]= $k."=".$v; + } + $postdata = implode("&",$postData); + $url = $this->config->get('molpay_type')."MOLPay/API/chkstat/returnipn.php"; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_POST , 1); + curl_setopt($ch, CURLOPT_POSTFIELDS , $postdata); + curl_setopt($ch, CURLOPT_URL , $url); + curl_setopt($ch, CURLOPT_HEADER , 1); + curl_setopt($ch, CURLINFO_HEADER_OUT , TRUE); + curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , FALSE); + curl_setopt($ch, CURLOPT_SSLVERSION , 6); + $result = curl_exec( $ch ); + curl_close( $ch ); + } + /*********************************************************** + * End of Acknowledge method for IPN + ************************************************************/ + $key0 = md5($tranID.$orderid.$status.$domain.$amount.$currency); - $key1 = md5($paydate.$domain.$key0.$appcode.$vkey); + $key1 = md5($paydate.$domain.$key0.$appcode.$secretkey); if ( $skey != $key1 ) $status = -1 ; + + $order_info = $this->model_checkout_order->getOrder($this->request->post['orderid']); // orderid - if ($nbcb == 2) { - echo "CBTOKEN:MPSTATOK"; - $order_info = $this->model_checkout_order->getOrder($this->request->post['orderid']); // orderid - - $order_status_id = $this->config->get('config_order_status_id'); - - if ( $status == "00" ) { - $order_status_id = $this->config->get('molpay_completed_status_id'); - - } elseif( $status == "22" ) { - $order_status_id = $this->config->get('molpay_pending_status_id'); - - } else { - $order_status_id = $this->config->get('molpay_failed_status_id'); - - } - - if (!$order_info['order_status_id']) { - $this->model_checkout_order->addOrderHistory($orderid, $order_status_id); - } else { - $this->model_checkout_order->addOrderHistory($orderid, $order_status_id); - } - } + if ( $status == "00" ) { + $order_status_id = $this->config->get('molpay_completed_status_id'); + } elseif( $status == "22" ) { + $order_status_id = $this->config->get('molpay_pending_status_id'); + } else { + $order_status_id = $this->config->get('molpay_failed_status_id'); + } + + $response=array(); + foreach ($_POST as $k => $v) { + $response[] = "[".$k."]=".$v; + } + if ($order_info['order_status_id'] != $this->config->get('molpay_completed_status_id')) + $this->model_checkout_order->addOrderHistory($orderid, $order_status_id, "NOTIFICATION URL \n".implode("\n ", $response), false, false); } } diff --git a/OpenCart2.0_Seamless_Plugin/catalog/language/english/payment/molpay.php b/OpenCart2.0_Seamless_Plugin/catalog/language/en-gb/payment/molpay.php similarity index 90% rename from OpenCart2.0_Seamless_Plugin/catalog/language/english/payment/molpay.php rename to OpenCart2.0_Seamless_Plugin/catalog/language/en-gb/payment/molpay.php index f0941fc..17dbf96 100644 --- a/OpenCart2.0_Seamless_Plugin/catalog/language/english/payment/molpay.php +++ b/OpenCart2.0_Seamless_Plugin/catalog/language/en-gb/payment/molpay.php @@ -4,7 +4,7 @@ * * @package Payment Gateway * @author MOLPay Technical Team - * @version 2.0 + * @version 2.0.1 */ // Text @@ -31,9 +31,8 @@ 'credit3' => 'Multi Currency Credit Card', 'NGANLUONG' => 'NGANLUONG', 'crossborder' => 'Credit Card/ Debit Card (PayVision)', - 'PEXPLUS' => 'PEx+', - 'jompay' => 'JOMPay', + 'PEXPLUS' => 'PEx+', + 'jompay' => 'JOMPay', 'Cash-Esapay' => 'Cash Esapay', - 'alipay' => 'Alipay.com' - + 'alipay' => 'Alipay.com' ); diff --git a/OpenCart2.0_Seamless_Plugin/catalog/model/payment/molpay.php b/OpenCart2.0_Seamless_Plugin/catalog/model/payment/molpay.php index fe50f77..d3f5dda 100644 --- a/OpenCart2.0_Seamless_Plugin/catalog/model/payment/molpay.php +++ b/OpenCart2.0_Seamless_Plugin/catalog/model/payment/molpay.php @@ -1,4 +1,12 @@ + * @version 2.0.1 + */ + class ModelPaymentMolpay extends Model { public function getMethod($address, $total) { $this->load->language('payment/molpay'); diff --git a/OpenCart2.0_Seamless_Plugin/catalog/view/theme/default/template/payment/molpay.tpl b/OpenCart2.0_Seamless_Plugin/catalog/view/theme/default/template/payment/molpay.tpl index 421016c..c50538c 100644 --- a/OpenCart2.0_Seamless_Plugin/catalog/view/theme/default/template/payment/molpay.tpl +++ b/OpenCart2.0_Seamless_Plugin/catalog/view/theme/default/template/payment/molpay.tpl @@ -12,7 +12,7 @@ " /> - +

Pay via:


diff --git a/dist/OpenCart2.0_Seamless_Plugin.zip b/dist/OpenCart2.0_Seamless_Plugin.zip index a6f40e8..e13cb83 100644 Binary files a/dist/OpenCart2.0_Seamless_Plugin.zip and b/dist/OpenCart2.0_Seamless_Plugin.zip differ