diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..496ee2c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/Magento_V1.x/README.md b/Magento_V1.x/README.md new file mode 100644 index 0000000..c9249f5 --- /dev/null +++ b/Magento_V1.x/README.md @@ -0,0 +1,2 @@ +# Paytm Payment plugin for Magento version 1.x +* Developer Docs: https://developer.paytm.com/docs/eCommerce-plugin/magento/#v1-x \ No newline at end of file diff --git a/Magento_V1.x/app/code/community/One97/Paytm/Block/Adminhtml/Order/View/Tab/Contents.php b/Magento_V1.x/app/code/community/One97/Paytm/Block/Adminhtml/Order/View/Tab/Contents.php new file mode 100755 index 0000000..1f30b7d --- /dev/null +++ b/Magento_V1.x/app/code/community/One97/Paytm/Block/Adminhtml/Order/View/Tab/Contents.php @@ -0,0 +1,72 @@ +setTemplate('paytm/order/view/tab/contents.phtml'); + } + + public function getTabLabel() { + return $this->__('Paytm Response'); + } + + public function getTabTitle() { + // return $this->__($test); + return $this->__('Paytm Response'); + } + + public function canShowTab() { + $order=$this->getOrder(); + $orderId=$order->getIncrementId(); + $connectionRead = Mage::getSingleton('core/resource')->getConnection('core_write'); + $tableName = Mage::getSingleton('core/resource')->getTableName('paytm_order_data'); + $query="SELECT id FROM ".$tableName." WHERE order_id='".$orderId."' ORDER BY ID DESC"; + $results = $connectionRead->fetchAll($query); + if(isset($results[0]['id'])){ + return true; + }else{ + return false; + } + } + + public function isHidden() { + return false; + } + + public function getOrder(){ + return Mage::registry('current_order'); + } + + public function paytmResponse($fetchButton=false){ + $order=$this->getOrder(); + $orderId=$order->getIncrementId(); + $connectionRead = Mage::getSingleton('core/resource')->getConnection('core_write'); + $tableName = Mage::getSingleton('core/resource')->getTableName('paytm_order_data'); + $query="SELECT * FROM ".$tableName." WHERE order_id='".$orderId."' ORDER BY ID DESC"; + $results = $connectionRead->fetchAll($query); + if($fetchButton){ + if(isset($results[0]['paytm_response'])){ + $tableBody=' '; + } + }else{ + $tableBody=' No Data '; + if(isset($results[0]['paytm_response'])){ + if(trim($results[0]['paytm_response'])!=''){ + $jsonResponse = json_decode($results[0]['paytm_response'], true); + if(is_array($jsonResponse)){ + $tableBody=''; + ksort($jsonResponse); + foreach($jsonResponse as $key=>$value){ + if($key=="STATUS"){ + $tableBody.=' '.$key.' '.$value.' '; + }else{ + $tableBody.=' '.$key.' '.$value.' '; + } + } + } + } + } + } + return $tableBody; + } +} \ No newline at end of file diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Block/Cancel.php b/Magento_V1.x/app/code/community/One97/Paytm/Block/Cancel.php similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Block/Cancel.php rename to Magento_V1.x/app/code/community/One97/Paytm/Block/Cancel.php diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Block/Failure.php b/Magento_V1.x/app/code/community/One97/Paytm/Block/Failure.php similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Block/Failure.php rename to Magento_V1.x/app/code/community/One97/Paytm/Block/Failure.php diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Block/Form.php b/Magento_V1.x/app/code/community/One97/Paytm/Block/Form.php similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Block/Form.php rename to Magento_V1.x/app/code/community/One97/Paytm/Block/Form.php diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Block/Info.php b/Magento_V1.x/app/code/community/One97/Paytm/Block/Info.php similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Block/Info.php rename to Magento_V1.x/app/code/community/One97/Paytm/Block/Info.php diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Block/Redirect.php b/Magento_V1.x/app/code/community/One97/Paytm/Block/Redirect.php similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Block/Redirect.php rename to Magento_V1.x/app/code/community/One97/Paytm/Block/Redirect.php diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Block/Success.php b/Magento_V1.x/app/code/community/One97/Paytm/Block/Success.php similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Block/Success.php rename to Magento_V1.x/app/code/community/One97/Paytm/Block/Success.php diff --git a/Magento_V1.x/app/code/community/One97/Paytm/Helper/Data.php b/Magento_V1.x/app/code/community/One97/Paytm/Helper/Data.php new file mode 100644 index 0000000..c3a7156 --- /dev/null +++ b/Magento_V1.x/app/code/community/One97/Paytm/Helper/Data.php @@ -0,0 +1,216 @@ + strlen($text)) + return false; + return substr($text, 0, -1 * $pad); + } + // PaytmChecksum.php end + + // PaytmHelper.php start + /** + * exclude timestap with order id + */ + public static function getTransactionURL($isProduction = 0){ + if($isProduction == 1){ + $transactionURL= One97_paytm_Helper_Data::TRANSACTION_URL_PRODUCTION; + }else{ + $transactionURL= One97_paytm_Helper_Data::TRANSACTION_URL_STAGING; + } + return $transactionURL; + } + /** + * exclude timestap with order id + */ + public static function getTransactionStatusURL($isProduction = 0){ + if($isProduction == 1){ + return One97_paytm_Helper_Data::TRANSACTION_STATUS_URL_PRODUCTION; + }else{ + return One97_paytm_Helper_Data::TRANSACTION_STATUS_URL_STAGING; + } + } + + public static function getcURLversion(){ + if(function_exists('curl_version')){ + $curl_version = curl_version(); + if(!empty($curl_version['version'])){ + return $curl_version['version']; + } + } + return false; + } + + public static function executecUrl($apiURL, $requestParamList) { + $responseParamList = array(); + $JsonData = json_encode($requestParamList); + $postData = 'JsonData='.urlencode($JsonData); + $ch = curl_init($apiURL); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, One97_paytm_Helper_Data::CONNECT_TIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, One97_paytm_Helper_Data::TIMEOUT); + + /* + ** default value is 2 and we also want to use 2 + ** so no need to specify since older PHP version might not support 2 as valid value + ** see https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html + */ + // curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 2); + + // TLS 1.2 or above required + // curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); + + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json', + 'Content-Length: ' . strlen($postData)) + ); + $jsonResponse = curl_exec($ch); + + if (!curl_errno($ch)) { + return json_decode($jsonResponse, true); + } else { + return false; + } + } + // PaytmHelper.php end +} diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/Cc.php b/Magento_V1.x/app/code/community/One97/Paytm/Model/Cc.php similarity index 54% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/Cc.php rename to Magento_V1.x/app/code/community/One97/Paytm/Model/Cc.php index 987785d..0eb059c 100644 --- a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/Cc.php +++ b/Magento_V1.x/app/code/community/One97/Paytm/Model/Cc.php @@ -21,13 +21,12 @@ class One97_paytm_Model_Cc extends Mage_Payment_Model_Method_Abstract protected $_formBlockType = 'paytm/form'; protected $_infoBlockType = 'paytm/info'; protected $_order; - - public function isAvailable($quote = null) - { - if($this->getConfigData('active')==1){ - return true; - } - return false; + + public function isAvailable($quote = null) { + if($this->getConfigData('active')==1){ + return true; + } + return false; } //Get order model @@ -54,12 +53,9 @@ public function getPaymentMethodType() return $this->_paymentMethod; } - public function getUrl() - { - $transaction_url = Mage::getStoreConfig('payment/paytm_cc/transaction_url'); - $const = (string)Mage::getConfig()->getNode('global/crypt/key'); - $this->_liveUrl= Mage::helper('paytm')->decrypt_e($transaction_url,$const); - return $this->_liveUrl; + public function getUrl() { + $this->_liveUrl=Mage::helper('paytm')->getTransactionURL(Mage::getStoreConfig('payment/paytm_cc/transaction_environment')); + return $this->_liveUrl; } @@ -80,12 +76,16 @@ public function getFormFields() $const = (string)Mage::getConfig()->getNode('global/crypt/key');// Mage::getStoreConfig('payment/paytm_cc/constpaytm'); - $mer = Mage::helper('paytm')->decrypt_e($this->getConfigData('inst_key'),$const); - $merid = Mage::helper('paytm')->decrypt_e($this->getConfigData('inst_id'),$const); + $mer = Mage::helper('paytm')->decrypt($this->getConfigData('inst_key'),$const); + $merid = Mage::helper('paytm')->decrypt($this->getConfigData('inst_id'),$const); $website = $this->getConfigData('website'); $industry_type = $this->getConfigData('industrytype'); $is_callback = $this->getConfigData('custom_callbackurl'); - $callbackUrl = rtrim(Mage::getUrl('paytm/processing/response',array('_nosid'=>true)),'/'); + if(Mage::helper('paytm')::CUSTOM_CALLBACK_URL==""){ + $callbackUrl = rtrim(Mage::getUrl('paytm/processing/response',array('_nosid'=>true)),'/'); + }else{ + $callbackUrl = Mage::helper('paytm')::CUSTOM_CALLBACK_URL; + } $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId(); $order = Mage::getSingleton('sales/order'); $order->load($lastOrderId); @@ -93,39 +93,45 @@ public function getFormFields() $email = $_totalData['customer_email']; $telephone = $order->getBillingAddress()->getTelephone(); //create array using which checksum is calculated - + $oldOrderId=$orderId=$this->getOrder()->getRealOrderId(); + if(Mage::helper('paytm')::APPEND_TIMESTAMP){ + $orderId=$orderId."_".time(); + } + if(Mage::helper('paytm')::SAVE_PAYTM_RESPONSE){ + $tableName = Mage::getSingleton('core/resource')->getTableName('paytm_order_data'); + $tableCheck=Mage::getSingleton('core/resource')->getConnection('core_write')->isTableExists($tableName); + $connection = Mage::getSingleton('core/resource')->getConnection('core_write'); + if(!$tableCheck){ + $query="CREATE TABLE `".$tableName."` (`id` int(10) unsigned NOT NULL auto_increment, `order_id` text NOT NULL, `paytm_order_id` text NOT NULL, `transaction_id` text, `status` tinyint(1) DEFAULT 0, `paytm_response` text, `date_added` datetime DEFAULT CURRENT_TIMESTAMP, `date_modified` datetime DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; + $connection->query($query); + } + $query = "INSERT INTO ".$tableName." (`order_id`, `paytm_order_id`, `date_added`, `date_modified`) VALUES ('".$oldOrderId."', '".$orderId."', '".date('Y-m-d H:i:s')."', '".date('Y-m-d H:i:s')."')"; + $connection->query($query); + } $params = array( - 'MID' => $merid, - 'TXN_AMOUNT' => $price, - 'CHANNEL_ID' => "WEB", - 'INDUSTRY_TYPE_ID' => $industry_type, - 'WEBSITE' => $website, + 'MID' => trim($merid), + 'TXN_AMOUNT' => trim($price), + 'CHANNEL_ID' => Mage::helper('paytm')::CHANNEL_ID, + 'INDUSTRY_TYPE_ID' => trim($industry_type), + 'WEBSITE' => trim($website), 'CUST_ID' => Mage::getSingleton('customer/session')->getCustomer()->getId(), - 'ORDER_ID' => $this->getOrder()->getRealOrderId(), - 'EMAIL'=> $email, + 'ORDER_ID' => $orderId, + 'EMAIL'=> trim($email), 'MOBILE_NO' => preg_replace('#[^0-9]{0,13}#is','',$telephone) ); if($is_callback=='1'){ $callbackUrl=$this->getConfigData('callback_url')!=''?$this->getConfigData('callback_url'):$callbackUrl; } - $params['CALLBACK_URL'] = $callbackUrl; - + $params['CALLBACK_URL'] = trim($callbackUrl); + //generate customer id in case this is a guest checkout if(empty($params['CUST_ID'])){ - $params['CUST_ID'] = $email; + $params['CUST_ID'] = trim($email); } - - if(Mage::getSingleton('core/session')->getPROMO_CAMP_ID()){ - $params['PROMO_CAMP_ID'] = Mage::getSingleton('core/session')->getPROMO_CAMP_ID(); - - // unset Promo Code form session - Mage::getSingleton('core/session')->unsPROMO_CAMP_ID(); - } - - - $checksum = Mage::helper('paytm')->getChecksumFromArray($params, $mer);//generate checksum - $params['CHECKSUMHASH'] = $checksum; - return $params; + $checksum = Mage::helper('paytm')->generateSignature($params, $mer);//generate checksum + $params['CHECKSUMHASH'] = $checksum; + $params['X-REQUEST-ID']=Mage::helper('paytm')::X_REQUEST_ID.Mage::getVersion()."_".date("d-F-Y", strtotime(Mage::helper('paytm')::LAST_UPDATED)); + return $params; } protected function _debug($debugData) diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/Config/Backend/Instid.php b/Magento_V1.x/app/code/community/One97/Paytm/Model/Config/Backend/Instid.php similarity index 71% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/Config/Backend/Instid.php rename to Magento_V1.x/app/code/community/One97/Paytm/Model/Config/Backend/Instid.php index ff7f7ae..d27ebf6 100644 --- a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/Config/Backend/Instid.php +++ b/Magento_V1.x/app/code/community/One97/Paytm/Model/Config/Backend/Instid.php @@ -3,11 +3,11 @@ class One97_paytm_Model_Config_Backend_Instid extends Mage_Core_Model_Config_Data { - //decrypt value when loading + //decrypt value when loading protected function _afterLoad() { $value = (string)$this->getValue(); - if (!empty($value) && ($decrypted = Mage::helper('paytm')->decrypt_e($value, $const = (string)Mage::getConfig()->getNode('global/crypt/key')))) { + if (!empty($value) && ($decrypted = Mage::helper('paytm')->decrypt($value, $const = (string)Mage::getConfig()->getNode('global/crypt/key')))) { $this->setValue($decrypted); } } @@ -18,10 +18,10 @@ protected function _afterLoad() protected function _beforeSave() { $value = (string)$this->getValue(); - if (!empty($value) && ($encrypted = Mage::helper('paytm')->encrypt_e($value, $const = (string)Mage::getConfig()->getNode('global/crypt/key')))) { + if (!empty($value) && ($encrypted = Mage::helper('paytm')->encrypt($value, $const = (string)Mage::getConfig()->getNode('global/crypt/key')))) { $this->setValue($encrypted); } } - - + + } diff --git a/Magento_V1.x/app/code/community/One97/Paytm/Model/Config/Backend/Transactionenv.php b/Magento_V1.x/app/code/community/One97/Paytm/Model/Config/Backend/Transactionenv.php new file mode 100644 index 0000000..e0d8af6 --- /dev/null +++ b/Magento_V1.x/app/code/community/One97/Paytm/Model/Config/Backend/Transactionenv.php @@ -0,0 +1,28 @@ + 1, 'label'=>'Production'), + array('value' => 0, 'label'=>'Staging'), + ); + } + + /** + * Get options in "key-value" format + * + * @return array + */ + public function toArray() + { + return array( + 0 => Mage::helper('adminhtml')->__('No'), + 1 => Mage::helper('adminhtml')->__('Yes'), + ); + } + + +} diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/Config/Source/Instid2.php b/Magento_V1.x/app/code/community/One97/Paytm/Model/Config/Source/Instid2.php similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/Config/Source/Instid2.php rename to Magento_V1.x/app/code/community/One97/Paytm/Model/Config/Source/Instid2.php diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/Mysql4/paytm.php b/Magento_V1.x/app/code/community/One97/Paytm/Model/Mysql4/paytm.php similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/Mysql4/paytm.php rename to Magento_V1.x/app/code/community/One97/Paytm/Model/Mysql4/paytm.php diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/Mysql4/paytm/Collection.php b/Magento_V1.x/app/code/community/One97/Paytm/Model/Mysql4/paytm/Collection.php similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/Mysql4/paytm/Collection.php rename to Magento_V1.x/app/code/community/One97/Paytm/Model/Mysql4/paytm/Collection.php diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/paytm.php b/Magento_V1.x/app/code/community/One97/Paytm/Model/paytm.php similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/Model/paytm.php rename to Magento_V1.x/app/code/community/One97/Paytm/Model/paytm.php diff --git a/Magento_V1.x/app/code/community/One97/Paytm/controllers/ProcessingController.php b/Magento_V1.x/app/code/community/One97/Paytm/controllers/ProcessingController.php new file mode 100644 index 0000000..55a8430 --- /dev/null +++ b/Magento_V1.x/app/code/community/One97/Paytm/controllers/ProcessingController.php @@ -0,0 +1,499 @@ +_getCheckout(); + //get order singleton + $order = Mage::getModel('sales/order'); + $order->loadByIncrementId($session->getLastRealOrderId()); + if (!$order->getId()) { + Mage::throwException('No order for processing found'); + } + + //set order status + if ($order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) { + $order->setState( + Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, + $this->_getPendingPaymentStatus(), + Mage::helper('paytm')->__('Customer was redirected to paytm.') + )->save(); + } + //save order and quote ids + if ($session->getQuoteId() && $session->getLastSuccessQuoteId()) { + $session->setpaytmQuoteId($session->getQuoteId()); + $session->setpaytmSuccessQuoteId($session->getLastSuccessQuoteId()); + $session->setpaytmRealOrderId($session->getLastRealOrderId()); + $session->getQuote()->setIsActive(false)->save(); + $session->clear(); + } + //load basic blank page + $this->loadLayout(); + $this->renderLayout(); + return; + } catch (Mage_Core_Exception $e) { + $this->_getCheckout()->addError($e->getMessage()); + } catch(Exception $e) { + Mage::logException($e); + } + $this->_redirect('checkout/cart'); + } + + //handle callback values and takes appropriate action + public function responseAction() { + $session = $this->_getCheckout(); + $order = Mage::getModel('sales/order'); + Mage::log($request); + if (!$order->getId()) { + Mage::log('No order for processing found'); + } + $request = $this->_checkReturnedPost(); + $orderIdArr=explode('_', $request['ORDERID']); + $orderIdMagento=$orderIdArr[0]; + try { + $parameters = array(); + foreach($request as $key=>$value) { + $parameters[$key] = $request[$key]; + } + $session = $this->_getCheckout(); + $txnstatus = false; + $authStatus = false; + $mer_encrypted = Mage::getStoreConfig('payment/paytm_cc/inst_key'); + $const = (string)Mage::getConfig()->getNode('global/crypt/key'); + $mer_decrypted= Mage::helper('paytm')->decrypt($mer_encrypted,$const); + + $transactionProcess="STATUS_FRAUD"; + $tableName = Mage::getSingleton('core/resource')->getTableName('paytm_order_data'); + if(trim($request['ORDERID'])!='' && trim($request['MID'])){ + $isValidChecksum = false; + if(isset($parameters['CHECKSUMHASH'])){ + $tmpChecksum=$parameters['CHECKSUMHASH']; + unset($parameters['CHECKSUMHASH']); + $return = Mage::helper('paytm')->verifySignature($parameters, $mer_decrypted, $tmpChecksum); + if($return == "TRUE") + $isValidChecksum = true; + } + if($isValidChecksum){ + $connectionRead = Mage::getSingleton('core/resource')->getConnection('core_write'); + $query="SELECT * FROM ".$tableName." WHERE order_id='".$orderIdMagento."' AND paytm_order_id='".$request['ORDERID']."' ORDER BY ID DESC"; + $results = $connectionRead->fetchAll($query); + if(isset($results[0]['id'])){ + $connection = Mage::getSingleton('core/resource')->getConnection('core_write'); + $query = "UPDATE ".$tableName." SET transaction_id='".@$request['TXNID']."', paytm_response='".json_encode($request, JSON_UNESCAPED_SLASHES)."', date_modified='".date('Y-m-d H:i:s')."' WHERE id='".$results[0]['id']."'"; + $connection->query($query); + } + $requestParamList = array("MID" => $request['MID'] , "ORDERID" => $request['ORDERID']); + $StatusCheckSum = Mage::helper('paytm')->generateSignature($requestParamList, $mer_decrypted); + $requestParamList['CHECKSUMHASH'] = $StatusCheckSum; + + $transactionEnvironment = Mage::getStoreConfig('payment/paytm_cc/transaction_environment'); + $const = (string)Mage::getConfig()->getNode('global/crypt/key'); + $check_status_url=Mage::helper('paytm')->getTransactionStatusURL(Mage::helper('paytm')->decrypt($transactionEnvironment,$const)); + $responseParamList=array(); + $retry = Mage::helper('paytm')::MAX_RETRY_COUNT; + do{ + $responseParamList = Mage::helper('paytm')->executecUrl($check_status_url, $requestParamList); + $retry++; + } while(empty($responseParamList) && $retry < $maxRetryCount); + if(!empty($responseParamList)){ + if($responseParamList['STATUS']=="TXN_SUCCESS" && $responseParamList['TXNAMOUNT']==$request["TXNAMOUNT"]){ + if($request["STATUS"]!="TXN_SUCCESS"){ + $request=array(); + $request=$responseParamList; + } + $transactionProcess="STATE_SUCCESS"; + }else if($responseParamList['STATUS']=="PENDING"){ + if($request["STATUS"]!="PENDING"){ + $request=array(); + $request=$responseParamList; + } + $transactionProcess="STATE_PENDING_PAYMENT"; + }else{ + // $request=array(); + // $request=$responseParamList; + $transactionProcess="STATE_CANCELED"; + } + }else{ + $transactionProcess="CURL_NOT_ENABLE"; + } + } + } + if(isset($results[0]['id'])){ + $connection = Mage::getSingleton('core/resource')->getConnection('core_write'); + if($transactionProcess=="STATE_SUCCESS"){ + $query = "UPDATE ".$tableName." SET paytm_response='".json_encode($request, JSON_UNESCAPED_SLASHES)."', status='1', date_modified='".date('Y-m-d H:i:s')."' WHERE id='".$results[0]['id']."'"; + }else{ + $query = "UPDATE ".$tableName." SET paytm_response='".json_encode($request, JSON_UNESCAPED_SLASHES)."', date_modified='".date('Y-m-d H:i:s')."' WHERE id='".$results[0]['id']."'"; + } + $connection->query($query); + } + switch ($transactionProcess) { + case 'STATE_SUCCESS': + $this->_processSale(array("ORDERID"=>$orderIdMagento)); + $order_mail = new Mage_Sales_Model_Order(); + $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); + $order_mail->loadByIncrementId($incrementId); + $i = Mage::getVersion(); + $updatedVersion=false; + if(strpos($i,"1.9")===0){ + $updatedVersion=true; + } + if(!$updatedVersion){ // latest from 1.9.0 version, not support sendNewOrderEmail() fumction + try{ + $order_mail->sendNewOrderEmail(); + } catch (Exception $ex) { } + } + break; + case 'STATE_PENDING_PAYMENT': + $this->_processCancel(array("ORDERID"=>$orderIdMagento, "RESPMSG"=>$request['RESPMSG'], "STATUS"=>$request['STATUS'])); + break; + case 'STATE_CANCELED': + $this->_processCancel(array("ORDERID"=>$orderIdMagento, "RESPMSG"=>$request['RESPMSG'])); + break; + case 'CURL_NOT_ENABLE': + $this->_processFail(array("ORDERID"=>$orderIdMagento, "failCase"=>"CURL_NOT_ENABLE")); + break; + case 'STATUS_FRAUD': + $this->_processFail(array("ORDERID"=>$orderIdMagento, "failCase"=>"STATUS_FRAUD")); + break; + + default: + # code... + break; + } + } catch (Mage_Core_Exception $e) { + $this->getResponse()->setBody( + $this->getLayout() + ->createBlock($this->_failureBlockType) + ->setOrder($this->_order) + ->toHtml() + ); + $this->_processFail(array("ORDERID"=>$orderIdMagento)); + } + } + + protected function _getPendingPaymentStatus() { + return Mage::helper('paytm')->getPendingPaymentStatus(); + } + + // Checking POST variables. + protected function _checkReturnedPost() { + // check request type + if (!$this->getRequest()->isPost()) + Mage::throwException('Wrong request type.'); + + // get request variables + $request = $this->getRequest()->getPost(); + if (empty($request)) + Mage::throwException('Request doesn\'t contain POST elements.'); + + Mage::log($request); + // check order id + if (empty($request['ORDERID']) ) + Mage::throwException('Missing or invalid order ID'); + + $orderIdArr=explode('_', $request['ORDERID']); + $orderIdMagento=$orderIdArr[0]; + + // load order for further validation + $this->_order = Mage::getModel('sales/order')->loadByIncrementId($orderIdMagento); + if (!$this->_order->getId()) + Mage::throwException('Order not found'); + + return $request; + } + + //if success process sale + protected function _processSale($request) { + $session = $this->_getCheckout(); + $order = Mage::getModel('sales/order'); + $order->loadByIncrementId($request['ORDERID']); + + //save transaction information + $invoice = $order->prepareInvoice(); + $invoice->register()->capture(); + Mage::getModel('core/resource_transaction') + ->addObject($invoice) + ->addObject($invoice->getOrder()) + ->save(); + + $order->addStatusToHistory(Mage::getStoreConfig('payment/paytm_cc/success_transaction_status'),Mage::helper('paytm')->__('Payment successful through Paytm PG')); + $order->save(); + $this->getResponse()->setBody( + $this->getLayout() + ->createBlock($this->_successBlockType) + ->setOrder($this->_order) + ->toHtml() + ); + } + + //cancel order if failure + protected function _processFail($request) { + $mass="Checksum Mismatch."; + $isPending=false; + if(isset($request['STATUS'])){ + if($request['STATUS']=="PENDING"){ + $isPending=true; + } + } + if($request['failCase']=='CURL_NOT_ENABLE'){ + $mass="It seems some issue in server to server communication. Kindly connect with administrator."; + }else if($isPending){ + $mass=$request['RESPMSG']; + } + $this->_order = Mage::getModel('sales/order')->loadByIncrementId($request['ORDERID']); + if ($this->_order->canCancel()) { + $this->_order->cancel(); + if($isPending){ + $this->_order->addStatusToHistory($this->_getPendingPaymentStatus(), Mage::helper('paytm')->__('Payment was failed, due to reason: '.$mass)); + }else{ + $this->_order->addStatusToHistory(Mage_Sales_Model_Order::STATUS_FRAUD, Mage::helper('paytm')->__('Payment was failed, due to reason: '.$mass)); + } + $this->_order->save(); + } + $session = $this->_getCheckout(); + if(isset($request['failCase'])){ + $session->addError(Mage::helper('paytm')->__('Reason: '.$mass)); + } + $this->_redirect('checkout/cart'); + } + + //cancel order if failure + protected function _processCancel($request) { + // cancel order + $mass="Not Defined!"; + if(isset($request['RESPMSG'])){ + $mass=$request['RESPMSG']; + } + $this->_order = Mage::getModel('sales/order')->loadByIncrementId($request['ORDERID']); + if ($this->_order->canCancel()) { + $this->_order->cancel(); + $this->_order->addStatusToHistory(Mage::getStoreConfig('payment/paytm_cc/cancel_transaction_status'), Mage::helper('paytm')->__('Payment was canceled, due to Reason: '.$mass)); + $this->_order->save(); + } + $session = $this->_getCheckout(); + $session->addError(Mage::helper('paytm')->__('Reason: '.$mass)); + $this->getResponse()->setBody( + $this->getLayout() + ->createBlock($this->_cancelBlockType) + ->setOrder($this->_order) + ->toHtml() + ); + } + + public function curltestAction() { + $debug = array(); + if(!function_exists("curl_init")){ + $debug[0]["info"][] = "cURL extension is either not available or disabled. Check phpinfo for more info."; + + }else{ + // this site homepage URL + $testing_urls=array(); + + if(!empty($_GET)){ + foreach ($_GET as $key => $value) { + $testing_urls[]=$value; + } + }else{ + $testing_urls = array( + Mage::getBaseUrl(), + "https://www.gstatic.com/generate_204", + Mage::helper('paytm')::TRANSACTION_STATUS_URL_PRODUCTION, + Mage::helper('paytm')::TRANSACTION_STATUS_URL_STAGING + ); + } + + // loop over all URLs, maintain debug log for each response received + foreach($testing_urls as $key=>$url){ + + $debug[$key]["info"][] = "Connecting to " . $url . " using cURL"; + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $res = curl_exec($ch); + + if (!curl_errno($ch)) { + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $debug[$key]["info"][] = "cURL executed succcessfully."; + $debug[$key]["info"][] = "HTTP Response Code: ". $http_code . ""; + + // $debug[$key]["content"] = $res; + + } else { + $debug[$key]["info"][] = "Connection Failed !!"; + $debug[$key]["info"][] = "Error Code: " . curl_errno($ch) . ""; + $debug[$key]["info"][] = "Error: " . curl_error($ch) . ""; + break; + } + + if((in_array($url, array(Mage::helper('paytm')::TRANSACTION_STATUS_URL_STAGING , Mage::helper('paytm')::TRANSACTION_STATUS_URL_PRODUCTION)))){ + $debug[$key]["info"][] = "Response:
" . $res; + } + curl_close($ch); + } + } + foreach($debug as $k=>$v){ + echo ""; + echo "
"; + } + die; + } + + //runs on success of payment + public function successAction() { + try { + $session = $this->_getCheckout(); + $session->unspaytmRealOrderId(); + $session->setQuoteId($session->getpaytmQuoteId(true)); + // $session->setLastSuccessQuoteId($session->getpaytmSuccessQuoteId(true)); + $session->setLastSuccessQuoteId($session->getLastQuoteId()); + $this->_redirect('checkout/onepage/success'); + return; + } catch (Mage_Core_Exception $e) { + $this->_getCheckout()->addError($e->getMessage()); + } catch(Exception $e) { + $this->_debug('paytm error: ' . $e->getMessage()); + Mage::logException($e); + } + $this->_redirect('checkout/cart'); + } + + public function failAction() { + // set quote to active + $session = $this->_getCheckout(); + if ($quoteId = $session->getpaytmQuoteId()) { + $quote = Mage::getModel('sales/quote')->load($quoteId); + if ($quote->getId()) { + $quote->setIsActive(true)->save(); + $session->setQuoteId($quoteId); + } + } + Mage::log("failed"); + $session->addError(Mage::helper('paytm')->__('The order has failed.')); + $this->_redirect('checkout/cart'); + } + + //runs on cancel action + public function cancelAction() { + // set quote to active + $session = $this->_getCheckout(); + $order = Mage::getModel('sales/order'); + $order->loadByIncrementId($session->getLastRealOrderId()); + if (!$order->getId()) { + Mage::throwException('No order for processing found'); + } + + if ($quoteId = $session->getpaytmQuoteId()) { + $quote = Mage::getModel('sales/quote')->load($quoteId); + if ($quote->getId()) { + $quote->setIsActive(true)->save(); + $session->setQuoteId($quoteId); + } + } + $this->_redirect('checkout/cart'); + } + + public function statsucheckAction(){ + $json = array("response" => "false", "tableBody" => ""); + $tableBody=''; + if(isset($_POST['paytmResponseId'])){ + if(trim($_POST['paytmResponseId'])!=''){ + $tableName = Mage::getSingleton('core/resource')->getTableName('paytm_order_data'); + $connectionRead = Mage::getSingleton('core/resource')->getConnection('core_write'); + $query="SELECT * FROM ".$tableName." WHERE id='".$_POST['paytmResponseId']."' ORDER BY ID DESC"; + $results = $connectionRead->fetchAll($query); + if(isset($results[0]['id'])){ + $merchantID = Mage::getStoreConfig('payment/paytm_cc/inst_id'); + $merchantKey = Mage::getStoreConfig('payment/paytm_cc/inst_key'); + $transactionEnvironment = Mage::getStoreConfig('payment/paytm_cc/transaction_environment'); + $const = (string)Mage::getConfig()->getNode('global/crypt/key'); + $mid= Mage::helper('paytm')->decrypt($merchantID,$const); + $mKey= Mage::helper('paytm')->decrypt($merchantKey,$const); + $check_status_url=Mage::helper('paytm')->getTransactionStatusURL(Mage::helper('paytm')->decrypt($transactionEnvironment,$const)); + $requestParamList = array("MID" => $mid , "ORDERID" => $results[0]['paytm_order_id']); + $StatusCheckSum = Mage::helper('paytm')->generateSignature($requestParamList, $mKey); + $requestParamList['CHECKSUMHASH'] = $StatusCheckSum; + $responseParamList=array(); + $retry = Mage::helper('paytm')::MAX_RETRY_COUNT; + do{ + $responseParamList = Mage::helper('paytm')->executecUrl($check_status_url, $requestParamList); + $retry++; + } while(empty($responseParamList) && $retry < $maxRetryCount); + if(!empty($responseParamList)){ + if(isset($results[0]['id'])){ + $connection = Mage::getSingleton('core/resource')->getConnection('core_write'); + if($responseParamList['STATUS']=="TXN_SUCCESS"){ + $query = "UPDATE ".$tableName." SET paytm_response='".json_encode($responseParamList, JSON_UNESCAPED_SLASHES)."', status='1', date_modified='".date('Y-m-d H:i:s')."' WHERE id='".$results[0]['id']."'"; + }else{ + $query = "UPDATE ".$tableName." SET paytm_response='".json_encode($responseParamList, JSON_UNESCAPED_SLASHES)."', date_modified='".date('Y-m-d H:i:s')."' WHERE id='".$results[0]['id']."'"; + } + $connection->query($query); + } + $jsonResponse = $responseParamList; + if(is_array($jsonResponse)){ + ksort($jsonResponse); + $successResponse=false; + foreach($jsonResponse as $key=>$value){ + if($key=="STATUS"){ + $order = Mage::getModel('sales/order'); + $order->loadByIncrementId($results[0]['order_id']); + if($value=="TXN_SUCCESS"){ + //save transaction information + $invoice = $order->prepareInvoice(); + $invoice->register()->capture(); + Mage::getModel('core/resource_transaction') + ->addObject($invoice) + ->addObject($invoice->getOrder()) + ->save(); + + $order->addStatusToHistory(Mage::getStoreConfig('payment/paytm_cc/success_transaction_status'),Mage::helper('paytm')->__('Payment successful through Paytm PG in fetchStatus API.')); + $order->save(); + + $successResponse=true; + }else if($value=="TXN_FAILURE"){ + $order->cancel(); + $order->addStatusToHistory(Mage::getStoreConfig('payment/paytm_cc/cancel_transaction_status'), Mage::helper('paytm')->__('Payment was canceled, due to Reason: '.$jsonResponse['RESPMSG'])); + $order->save(); + } + $tableBody.=' '.$key.' '.$value.' '; + }else{ + $tableBody.=' '.$key.' '.$value.' '; + } + } + if($successResponse){ + $json = array("response" => "success", "tableBody" => $tableBody); + }else{ + $json = array("response" => "false", "tableBody" => $tableBody); + } + } + } + } + } + } + $this->getResponse()->setHeader('Content-type', 'application/json'); + $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($json)); + } + + public function versioncheckAction(){ + $json = array("version" => Mage::getVersion(), "lastupdate" => date("d-F-Y", strtotime(Mage::helper('paytm')::LAST_UPDATED)), "pluginVersion" => Mage::helper('paytm')::PLUGIN_VERSION, "phpCurlVersion" => Mage::helper('paytm')->getcURLversion()); + $this->getResponse()->setHeader('Content-type', 'application/json'); + $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($json)); + } +} diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/etc/config.xml b/Magento_V1.x/app/code/community/One97/Paytm/etc/config.xml similarity index 78% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/etc/config.xml rename to Magento_V1.x/app/code/community/One97/Paytm/etc/config.xml index 9776086..896673b 100644 --- a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/etc/config.xml +++ b/Magento_V1.x/app/code/community/One97/Paytm/etc/config.xml @@ -1,14 +1,10 @@ - 0.1.0 - - - @@ -24,23 +20,15 @@ - - - - - - - One97_paytm_Helper - + + One97_paytm_Helper + - - One97_paytm - core_setup @@ -57,22 +45,10 @@ - - - - One97_paytm_Block + One97_Paytm_Block - - - - - - - - - /paytm/processing @@ -93,13 +69,15 @@ - - - - - - + + + + + one97_paytm.xml + + + @@ -110,28 +88,22 @@ - - - 0 paytm/cc - 1 + 1 + 1 Paytm PG 0 - - + 0 - 0 - 0 - - + \ No newline at end of file diff --git a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/etc/system.xml b/Magento_V1.x/app/code/community/One97/Paytm/etc/system.xml similarity index 50% rename from Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/etc/system.xml rename to Magento_V1.x/app/code/community/One97/Paytm/etc/system.xml index 7b7af4f..0ad1c53 100644 --- a/Magento_v1.x/Magento Plugin V1.0/app/code/community/One97/Paytm/etc/system.xml +++ b/Magento_V1.x/app/code/community/One97/Paytm/etc/system.xml @@ -11,6 +11,16 @@ 1 1 0 + + Developer Docs +
+ | + | + | + + ]]> +
@@ -21,99 +31,46 @@ 1 0 - - - select - adminhtml/system_config_source_order_status - - 2 - 1 - 1 - 0 - - <label>Title</label> <frontend_type>text</frontend_type> - <!-- <validate>required-entry</validate> --> - <sort_order>3</sort_order> + <sort_order>2</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> - - + + + select + paytm/config_backend_transactionenv + 3 + 1 + 1 + 1 + text paytm/config_backend_instid - 4 1 1 0 - text paytm/config_backend_instid - 5 1 1 0 - - - - select - adminhtml/system_config_source_yesno - 6 - 1 - 1 - 1 - - - - - text - required-entry validate-url - 7 - 1 - 1 - 1 - - 1 - - - - - - text - paytm/config_backend_instid - - 8 - 1 - 1 - 0 - - - - text - paytm/config_backend_instid - - 9 - 1 - 1 - 0 - - text - 10 + 6 1 1 0 @@ -122,41 +79,30 @@ text - 11 + 7 1 1 0 - - - - + + select - adminhtml/system_config_source_yesno - 12 + adminhtml/system_config_source_order_status + 8 1 1 - 1 - - - + 0 + + + select - adminhtml/system_config_source_yesno - 13 - 1 - 1 - 1 - - - - text - 14 + adminhtml/system_config_source_order_status + 9 1 1 0 - + - diff --git a/Magento_V1.x/app/code/community/One97/Paytm/sql/paytm_setup/mysql4-install-0.1.0.php b/Magento_V1.x/app/code/community/One97/Paytm/sql/paytm_setup/mysql4-install-0.1.0.php new file mode 100644 index 0000000..0ea74bd --- /dev/null +++ b/Magento_V1.x/app/code/community/One97/Paytm/sql/paytm_setup/mysql4-install-0.1.0.php @@ -0,0 +1,22 @@ +getTableName('paytm_order_data'); +$installer = $this; +$installer->startSetup(); +$installer->run(" +DROP TABLE IF EXISTS `paytm`; +DROP TABLE IF EXISTS `".$tableName."`; +CREATE TABLE `".$tableName."` ( + `id` int(10) unsigned NOT NULL auto_increment, + `order_id` text NOT NULL, + `paytm_order_id` text NOT NULL, + `transaction_id` text, + `status` tinyint(1) DEFAULT 0, + `paytm_response` text, + `date_added` datetime DEFAULT CURRENT_TIMESTAMP, + `date_modified` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +" +); +$installer->endSetup(); diff --git a/Magento_V1.x/app/design/adminhtml/default/default/layout/one97_paytm.xml b/Magento_V1.x/app/design/adminhtml/default/default/layout/one97_paytm.xml new file mode 100755 index 0000000..09284b3 --- /dev/null +++ b/Magento_V1.x/app/design/adminhtml/default/default/layout/one97_paytm.xml @@ -0,0 +1,19 @@ + + + + + + one97_paytm_order_view_tab + paytm/adminhtml_order_view_tab_contents + + + + + + + js + paytm/adminhtml/paytm.js + + + + \ No newline at end of file diff --git a/Magento_v1.x/Magento Plugin V1.0/app/design/adminhtml/default/default/template/paytm/info.phtml b/Magento_V1.x/app/design/adminhtml/default/default/template/paytm/info.phtml similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/design/adminhtml/default/default/template/paytm/info.phtml rename to Magento_V1.x/app/design/adminhtml/default/default/template/paytm/info.phtml diff --git a/Magento_V1.x/app/design/adminhtml/default/default/template/paytm/order/view/tab/contents.phtml b/Magento_V1.x/app/design/adminhtml/default/default/template/paytm/order/view/tab/contents.phtml new file mode 100755 index 0000000..797e69a --- /dev/null +++ b/Magento_V1.x/app/design/adminhtml/default/default/template/paytm/order/view/tab/contents.phtml @@ -0,0 +1,47 @@ +getBlockClassName('One97_Paytm_Block_Adminhtml_Order_View_Tab_Contents'); + $block = new $className(); + $dealerRespnce = $block->paytmResponse(); + $setchButton = $block->paytmResponse(true); +?> +
+
+

Paytm Response

+ +
+
+
+ + + + + + + + + + +
KeyValues
+
+ +
+
\ No newline at end of file diff --git a/Magento_v1.x/Magento Plugin V1.0/app/design/adminhtml/default/default/template/paytm/pdf/info.phtml b/Magento_V1.x/app/design/adminhtml/default/default/template/paytm/pdf/info.phtml similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/design/adminhtml/default/default/template/paytm/pdf/info.phtml rename to Magento_V1.x/app/design/adminhtml/default/default/template/paytm/pdf/info.phtml diff --git a/Magento_v1.x/Magento Plugin V1.0/app/design/frontend/base/default/layout/paytm.xml b/Magento_V1.x/app/design/frontend/base/default/layout/paytm.xml similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/design/frontend/base/default/layout/paytm.xml rename to Magento_V1.x/app/design/frontend/base/default/layout/paytm.xml diff --git a/Magento_v1.x/Magento Plugin V1.0/app/design/frontend/base/default/template/paytm/blank.phtml b/Magento_V1.x/app/design/frontend/base/default/template/paytm/blank.phtml similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/design/frontend/base/default/template/paytm/blank.phtml rename to Magento_V1.x/app/design/frontend/base/default/template/paytm/blank.phtml diff --git a/Magento_v1.x/Magento Plugin V1.0/app/design/frontend/base/default/template/paytm/cancel.phtml b/Magento_V1.x/app/design/frontend/base/default/template/paytm/cancel.phtml similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/design/frontend/base/default/template/paytm/cancel.phtml rename to Magento_V1.x/app/design/frontend/base/default/template/paytm/cancel.phtml diff --git a/Magento_v1.x/Magento Plugin V1.0/app/design/frontend/base/default/template/paytm/failure.phtml b/Magento_V1.x/app/design/frontend/base/default/template/paytm/failure.phtml similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/design/frontend/base/default/template/paytm/failure.phtml rename to Magento_V1.x/app/design/frontend/base/default/template/paytm/failure.phtml diff --git a/Magento_V1.x/app/design/frontend/base/default/template/paytm/form.phtml b/Magento_V1.x/app/design/frontend/base/default/template/paytm/form.phtml new file mode 100644 index 0000000..c1b4b1e --- /dev/null +++ b/Magento_V1.x/app/design/frontend/base/default/template/paytm/form.phtml @@ -0,0 +1,10 @@ + +
+ getMethodCode() ?> + +
\ No newline at end of file diff --git a/Magento_v1.x/Magento Plugin V1.0/app/design/frontend/base/default/template/paytm/info.phtml b/Magento_V1.x/app/design/frontend/base/default/template/paytm/info.phtml similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/design/frontend/base/default/template/paytm/info.phtml rename to Magento_V1.x/app/design/frontend/base/default/template/paytm/info.phtml diff --git a/Magento_v1.x/Magento Plugin V1.0/app/design/frontend/base/default/template/paytm/redirect.phtml b/Magento_V1.x/app/design/frontend/base/default/template/paytm/redirect.phtml similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/design/frontend/base/default/template/paytm/redirect.phtml rename to Magento_V1.x/app/design/frontend/base/default/template/paytm/redirect.phtml diff --git a/Magento_v1.x/Magento Plugin V1.0/app/etc/modules/One97_paytm.xml b/Magento_V1.x/app/etc/modules/One97_paytm.xml similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/etc/modules/One97_paytm.xml rename to Magento_V1.x/app/etc/modules/One97_paytm.xml diff --git a/Magento_v1.x/Magento Plugin V1.0/app/locale/en_US/One97_paytm.csv b/Magento_V1.x/app/locale/en_US/One97_paytm.csv similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/app/locale/en_US/One97_paytm.csv rename to Magento_V1.x/app/locale/en_US/One97_paytm.csv diff --git a/Magento_V1.x/js/paytm/adminhtml/paytm.js b/Magento_V1.x/js/paytm/adminhtml/paytm.js new file mode 100644 index 0000000..15fc905 --- /dev/null +++ b/Magento_V1.x/js/paytm/adminhtml/paytm.js @@ -0,0 +1,31 @@ +var url = window.location.protocol + "//" + window.location.host; +var path=document.location.pathname; +var pathArr=path.split('admin'); +url+=pathArr[0]+"paytm/processing/versioncheck"; +window.onload = function(e){ + versionLastUpdateAjax(); +} +function versionLastUpdateAjax() { + new Ajax.Request(url, { + parameters: {isAjax: 1, method: 'POST'}, + onSuccess: function(transport) { + var data=transport.responseJSON; + var magentoVersion=document.getElementById('magentoVersion'); + var paytmLastUpdate=document.getElementById('paytmLastUpdate'); + var paytmPluginVersion=document.getElementById('paytmPluginVersion'); + var phpCurlVersion=document.getElementById('phpCurlVersion'); + if(magentoVersion!=null){ + magentoVersion.innerHTML = "Magento Version: "+data.version; + } + if(paytmLastUpdate!=null){ + paytmLastUpdate.innerHTML = "Last Updated: "+data.lastupdate; + } + if(paytmPluginVersion!=null){ + paytmPluginVersion.innerHTML = "Paytm Plugin Version: "+data.pluginVersion; + } + if(phpCurlVersion!=null){ + phpCurlVersion.innerHTML = "PHP cURL Version: "+data.phpCurlVersion; + } + } + }); +}; \ No newline at end of file diff --git a/Magento_v1.x/Magento Plugin V1.0/skin/frontend/base/default/images/paytm.png b/Magento_V1.x/skin/frontend/base/default/images/paytm.png similarity index 100% rename from Magento_v1.x/Magento Plugin V1.0/skin/frontend/base/default/images/paytm.png rename to Magento_V1.x/skin/frontend/base/default/images/paytm.png diff --git a/Magento_V2.3x/README.md b/Magento_V2.3x/README.md new file mode 100644 index 0000000..6a79d44 --- /dev/null +++ b/Magento_V2.3x/README.md @@ -0,0 +1,2 @@ +# Paytm Payment plugin for Magento version 2.3x +* Developer Docs: https://developer.paytm.com/docs/eCommerce-plugin/magento/#v2-3x \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Block/Adminhtml/OrderEdit/Tab/View.php b/Magento_V2.3x/app/code/One97/Paytm/Block/Adminhtml/OrderEdit/Tab/View.php new file mode 100755 index 0000000..90ac4d5 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Block/Adminhtml/OrderEdit/Tab/View.php @@ -0,0 +1,113 @@ +_coreRegistry = $registry; + $this->jsonHelper = $jsonHelper; + parent::__construct($context, $data); + } + + public function getOrder() { + return $this->_coreRegistry->registry('current_order'); + } + + public function getOrderId() { + return $this->getOrder()->getEntityId(); + } + + public function getOrderIncrementId() { + return $this->getOrder()->getIncrementId(); + } + + public function getTabLabel() { + return __('Paytm Response'); + } + + public function getTabTitle() { + return __('Paytm Response'); + } + + public function canShowTab() { + $magentoOrderId=$this->getOrderIncrementId(); + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $connection = $resource->getConnection(); + $tableName = $resource->getTableName('paytm_order_data'); + if($connection->isTableExists($tableName)){ + $sql = "Select * FROM ".$tableName." WHERE order_id=".$magentoOrderId." ORDER BY id DESC"; + $result = $connection->fetchAll($sql); + if(!empty($result)){ + if(isset($result[0]['paytm_response']) || trim($result[0]['paytm_response'])==''){ + return true; + }else{ + return false; + } + }else{ + return false; + } + }else{ + return false; + } + } + + public function isHidden() { + return false; + } + + public function getPaytmResponseHtml($viewButton=false) { + $response=' No Record '; + $magentoOrderId=$this->getOrderIncrementId(); + + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface'); + $fetchStatusURL=$storeManager->getStore()->getBaseUrl().'paytm/Standard/Fetchstatus/'; + + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $connection = $resource->getConnection(); + $tableName = $resource->getTableName('paytm_order_data'); + $sql = "Select * FROM ".$tableName." WHERE order_id=".$magentoOrderId." ORDER BY id DESC"; //take always letest response + $result = $connection->fetchAll($sql); + $resArr=array(); + $button=''; + if(!empty($result)){ + $fetchStatusURL.='?fetchId='.$result[0]['id']; + if(trim($result[0]['paytm_response'])!=''){ + $resArr=$this->jsonHelper->jsonDecode($result[0]['paytm_response']); + $response=''; + ksort($resArr); + foreach ($resArr as $k => $val) { + switch ($k) { + case 'CHECKSUMHASH': + break; + case 'STATUS': + $response.=' '.$k.' '.$val.' '; + $val!='TXN_SUCCESS'?$button='':''; + break; + + default: + $response.=' '.$k.' '.$val.' '; + break; + } + } + }else{ + $button=''; + } + } + if($viewButton){ + return $button; + }else{ + return $response; + } + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Block/Form/Paytm.php b/Magento_V2.3x/app/code/One97/Paytm/Block/Form/Paytm.php new file mode 100755 index 0000000..8dd2c62 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Block/Form/Paytm.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Block/Info/Paytm.php b/Magento_V2.3x/app/code/One97/Paytm/Block/Info/Paytm.php new file mode 100755 index 0000000..bd53f36 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Block/Info/Paytm.php @@ -0,0 +1,15 @@ +get('\Magento\Store\Model\StoreManagerInterface'); + $fetchStatusURL=$storeManager->getStore()->getBaseUrl(); + return $fetchStatusURL; + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Controller/Paytm.php b/Magento_V2.3x/app/code/One97/Paytm/Controller/Paytm.php new file mode 100755 index 0000000..f7d255c --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Controller/Paytm.php @@ -0,0 +1,113 @@ +_customerSession = $customerSession; + $this->_checkoutSession = $checkoutSession; + $this->_orderFactory = $orderFactory; + $this->_logger = $logger; + $this->_orderHistoryFactory = $orderHistoryFactory; + $this->_paytmModel = $paytmModel; + $this->_paytmHelper = $paytmHelper; + $this->resultJsonFactory = $resultJsonFactory; + $this->jsonHelper = $jsonHelper; + $this->resultPageFactory = $resultPageFactory; + $this->messageManager = $messageManager; + parent::__construct($context); + } + + public function createCsrfValidationException( + RequestInterface $request + ): ?InvalidRequestException { + return null; + } + + public function validateForCsrf(RequestInterface $request): ?bool { + return true; + } + + protected function _cancelPayment($errorMsg = '') { + $gotoSection = false; + $this->_paytmHelper->cancelCurrentOrder($errorMsg); + if ($this->_checkoutSession->restoreQuote()) { + $gotoSection = 'paymentMethod'; + } + return $gotoSection; + } + + protected function getOrderById($order_id) { + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $order = $objectManager->get('Magento\Sales\Model\Order'); + $order_info = $order->loadByIncrementId($order_id); + return $order_info; + } + + protected function getOrder() { + return $this->_orderFactory->create()->loadByIncrementId( + $this->_checkoutSession->getLastRealOrderId() + ); + } + + protected function addOrderHistory($order,$comment){ + $history = $this->_orderHistoryFactory->create() + ->setComment($comment) + ->setEntityName('order') + ->setOrder($order); + $history->save(); + return true; + } + + protected function getQuote() { + if (!$this->_quote) { + $this->_quote = $this->_getCheckoutSession()->getQuote(); + } + return $this->_quote; + } + + protected function getCheckoutSession() { + return $this->_checkoutSession; + } + + protected function getCustomerSession() { + return $this->_customerSession; + } + + protected function getPaytmModel() { + return $this->_paytmModel; + } + + protected function getPaytmHelper() { + return $this->_paytmHelper; + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Curlconfig.php b/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Curlconfig.php new file mode 100755 index 0000000..bb94a39 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Curlconfig.php @@ -0,0 +1,63 @@ +getRequest()->getParams(); + $resultJson = $this->resultJsonFactory->create(); + if(isset($reqData['getlastUpdate'])){ + $getLastUpdate=$this->getPaytmModel()->getLastUpdate(); + $getLastUpdateArr=explode('|',$getLastUpdate); + return $resultJson->setData(['version' => $getLastUpdateArr[0], 'lastupdate' => $getLastUpdateArr[1], 'phpCurlVersion' => $this->getPaytmModel()->getcURLversion(), 'paytmPluginVersion' => $this->getPaytmModel()->getpluginversion()]); + }else{ + $responseTableBody=''; + $response=false; + $transactionURL=$this->getPaytmModel()->getNewStatusQueryUrl(); + $ch = curl_init($transactionURL); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $res = curl_exec($ch); + $response = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + $returnResponse="Curl is not enable for external IP. Please enable this by your domain provider."; + switch ($response) { + case '403': + if (strpos($res, "Access Denied") == false) { + } else { + $returnResponse="Your domain is not whitelisted on Paytm side. Please request to Paytm for whitelisting your public IP."; + } + break; + case '200': + if(json_decode($res)==null){ + }else{ + $returnResponse="All is done."; + } + break; + + default: + # code... + break; + } + // $this->messageManager->addWarningMessage( __($returnResponse) ); + return $resultJson->setData(['response' => $response,'responseTableBody' => $returnResponse]); + } + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Curltest.php b/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Curltest.php new file mode 100755 index 0000000..aa26ecf --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Curltest.php @@ -0,0 +1,78 @@ +getRequest()->getParams(); + if(!empty($getData)){ + foreach ($getData as $key => $value) { + $testing_urls[]=$value; + } + }else{ + $currentPath = $_SERVER['PHP_SELF']; + $pathInfo = pathinfo($currentPath); + $hostName = $_SERVER['HTTP_HOST']; + + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface'); + $fetchStatusURL=$storeManager->getStore()->getBaseUrl(); + + $testing_urls = array( + $fetchStatusURL, + "https://www.gstatic.com/generate_204", + $this->getPaytmHelper()::TRANSACTION_STATUS_URL_PRODUCTION, + $this->getPaytmHelper()::TRANSACTION_STATUS_URL_STAGING + ); + } + foreach($testing_urls as $key=>$url){ + $debug[$key]["info"][] = "Connecting to " . $url . " using cURL"; + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $res = curl_exec($ch); + if (!curl_errno($ch)) { + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $debug[$key]["info"][] = "cURL executed succcessfully."; + $debug[$key]["info"][] = "HTTP Response Code: ". $http_code . ""; + } else { + $debug[$key]["info"][] = "Connection Failed !!"; + $debug[$key]["info"][] = "Error Code: " . curl_errno($ch) . ""; + $debug[$key]["info"][] = "Error: " . curl_error($ch) . ""; + } + if((in_array($url, array($this->getPaytmHelper()::TRANSACTION_STATUS_URL_PRODUCTION , $this->getPaytmHelper()::TRANSACTION_STATUS_URL_STAGING)))){ + $debug[$key]["info"][] = "Response:
" . $res; + } + curl_close($ch); + } + } + foreach($debug as $k=>$v){ + echo ""; + echo "
"; + } + die; + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Fetchstatus.php b/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Fetchstatus.php new file mode 100755 index 0000000..02023a8 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Fetchstatus.php @@ -0,0 +1,99 @@ +getRequest()->getParams(); + $responseTableBody=''; + $response=false; + // echo "test"; + if(isset($reqData['fetchId'])){ + if(trim($reqData['fetchId'])!='' && $this->getPaytmHelper()::SAVE_PAYTM_RESPONSE){ + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $connection = $resource->getConnection(); + $tableName = $resource->getTableName('paytm_order_data'); + $sql = "Select * FROM ".$tableName." WHERE id=".$reqData['fetchId']; + $result = $connection->fetchAll($sql); + $requestParamList = array("MID" => $this->getPaytmModel()->getMID() , "ORDERID" => $result[0]['paytm_order_id']); + $StatusCheckSum = $this->getPaytmModel()->generateStatusChecksum($requestParamList); + $requestParamList['CHECKSUMHASH'] = $StatusCheckSum; + $check_status_url = $this->getPaytmModel()->getNewStatusQueryUrl(); + $responseParamList = $this->getPaytmHelper()->executecUrl($check_status_url, $requestParamList); + if(!empty($responseParamList)){ + $objDate = $objectManager->create('Magento\Framework\Stdlib\DateTime\DateTime'); + $date = $objDate->gmtDate(); + + $paytmRes=$this->jsonHelper->jsonEncode($responseParamList); + $sql = "UPDATE ".$tableName." SET transaction_id='".$responseParamList['TXNID']."', paytm_response='".$paytmRes."', status='1', date_modified='".$date."' where id=".$reqData['fetchId']; + $connection->query($sql); + ksort($responseParamList); + foreach ($responseParamList as $k => $val) { + switch ($k) { + case 'CHECKSUMHASH': + break; + case 'STATUS': + $responseTableBody.=' '.$k.' '.$val.' '; + break; + + default: + $responseTableBody.=' '.$k.' '.$val.' '; + break; + } + } + $order = $this->getOrderById($result[0]['order_id']); + if($responseParamList['STATUS']=='TXN_SUCCESS'){ + $autoInvoice = $this->getPaytmModel()->autoInvoiceGen(); + if($autoInvoice=='authorize_capture'){ + $payment = $order->getPayment(); + $payment->setTransactionId($responseParamList['TXNID']) + ->setPreparedMessage(__('Paytm transaction has been successful.')) + ->setShouldCloseParentTransaction(true) + ->setIsTransactionClosed(0) + ->setAdditionalInformation(['One97','paytm']) + ->registerCaptureNotification( + $responseParamList['TXNAMOUNT'], + true + ); + $invoice = $payment->getCreatedInvoice(); + } + $comment = "Transaction has marked as successfull by checkStatus API."; + $order->setState("complete"); + $order->setStatus($this->_paytmModel->getSuccessOrderStatus()); + $order->setExtOrderId($result[0]['paytm_order_id']); + $order->addStatusToHistory($order->getStatus(), $comment); + $order->save(); + $response=true; + }else if($responseParamList['STATUS']=="TXN_FAILURE"){ + $comment = $responseParamList['RESPMSG']; + $order->setState("canceled")->setStatus($this->_paytmModel->getFailOrderStatus()); + $order->addStatusToHistory($order->getStatus(), $comment); + $order->save(); + } + } + } + } + + $resultJson = $this->resultJsonFactory->create(); + return $resultJson->setData(['response' => $response,'responseTableBody' => $responseTableBody]); + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Redirect.php b/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Redirect.php new file mode 100755 index 0000000..e9f7e82 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Redirect.php @@ -0,0 +1,50 @@ +getOrder(); + if ($order->getBillingAddress()) { + $order->setState("pending_payment")->setStatus("pending_payment"); + $order->addStatusToHistory($order->getStatus(), "Customer was redirected to paytm."); + $order->save(); + if($promo!=''){ + $order->paytmPromoCode=$promo; + } + $data['inputForm']=$this->_paytmModel->buildPaytmRequest($order); + $data['actionURL']=$this->_paytmModel->getRedirectUrl(); + $resultPage = $this->resultPageFactory->create(); + $resultPage->getLayout()->initMessages(); + $resultPage->getLayout()->getBlock('paytm_standard_redirect')->setName($data); + return $resultPage; + } else { + $this->_cancelPayment(); + $this->_paytmSession->restoreQuote(); + $this->getResponse()->setRedirect( + $this->getPaytmHelper()->getUrl('checkout') + ); + } + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Response.php b/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Response.php new file mode 100755 index 0000000..a37f523 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Controller/Standard/Response.php @@ -0,0 +1,220 @@ + $val){ + if($key != "CHECKSUMHASH"){ + $comment .= $key . "=" . $val . ", \n
"; + } + } + } + + // var_dump($this->getPaytmHelper()::SAVE_PAYTM_RESPONSE);die; + $errorMsg = ''; + $successFlag = false; + $resMessage=$this->getRequest()->getParam('RESPMSG'); + $globalErrMass="Your payment has been failed!"; + if(trim($resMessage)!=''){ + $globalErrMass.=" Reason: ".$resMessage; + } + $returnUrl = $this->getPaytmHelper()->getUrl('/'); + $orderMID = $this->getRequest()->getParam('MID'); + $paytmOrderId = $this->getRequest()->getParam('ORDERID'); + $magentoOrderIdArr=explode('_', $paytmOrderId); + $magentoOrderId=$magentoOrderIdArr[0]; + $orderTXNID = $this->getRequest()->getParam('TXNID'); + $paytmResponse=$this->getRequest()->getParams(); + $paytmJsonResponse=json_encode($paytmResponse); + + if(trim($paytmOrderId)!='' && trim($orderMID)!=''){ + $order = $this->getOrderById($magentoOrderId); + $orderTotal = round($order->getGrandTotal(), 2); + $orderStatus = $this->getRequest()->getParam('STATUS'); + $resCode = $this->getRequest()->getParam('RESPCODE'); + $orderTxnAmount = $this->getRequest()->getParam('TXNAMOUNT'); + $transactionResponse=""; + $paytmJsonResponseOnPending=''; + if($this->getPaytmModel()->validateResponse($request, $magentoOrderId)) { + if($this->getPaytmHelper()::SAVE_PAYTM_RESPONSE){ + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $objDate = $objectManager->create('Magento\Framework\Stdlib\DateTime\DateTime'); + $date = $objDate->gmtDate(); + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $tableName = $resource->getTableName('paytm_order_data'); + $sql = "UPDATE ".$tableName." SET transaction_id='".$orderTXNID."', paytm_response='".$paytmJsonResponse."', date_modified='".$date."' WHERE order_id='".$magentoOrderId."' AND paytm_order_id='".$paytmOrderId."'"; + $this->updateTable($sql); + } + if($orderStatus == "TXN_SUCCESS"){ + $requestParamList = array("MID" => $orderMID , "ORDERID" => $paytmOrderId); + $responseParamList=$this->checkStatusCall($requestParamList); + if(isset($responseParamList['STATUS'])){ + if($responseParamList['STATUS'] == "PENDING"){ + $transactionResponse="PENDING"; + }else{ + if($responseParamList['STATUS']=='TXN_SUCCESS' && $responseParamList['TXNAMOUNT']==$orderTxnAmount) { + $transactionResponse="PROCESSING"; + } else{ + $transactionResponse="CANCELED"; + } + } + }else{ + $transactionResponse="FRAUD"; + } + }else{ + if($orderStatus == "PENDING"){ + $requestParamList = array("MID" => $orderMID , "ORDERID" => $paytmOrderId); + $responseParamList=$this->checkStatusCall($requestParamList); + if(isset($responseParamList['STATUS'])){ + if($responseParamList['STATUS'] == "PENDING"){ + $transactionResponse="PENDING"; + }else{ + if($responseParamList['STATUS']=='TXN_SUCCESS' && $responseParamList['TXNAMOUNT']==$orderTxnAmount) { + $transactionResponse="PROCESSING"; + $paytmJsonResponseOnPending=json_encode($responseParamList); + } else{ + $transactionResponse="CANCELED"; + } + } + }else{ + $transactionResponse="FRAUD"; + } + }else{ + $transactionResponse="CANCELED"; + } + } + } else { + $transactionResponse="FRAUD_CHECKSUM_MISMATCH"; + } + + switch ($transactionResponse) { + case 'FRAUD': + $errorMsg = 'It seems some issue in server to server communication. Kindly connect with administrator.'; + $comment .= "Fraud Detucted"; + $order->setStatus($order::STATUS_FRAUD); + $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); + break; + case "FRAUD_CHECKSUM_MISMATCH": + $errorMsg = $globalErrMass." Reason: Checksum Mismatch."; + $comment .= "Fraud Detucted"; + $order->setState("canceled")->setStatus($order::STATUS_FRAUD); + $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); + break; + case "CANCELED": + if($orderStatus == "PENDING"){ + $errorMsg = 'Paytm Transaction Pending!'; + if(trim($resMessage)==''){ + $errorMsg.=" Reason: ".$resMessage; + } + $comment .= "Pending"; + $order->setState("pending_payment")->setStatus("pending_payment"); + }else{ + $this->getPaytmHelper()->updateStockQty($order); + $errorMsg = $globalErrMass; + $comment .= $globalErrMass; + $order->setState("canceled")->setStatus($this->_paytmModel->getFailOrderStatus()); + } + $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); + break; + case "PROCESSING": + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $tableName = $resource->getTableName('paytm_order_data'); + $paytmJsonResponseOnPending==''?$sql="UPDATE ".$tableName." SET status='1' WHERE order_id='".$magentoOrderId."' AND paytm_order_id='".$paytmOrderId."'":$sql = "UPDATE ".$tableName." SET status='1', paytm_response='".$paytmJsonResponseOnPending."' WHERE order_id='".$magentoOrderId."' AND paytm_order_id='".$paytmOrderId."'"; + if($this->getPaytmHelper()::SAVE_PAYTM_RESPONSE){ + $this->updateTable($sql); + } + $autoInvoice = $this->getPaytmModel()->autoInvoiceGen(); + if($autoInvoice=='authorize_capture'){ + $payment = $order->getPayment(); + $payment->setTransactionId($orderTXNID) + ->setPreparedMessage(__('Paytm transaction has been successful.')) + ->setShouldCloseParentTransaction(true) + ->setIsTransactionClosed(0) + ->setAdditionalInformation(['One97','paytm']) + ->registerCaptureNotification( + $responseParamList['TXNAMOUNT'], + true + ); + $invoice = $payment->getCreatedInvoice(); + } + $successFlag = true; + $comment .= "Success "; + $order->setState("complete"); + $order->setStatus($this->_paytmModel->getSuccessOrderStatus()); + $order->setExtOrderId($paytmOrderId); + $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/success'); + break; + case "PENDING": + $errorMsg = 'Paytm Transaction Pending!'; + if(trim($resMessage)==''){ + $errorMsg.=" Reason: ".$resMessage; + } + $comment .= "Pending"; + $order->setState("pending_payment")->setStatus("pending_payment"); + $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); + break; + + default: + # code... + break; + } + $order->addStatusToHistory($order->getStatus(), $comment); + $order->save(); + if($successFlag){ + $this->messageManager->addSuccess( __('Paytm transaction has been successful.') ); + }else{ + $this->messageManager->addError( __($errorMsg) ); + } + } + $this->getResponse()->setRedirect($returnUrl); + } + + /* Paytm transaction status S2S call */ + public function checkStatusCall($requestParamList){ + $response=array(); + if(!empty($requestParamList)){ + $StatusCheckSum = $this->getPaytmModel()->generateStatusChecksum($requestParamList); + $requestParamList['CHECKSUMHASH'] = $StatusCheckSum; + $check_status_url = $this->getPaytmModel()->getNewStatusQueryUrl(); + $responseParamList=array(); + $retry = $this->getPaytmHelper()::MAX_RETRY_COUNT; + do{ + $response = $this->getPaytmHelper()->executecUrl($check_status_url, $requestParamList); + $retry++; + } while(empty($response) && $retry < $retry); + } + return $response; + } + + public function updateTable($sql){ + $updateDone=false; + if(trim($sql)!=''){ + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $connection = $resource->getConnection(); + $sql = $sql; + $connection->query($sql); + $updateDone=true; + } + return $updateDone; + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Helper/Data.php b/Magento_V2.3x/app/code/One97/Paytm/Helper/Data.php new file mode 100755 index 0000000..d7c8fdc --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Helper/Data.php @@ -0,0 +1,261 @@ +session = $session; + $this->stockRegistry = $stockRegistry; + parent::__construct($context); + } + + public function updateStockQty($order) { + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $stockItem = $objectManager->create('\Magento\CatalogInventory\Model\Stock\StockItemRepository'); + $orderItems = $order->getAllItems(); + foreach ($orderItems as $item) { + $product_id = $item->getProductId(); + + $sku = $item->getSku(); + $current_qty = $this->stockRegistry->getStockItemBySku($sku)->getQty(); + $order_qty = (int)$item->getQtyOrdered(); + $update_stock_qty = $current_qty + $order_qty; + + $stockItem = $this->stockRegistry->getStockItemBySku($sku); + $stockItem->setQty($update_stock_qty); + $stockItem->setIsInStock((bool)$update_stock_qty); // this line + $this->stockRegistry->updateStockItemBySku($sku, $stockItem); + } + } + + public function cancelCurrentOrder($comment) { + $order = $this->session->getLastRealOrder(); + if ($order->getId() && $order->getState() != Order::STATE_CANCELED) { + $order->registerCancellation($comment)->save(); + return true; + } + return false; + } + + public function restoreQuote() { + return $this->session->restoreQuote(); + } + + public function getUrl($route, $params = []) { + return $this->_getUrl($route, $params); + } + + // PaytmChecksum.php start + private static $iv = "@@@@&&&&####$$$$"; + + static public function encrypt($input, $key) { + $key = html_entity_decode($key); + + if(function_exists('openssl_encrypt')){ + $data = openssl_encrypt ( $input , "AES-128-CBC" , $key, 0, self::$iv ); + } else { + $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, 'cbc'); + $input = self::pkcs5Pad($input, $size); + $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', ''); + mcrypt_generic_init($td, $key, self::$iv); + $data = mcrypt_generic($td, $input); + mcrypt_generic_deinit($td); + mcrypt_module_close($td); + $data = base64_encode($data); + } + return $data; + } + + static public function decrypt($encrypted, $key) { + $key = html_entity_decode($key); + + if(function_exists('openssl_decrypt')){ + $data = openssl_decrypt ( $encrypted , "AES-128-CBC" , $key, 0, self::$iv ); + } else { + $encrypted = base64_decode($encrypted); + $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', ''); + mcrypt_generic_init($td, $key, self::$iv); + $data = mdecrypt_generic($td, $encrypted); + mcrypt_generic_deinit($td); + mcrypt_module_close($td); + $data = self::pkcs5Unpad($data); + $data = rtrim($data); + } + return $data; + } + + static public function generateSignature($params, $key) { + if(!is_array($params) && !is_string($params)){ + throw new Exception("string or array expected, ".gettype($params)." given"); + } + if(is_array($params)){ + $params = self::getStringByParams($params); + } + return self::generateSignatureByString($params, $key); + } + + static public function verifySignature($params, $key, $checksum){ + if(!is_array($params) && !is_string($params)){ + throw new Exception("string or array expected, ".gettype($params)." given"); + } + if(is_array($params)){ + $params = self::getStringByParams($params); + } + return self::verifySignatureByString($params, $key, $checksum); + } + + static private function generateSignatureByString($params, $key){ + $salt = self::generateRandomString(4); + return self::calculateChecksum($params, $key, $salt); + } + + static private function verifySignatureByString($params, $key, $checksum){ + $paytm_hash = self::decrypt($checksum, $key); + $salt = substr($paytm_hash, -4); + return $paytm_hash == self::calculateHash($params, $salt) ? true : false; + } + + static private function generateRandomString($length) { + $random = ""; + srand((double) microtime() * 1000000); + + $data = "9876543210ZYXWVUTSRQPONMLKJIHGFEDCBAabcdefghijklmnopqrstuvwxyz!@#$&_"; + + for ($i = 0; $i < $length; $i++) { + $random .= substr($data, (rand() % (strlen($data))), 1); + } + + return $random; + } + + static private function getStringByParams($params) { + ksort($params); + $params = array_map(function ($value){ + return ($value == null) ? "" : $value; + }, $params); + return implode("|", $params); + } + + static private function calculateHash($params, $salt){ + $finalString = $params . "|" . $salt; + $hash = hash("sha256", $finalString); + return $hash . $salt; + } + + static private function calculateChecksum($params, $key, $salt){ + $hashString = self::calculateHash($params, $salt); + return self::encrypt($hashString, $key); + } + + static private function pkcs5Pad($text, $blocksize) { + $pad = $blocksize - (strlen($text) % $blocksize); + return $text . str_repeat(chr($pad), $pad); + } + + static private function pkcs5Unpad($text) { + $pad = ord($text{strlen($text) - 1}); + if ($pad > strlen($text)) + return false; + return substr($text, 0, -1 * $pad); + } + // PaytmChecksum.php end + + // PaytmHelper.php start + /** + * exclude timestap with order id + */ + public static function getTransactionURL($isProduction = 0){ + if($isProduction == 1){ + return Data::TRANSACTION_URL_PRODUCTION; + }else{ + return Data::TRANSACTION_URL_STAGING; + } + } + /** + * exclude timestap with order id + */ + public static function getTransactionStatusURL($isProduction = 0){ + if($isProduction == 1){ + return Data::TRANSACTION_STATUS_URL_PRODUCTION; + }else{ + return Data::TRANSACTION_STATUS_URL_STAGING; + } + } + + public static function getcURLversion(){ + if(function_exists('curl_version')){ + $curl_version = curl_version(); + if(!empty($curl_version['version'])){ + return $curl_version['version']; + } + } + return false; + } + + public static function executecUrl($apiURL, $requestParamList) { + $responseParamList = array(); + $JsonData = json_encode($requestParamList); + $postData = 'JsonData='.urlencode($JsonData); + $ch = curl_init($apiURL); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, Data::CONNECT_TIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, Data::TIMEOUT); + + /* + ** default value is 2 and we also want to use 2 + ** so no need to specify since older PHP version might not support 2 as valid value + ** see https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html + */ + // curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 2); + + // TLS 1.2 or above required + // curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); + + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json', + 'Content-Length: ' . strlen($postData)) + ); + $jsonResponse = curl_exec($ch); + + if (!curl_errno($ch)) { + return json_decode($jsonResponse, true); + } else { + return false; + } + } + // PaytmHelper.php start + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Model/EnvAction.php b/Magento_V2.3x/app/code/One97/Paytm/Model/EnvAction.php new file mode 100755 index 0000000..25bdd86 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Model/EnvAction.php @@ -0,0 +1,13 @@ + '0', 'label' => __('Staging')], ['value' => '1', 'label' => __('Production')]]; + } + + public function toArray() { + return [0 => __('No'), 1 => __('Yes')]; + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Model/PaymentAction.php b/Magento_V2.3x/app/code/One97/Paytm/Model/PaymentAction.php new file mode 100755 index 0000000..d405307 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Model/PaymentAction.php @@ -0,0 +1,13 @@ + 'authorize_capture', 'label' => __('Yes')], ['value' => 'capture', 'label' => __('No')]]; + } + + public function toArray() { + return [0 => __('No'), 1 => __('Yes')]; + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Model/Paytm.php b/Magento_V2.3x/app/code/One97/Paytm/Model/Paytm.php new file mode 100755 index 0000000..069cb6a --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Model/Paytm.php @@ -0,0 +1,199 @@ +helper = $helper; + parent::__construct( + $context, + $registry, + $extensionFactory, + $customAttributeFactory, + $paymentData, + $scopeConfig, + $logger + ); + $this->_minAmount = "0.50"; + $this->_maxAmount = "1000000"; + $this->urlBuilder = $urlBuilder; + } + + public function initialize($paymentAction, $stateObject) { + $payment = $this->getInfoInstance(); + $order = $payment->getOrder(); + $order->setCanSendNewEmailFlag(false); + $stateObject->setState(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT); + $stateObject->setStatus('pending_payment'); + $stateObject->setIsNotified(false); + } + + /* this function check ammount limit */ + public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { + if ($quote && ( + $quote->getBaseGrandTotal() < $this->_minAmount || ($this->_maxAmount && $quote->getBaseGrandTotal() > $this->_maxAmount)) + ) { + return false; + } + return parent::isAvailable($quote); + } + + /* this function for currency check*/ + public function canUseForCurrency($currencyCode) { + if (!in_array($currencyCode, $this->_supportedCurrencyCodes)) { + return false; + } + return true; + } + + /* this function return Paytm redirect form post */ + public function buildPaytmRequest($order) { + $paytmOrderId=$magentoOrderId=$order->getRealOrderId(); + if($this->helper::APPEND_TIMESTAMP){ + $paytmOrderId=$magentoOrderId.'_'.time(); + } + + if($this->helper::SAVE_PAYTM_RESPONSE){ + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + + $objDate = $objectManager->create('Magento\Framework\Stdlib\DateTime\DateTime'); + $date = $objDate->gmtDate(); + + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $connection = $resource->getConnection(); + + $tableName = $resource->getTableName('paytm_order_data'); + if(!$connection->isTableExists($tableName)){ + $sql = "CREATE TABLE ".$tableName."(id INT(11) PRIMARY KEY AUTO_INCREMENT, order_id TEXT NOT NULL, paytm_order_id TEXT NOT NULL, transaction_id TEXT, status TINYINT(1) DEFAULT '0', paytm_response TEXT, date_added DATETIME, date_modified DATETIME )"; + $connection->query($sql); + } + $tableName = $resource->getTableName('paytm_order_data'); + $sql = "INSERT INTO ".$tableName."(order_id, paytm_order_id, date_added, date_modified) VALUES ('".$magentoOrderId."', '".$paytmOrderId."', '".$date."', '".$date."')"; + $connection->query($sql); + } + + $callBackUrl=$this->urlBuilder->getUrl('paytm/Standard/Response', ['_secure' => true]); + if($this->helper::CUSTOM_CALLBACK_URL!=''){ + $callBackUrl=$this->helper::CUSTOM_CALLBACK_URL; + } + if($this->getConfigData("custom_callbackurl")=='1'){ + $callBackUrl=$this->getConfigData("callback_url")!=''?$this->getConfigData("callback_url"):$callBackUrl; + } + $params = array( + 'MID' => trim($this->getConfigData("MID")), + 'TXN_AMOUNT' => round($order->getGrandTotal(), 2), + 'CHANNEL_ID' => $this->helper::CHANNEL_ID, + 'INDUSTRY_TYPE_ID' => trim($this->getConfigData("Industry_id")), + 'WEBSITE' => trim($this->getConfigData("Website")), + 'CUST_ID' => $order->getCustomerEmail(), + 'ORDER_ID' => $paytmOrderId, + 'EMAIL' => $order->getCustomerEmail(), + 'CALLBACK_URL' => trim($callBackUrl) + ); + if(isset($order->paytmPromoCode)){ + $params['PROMO_CAMP_ID']=$order->paytmPromoCode; + } + $checksum = $this->helper->generateSignature($params, $this->getConfigData("merchant_key")); + $params['CHECKSUMHASH'] = $checksum; + + $version = $this->getLastUpdate(); + $params['X-REQUEST-ID']=$this->helper::X_REQUEST_ID.str_replace('|', '_', str_replace(' ', '-', $version)); + $inputForm=''; + foreach ($params as $key => $value) { + $inputForm.=""; + } + return $inputForm; + } + + /* this function for checksum validation */ + public function validateResponse($res,$order_id) { + $checksum = @$res["CHECKSUMHASH"]; + unset($res["CHECKSUMHASH"]); + if ($this->helper->verifySignature($res,$this->getConfigData("merchant_key"),$checksum)) { + $result = true; + } else { + $result = false; + } + return $result; + } + + /* this function for php curl version */ + public function getcURLversion() { + return $this->helper->getcURLversion(); + } + + /* this function for php curl version */ + public function getpluginversion() { + return $this->helper::PLUGIN_VERSION; + } + + /* this function for genrating checksum */ + public function generateStatusChecksum($requestParamList) { + $result = $this->helper->generateSignature($requestParamList,$this->getConfigData("merchant_key")); + return $result; + } + + /* this function for return MID */ + public function getMID() { + return $this->getConfigData("MID"); + } + + public function autoInvoiceGen() { + $result = $this->getConfigData("payment_action"); + return $result; + } + + /* this function return transaction URL from admin config */ + public function getRedirectUrl() { + return $this->helper->getTransactionURL($this->getConfigData('environment')); + } + + /* this function return transaction status URL from admin config */ + public function getNewStatusQueryUrl() { + return $this->helper->getTransactionStatusURL($this->getConfigData('environment')); + } + + /* this function return success order status */ + public function getSuccessOrderStatus() { + return $this->getConfigData("success_order_status"); + } + + /* this function return fail order status */ + public function getFailOrderStatus() { + return $this->getConfigData("fail_order_status"); + } + + /* this function return Magento version and last update date of plugin */ + public function getLastUpdate(){ + $objectManagerVs = \Magento\Framework\App\ObjectManager::getInstance(); + $productMetadata = $objectManagerVs->get('Magento\Framework\App\ProductMetadataInterface'); + $version = $productMetadata->getVersion(); + + $lastUpdated=date('d M Y',strtotime($this->helper::LAST_UPDATED)); + return $version."|".$lastUpdated; + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Model/PaytmConfigProvider.php b/Magento_V2.3x/app/code/One97/Paytm/Model/PaytmConfigProvider.php new file mode 100755 index 0000000..79f3e3d --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Model/PaytmConfigProvider.php @@ -0,0 +1,27 @@ +method = $paymentHelper->getMethodInstance($this->methodCode); + $this->urlBuilder = $urlBuilder; + } + + public function getConfig() { + return $this->method->isAvailable() ? [ + 'payment' => [ + 'paytm' => [ + 'redirectUrl' => $this->urlBuilder->getUrl('paytm/Standard/Redirect', ['_secure' => true]) + ] + ] + ] : []; + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Model/SuccessFailStatus.php b/Magento_V2.3x/app/code/One97/Paytm/Model/SuccessFailStatus.php new file mode 100755 index 0000000..97e6591 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Model/SuccessFailStatus.php @@ -0,0 +1,19 @@ +statusCollectionFactory = $statusCollectionFactory; + } + + public function toOptionArray() { + $options = $this->statusCollectionFactory->create()->toOptionArray(); + return $options; + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Observer/SendMailOnOrderSuccess.php b/Magento_V2.3x/app/code/One97/Paytm/Observer/SendMailOnOrderSuccess.php new file mode 100755 index 0000000..8cf5b37 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Observer/SendMailOnOrderSuccess.php @@ -0,0 +1,29 @@ +orderModel = $orderModel; + $this->orderSender = $orderSender; + $this->checkoutSession = $checkoutSession; + } + + public function execute(\Magento\Framework\Event\Observer $observer) { + $orderIds = $observer->getEvent()->getOrderIds(); + if(count($orderIds)) { + $this->checkoutSession->setForceOrderMailSentOnSuccess(true); + $order = $this->orderModel->create()->load($orderIds[0]); + $this->orderSender->send($order, true); + } + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Plugin/Sales/Order/Email/Container/OrderIdentityPlugin.php b/Magento_V2.3x/app/code/One97/Paytm/Plugin/Sales/Order/Email/Container/OrderIdentityPlugin.php new file mode 100755 index 0000000..cff67d7 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Plugin/Sales/Order/Email/Container/OrderIdentityPlugin.php @@ -0,0 +1,26 @@ +checkoutSession = $checkoutSession; + } + + public function aroundIsEnabled(\Magento\Sales\Model\Order\Email\Container\OrderIdentity $subject, callable $proceed) { + $returnValue = $proceed(); + $forceOrderMailSentOnSuccess = $this->checkoutSession->getForceOrderMailSentOnSuccess(); + if(isset($forceOrderMailSentOnSuccess) && $forceOrderMailSentOnSuccess) { + if($returnValue) + $returnValue = false; + else + $returnValue = true; + $this->checkoutSession->unsForceOrderMailSentOnSuccess(); + } + return $returnValue; + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/Setup/InstallSchema.php b/Magento_V2.3x/app/code/One97/Paytm/Setup/InstallSchema.php new file mode 100755 index 0000000..60c1644 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/Setup/InstallSchema.php @@ -0,0 +1,78 @@ +startSetup(); + $conn = $setup->getConnection(); + $tableName = $setup->getTable('paytm_order_data'); + if($conn->isTableExists($tableName) != true){ + $table = $conn->newTable($tableName) + ->addColumn( + 'id', + Table::TYPE_INTEGER, + null, + ['identity'=>true,'unsigned'=>true,'nullable'=>false,'primary'=>true], + 'ID' + ) + ->addColumn( + 'order_id', + Table::TYPE_TEXT, + null, + ['nullable'=>false,'default'=>''], + 'Magento OrderId' + ) + ->addColumn( + 'paytm_order_id', + Table::TYPE_TEXT, + null, + ['nullable'=>false,'default'=>''], + 'Paytm OrderId' + ) + ->addColumn( + 'transaction_id', + Table::TYPE_TEXT, + null, + ['nullable'=>false,'default'=>''], + 'Paytm TransactionId' + ) + ->addColumn( + 'status', + Table::TYPE_BOOLEAN, + null, + ['nullable'=>false,'default'=>'0'], + 'Transaction Status' + ) + ->addColumn( + 'paytm_response', + Table::TYPE_TEXT, + null, + ['nullable'=>false,'default'=>''], + 'Paytm Response' + ) + ->addColumn( + 'date_added', + Table::TYPE_DATETIME, + null, + ['nullable'=>false,'default'=>'0000-00-00 00:00:00'], + 'Created Dtae' + ) + ->addColumn( + 'date_modified', + Table::TYPE_DATETIME, + null, + ['nullbale'=>false,'default'=>'0000-00-00 00:00:00'], + 'Modified Date' + ) + ->setOption('charset','utf8'); + $conn->createTable($table); + } + $setup->endSetup(); + } + } +?> \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/etc/adminhtml/system.xml b/Magento_V2.3x/app/code/One97/Paytm/etc/adminhtml/system.xml new file mode 100755 index 0000000..1042490 --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/etc/adminhtml/system.xml @@ -0,0 +1,84 @@ + + +
+ + + + Developer Docs +
+ | + | + | + + ]]> +
+ + + Magento\Config\Model\Config\Source\Yesno + payment/paytm/active + paytmEnbDrpDwn + + + + payment/paytm/title + + + + One97\Paytm\Model\PaymentAction + payment/paytm/payment_action + + + + One97\Paytm\Model\EnvAction + payment/paytm/environment + + + + Provided By Paytm + payment/paytm/MID + + + + Provided By Paytm + payment/paytm/merchant_key + + + + Provided By Paytm + payment/paytm/Industry_id + + + + Provided By Paytm + payment/paytm/Website + + + + One97\Paytm\Model\SuccessFailStatus + payment/paytm/success_order_status + + + + One97\Paytm\Model\SuccessFailStatus + payment/paytm/fail_order_status + + + + validate-number + payment/paytm/sort_order + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/paytm/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/paytm/specificcountry + +
+
+
+
\ No newline at end of file diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/config.xml b/Magento_V2.3x/app/code/One97/Paytm/etc/config.xml old mode 100644 new mode 100755 similarity index 82% rename from Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/config.xml rename to Magento_V2.3x/app/code/One97/Paytm/etc/config.xml index cc5fc1b..09f711c --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/config.xml +++ b/Magento_V2.3x/app/code/One97/Paytm/etc/config.xml @@ -4,19 +4,18 @@ One97\Paytm\Model\Paytm + 0 Paytm Wallet authorize_capture - 0 - pending_payment MID merchant_key 0 - - + Industry_id - WEB Website + processing + canceled 0 0 0 diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/frontend/di.xml b/Magento_V2.3x/app/code/One97/Paytm/etc/frontend/di.xml old mode 100644 new mode 100755 similarity index 97% rename from Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/frontend/di.xml rename to Magento_V2.3x/app/code/One97/Paytm/etc/frontend/di.xml index 2672f37..cdae513 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/frontend/di.xml +++ b/Magento_V2.3x/app/code/One97/Paytm/etc/frontend/di.xml @@ -7,4 +7,4 @@ - + \ No newline at end of file diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/frontend/events.xml b/Magento_V2.3x/app/code/One97/Paytm/etc/frontend/events.xml old mode 100644 new mode 100755 similarity index 100% rename from Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/frontend/events.xml rename to Magento_V2.3x/app/code/One97/Paytm/etc/frontend/events.xml diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/frontend/routes.xml b/Magento_V2.3x/app/code/One97/Paytm/etc/frontend/routes.xml old mode 100644 new mode 100755 similarity index 100% rename from Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/frontend/routes.xml rename to Magento_V2.3x/app/code/One97/Paytm/etc/frontend/routes.xml diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/module.xml b/Magento_V2.3x/app/code/One97/Paytm/etc/module.xml old mode 100644 new mode 100755 similarity index 100% rename from Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/module.xml rename to Magento_V2.3x/app/code/One97/Paytm/etc/module.xml diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/payment.xml b/Magento_V2.3x/app/code/One97/Paytm/etc/payment.xml old mode 100644 new mode 100755 similarity index 100% rename from Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/payment.xml rename to Magento_V2.3x/app/code/One97/Paytm/etc/payment.xml diff --git a/Magento_V2.3x/app/code/One97/Paytm/registration.php b/Magento_V2.3x/app/code/One97/Paytm/registration.php new file mode 100755 index 0000000..981e72b --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/registration.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/Magento_V2.3x/app/code/One97/Paytm/view/adminhtml/layout/adminhtml_system_config_edit.xml b/Magento_V2.3x/app/code/One97/Paytm/view/adminhtml/layout/adminhtml_system_config_edit.xml new file mode 100755 index 0000000..168995f --- /dev/null +++ b/Magento_V2.3x/app/code/One97/Paytm/view/adminhtml/layout/adminhtml_system_config_edit.xml @@ -0,0 +1,14 @@ + + + + + -
- getMethodCode() ?> - \ No newline at end of file diff --git a/Magento_v1.x/Magento Plugin V1.0/installation instructions.doc b/Magento_v1.x/Magento Plugin V1.0/installation instructions.doc deleted file mode 100644 index 8121ef8..0000000 Binary files a/Magento_v1.x/Magento Plugin V1.0/installation instructions.doc and /dev/null differ diff --git a/Magento_v2.3.x/LICENSE b/Magento_v2.3.x/LICENSE deleted file mode 100644 index 23cb790..0000000 --- a/Magento_v2.3.x/LICENSE +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {description} - Copyright (C) {year} {fullname} - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - {signature of Ty Coon}, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Block/Form/Paytm.php b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Block/Form/Paytm.php deleted file mode 100644 index ddc9585..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Block/Form/Paytm.php +++ /dev/null @@ -1,8 +0,0 @@ -_customerSession = $customerSession; - $this->_checkoutSession = $checkoutSession; - $this->_orderFactory = $orderFactory; - $this->_logger = $logger; - $this->_orderHistoryFactory = $orderHistoryFactory; - $this->_paytmModel = $paytmModel; - $this->_paytmHelper = $paytmHelper; - parent::__construct($context); - } - - public function createCsrfValidationException( - RequestInterface $request - ): ?InvalidRequestException { - return null; - } - - public function validateForCsrf(RequestInterface $request): ?bool - { - return true; - } - - - /** - * Cancel order, return quote to customer - * - * @param string $errorMsg - * @return false|string - */ - protected function _cancelPayment($errorMsg = '') - { - $gotoSection = false; - $this->_paytmHelper->cancelCurrentOrder($errorMsg); - if ($this->_checkoutSession->restoreQuote()) { - //Redirect to payment step - $gotoSection = 'paymentMethod'; - } - - return $gotoSection; - } - - /** - * Get order object - * - * @return \Magento\Sales\Model\Order - */ - protected function getOrderById($order_id) - { - $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); - $order = $objectManager->get('Magento\Sales\Model\Order'); - $order_info = $order->loadByIncrementId($order_id); - return $order_info; - } - - /** - * Get order object - * - * @return \Magento\Sales\Model\Order - */ - protected function getOrder() - { - return $this->_orderFactory->create()->loadByIncrementId( - $this->_checkoutSession->getLastRealOrderId() - ); - } - - protected function addOrderHistory($order,$comment){ - $history = $this->_orderHistoryFactory->create() - ->setComment($comment) - ->setEntityName('order') - ->setOrder($order); - $history->save(); - return true; - } - - protected function getQuote() - { - if (!$this->_quote) { - $this->_quote = $this->_getCheckoutSession()->getQuote(); - } - return $this->_quote; - } - - protected function getCheckoutSession() - { - return $this->_checkoutSession; - } - - protected function getCustomerSession() - { - return $this->_customerSession; - } - - protected function getPaytmModel() - { - return $this->_paytmModel; - } - - protected function getPaytmHelper() - { - return $this->_paytmHelper; - } -} diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Controller/Standard/Cancel.php b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Controller/Standard/Cancel.php deleted file mode 100644 index 68df396..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Controller/Standard/Cancel.php +++ /dev/null @@ -1,30 +0,0 @@ -_cancelPayment(); - $this->_checkoutSession->restoreQuote(); - $this->getResponse()->setRedirect( - $this->getPaytmHelper()->getUrl('checkout') - ); - } - -} diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Controller/Standard/Curltest.php b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Controller/Standard/Curltest.php deleted file mode 100644 index 98a0965..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Controller/Standard/Curltest.php +++ /dev/null @@ -1,87 +0,0 @@ -getRequest()->getParams(); - if(!empty($getData)){ - foreach ($getData as $key => $value) { - $testing_urls[]=$value; - } - }else{ - $currentPath = $_SERVER['PHP_SELF']; - $pathInfo = pathinfo($currentPath); - $hostName = $_SERVER['HTTP_HOST']; - $protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https://'?'https://':'http://'; - $check_status_url = $this->getPaytmModel()->getNewStatusQueryUrl(); - $testing_urls = array( - $protocol.$hostName.$pathInfo['dirname']."/", - "www.google.co.in", - $check_status_url - ); - } - /*echo "
";print_r($testing_urls);
-    		echo "
";*/ - // loop over all URLs, maintain debug log for each response received - foreach($testing_urls as $key=>$url){ - - $debug[$key]["info"][] = "Connecting to " . $url . " using cURL"; - - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - $res = curl_exec($ch); - - if (!curl_errno($ch)) { - $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); - $debug[$key]["info"][] = "cURL executed succcessfully."; - $debug[$key]["info"][] = "HTTP Response Code: ". $http_code . ""; - - // $debug[$key]["content"] = $res; - - } else { - $debug[$key]["info"][] = "Connection Failed !!"; - $debug[$key]["info"][] = "Error Code: " . curl_errno($ch) . ""; - $debug[$key]["info"][] = "Error: " . curl_error($ch) . ""; - break; - } - curl_close($ch); - } - } - foreach($debug as $k=>$v){ - echo "
    "; - foreach($v["info"] as $info){ - echo "
  • ".$info."
  • "; - } - echo "
"; - - // echo "
" . $v["content"] . "
"; - echo "
"; - } - die; - } -} diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Controller/Standard/Redirect.php b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Controller/Standard/Redirect.php deleted file mode 100644 index e018064..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Controller/Standard/Redirect.php +++ /dev/null @@ -1,53 +0,0 @@ -getOrder(); - if ($order->getBillingAddress()) - { - $order->setState("pending_payment")->setStatus("pending_payment"); - $order->addStatusToHistory($order->getStatus(), "Customer was redirected to paytm."); - $order->save(); - - if($promo!=''){ - $order->paytmPromoCode=$promo; - } - $this->getResponse()->setRedirect( - $this->getPaytmModel()->buildPaytmRequest($order) - ); - } - else - { - $this->_cancelPayment(); - $this->_paytmSession->restoreQuote(); - $this->getResponse()->setRedirect( - $this->getPaytmHelper()->getUrl('checkout') - ); - } - } -} \ No newline at end of file diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Controller/Standard/Response.php b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Controller/Standard/Response.php deleted file mode 100644 index 31d4e6c..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Controller/Standard/Response.php +++ /dev/null @@ -1,137 +0,0 @@ - $val){ - if($key != "CHECKSUMHASH"){ - $comment .= $key . "=" . $val . ", \n
"; - } - } - } - $errorMsg = ''; - $successFlag = false; - $resMessage=$this->getRequest()->getParam('RESPMSG'); - $globalErrMass="Your payment has been failed!"; - if(trim($resMessage)!=''){ - $globalErrMass.=" Reason: ".$resMessage; - } - $returnUrl = $this->getPaytmHelper()->getUrl('/'); - $orderMID = $this->getRequest()->getParam('MID'); - $orderId = $this->getRequest()->getParam('ORDERID'); - $orderTXNID = $this->getRequest()->getParam('TXNID'); - if(trim($orderId)!='' && trim($orderMID)!=''){ - $order = $this->getOrderById($orderId); - $orderTotal = round($order->getGrandTotal(), 2); - - $orderStatus = $this->getRequest()->getParam('STATUS'); - $resCode = $this->getRequest()->getParam('RESPCODE'); - $orderTxnAmount = $this->getRequest()->getParam('TXNAMOUNT'); - - if($this->getPaytmModel()->validateResponse($request, $orderId)) { - if($orderStatus == "TXN_SUCCESS" && $orderTotal == $orderTxnAmount){ - // Create an array having all required parameters for status query. - $requestParamList = array("MID" => $orderMID , "ORDERID" => $orderId); - $StatusCheckSum = $this->getPaytmModel()->generateStatusChecksum($requestParamList); - $requestParamList['CHECKSUMHASH'] = $StatusCheckSum; - - // Call the PG's getTxnStatus() function for verifying the transaction status. - $check_status_url = $this->getPaytmModel()->getNewStatusQueryUrl(); - $responseParamList = $this->getPaytmHelper()->callNewAPI($check_status_url, $requestParamList); - if($responseParamList['STATUS'] == "PENDING"){ - $errorMsg = 'Paytm Transaction Pending!'; - if(trim($resMessage)==''){ - $errorMsg.=" Reason: ".$resMessage; - } - $comment .= "Pending"; - $order->setState("pending_payment")->setStatus("pending_payment"); - // $this->_cancelPayment($errorMsg); - $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); - }else{ - if($responseParamList['STATUS']=='TXN_SUCCESS' && $responseParamList['TXNAMOUNT']==$orderTxnAmount) - { - $autoInvoice = $this->getPaytmModel()->autoInvoiceGen(); - if($autoInvoice=='authorize_capture'){ - $payment = $order->getPayment(); - $payment->setTransactionId($orderTXNID) - ->setPreparedMessage(__('Paytm transaction has been successful.')) - ->setShouldCloseParentTransaction(true) - ->setIsTransactionClosed(0) - ->setAdditionalInformation(['One97','paytm']) - ->registerCaptureNotification( - $responseParamList['TXNAMOUNT'], - true - ); - $invoice = $payment->getCreatedInvoice(); - } - - $successFlag = true; - $comment .= "Success "; - $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING); - $order->setStatus($order::STATE_PROCESSING); - $order->setExtOrderId($orderId); - $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/success'); - } else{ - $errorMsg = 'It seems some issue in server to server communication. Kindly connect with administrator.'; - $comment .= "Fraud Detucted"; - $order->setStatus($order::STATUS_FRAUD); - // $this->_cancelPayment($errorMsg); - $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); - } - } - }else{ - if($orderStatus == "PENDING"){ - $errorMsg = 'Paytm Transaction Pending!'; - if(trim($resMessage)==''){ - $errorMsg.=" Reason: ".$resMessage; - } - $comment .= "Pending"; - // $this->_cancelPayment($errorMsg); - $order->setState("pending_payment")->setStatus("pending_payment"); - }else{ - $errorMsg = $globalErrMass; - $comment .= $globalErrMass; - $order->setStatus($order::STATE_CANCELED); - // $this->_cancelPayment($globalErrMass); - } - $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); - } - } else { - $errorMsg = $globalErrMass." Reason: Checksum Mismatch."; - $comment .= "Fraud Detucted"; - $order->setStatus($order::STATUS_FRAUD); - // $this->_cancelPayment("Fraud Detucted"); - $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); - } - // $this->addOrderHistory($order,$comment); - $order->addStatusToHistory($order->getStatus(), $comment); - $order->save(); - if($successFlag){ - $this->messageManager->addSuccess( __('Paytm transaction has been successful.') ); - }else{ - $this->messageManager->addError( __($errorMsg) ); - } - } - $this->getResponse()->setRedirect($returnUrl); - } -} diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Helper/Data.php b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Helper/Data.php deleted file mode 100644 index 938f577..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Helper/Data.php +++ /dev/null @@ -1,187 +0,0 @@ -session = $session; - parent::__construct($context); - } - - public function cancelCurrentOrder($comment) { - $order = $this->session->getLastRealOrder(); - if ($order->getId() && $order->getState() != Order::STATE_CANCELED) { - $order->registerCancellation($comment)->save(); - return true; - } - return false; - } - - public function restoreQuote() { - return $this->session->restoreQuote(); - } - - public function getUrl($route, $params = []) { - return $this->_getUrl($route, $params); - } - - public function encrypt_e($input, $ky) { - $key = html_entity_decode($ky); - $iv = "@@@@&&&&####$$$$"; - $data = openssl_encrypt ( $input , "AES-128-CBC" , $key, 0, $iv ); - return $data; - } - - public function decrypt_e($crypt, $ky) { - $key = html_entity_decode($ky); - $iv = "@@@@&&&&####$$$$"; - $data = openssl_decrypt ( $crypt , "AES-128-CBC" , $key, 0, $iv ); - return $data; - } - - public function generateSalt_e($length) { - $random = ""; - srand((double) microtime() * 1000000); - $data = "AbcDE123IJKLMN67QRSTUVWXYZ"; - $data .= "aBCdefghijklmn123opq45rs67tuv89wxyz"; - $data .= "0FGH45OP89"; - for ($i = 0; $i < $length; $i++) { - $random .= substr($data, (rand() % (strlen($data))), 1); - } - return $random; - } - - public function checkString_e($value) { - $myvalue = ltrim($value); - $myvalue = rtrim($myvalue); - if ($myvalue == 'null') - $myvalue = ''; - return $myvalue; - } - - public function getChecksumFromArray($arrayList, $key) { - ksort($arrayList); - $str = $this->getArray2Str($arrayList); - $salt = $this->generateSalt_e(4); - $finalString = $str . "|" . $salt; - $hash = hash("sha256", $finalString); - $hashString = $hash . $salt; - $checksum = $this->encrypt_e($hashString, $key); - return $checksum; - } - - public function verifychecksum_e($arrayList, $key, $checksumvalue) { - $arrayList = $this->removeCheckSumParam($arrayList); - ksort($arrayList); - $str = $this->getArray2StrForVerify($arrayList); - $paytm_hash = $this->decrypt_e($checksumvalue, $key); - $salt = substr($paytm_hash, -4); - $finalString = $str . "|" . $salt; - $website_hash = hash("sha256", $finalString); - $website_hash .= $salt; - $validFlag = FALSE; - if ($website_hash == $paytm_hash) { - $validFlag = TRUE; - } else { - $validFlag = FALSE; - } - return $validFlag; - } - - public function getArray2StrForVerify($arrayList) { - $paramStr = ""; - $flag = 1; - foreach ($arrayList as $key => $value) { - if ($flag) { - $paramStr .= $this->checkString_e($value); - $flag = 0; - } else { - $paramStr .= "|" . $this->checkString_e($value); - } - } - return $paramStr; - } - - public function getArray2Str($arrayList) { - $findme = 'REFUND'; - $findmepipe = '|'; - $paramStr = ""; - $flag = 1; - foreach ($arrayList as $key => $value) { - $pos = strpos($value, $findme); - $pospipe = strpos($value, $findmepipe); - if ($pos !== false || $pospipe !== false) - { - continue; - } - if ($flag) { - $paramStr .= $this->checkString_e($value); - $flag = 0; - } else { - $paramStr .= "|" . $this->checkString_e($value); - } - } - return $paramStr; - } - - public function redirect2PG($paramList, $key) { - $hashString = $this->getchecksumFromArray($paramList); - $checksum = $this->encrypt_e($hashString, $key); - } - - public function removeCheckSumParam($arrayList) { - if (isset($arrayList["CHECKSUMHASH"])) { - unset($arrayList["CHECKSUMHASH"]); - } - return $arrayList; - } - function callAPI($apiURL, $requestParamList) - { - $jsonResponse = ""; - $responseParamList = array(); - $JsonData = json_encode($requestParamList); - $postData = 'JsonData=' . urlencode($JsonData); - $ch = curl_init($apiURL); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Content-Type: application/json', - 'Content-Length: ' . strlen($postData) - )); - $jsonResponse = curl_exec($ch); - $responseParamList = json_decode($jsonResponse, true); - return $responseParamList; - } - - function callNewAPI($apiURL, $requestParamList) - { - $jsonResponse = ""; - $responseParamList = array(); - $JsonData = json_encode($requestParamList); - $postData = 'JsonData=' . urlencode($JsonData); - $ch = curl_init($apiURL); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Content-Type: application/json', - 'Content-Length: ' . strlen($postData) - )); - $jsonResponse = curl_exec($ch); - $responseParamList = json_decode($jsonResponse, true); - return $responseParamList; - } - -} diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Model/PaymentAction.php b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Model/PaymentAction.php deleted file mode 100644 index d231122..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Model/PaymentAction.php +++ /dev/null @@ -1,33 +0,0 @@ - 'authorize_capture', 'label' => __('Yes')], ['value' => 'capture', 'label' => __('No')]]; - } - - /** - * Get options in "key-value" format - * - * @return array - */ - public function toArray() - { - return [0 => __('No'), 1 => __('Yes')]; - } -} diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Model/Paytm.php b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Model/Paytm.php deleted file mode 100644 index 0e9c7c5..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Model/Paytm.php +++ /dev/null @@ -1,169 +0,0 @@ -helper = $helper; - parent::__construct( - $context, - $registry, - $extensionFactory, - $customAttributeFactory, - $paymentData, - $scopeConfig, - $logger - ); - - $this->_minAmount = "0.50"; - $this->_maxAmount = "1000000"; - $this->urlBuilder = $urlBuilder; - } - - /** - * Instantiate state and set it to state object. - * - * @param string $paymentAction - * @param \Magento\Framework\DataObject $stateObject - */ - public function initialize($paymentAction, $stateObject) - { - $payment = $this->getInfoInstance(); - $order = $payment->getOrder(); - $order->setCanSendNewEmailFlag(false); - - $stateObject->setState(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT); - $stateObject->setStatus('pending_payment'); - $stateObject->setIsNotified(false); - } - - public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) - { - if ($quote && ( - $quote->getBaseGrandTotal() < $this->_minAmount - || ($this->_maxAmount && $quote->getBaseGrandTotal() > $this->_maxAmount)) - ) { - return false; - } - - return parent::isAvailable($quote); - } - - public function canUseForCurrency($currencyCode) - { - if (!in_array($currencyCode, $this->_supportedCurrencyCodes)) { - return false; - } - return true; - } - - public function buildPaytmRequest($order) - { - $callBackUrl=$this->urlBuilder->getUrl('paytm/Standard/Response', ['_secure' => true]); - if($this->getConfigData("custom_callbackurl")=='1'){ - $callBackUrl=$this->getConfigData("callback_url")!=''?$this->getConfigData("callback_url"):$callBackUrl; - } - $params = array('MID' => $this->getConfigData("MID"), - 'TXN_AMOUNT' => round($order->getGrandTotal(), 2), - 'CHANNEL_ID' => $this->getConfigData("Channel_Id"), - 'INDUSTRY_TYPE_ID' => $this->getConfigData("Industry_id"), - 'WEBSITE' => $this->getConfigData("Website"), - 'CUST_ID' => $order->getCustomerEmail(), - 'ORDER_ID' => $order->getRealOrderId(), - 'EMAIL' => $order->getCustomerEmail(), - 'CALLBACK_URL' => $callBackUrl); - if(isset($order->paytmPromoCode)){ - $params['PROMO_CAMP_ID']=$order->paytmPromoCode; - } - - $checksum = $this->helper->getChecksumFromArray($params, $this->getConfigData("merchant_key")); - - $params['CHECKSUMHASH'] = str_replace("+","%2b",$checksum); - - $url = $this->getConfigData('transaction_url')."?"; - $urlparam = ""; - foreach($params as $key => $val){ - $urlparam = $urlparam.$key."=".$val."&"; - } - $url = $url . $urlparam; - return $url; - } - - public function validateResponse($res,$order_id) - { - //print_r($res); - $checksum = $res["CHECKSUMHASH"]; - if ($this->helper->verifychecksum_e($res,$this->getConfigData("merchant_key"),$checksum)) { - $result = true; - } else { - $result = false; - } - return $result; - } - - public function generateStatusChecksum($requestParamList) - { - $result = $this->helper->getChecksumFromArray($requestParamList,$this->getConfigData("merchant_key")); - return $result; - } - - public function autoInvoiceGen() - { - $result = $this->getConfigData("payment_action"); - return $result; - } - - public function getRedirectUrl() - { - $url = $this->getConfigData('transaction_url'); - return $url; - } - - public function getStatusQueryUrl() - { - $url = $this->getConfigData('transaction_status_url'); - return $url; - } - - public function getNewStatusQueryUrl() - { - $url = $this->getConfigData('transaction_status_url'); - return $url; - } - - public function getReturnUrl() - { - - } - - public function getCancelUrl() - { - - } -} diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Model/PaytmConfigProvider.php b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Model/PaytmConfigProvider.php deleted file mode 100644 index d9cc567..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Model/PaytmConfigProvider.php +++ /dev/null @@ -1,48 +0,0 @@ -method = $paymentHelper->getMethodInstance($this->methodCode); - $this->urlBuilder = $urlBuilder; - } - - public function getConfig() - { - $promo=$this->method->getConfigData("promo_code"); - $hide_promo_field=$this->method->getConfigData("hide_promo_field"); - $promo_code_local_validation=$this->method->getConfigData("promo_code_local_validation"); - return $this->method->isAvailable() ? [ - 'payment' => [ - 'paytm' => [ - 'redirectUrl' => $this->urlBuilder->getUrl('paytm/Standard/Redirect', ['_secure' => true]), - 'promoCode'=>$promo, - 'hide_promo_field'=>$hide_promo_field, - 'promo_code_local_validation'=>$promo_code_local_validation - ] - ] - ] : []; - } - - protected function getRedirectUrl() - { - return $this->_urlBuilder->getUrl('paypal/ipn/'); - } - - protected function getFormData() - { - return $this->method->getRedirectUrl(); - } -} diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Observer/SendMailOnOrderSuccess.php b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Observer/SendMailOnOrderSuccess.php deleted file mode 100644 index 8ddcc55..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Observer/SendMailOnOrderSuccess.php +++ /dev/null @@ -1,56 +0,0 @@ -orderModel = $orderModel; - $this->orderSender = $orderSender; - $this->checkoutSession = $checkoutSession; - } - - /** - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function execute(\Magento\Framework\Event\Observer $observer) - { - $orderIds = $observer->getEvent()->getOrderIds(); - if(count($orderIds)) - { - $this->checkoutSession->setForceOrderMailSentOnSuccess(true); - $order = $this->orderModel->create()->load($orderIds[0]); - $this->orderSender->send($order, true); - } - } -} \ No newline at end of file diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Plugin/Sales/Order/Email/Container/OrderIdentityPlugin.php b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Plugin/Sales/Order/Email/Container/OrderIdentityPlugin.php deleted file mode 100644 index a3dddbf..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/Plugin/Sales/Order/Email/Container/OrderIdentityPlugin.php +++ /dev/null @@ -1,46 +0,0 @@ -checkoutSession = $checkoutSession; - } - - /** - * @param \Magento\Sales\Model\Order\Email\Container\OrderIdentity $subject - * @param callable $proceed - * @return bool - */ - public function aroundIsEnabled(\Magento\Sales\Model\Order\Email\Container\OrderIdentity $subject, callable $proceed) - { - $returnValue = $proceed(); - - $forceOrderMailSentOnSuccess = $this->checkoutSession->getForceOrderMailSentOnSuccess(); - if(isset($forceOrderMailSentOnSuccess) && $forceOrderMailSentOnSuccess) - { - if($returnValue) - $returnValue = false; - else - $returnValue = true; - - $this->checkoutSession->unsForceOrderMailSentOnSuccess(); - } - - return $returnValue; - } -} \ No newline at end of file diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/README.md b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/README.md deleted file mode 100644 index 06e561f..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Magento 2.3.0 Paytm Payment Gateway -====================== - -See Video : https://www.youtube.com/watch?v=bR18KwhY4V8 \ No newline at end of file diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/adminhtml/system.xml b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/adminhtml/system.xml deleted file mode 100644 index 541171a..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/adminhtml/system.xml +++ /dev/null @@ -1,134 +0,0 @@ - - -
- - - - Click here to sign up for Paytm account]]> - - - - Magento\Config\Model\Config\Source\Yesno - payment/paytm/active - - - - payment/paytm/title - - - - - One97\Paytm\Model\PaymentAction - payment/paytm/payment_action - - - - Provided By Paytm - payment/paytm/MID - - - - - Provided By Paytm - payment/paytm/merchant_key - - - - - - - Magento\Config\Model\Config\Source\Yesno - - - - Provided By Merchant (hint: https://domainName/paytm/Standard/Response) - payment/paytm/callback_url - - - 1 - - - - - - Provided By Paytm - payment/paytm/transaction_url - - - - - Provided By Paytm - payment/paytm/transaction_status_url - - - - - - - Provided By Paytm - payment/paytm/Industry_id - - - - - - Provided By Paytm - payment/paytm/Channel_Id - - - - - - Provided By Paytm - payment/paytm/Website - - - - - - Magento\Sales\Model\Config\Source\Order\Status\Processing - payment/paytm/order_status - - - - - - validate-number - payment/paytm/sort_order - - - - - - Magento\Payment\Model\Config\Source\Allspecificcountries - payment/paytm/allowspecific - - - - - Magento\Directory\Model\Config\Source\Country - payment/paytm/specificcountry - - - - - - Selecting yes, will show Promo Code field at Checkout. - Magento\Config\Model\Config\Source\Yesno - - - - - Validate applied Promo Code before proceeding to Paytm payment page. Transaction will be failed in case of Promo Code failure at Paytm's end. - Magento\Config\Model\Config\Source\Yesno - - - - - These promo codes must be configured with your Paytm MID. Use comma ( , ) to separate multiple codes i.e. FB50,CASHBACK10 etc. - payment/paytm/promo_code - - -
-
-
\ No newline at end of file diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/di.xml b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/di.xml deleted file mode 100644 index ac6c650..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/di.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/paytm_version.txt b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/paytm_version.txt deleted file mode 100644 index 7f7fca6..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/etc/paytm_version.txt +++ /dev/null @@ -1 +0,0 @@ -19-12-2018 \ No newline at end of file diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/registration.php b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/registration.php deleted file mode 100644 index b8e5255..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/registration.php +++ /dev/null @@ -1,7 +0,0 @@ -getMethod()->getDescription()): ?> - - \ No newline at end of file diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/view/frontend/web/js/view/payment/method-renderer/one97-paytm.js b/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/view/frontend/web/js/view/payment/method-renderer/one97-paytm.js deleted file mode 100644 index fde87c6..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/app/code/One97/Paytm/view/frontend/web/js/view/payment/method-renderer/one97-paytm.js +++ /dev/null @@ -1,115 +0,0 @@ -define( - [ - 'jquery', - 'Magento_Checkout/js/view/payment/default', - 'Magento_Checkout/js/action/place-order', - 'Magento_Checkout/js/action/select-payment-method', - 'Magento_Customer/js/model/customer', - 'Magento_Checkout/js/checkout-data', - 'Magento_Checkout/js/model/payment/additional-validators' - ], - function ($, Component, placeOrderAction, selectPaymentMethodAction, customer, checkoutData, additionalValidators) { - 'use strict'; - $('.errP').text(''); - var promo=''; - /*alert(window.checkoutConfig.payment.paytm.hide_promo_field); - alert($.trim(window.checkoutConfig.payment.paytm.promoCode)); - alert($.trim(window.checkoutConfig.payment.paytm.promoCode).length); - alert(window.checkoutConfig.payment.paytm.promoCode);*/ - if(window.checkoutConfig.payment.paytm.hide_promo_field=='1'){ - if(window.checkoutConfig.payment.paytm.promo_code_local_validation=='1' && ($.trim(window.checkoutConfig.payment.paytm.promoCode).length=='0' || $.trim(window.checkoutConfig.payment.paytm.promoCode)=='')){ - // $('.customDiv').css('display','block'); - }else{ - setTimeout(function(){ - $('.customDiv').css('display','block'); - }, 1000); - } - - } - $(document).on('click','.promoApplyBtn',function(){ - // alert(window.checkoutConfig.payment.paytm.promoCode); - if(window.checkoutConfig.payment.paytm.promo_code_local_validation=='1'){ - if($.trim($('.promoCodeField').val())==''){ - $('.errP').text('Please enter your promo code.'); - }else{ - var promoCode=window.checkoutConfig.payment.paytm.promoCode; - var promoCodeArr=promoCode.split(','); - var matchCode=0; - $.each(promoCodeArr, function( index, value ) { - if($.trim($('.promoCodeField').val())==$.trim(value )){ - matchCode=1; - } - }); - if(matchCode==1){ - $('.promoApplyBtn').val('Remove Code'); - $('.promoApplyBtn').addClass('promoRemoveBtn'); - $('.promoApplyBtn').removeClass('promoApplyBtn'); - $('.promoRemoveBtn').css('background','red'); - $('.promoRemoveBtn').css('border','1px solid red'); - $('.promoCodeField').attr('disabled',true); - $('.errP').text('Applied Successfully'); - promo=$.trim($('.promoCodeField').val()); - }else{ - $('.errP').text('Incorrect Promo Code'); - promo=''; - } - } - }else{ - $('.promoApplyBtn').val('Remove Code'); - $('.promoApplyBtn').addClass('promoRemoveBtn'); - $('.promoApplyBtn').removeClass('promoApplyBtn'); - $('.promoRemoveBtn').css('background','red'); - $('.promoRemoveBtn').css('border','1px solid red'); - $('.promoCodeField').attr('disabled',true); - $('.errP').text('Applied Successfully'); - promo=$.trim($('.promoCodeField').val()); - } - }); - $(document).on('click','.promoRemoveBtn',function(){ - $('.promoRemoveBtn').val('Apply'); - $('.promoRemoveBtn').addClass('promoApplyBtn'); - $('.promoRemoveBtn').removeClass('promoRemoveBtn'); - $('.promoApplyBtn').css('background','#006bb4'); - $('.promoApplyBtn').css('border','1px solid #006bb4'); - $('.promoCodeField').attr('disabled',false); - $('.promoCodeField').val(''); - $('.errP').text(''); - promo=''; - }); - return Component.extend({ - defaults: { - template: 'One97_Paytm/payment/one97' - }, - placeOrder: function (data, event) { - if (event) { - event.preventDefault(); - } - var self = this, - placeOrder, - emailValidationResult = customer.isLoggedIn(), - loginFormSelector = 'form[data-role=email-with-possible-login]'; - if (!customer.isLoggedIn()) { - $(loginFormSelector).validation(); - emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid()); - } - if (emailValidationResult && this.validate() && additionalValidators.validate()) { - this.isPlaceOrderActionAllowed(false); - placeOrder = placeOrderAction(this.getData(), false, this.messageContainer); - - $.when(placeOrder).fail(function () { - self.isPlaceOrderActionAllowed(true); - }).done(this.afterPlaceOrder.bind(this)); - return true; - } - return false; - }, - afterPlaceOrder: function () { - if(promo==''){ - $.mage.redirect(window.checkoutConfig.payment.paytm.redirectUrl); - }else{ - $.mage.redirect(window.checkoutConfig.payment.paytm.redirectUrl+"?promo="+promo); - } - } - }); - } -); \ No newline at end of file diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/readme.md b/Magento_v2.3.x/Magento Plugin V2.3.0/readme.md deleted file mode 100644 index 31866ba..0000000 --- a/Magento_v2.3.x/Magento Plugin V2.3.0/readme.md +++ /dev/null @@ -1,44 +0,0 @@ -# Magento 2.3.0:- - - 1. Download the plugin. - 2. Extract the files from the downloaded folder. - 3. Copy App folder from the required Magento version and place them into the root folder. If prompted to overwrite the files, click yes. - 4. Run below command: - php bin/magento module:enable One97_Paytm - php bin/magento setup:upgrade - php bin/magento setup:static-content:deploy -f - php bin/magento setup:upgrade - 5. Login to Magento Admin Panel and choose Payments Methods - System- > Configuration - > Payment Methods - 6. Enable Paytm option from Payment Methods - 7. Go to the Paytm PG Configuration and save below configuration - - * Enable - Yes - * Title - Paytm PG - * Merchant ID - MID provided by Paytm - * Merchant Key - Key provided by Paytm - * Transaction URL - * Staging - https://securegw-stage.paytm.in/theia/processTransaction - * Production - https://securegw.paytm.in/theia/processTransaction - * Transaction Status URL - * Staging - https://securegw-stage.paytm.in/merchant-status/getTxnStatus - * Production - https://securegw.paytm.in/merchant-status/getTxnStatus - * Website Name - * WEBSTAGING for Staging - * WEBPROD for Production - * Custom Callback Url - No - * Callback Url - customized callback url(this is visible when Custom Callback Url is yes) - * Industry Type - * Retail for staging - * Industry type for Production will be provided by Paytm - * Channel ID - WEB/WAP - * Sort Order - 2 - * Applicable Country - All allowed country - - 8. Please note if you have Linux server, please make sure folder permission are set to 755 & file permission to 644. - 9. Once plugin is installed, please logout from the admin panel and clear the cache of the Magento. - 10. Your plug-in is installed now, you can now make payment with Paytm. - -See Video : https://www.youtube.com/watch?v=bR18KwhY4V8 - -# In case of any query, please contact to Paytm. diff --git a/Magento_v2.3.x/Magento Plugin V2.3.0/readme.rtf b/Magento_v2.3.x/Magento Plugin V2.3.0/readme.rtf deleted file mode 100644 index 1a83cc6..0000000 Binary files a/Magento_v2.3.x/Magento Plugin V2.3.0/readme.rtf and /dev/null differ diff --git a/Magento_v2.3.x/README.md b/Magento_v2.3.x/README.md deleted file mode 100644 index db649a9..0000000 --- a/Magento_v2.3.x/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Paytm_Magento_v2.3.x_Kit - -Supported Versions -Paytm Plugin version V3.0 Magento supported version 2.3.X onward - -Installation and Configuration -upload app/code/One97 (all files and folder) at you server end. - -Run below command: -php bin/magento module:enable One97_Paytm -php bin/magento setup:upgrade -php bin/magento setup:static-content:deploy -f -php bin/magento setup:upgrade - -goto Admin->Store->Configuration->Sales->Payment Method->Paytm -fill details here and save them. - -goto Admin->System->Cache Management -Clear all Cache. - -Now you can collect payment via Paytm . - -See Video : https://www.youtube.com/watch?v=bR18KwhY4V8 \ No newline at end of file diff --git a/Magento_v2.x/LICENSE b/Magento_v2.x/LICENSE deleted file mode 100644 index 23cb790..0000000 --- a/Magento_v2.x/LICENSE +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {description} - Copyright (C) {year} {fullname} - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - {signature of Ty Coon}, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Block/Form/Paytm.php b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Block/Form/Paytm.php deleted file mode 100644 index ddc9585..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Block/Form/Paytm.php +++ /dev/null @@ -1,8 +0,0 @@ -_customerSession = $customerSession; - $this->_checkoutSession = $checkoutSession; - $this->_orderFactory = $orderFactory; - $this->_logger = $logger; - $this->_orderHistoryFactory = $orderHistoryFactory; - $this->_paytmModel = $paytmModel; - $this->_paytmHelper = $paytmHelper; - parent::__construct($context); - } - - - - /** - * Cancel order, return quote to customer - * - * @param string $errorMsg - * @return false|string - */ - protected function _cancelPayment($errorMsg = '') - { - $gotoSection = false; - $this->_paytmHelper->cancelCurrentOrder($errorMsg); - if ($this->_checkoutSession->restoreQuote()) { - //Redirect to payment step - $gotoSection = 'paymentMethod'; - } - - return $gotoSection; - } - - /** - * Get order object - * - * @return \Magento\Sales\Model\Order - */ - protected function getOrderById($order_id) - { - $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); - $order = $objectManager->get('Magento\Sales\Model\Order'); - $order_info = $order->loadByIncrementId($order_id); - return $order_info; - } - - /** - * Get order object - * - * @return \Magento\Sales\Model\Order - */ - protected function getOrder() - { - return $this->_orderFactory->create()->loadByIncrementId( - $this->_checkoutSession->getLastRealOrderId() - ); - } - - protected function addOrderHistory($order,$comment){ - $history = $this->_orderHistoryFactory->create() - ->setComment($comment) - ->setEntityName('order') - ->setOrder($order); - $history->save(); - return true; - } - - protected function getQuote() - { - if (!$this->_quote) { - $this->_quote = $this->_getCheckoutSession()->getQuote(); - } - return $this->_quote; - } - - protected function getCheckoutSession() - { - return $this->_checkoutSession; - } - - protected function getCustomerSession() - { - return $this->_customerSession; - } - - protected function getPaytmModel() - { - return $this->_paytmModel; - } - - protected function getPaytmHelper() - { - return $this->_paytmHelper; - } -} diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Controller/Standard/Cancel.php b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Controller/Standard/Cancel.php deleted file mode 100644 index 8cf1a63..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Controller/Standard/Cancel.php +++ /dev/null @@ -1,17 +0,0 @@ -_cancelPayment(); - $this->_checkoutSession->restoreQuote(); - $this->getResponse()->setRedirect( - $this->getPaytmHelper()->getUrl('checkout') - ); - } - -} diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Controller/Standard/Curltest.php b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Controller/Standard/Curltest.php deleted file mode 100644 index 1978524..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Controller/Standard/Curltest.php +++ /dev/null @@ -1,71 +0,0 @@ -getRequest()->getParams(); - if(!empty($getData)){ - foreach ($getData as $key => $value) { - $testing_urls[]=$value; - } - }else{ - $currentPath = $_SERVER['PHP_SELF']; - $pathInfo = pathinfo($currentPath); - $hostName = $_SERVER['HTTP_HOST']; - $protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https://'?'https://':'http://'; - $check_status_url = $this->getPaytmModel()->getNewStatusQueryUrl(); - $testing_urls = array( - $protocol.$hostName.$pathInfo['dirname']."/", - "www.google.co.in", - $check_status_url - ); - } - /*echo "
";print_r($testing_urls);
-    		echo "
";*/ - // loop over all URLs, maintain debug log for each response received - foreach($testing_urls as $key=>$url){ - - $debug[$key]["info"][] = "Connecting to " . $url . " using cURL"; - - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - $res = curl_exec($ch); - - if (!curl_errno($ch)) { - $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); - $debug[$key]["info"][] = "cURL executed succcessfully."; - $debug[$key]["info"][] = "HTTP Response Code: ". $http_code . ""; - - // $debug[$key]["content"] = $res; - - } else { - $debug[$key]["info"][] = "Connection Failed !!"; - $debug[$key]["info"][] = "Error Code: " . curl_errno($ch) . ""; - $debug[$key]["info"][] = "Error: " . curl_error($ch) . ""; - break; - } - curl_close($ch); - } - } - foreach($debug as $k=>$v){ - echo "
    "; - foreach($v["info"] as $info){ - echo "
  • ".$info."
  • "; - } - echo "
"; - - // echo "
" . $v["content"] . "
"; - echo "
"; - } - die; - } -} diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Controller/Standard/Redirect.php b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Controller/Standard/Redirect.php deleted file mode 100644 index c05adad..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Controller/Standard/Redirect.php +++ /dev/null @@ -1,38 +0,0 @@ -getOrder(); - if ($order->getBillingAddress()) - { - $order->setState("pending_payment")->setStatus("pending_payment"); - $order->addStatusToHistory($order->getStatus(), "Customer was redirected to paytm."); - $order->save(); - - if($promo!=''){ - $order->paytmPromoCode=$promo; - } - $this->getResponse()->setRedirect( - $this->getPaytmModel()->buildPaytmRequest($order) - ); - } - else - { - $this->_cancelPayment(); - $this->_paytmSession->restoreQuote(); - $this->getResponse()->setRedirect( - $this->getPaytmHelper()->getUrl('checkout') - ); - } - } -} \ No newline at end of file diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Controller/Standard/Response.php b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Controller/Standard/Response.php deleted file mode 100644 index d50d7b5..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Controller/Standard/Response.php +++ /dev/null @@ -1,121 +0,0 @@ - $val){ - if($key != "CHECKSUMHASH"){ - $comment .= $key . "=" . $val . ", \n
"; - } - } - } - $errorMsg = ''; - $successFlag = false; - $resMessage=$this->getRequest()->getParam('RESPMSG'); - $globalErrMass="Your payment has been failed!"; - if(trim($resMessage)!=''){ - $globalErrMass.=" Reason: ".$resMessage; - } - $returnUrl = $this->getPaytmHelper()->getUrl('/'); - $orderMID = $this->getRequest()->getParam('MID'); - $orderId = $this->getRequest()->getParam('ORDERID'); - $orderTXNID = $this->getRequest()->getParam('TXNID'); - if(trim($orderId)!='' && trim($orderMID)!=''){ - $order = $this->getOrderById($orderId); - $orderTotal = round($order->getGrandTotal(), 2); - - $orderStatus = $this->getRequest()->getParam('STATUS'); - $resCode = $this->getRequest()->getParam('RESPCODE'); - $orderTxnAmount = $this->getRequest()->getParam('TXNAMOUNT'); - - if($this->getPaytmModel()->validateResponse($request, $orderId)) { - if($orderStatus == "TXN_SUCCESS" && $orderTotal == $orderTxnAmount){ - // Create an array having all required parameters for status query. - $requestParamList = array("MID" => $orderMID , "ORDERID" => $orderId); - $StatusCheckSum = $this->getPaytmModel()->generateStatusChecksum($requestParamList); - $requestParamList['CHECKSUMHASH'] = $StatusCheckSum; - - // Call the PG's getTxnStatus() function for verifying the transaction status. - $check_status_url = $this->getPaytmModel()->getNewStatusQueryUrl(); - $responseParamList = $this->getPaytmHelper()->callNewAPI($check_status_url, $requestParamList); - if($responseParamList['STATUS'] == "PENDING"){ - $errorMsg = 'Paytm Transaction Pending!'; - if(trim($resMessage)==''){ - $errorMsg.=" Reason: ".$resMessage; - } - $comment .= "Pending"; - $order->setState("pending_payment")->setStatus("pending_payment"); - // $this->_cancelPayment($errorMsg); - $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); - }else{ - if($responseParamList['STATUS']=='TXN_SUCCESS' && $responseParamList['TXNAMOUNT']==$orderTxnAmount) - { - $autoInvoice = $this->getPaytmModel()->autoInvoiceGen(); - if($autoInvoice=='authorize_capture'){ - $payment = $order->getPayment(); - $payment->setTransactionId($orderTXNID) - ->setPreparedMessage(__('Paytm transaction has been successful.')) - ->setShouldCloseParentTransaction(true) - ->setIsTransactionClosed(0) - ->setAdditionalInformation(['One97','paytm']) - ->registerCaptureNotification( - $responseParamList['TXNAMOUNT'], - true - ); - $invoice = $payment->getCreatedInvoice(); - } - - $successFlag = true; - $comment .= "Success "; - $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING); - $order->setStatus($order::STATE_PROCESSING); - $order->setExtOrderId($orderId); - $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/success'); - } else{ - $errorMsg = 'It seems some issue in server to server communication. Kindly connect with administrator.'; - $comment .= "Fraud Detucted"; - $order->setStatus($order::STATUS_FRAUD); - // $this->_cancelPayment($errorMsg); - $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); - } - } - }else{ - if($orderStatus == "PENDING"){ - $errorMsg = 'Paytm Transaction Pending!'; - if(trim($resMessage)==''){ - $errorMsg.=" Reason: ".$resMessage; - } - $comment .= "Pending"; - // $this->_cancelPayment($errorMsg); - $order->setState("pending_payment")->setStatus("pending_payment"); - }else{ - $errorMsg = $globalErrMass; - $comment .= $globalErrMass; - $order->setStatus($order::STATE_CANCELED); - // $this->_cancelPayment($globalErrMass); - } - $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); - } - } else { - $errorMsg = $globalErrMass." Reason: Checksum Mismatch."; - $comment .= "Fraud Detucted"; - $order->setStatus($order::STATUS_FRAUD); - // $this->_cancelPayment("Fraud Detucted"); - $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); - } - // $this->addOrderHistory($order,$comment); - $order->addStatusToHistory($order->getStatus(), $comment); - $order->save(); - if($successFlag){ - $this->messageManager->addSuccess( __('Paytm transaction has been successful.') ); - }else{ - $this->messageManager->addError( __($errorMsg) ); - } - } - $this->getResponse()->setRedirect($returnUrl); - } -} diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Helper/Data.php b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Helper/Data.php deleted file mode 100644 index 938f577..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Helper/Data.php +++ /dev/null @@ -1,187 +0,0 @@ -session = $session; - parent::__construct($context); - } - - public function cancelCurrentOrder($comment) { - $order = $this->session->getLastRealOrder(); - if ($order->getId() && $order->getState() != Order::STATE_CANCELED) { - $order->registerCancellation($comment)->save(); - return true; - } - return false; - } - - public function restoreQuote() { - return $this->session->restoreQuote(); - } - - public function getUrl($route, $params = []) { - return $this->_getUrl($route, $params); - } - - public function encrypt_e($input, $ky) { - $key = html_entity_decode($ky); - $iv = "@@@@&&&&####$$$$"; - $data = openssl_encrypt ( $input , "AES-128-CBC" , $key, 0, $iv ); - return $data; - } - - public function decrypt_e($crypt, $ky) { - $key = html_entity_decode($ky); - $iv = "@@@@&&&&####$$$$"; - $data = openssl_decrypt ( $crypt , "AES-128-CBC" , $key, 0, $iv ); - return $data; - } - - public function generateSalt_e($length) { - $random = ""; - srand((double) microtime() * 1000000); - $data = "AbcDE123IJKLMN67QRSTUVWXYZ"; - $data .= "aBCdefghijklmn123opq45rs67tuv89wxyz"; - $data .= "0FGH45OP89"; - for ($i = 0; $i < $length; $i++) { - $random .= substr($data, (rand() % (strlen($data))), 1); - } - return $random; - } - - public function checkString_e($value) { - $myvalue = ltrim($value); - $myvalue = rtrim($myvalue); - if ($myvalue == 'null') - $myvalue = ''; - return $myvalue; - } - - public function getChecksumFromArray($arrayList, $key) { - ksort($arrayList); - $str = $this->getArray2Str($arrayList); - $salt = $this->generateSalt_e(4); - $finalString = $str . "|" . $salt; - $hash = hash("sha256", $finalString); - $hashString = $hash . $salt; - $checksum = $this->encrypt_e($hashString, $key); - return $checksum; - } - - public function verifychecksum_e($arrayList, $key, $checksumvalue) { - $arrayList = $this->removeCheckSumParam($arrayList); - ksort($arrayList); - $str = $this->getArray2StrForVerify($arrayList); - $paytm_hash = $this->decrypt_e($checksumvalue, $key); - $salt = substr($paytm_hash, -4); - $finalString = $str . "|" . $salt; - $website_hash = hash("sha256", $finalString); - $website_hash .= $salt; - $validFlag = FALSE; - if ($website_hash == $paytm_hash) { - $validFlag = TRUE; - } else { - $validFlag = FALSE; - } - return $validFlag; - } - - public function getArray2StrForVerify($arrayList) { - $paramStr = ""; - $flag = 1; - foreach ($arrayList as $key => $value) { - if ($flag) { - $paramStr .= $this->checkString_e($value); - $flag = 0; - } else { - $paramStr .= "|" . $this->checkString_e($value); - } - } - return $paramStr; - } - - public function getArray2Str($arrayList) { - $findme = 'REFUND'; - $findmepipe = '|'; - $paramStr = ""; - $flag = 1; - foreach ($arrayList as $key => $value) { - $pos = strpos($value, $findme); - $pospipe = strpos($value, $findmepipe); - if ($pos !== false || $pospipe !== false) - { - continue; - } - if ($flag) { - $paramStr .= $this->checkString_e($value); - $flag = 0; - } else { - $paramStr .= "|" . $this->checkString_e($value); - } - } - return $paramStr; - } - - public function redirect2PG($paramList, $key) { - $hashString = $this->getchecksumFromArray($paramList); - $checksum = $this->encrypt_e($hashString, $key); - } - - public function removeCheckSumParam($arrayList) { - if (isset($arrayList["CHECKSUMHASH"])) { - unset($arrayList["CHECKSUMHASH"]); - } - return $arrayList; - } - function callAPI($apiURL, $requestParamList) - { - $jsonResponse = ""; - $responseParamList = array(); - $JsonData = json_encode($requestParamList); - $postData = 'JsonData=' . urlencode($JsonData); - $ch = curl_init($apiURL); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Content-Type: application/json', - 'Content-Length: ' . strlen($postData) - )); - $jsonResponse = curl_exec($ch); - $responseParamList = json_decode($jsonResponse, true); - return $responseParamList; - } - - function callNewAPI($apiURL, $requestParamList) - { - $jsonResponse = ""; - $responseParamList = array(); - $JsonData = json_encode($requestParamList); - $postData = 'JsonData=' . urlencode($JsonData); - $ch = curl_init($apiURL); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Content-Type: application/json', - 'Content-Length: ' . strlen($postData) - )); - $jsonResponse = curl_exec($ch); - $responseParamList = json_decode($jsonResponse, true); - return $responseParamList; - } - -} diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Model/PaymentAction.php b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Model/PaymentAction.php deleted file mode 100644 index d231122..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Model/PaymentAction.php +++ /dev/null @@ -1,33 +0,0 @@ - 'authorize_capture', 'label' => __('Yes')], ['value' => 'capture', 'label' => __('No')]]; - } - - /** - * Get options in "key-value" format - * - * @return array - */ - public function toArray() - { - return [0 => __('No'), 1 => __('Yes')]; - } -} diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Model/Paytm.php b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Model/Paytm.php deleted file mode 100644 index 0e9c7c5..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Model/Paytm.php +++ /dev/null @@ -1,169 +0,0 @@ -helper = $helper; - parent::__construct( - $context, - $registry, - $extensionFactory, - $customAttributeFactory, - $paymentData, - $scopeConfig, - $logger - ); - - $this->_minAmount = "0.50"; - $this->_maxAmount = "1000000"; - $this->urlBuilder = $urlBuilder; - } - - /** - * Instantiate state and set it to state object. - * - * @param string $paymentAction - * @param \Magento\Framework\DataObject $stateObject - */ - public function initialize($paymentAction, $stateObject) - { - $payment = $this->getInfoInstance(); - $order = $payment->getOrder(); - $order->setCanSendNewEmailFlag(false); - - $stateObject->setState(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT); - $stateObject->setStatus('pending_payment'); - $stateObject->setIsNotified(false); - } - - public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) - { - if ($quote && ( - $quote->getBaseGrandTotal() < $this->_minAmount - || ($this->_maxAmount && $quote->getBaseGrandTotal() > $this->_maxAmount)) - ) { - return false; - } - - return parent::isAvailable($quote); - } - - public function canUseForCurrency($currencyCode) - { - if (!in_array($currencyCode, $this->_supportedCurrencyCodes)) { - return false; - } - return true; - } - - public function buildPaytmRequest($order) - { - $callBackUrl=$this->urlBuilder->getUrl('paytm/Standard/Response', ['_secure' => true]); - if($this->getConfigData("custom_callbackurl")=='1'){ - $callBackUrl=$this->getConfigData("callback_url")!=''?$this->getConfigData("callback_url"):$callBackUrl; - } - $params = array('MID' => $this->getConfigData("MID"), - 'TXN_AMOUNT' => round($order->getGrandTotal(), 2), - 'CHANNEL_ID' => $this->getConfigData("Channel_Id"), - 'INDUSTRY_TYPE_ID' => $this->getConfigData("Industry_id"), - 'WEBSITE' => $this->getConfigData("Website"), - 'CUST_ID' => $order->getCustomerEmail(), - 'ORDER_ID' => $order->getRealOrderId(), - 'EMAIL' => $order->getCustomerEmail(), - 'CALLBACK_URL' => $callBackUrl); - if(isset($order->paytmPromoCode)){ - $params['PROMO_CAMP_ID']=$order->paytmPromoCode; - } - - $checksum = $this->helper->getChecksumFromArray($params, $this->getConfigData("merchant_key")); - - $params['CHECKSUMHASH'] = str_replace("+","%2b",$checksum); - - $url = $this->getConfigData('transaction_url')."?"; - $urlparam = ""; - foreach($params as $key => $val){ - $urlparam = $urlparam.$key."=".$val."&"; - } - $url = $url . $urlparam; - return $url; - } - - public function validateResponse($res,$order_id) - { - //print_r($res); - $checksum = $res["CHECKSUMHASH"]; - if ($this->helper->verifychecksum_e($res,$this->getConfigData("merchant_key"),$checksum)) { - $result = true; - } else { - $result = false; - } - return $result; - } - - public function generateStatusChecksum($requestParamList) - { - $result = $this->helper->getChecksumFromArray($requestParamList,$this->getConfigData("merchant_key")); - return $result; - } - - public function autoInvoiceGen() - { - $result = $this->getConfigData("payment_action"); - return $result; - } - - public function getRedirectUrl() - { - $url = $this->getConfigData('transaction_url'); - return $url; - } - - public function getStatusQueryUrl() - { - $url = $this->getConfigData('transaction_status_url'); - return $url; - } - - public function getNewStatusQueryUrl() - { - $url = $this->getConfigData('transaction_status_url'); - return $url; - } - - public function getReturnUrl() - { - - } - - public function getCancelUrl() - { - - } -} diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Model/PaytmConfigProvider.php b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Model/PaytmConfigProvider.php deleted file mode 100644 index d9cc567..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Model/PaytmConfigProvider.php +++ /dev/null @@ -1,48 +0,0 @@ -method = $paymentHelper->getMethodInstance($this->methodCode); - $this->urlBuilder = $urlBuilder; - } - - public function getConfig() - { - $promo=$this->method->getConfigData("promo_code"); - $hide_promo_field=$this->method->getConfigData("hide_promo_field"); - $promo_code_local_validation=$this->method->getConfigData("promo_code_local_validation"); - return $this->method->isAvailable() ? [ - 'payment' => [ - 'paytm' => [ - 'redirectUrl' => $this->urlBuilder->getUrl('paytm/Standard/Redirect', ['_secure' => true]), - 'promoCode'=>$promo, - 'hide_promo_field'=>$hide_promo_field, - 'promo_code_local_validation'=>$promo_code_local_validation - ] - ] - ] : []; - } - - protected function getRedirectUrl() - { - return $this->_urlBuilder->getUrl('paypal/ipn/'); - } - - protected function getFormData() - { - return $this->method->getRedirectUrl(); - } -} diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Observer/SendMailOnOrderSuccess.php b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Observer/SendMailOnOrderSuccess.php deleted file mode 100644 index 8ddcc55..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Observer/SendMailOnOrderSuccess.php +++ /dev/null @@ -1,56 +0,0 @@ -orderModel = $orderModel; - $this->orderSender = $orderSender; - $this->checkoutSession = $checkoutSession; - } - - /** - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function execute(\Magento\Framework\Event\Observer $observer) - { - $orderIds = $observer->getEvent()->getOrderIds(); - if(count($orderIds)) - { - $this->checkoutSession->setForceOrderMailSentOnSuccess(true); - $order = $this->orderModel->create()->load($orderIds[0]); - $this->orderSender->send($order, true); - } - } -} \ No newline at end of file diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Plugin/Sales/Order/Email/Container/OrderIdentityPlugin.php b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Plugin/Sales/Order/Email/Container/OrderIdentityPlugin.php deleted file mode 100644 index a3dddbf..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/Plugin/Sales/Order/Email/Container/OrderIdentityPlugin.php +++ /dev/null @@ -1,46 +0,0 @@ -checkoutSession = $checkoutSession; - } - - /** - * @param \Magento\Sales\Model\Order\Email\Container\OrderIdentity $subject - * @param callable $proceed - * @return bool - */ - public function aroundIsEnabled(\Magento\Sales\Model\Order\Email\Container\OrderIdentity $subject, callable $proceed) - { - $returnValue = $proceed(); - - $forceOrderMailSentOnSuccess = $this->checkoutSession->getForceOrderMailSentOnSuccess(); - if(isset($forceOrderMailSentOnSuccess) && $forceOrderMailSentOnSuccess) - { - if($returnValue) - $returnValue = false; - else - $returnValue = true; - - $this->checkoutSession->unsForceOrderMailSentOnSuccess(); - } - - return $returnValue; - } -} \ No newline at end of file diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/README.md b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/README.md deleted file mode 100644 index 5957c37..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Magento 2 Paytm Payment Gateway -====================== - -See Video : https://www.youtube.com/watch?v=bR18KwhY4V8 \ No newline at end of file diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/adminhtml/system.xml b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/adminhtml/system.xml deleted file mode 100644 index 541171a..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/adminhtml/system.xml +++ /dev/null @@ -1,134 +0,0 @@ - - -
- - - - Click here to sign up for Paytm account]]> - - - - Magento\Config\Model\Config\Source\Yesno - payment/paytm/active - - - - payment/paytm/title - - - - - One97\Paytm\Model\PaymentAction - payment/paytm/payment_action - - - - Provided By Paytm - payment/paytm/MID - - - - - Provided By Paytm - payment/paytm/merchant_key - - - - - - - Magento\Config\Model\Config\Source\Yesno - - - - Provided By Merchant (hint: https://domainName/paytm/Standard/Response) - payment/paytm/callback_url - - - 1 - - - - - - Provided By Paytm - payment/paytm/transaction_url - - - - - Provided By Paytm - payment/paytm/transaction_status_url - - - - - - - Provided By Paytm - payment/paytm/Industry_id - - - - - - Provided By Paytm - payment/paytm/Channel_Id - - - - - - Provided By Paytm - payment/paytm/Website - - - - - - Magento\Sales\Model\Config\Source\Order\Status\Processing - payment/paytm/order_status - - - - - - validate-number - payment/paytm/sort_order - - - - - - Magento\Payment\Model\Config\Source\Allspecificcountries - payment/paytm/allowspecific - - - - - Magento\Directory\Model\Config\Source\Country - payment/paytm/specificcountry - - - - - - Selecting yes, will show Promo Code field at Checkout. - Magento\Config\Model\Config\Source\Yesno - - - - - Validate applied Promo Code before proceeding to Paytm payment page. Transaction will be failed in case of Promo Code failure at Paytm's end. - Magento\Config\Model\Config\Source\Yesno - - - - - These promo codes must be configured with your Paytm MID. Use comma ( , ) to separate multiple codes i.e. FB50,CASHBACK10 etc. - payment/paytm/promo_code - - -
-
-
\ No newline at end of file diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/di.xml b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/di.xml deleted file mode 100644 index ac6c650..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/di.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/paytm_version.txt b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/paytm_version.txt deleted file mode 100644 index 7f7fca6..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/paytm_version.txt +++ /dev/null @@ -1 +0,0 @@ -19-12-2018 \ No newline at end of file diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/registration.php b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/registration.php deleted file mode 100644 index b8e5255..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/registration.php +++ /dev/null @@ -1,7 +0,0 @@ -getMethod()->getDescription()): ?> - - \ No newline at end of file diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/view/frontend/web/js/view/payment/method-renderer/one97-paytm.js b/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/view/frontend/web/js/view/payment/method-renderer/one97-paytm.js deleted file mode 100644 index fde87c6..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/view/frontend/web/js/view/payment/method-renderer/one97-paytm.js +++ /dev/null @@ -1,115 +0,0 @@ -define( - [ - 'jquery', - 'Magento_Checkout/js/view/payment/default', - 'Magento_Checkout/js/action/place-order', - 'Magento_Checkout/js/action/select-payment-method', - 'Magento_Customer/js/model/customer', - 'Magento_Checkout/js/checkout-data', - 'Magento_Checkout/js/model/payment/additional-validators' - ], - function ($, Component, placeOrderAction, selectPaymentMethodAction, customer, checkoutData, additionalValidators) { - 'use strict'; - $('.errP').text(''); - var promo=''; - /*alert(window.checkoutConfig.payment.paytm.hide_promo_field); - alert($.trim(window.checkoutConfig.payment.paytm.promoCode)); - alert($.trim(window.checkoutConfig.payment.paytm.promoCode).length); - alert(window.checkoutConfig.payment.paytm.promoCode);*/ - if(window.checkoutConfig.payment.paytm.hide_promo_field=='1'){ - if(window.checkoutConfig.payment.paytm.promo_code_local_validation=='1' && ($.trim(window.checkoutConfig.payment.paytm.promoCode).length=='0' || $.trim(window.checkoutConfig.payment.paytm.promoCode)=='')){ - // $('.customDiv').css('display','block'); - }else{ - setTimeout(function(){ - $('.customDiv').css('display','block'); - }, 1000); - } - - } - $(document).on('click','.promoApplyBtn',function(){ - // alert(window.checkoutConfig.payment.paytm.promoCode); - if(window.checkoutConfig.payment.paytm.promo_code_local_validation=='1'){ - if($.trim($('.promoCodeField').val())==''){ - $('.errP').text('Please enter your promo code.'); - }else{ - var promoCode=window.checkoutConfig.payment.paytm.promoCode; - var promoCodeArr=promoCode.split(','); - var matchCode=0; - $.each(promoCodeArr, function( index, value ) { - if($.trim($('.promoCodeField').val())==$.trim(value )){ - matchCode=1; - } - }); - if(matchCode==1){ - $('.promoApplyBtn').val('Remove Code'); - $('.promoApplyBtn').addClass('promoRemoveBtn'); - $('.promoApplyBtn').removeClass('promoApplyBtn'); - $('.promoRemoveBtn').css('background','red'); - $('.promoRemoveBtn').css('border','1px solid red'); - $('.promoCodeField').attr('disabled',true); - $('.errP').text('Applied Successfully'); - promo=$.trim($('.promoCodeField').val()); - }else{ - $('.errP').text('Incorrect Promo Code'); - promo=''; - } - } - }else{ - $('.promoApplyBtn').val('Remove Code'); - $('.promoApplyBtn').addClass('promoRemoveBtn'); - $('.promoApplyBtn').removeClass('promoApplyBtn'); - $('.promoRemoveBtn').css('background','red'); - $('.promoRemoveBtn').css('border','1px solid red'); - $('.promoCodeField').attr('disabled',true); - $('.errP').text('Applied Successfully'); - promo=$.trim($('.promoCodeField').val()); - } - }); - $(document).on('click','.promoRemoveBtn',function(){ - $('.promoRemoveBtn').val('Apply'); - $('.promoRemoveBtn').addClass('promoApplyBtn'); - $('.promoRemoveBtn').removeClass('promoRemoveBtn'); - $('.promoApplyBtn').css('background','#006bb4'); - $('.promoApplyBtn').css('border','1px solid #006bb4'); - $('.promoCodeField').attr('disabled',false); - $('.promoCodeField').val(''); - $('.errP').text(''); - promo=''; - }); - return Component.extend({ - defaults: { - template: 'One97_Paytm/payment/one97' - }, - placeOrder: function (data, event) { - if (event) { - event.preventDefault(); - } - var self = this, - placeOrder, - emailValidationResult = customer.isLoggedIn(), - loginFormSelector = 'form[data-role=email-with-possible-login]'; - if (!customer.isLoggedIn()) { - $(loginFormSelector).validation(); - emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid()); - } - if (emailValidationResult && this.validate() && additionalValidators.validate()) { - this.isPlaceOrderActionAllowed(false); - placeOrder = placeOrderAction(this.getData(), false, this.messageContainer); - - $.when(placeOrder).fail(function () { - self.isPlaceOrderActionAllowed(true); - }).done(this.afterPlaceOrder.bind(this)); - return true; - } - return false; - }, - afterPlaceOrder: function () { - if(promo==''){ - $.mage.redirect(window.checkoutConfig.payment.paytm.redirectUrl); - }else{ - $.mage.redirect(window.checkoutConfig.payment.paytm.redirectUrl+"?promo="+promo); - } - } - }); - } -); \ No newline at end of file diff --git a/Magento_v2.x/Magento Plugin V2.0/readme.md b/Magento_v2.x/Magento Plugin V2.0/readme.md deleted file mode 100644 index a6189c8..0000000 --- a/Magento_v2.x/Magento Plugin V2.0/readme.md +++ /dev/null @@ -1,43 +0,0 @@ -# Magento 2.0:- - - 1. Download the plugin. - 2. Extract the files from the downloaded folder. - 3. Copy App folder from the required Magento version and place them into the root folder. If prompted to overwrite the files, click yes. - 4. Run below command: - php bin/magento module:enable One97_Paytm - php bin/magento setup:upgrade - php bin/magento setup:static-content:deploy - 5. Login to Magento Admin Panel and choose Payments Methods - System- > Configuration - > Payment Methods - 6. Enable Paytm option from Payment Methods - 7. Go to the Paytm PG Configuration and save below configuration - - * Enable - Yes - * Title - Paytm PG - * Merchant ID - MID provided by Paytm - * Merchant Key - Key provided by Paytm - * Transaction URL - * Staging - https://securegw-stage.paytm.in/theia/processTransaction - * Production - https://securegw.paytm.in/theia/processTransaction - * Transaction Status URL - * Staging - https://securegw-stage.paytm.in/merchant-status/getTxnStatus - * Production - https://securegw.paytm.in/merchant-status/getTxnStatus - * Website Name - * WEBSTAGING for Staging - * WEBPROD for Production - * Custom Callback Url - No - * Callback Url - customized callback url(this is visible when Custom Callback Url is yes) - * Industry Type - * Retail for staging - * Industry type for Production will be provided by Paytm - * Channel ID - WEB/WAP - * Sort Order - 2 - * Applicable Country - All allowed country - - 8. Please note if you have Linux server, please make sure folder permission are set to 755 & file permission to 644. - 9. Once plugin is installed, please logout from the admin panel and clear the cache of the Magento. - 10. Your plug-in is installed now, you can now make payment with Paytm. - -See Video : https://www.youtube.com/watch?v=bR18KwhY4V8 - -# In case of any query, please contact to Paytm. diff --git a/Magento_v2.x/Magento Plugin V2.0/readme.rtf b/Magento_v2.x/Magento Plugin V2.0/readme.rtf deleted file mode 100644 index 7af02e1..0000000 Binary files a/Magento_v2.x/Magento Plugin V2.0/readme.rtf and /dev/null differ diff --git a/Magento_v2.x/README.md b/Magento_v2.x/README.md index 525277e..e861f39 100644 --- a/Magento_v2.x/README.md +++ b/Magento_v2.x/README.md @@ -1,22 +1,2 @@ -# Paytm_Magento_v2.x_Kit - -Supported Versions -Paytm Plugin version V1.0 Magento supported version 2.0.X onward - -Installation and Configuration -upload app/code/One97 (all files and folder) at you server end. - -Run below command: -php bin/magento module:enable One97_Paytm -php bin/magento setup:upgrade -php bin/magento setup:static-content:deploy - -goto Admin->Store->Configuration->Sales->Payment Method->Paytm -fill details here and save them. - -goto Admin->System->Cache Management -Clear all Cache. - -Now you can collect payment via Paytm . - -See Video : https://www.youtube.com/watch?v=bR18KwhY4V8 \ No newline at end of file +# Paytm Payment plugin for Magento version 2.x +* Developer Docs: https://developer.paytm.com/docs/eCommerce-plugin/magento/#v2-x \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Block/Adminhtml/OrderEdit/Tab/View.php b/Magento_v2.x/app/code/One97/Paytm/Block/Adminhtml/OrderEdit/Tab/View.php new file mode 100755 index 0000000..90ac4d5 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Block/Adminhtml/OrderEdit/Tab/View.php @@ -0,0 +1,113 @@ +_coreRegistry = $registry; + $this->jsonHelper = $jsonHelper; + parent::__construct($context, $data); + } + + public function getOrder() { + return $this->_coreRegistry->registry('current_order'); + } + + public function getOrderId() { + return $this->getOrder()->getEntityId(); + } + + public function getOrderIncrementId() { + return $this->getOrder()->getIncrementId(); + } + + public function getTabLabel() { + return __('Paytm Response'); + } + + public function getTabTitle() { + return __('Paytm Response'); + } + + public function canShowTab() { + $magentoOrderId=$this->getOrderIncrementId(); + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $connection = $resource->getConnection(); + $tableName = $resource->getTableName('paytm_order_data'); + if($connection->isTableExists($tableName)){ + $sql = "Select * FROM ".$tableName." WHERE order_id=".$magentoOrderId." ORDER BY id DESC"; + $result = $connection->fetchAll($sql); + if(!empty($result)){ + if(isset($result[0]['paytm_response']) || trim($result[0]['paytm_response'])==''){ + return true; + }else{ + return false; + } + }else{ + return false; + } + }else{ + return false; + } + } + + public function isHidden() { + return false; + } + + public function getPaytmResponseHtml($viewButton=false) { + $response=' No Record '; + $magentoOrderId=$this->getOrderIncrementId(); + + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface'); + $fetchStatusURL=$storeManager->getStore()->getBaseUrl().'paytm/Standard/Fetchstatus/'; + + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $connection = $resource->getConnection(); + $tableName = $resource->getTableName('paytm_order_data'); + $sql = "Select * FROM ".$tableName." WHERE order_id=".$magentoOrderId." ORDER BY id DESC"; //take always letest response + $result = $connection->fetchAll($sql); + $resArr=array(); + $button=''; + if(!empty($result)){ + $fetchStatusURL.='?fetchId='.$result[0]['id']; + if(trim($result[0]['paytm_response'])!=''){ + $resArr=$this->jsonHelper->jsonDecode($result[0]['paytm_response']); + $response=''; + ksort($resArr); + foreach ($resArr as $k => $val) { + switch ($k) { + case 'CHECKSUMHASH': + break; + case 'STATUS': + $response.=' '.$k.' '.$val.' '; + $val!='TXN_SUCCESS'?$button='':''; + break; + + default: + $response.=' '.$k.' '.$val.' '; + break; + } + } + }else{ + $button=''; + } + } + if($viewButton){ + return $button; + }else{ + return $response; + } + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Block/Form/Paytm.php b/Magento_v2.x/app/code/One97/Paytm/Block/Form/Paytm.php new file mode 100755 index 0000000..8dd2c62 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Block/Form/Paytm.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Block/Info/Paytm.php b/Magento_v2.x/app/code/One97/Paytm/Block/Info/Paytm.php new file mode 100755 index 0000000..bd53f36 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Block/Info/Paytm.php @@ -0,0 +1,15 @@ +get('\Magento\Store\Model\StoreManagerInterface'); + $fetchStatusURL=$storeManager->getStore()->getBaseUrl(); + return $fetchStatusURL; + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Controller/Paytm.php b/Magento_v2.x/app/code/One97/Paytm/Controller/Paytm.php new file mode 100755 index 0000000..f1000d4 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Controller/Paytm.php @@ -0,0 +1,100 @@ +_customerSession = $customerSession; + $this->_checkoutSession = $checkoutSession; + $this->_orderFactory = $orderFactory; + $this->_logger = $logger; + $this->_orderHistoryFactory = $orderHistoryFactory; + $this->_paytmModel = $paytmModel; + $this->_paytmHelper = $paytmHelper; + $this->resultJsonFactory = $resultJsonFactory; + $this->jsonHelper = $jsonHelper; + $this->resultPageFactory = $resultPageFactory; + $this->messageManager = $messageManager; + parent::__construct($context); + } + + protected function _cancelPayment($errorMsg = '') { + $gotoSection = false; + $this->_paytmHelper->cancelCurrentOrder($errorMsg); + if ($this->_checkoutSession->restoreQuote()) { + $gotoSection = 'paymentMethod'; + } + return $gotoSection; + } + + protected function getOrderById($order_id) { + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $order = $objectManager->get('Magento\Sales\Model\Order'); + $order_info = $order->loadByIncrementId($order_id); + return $order_info; + } + + protected function getOrder() { + return $this->_orderFactory->create()->loadByIncrementId( + $this->_checkoutSession->getLastRealOrderId() + ); + } + + protected function addOrderHistory($order,$comment){ + $history = $this->_orderHistoryFactory->create() + ->setComment($comment) + ->setEntityName('order') + ->setOrder($order); + $history->save(); + return true; + } + + protected function getQuote() { + if (!$this->_quote) { + $this->_quote = $this->_getCheckoutSession()->getQuote(); + } + return $this->_quote; + } + + protected function getCheckoutSession() { + return $this->_checkoutSession; + } + + protected function getCustomerSession() { + return $this->_customerSession; + } + + protected function getPaytmModel() { + return $this->_paytmModel; + } + + protected function getPaytmHelper() { + return $this->_paytmHelper; + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Curlconfig.php b/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Curlconfig.php new file mode 100755 index 0000000..377e9bd --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Curlconfig.php @@ -0,0 +1,50 @@ +getRequest()->getParams(); + $resultJson = $this->resultJsonFactory->create(); + if(isset($reqData['getlastUpdate'])){ + $getLastUpdate=$this->getPaytmModel()->getLastUpdate(); + $getLastUpdateArr=explode('|',$getLastUpdate); + return $resultJson->setData(['version' => $getLastUpdateArr[0], 'lastupdate' => $getLastUpdateArr[1], 'phpCurlVersion' => $this->getPaytmModel()->getcURLversion(), 'paytmPluginVersion' => $this->getPaytmModel()->getpluginversion()]); + }else{ + $responseTableBody=''; + $response=false; + $transactionURL=$this->getPaytmModel()->getNewStatusQueryUrl(); + $ch = curl_init($transactionURL); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $res = curl_exec($ch); + $response = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + $returnResponse="Curl is not enable for external IP. Please enable this by your domain provider."; + switch ($response) { + case '403': + if (strpos($res, "Access Denied") == false) { + } else { + $returnResponse="Your domain is not whitelisted on Paytm side. Please request to Paytm for whitelisting your public IP."; + } + break; + case '200': + if(json_decode($res)==null){ + }else{ + $returnResponse="All is done."; + } + break; + + default: + # code... + break; + } + // $this->messageManager->addWarningMessage( __($returnResponse) ); + return $resultJson->setData(['response' => $response,'responseTableBody' => $returnResponse]); + } + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Curltest.php b/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Curltest.php new file mode 100755 index 0000000..c19d52e --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Curltest.php @@ -0,0 +1,65 @@ +getRequest()->getParams(); + if(!empty($getData)){ + foreach ($getData as $key => $value) { + $testing_urls[]=$value; + } + }else{ + $currentPath = $_SERVER['PHP_SELF']; + $pathInfo = pathinfo($currentPath); + $hostName = $_SERVER['HTTP_HOST']; + + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface'); + $fetchStatusURL=$storeManager->getStore()->getBaseUrl(); + + $testing_urls = array( + $fetchStatusURL, + "https://www.gstatic.com/generate_204", + $this->getPaytmHelper()::TRANSACTION_STATUS_URL_PRODUCTION, + $this->getPaytmHelper()::TRANSACTION_STATUS_URL_STAGING + ); + } + foreach($testing_urls as $key=>$url){ + $debug[$key]["info"][] = "Connecting to " . $url . " using cURL"; + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $res = curl_exec($ch); + if (!curl_errno($ch)) { + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $debug[$key]["info"][] = "cURL executed succcessfully."; + $debug[$key]["info"][] = "HTTP Response Code: ". $http_code . ""; + } else { + $debug[$key]["info"][] = "Connection Failed !!"; + $debug[$key]["info"][] = "Error Code: " . curl_errno($ch) . ""; + $debug[$key]["info"][] = "Error: " . curl_error($ch) . ""; + } + if((in_array($url, array($this->getPaytmHelper()::TRANSACTION_STATUS_URL_PRODUCTION , $this->getPaytmHelper()::TRANSACTION_STATUS_URL_STAGING)))){ + $debug[$key]["info"][] = "Response:
" . $res; + } + curl_close($ch); + } + } + foreach($debug as $k=>$v){ + echo "
    "; + foreach($v["info"] as $info){ + echo "
  • ".$info."
  • "; + } + echo "
"; + echo "
"; + } + die; + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Fetchstatus.php b/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Fetchstatus.php new file mode 100755 index 0000000..65d6803 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Fetchstatus.php @@ -0,0 +1,86 @@ +getRequest()->getParams(); + $responseTableBody=''; + $response=false; + // echo "test"; + if(isset($reqData['fetchId'])){ + if(trim($reqData['fetchId'])!='' && $this->getPaytmHelper()::SAVE_PAYTM_RESPONSE){ + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $connection = $resource->getConnection(); + $tableName = $resource->getTableName('paytm_order_data'); + $sql = "Select * FROM ".$tableName." WHERE id=".$reqData['fetchId']; + $result = $connection->fetchAll($sql); + $requestParamList = array("MID" => $this->getPaytmModel()->getMID() , "ORDERID" => $result[0]['paytm_order_id']); + $StatusCheckSum = $this->getPaytmModel()->generateStatusChecksum($requestParamList); + $requestParamList['CHECKSUMHASH'] = $StatusCheckSum; + $check_status_url = $this->getPaytmModel()->getNewStatusQueryUrl(); + $responseParamList = $this->getPaytmHelper()->executecUrl($check_status_url, $requestParamList); + if(!empty($responseParamList)){ + $objDate = $objectManager->create('Magento\Framework\Stdlib\DateTime\DateTime'); + $date = $objDate->gmtDate(); + + $paytmRes=$this->jsonHelper->jsonEncode($responseParamList); + $sql = "UPDATE ".$tableName." SET transaction_id='".$responseParamList['TXNID']."', paytm_response='".$paytmRes."', status='1', date_modified='".$date."' where id=".$reqData['fetchId']; + $connection->query($sql); + ksort($responseParamList); + foreach ($responseParamList as $k => $val) { + switch ($k) { + case 'CHECKSUMHASH': + break; + case 'STATUS': + $responseTableBody.=' '.$k.' '.$val.' '; + break; + + default: + $responseTableBody.=' '.$k.' '.$val.' '; + break; + } + } + $order = $this->getOrderById($result[0]['order_id']); + if($responseParamList['STATUS']=='TXN_SUCCESS'){ + $autoInvoice = $this->getPaytmModel()->autoInvoiceGen(); + if($autoInvoice=='authorize_capture'){ + $payment = $order->getPayment(); + $payment->setTransactionId($responseParamList['TXNID']) + ->setPreparedMessage(__('Paytm transaction has been successful.')) + ->setShouldCloseParentTransaction(true) + ->setIsTransactionClosed(0) + ->setAdditionalInformation(['One97','paytm']) + ->registerCaptureNotification( + $responseParamList['TXNAMOUNT'], + true + ); + $invoice = $payment->getCreatedInvoice(); + } + $comment = "Transaction has marked as successfull by checkStatus API."; + $order->setState("complete"); + $order->setStatus($this->_paytmModel->getSuccessOrderStatus()); + $order->setExtOrderId($result[0]['paytm_order_id']); + $order->addStatusToHistory($order->getStatus(), $comment); + $order->save(); + $response=true; + }else if($responseParamList['STATUS']=="TXN_FAILURE"){ + $comment = $responseParamList['RESPMSG']; + $order->setState("canceled")->setStatus($this->_paytmModel->getFailOrderStatus()); + $order->addStatusToHistory($order->getStatus(), $comment); + $order->save(); + } + } + } + } + + $resultJson = $this->resultJsonFactory->create(); + return $resultJson->setData(['response' => $response,'responseTableBody' => $responseTableBody]); + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Redirect.php b/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Redirect.php new file mode 100755 index 0000000..82a0220 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Redirect.php @@ -0,0 +1,37 @@ +getOrder(); + if ($order->getBillingAddress()) { + $order->setState("pending_payment")->setStatus("pending_payment"); + $order->addStatusToHistory($order->getStatus(), "Customer was redirected to paytm."); + $order->save(); + if($promo!=''){ + $order->paytmPromoCode=$promo; + } + $data['inputForm']=$this->_paytmModel->buildPaytmRequest($order); + $data['actionURL']=$this->_paytmModel->getRedirectUrl(); + $resultPage = $this->resultPageFactory->create(); + $resultPage->getLayout()->initMessages(); + $resultPage->getLayout()->getBlock('paytm_standard_redirect')->setName($data); + return $resultPage; + } else { + $this->_cancelPayment(); + $this->_paytmSession->restoreQuote(); + $this->getResponse()->setRedirect( + $this->getPaytmHelper()->getUrl('checkout') + ); + } + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Response.php b/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Response.php new file mode 100755 index 0000000..d588518 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Controller/Standard/Response.php @@ -0,0 +1,207 @@ + $val){ + if($key != "CHECKSUMHASH"){ + $comment .= $key . "=" . $val . ", \n
"; + } + } + } + + // var_dump($this->getPaytmHelper()::SAVE_PAYTM_RESPONSE);die; + $errorMsg = ''; + $successFlag = false; + $resMessage=$this->getRequest()->getParam('RESPMSG'); + $globalErrMass="Your payment has been failed!"; + if(trim($resMessage)!=''){ + $globalErrMass.=" Reason: ".$resMessage; + } + $returnUrl = $this->getPaytmHelper()->getUrl('/'); + $orderMID = $this->getRequest()->getParam('MID'); + $paytmOrderId = $this->getRequest()->getParam('ORDERID'); + $magentoOrderIdArr=explode('_', $paytmOrderId); + $magentoOrderId=$magentoOrderIdArr[0]; + $orderTXNID = $this->getRequest()->getParam('TXNID'); + $paytmResponse=$this->getRequest()->getParams(); + $paytmJsonResponse=json_encode($paytmResponse); + + if(trim($paytmOrderId)!='' && trim($orderMID)!=''){ + $order = $this->getOrderById($magentoOrderId); + $orderTotal = round($order->getGrandTotal(), 2); + $orderStatus = $this->getRequest()->getParam('STATUS'); + $resCode = $this->getRequest()->getParam('RESPCODE'); + $orderTxnAmount = $this->getRequest()->getParam('TXNAMOUNT'); + $transactionResponse=""; + $paytmJsonResponseOnPending=''; + if($this->getPaytmModel()->validateResponse($request, $magentoOrderId)) { + if($this->getPaytmHelper()::SAVE_PAYTM_RESPONSE){ + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $objDate = $objectManager->create('Magento\Framework\Stdlib\DateTime\DateTime'); + $date = $objDate->gmtDate(); + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $tableName = $resource->getTableName('paytm_order_data'); + $sql = "UPDATE ".$tableName." SET transaction_id='".$orderTXNID."', paytm_response='".$paytmJsonResponse."', date_modified='".$date."' WHERE order_id='".$magentoOrderId."' AND paytm_order_id='".$paytmOrderId."'"; + $this->updateTable($sql); + } + if($orderStatus == "TXN_SUCCESS"){ + $requestParamList = array("MID" => $orderMID , "ORDERID" => $paytmOrderId); + $responseParamList=$this->checkStatusCall($requestParamList); + if(isset($responseParamList['STATUS'])){ + if($responseParamList['STATUS'] == "PENDING"){ + $transactionResponse="PENDING"; + }else{ + if($responseParamList['STATUS']=='TXN_SUCCESS' && $responseParamList['TXNAMOUNT']==$orderTxnAmount) { + $transactionResponse="PROCESSING"; + } else{ + $transactionResponse="CANCELED"; + } + } + }else{ + $transactionResponse="FRAUD"; + } + }else{ + if($orderStatus == "PENDING"){ + $requestParamList = array("MID" => $orderMID , "ORDERID" => $paytmOrderId); + $responseParamList=$this->checkStatusCall($requestParamList); + if(isset($responseParamList['STATUS'])){ + if($responseParamList['STATUS'] == "PENDING"){ + $transactionResponse="PENDING"; + }else{ + if($responseParamList['STATUS']=='TXN_SUCCESS' && $responseParamList['TXNAMOUNT']==$orderTxnAmount) { + $transactionResponse="PROCESSING"; + $paytmJsonResponseOnPending=json_encode($responseParamList); + } else{ + $transactionResponse="CANCELED"; + } + } + }else{ + $transactionResponse="FRAUD"; + } + }else{ + $transactionResponse="CANCELED"; + } + } + } else { + $transactionResponse="FRAUD_CHECKSUM_MISMATCH"; + } + + switch ($transactionResponse) { + case 'FRAUD': + $errorMsg = 'It seems some issue in server to server communication. Kindly connect with administrator.'; + $comment .= "Fraud Detucted"; + $order->setStatus($order::STATUS_FRAUD); + $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); + break; + case "FRAUD_CHECKSUM_MISMATCH": + $errorMsg = $globalErrMass." Reason: Checksum Mismatch."; + $comment .= "Fraud Detucted"; + $order->setState("canceled")->setStatus($order::STATUS_FRAUD); + $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); + break; + case "CANCELED": + if($orderStatus == "PENDING"){ + $errorMsg = 'Paytm Transaction Pending!'; + if(trim($resMessage)==''){ + $errorMsg.=" Reason: ".$resMessage; + } + $comment .= "Pending"; + $order->setState("pending_payment")->setStatus("pending_payment"); + }else{ + $this->getPaytmHelper()->updateStockQty($order); + $errorMsg = $globalErrMass; + $comment .= $globalErrMass; + $order->setState("canceled")->setStatus($this->_paytmModel->getFailOrderStatus()); + } + $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); + break; + case "PROCESSING": + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $tableName = $resource->getTableName('paytm_order_data'); + $paytmJsonResponseOnPending==''?$sql="UPDATE ".$tableName." SET status='1' WHERE order_id='".$magentoOrderId."' AND paytm_order_id='".$paytmOrderId."'":$sql = "UPDATE ".$tableName." SET status='1', paytm_response='".$paytmJsonResponseOnPending."' WHERE order_id='".$magentoOrderId."' AND paytm_order_id='".$paytmOrderId."'"; + if($this->getPaytmHelper()::SAVE_PAYTM_RESPONSE){ + $this->updateTable($sql); + } + $autoInvoice = $this->getPaytmModel()->autoInvoiceGen(); + if($autoInvoice=='authorize_capture'){ + $payment = $order->getPayment(); + $payment->setTransactionId($orderTXNID) + ->setPreparedMessage(__('Paytm transaction has been successful.')) + ->setShouldCloseParentTransaction(true) + ->setIsTransactionClosed(0) + ->setAdditionalInformation(['One97','paytm']) + ->registerCaptureNotification( + $responseParamList['TXNAMOUNT'], + true + ); + $invoice = $payment->getCreatedInvoice(); + } + $successFlag = true; + $comment .= "Success "; + $order->setState("complete"); + $order->setStatus($this->_paytmModel->getSuccessOrderStatus()); + $order->setExtOrderId($paytmOrderId); + $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/success'); + break; + case "PENDING": + $errorMsg = 'Paytm Transaction Pending!'; + if(trim($resMessage)==''){ + $errorMsg.=" Reason: ".$resMessage; + } + $comment .= "Pending"; + $order->setState("pending_payment")->setStatus("pending_payment"); + $returnUrl = $this->getPaytmHelper()->getUrl('checkout/onepage/failure'); + break; + + default: + # code... + break; + } + $order->addStatusToHistory($order->getStatus(), $comment); + $order->save(); + if($successFlag){ + $this->messageManager->addSuccess( __('Paytm transaction has been successful.') ); + }else{ + $this->messageManager->addError( __($errorMsg) ); + } + } + $this->getResponse()->setRedirect($returnUrl); + } + + /* Paytm transaction status S2S call */ + public function checkStatusCall($requestParamList){ + $response=array(); + if(!empty($requestParamList)){ + $StatusCheckSum = $this->getPaytmModel()->generateStatusChecksum($requestParamList); + $requestParamList['CHECKSUMHASH'] = $StatusCheckSum; + $check_status_url = $this->getPaytmModel()->getNewStatusQueryUrl(); + $responseParamList=array(); + $retry = $this->getPaytmHelper()::MAX_RETRY_COUNT; + do{ + $response = $this->getPaytmHelper()->executecUrl($check_status_url, $requestParamList); + $retry++; + } while(empty($response) && $retry < $retry); + } + return $response; + } + + public function updateTable($sql){ + $updateDone=false; + if(trim($sql)!=''){ + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $connection = $resource->getConnection(); + $sql = $sql; + $connection->query($sql); + $updateDone=true; + } + return $updateDone; + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Helper/Data.php b/Magento_v2.x/app/code/One97/Paytm/Helper/Data.php new file mode 100755 index 0000000..d1cf733 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Helper/Data.php @@ -0,0 +1,261 @@ +session = $session; + $this->stockRegistry = $stockRegistry; + parent::__construct($context); + } + + public function updateStockQty($order) { + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $stockItem = $objectManager->create('\Magento\CatalogInventory\Model\Stock\StockItemRepository'); + $orderItems = $order->getAllItems(); + foreach ($orderItems as $item) { + $product_id = $item->getProductId(); + + $sku = $item->getSku(); + $current_qty = $this->stockRegistry->getStockItemBySku($sku)->getQty(); + $order_qty = (int)$item->getQtyOrdered(); + $update_stock_qty = $current_qty + $order_qty; + + $stockItem = $this->stockRegistry->getStockItemBySku($sku); + $stockItem->setQty($update_stock_qty); + $stockItem->setIsInStock((bool)$update_stock_qty); // this line + $this->stockRegistry->updateStockItemBySku($sku, $stockItem); + } + } + + public function cancelCurrentOrder($comment) { + $order = $this->session->getLastRealOrder(); + if ($order->getId() && $order->getState() != Order::STATE_CANCELED) { + $order->registerCancellation($comment)->save(); + return true; + } + return false; + } + + public function restoreQuote() { + return $this->session->restoreQuote(); + } + + public function getUrl($route, $params = []) { + return $this->_getUrl($route, $params); + } + + // PaytmChecksum.php start + private static $iv = "@@@@&&&&####$$$$"; + + static public function encrypt($input, $key) { + $key = html_entity_decode($key); + + if(function_exists('openssl_encrypt')){ + $data = openssl_encrypt ( $input , "AES-128-CBC" , $key, 0, self::$iv ); + } else { + $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, 'cbc'); + $input = self::pkcs5Pad($input, $size); + $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', ''); + mcrypt_generic_init($td, $key, self::$iv); + $data = mcrypt_generic($td, $input); + mcrypt_generic_deinit($td); + mcrypt_module_close($td); + $data = base64_encode($data); + } + return $data; + } + + static public function decrypt($encrypted, $key) { + $key = html_entity_decode($key); + + if(function_exists('openssl_decrypt')){ + $data = openssl_decrypt ( $encrypted , "AES-128-CBC" , $key, 0, self::$iv ); + } else { + $encrypted = base64_decode($encrypted); + $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', ''); + mcrypt_generic_init($td, $key, self::$iv); + $data = mdecrypt_generic($td, $encrypted); + mcrypt_generic_deinit($td); + mcrypt_module_close($td); + $data = self::pkcs5Unpad($data); + $data = rtrim($data); + } + return $data; + } + + static public function generateSignature($params, $key) { + if(!is_array($params) && !is_string($params)){ + throw new Exception("string or array expected, ".gettype($params)." given"); + } + if(is_array($params)){ + $params = self::getStringByParams($params); + } + return self::generateSignatureByString($params, $key); + } + + static public function verifySignature($params, $key, $checksum){ + if(!is_array($params) && !is_string($params)){ + throw new Exception("string or array expected, ".gettype($params)." given"); + } + if(is_array($params)){ + $params = self::getStringByParams($params); + } + return self::verifySignatureByString($params, $key, $checksum); + } + + static private function generateSignatureByString($params, $key){ + $salt = self::generateRandomString(4); + return self::calculateChecksum($params, $key, $salt); + } + + static private function verifySignatureByString($params, $key, $checksum){ + $paytm_hash = self::decrypt($checksum, $key); + $salt = substr($paytm_hash, -4); + return $paytm_hash == self::calculateHash($params, $salt) ? true : false; + } + + static private function generateRandomString($length) { + $random = ""; + srand((double) microtime() * 1000000); + + $data = "9876543210ZYXWVUTSRQPONMLKJIHGFEDCBAabcdefghijklmnopqrstuvwxyz!@#$&_"; + + for ($i = 0; $i < $length; $i++) { + $random .= substr($data, (rand() % (strlen($data))), 1); + } + + return $random; + } + + static private function getStringByParams($params) { + ksort($params); + $params = array_map(function ($value){ + return ($value == null) ? "" : $value; + }, $params); + return implode("|", $params); + } + + static private function calculateHash($params, $salt){ + $finalString = $params . "|" . $salt; + $hash = hash("sha256", $finalString); + return $hash . $salt; + } + + static private function calculateChecksum($params, $key, $salt){ + $hashString = self::calculateHash($params, $salt); + return self::encrypt($hashString, $key); + } + + static private function pkcs5Pad($text, $blocksize) { + $pad = $blocksize - (strlen($text) % $blocksize); + return $text . str_repeat(chr($pad), $pad); + } + + static private function pkcs5Unpad($text) { + $pad = ord($text{strlen($text) - 1}); + if ($pad > strlen($text)) + return false; + return substr($text, 0, -1 * $pad); + } + // PaytmChecksum.php end + + // PaytmHelper.php start + /** + * exclude timestap with order id + */ + public static function getTransactionURL($isProduction = 0){ + if($isProduction == 1){ + return Data::TRANSACTION_URL_PRODUCTION; + }else{ + return Data::TRANSACTION_URL_STAGING; + } + } + /** + * exclude timestap with order id + */ + public static function getTransactionStatusURL($isProduction = 0){ + if($isProduction == 1){ + return Data::TRANSACTION_STATUS_URL_PRODUCTION; + }else{ + return Data::TRANSACTION_STATUS_URL_STAGING; + } + } + + public static function getcURLversion(){ + if(function_exists('curl_version')){ + $curl_version = curl_version(); + if(!empty($curl_version['version'])){ + return $curl_version['version']; + } + } + return false; + } + + public static function executecUrl($apiURL, $requestParamList) { + $responseParamList = array(); + $JsonData = json_encode($requestParamList); + $postData = 'JsonData='.urlencode($JsonData); + $ch = curl_init($apiURL); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, Data::CONNECT_TIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, Data::TIMEOUT); + + /* + ** default value is 2 and we also want to use 2 + ** so no need to specify since older PHP version might not support 2 as valid value + ** see https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html + */ + // curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 2); + + // TLS 1.2 or above required + // curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); + + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json', + 'Content-Length: ' . strlen($postData)) + ); + $jsonResponse = curl_exec($ch); + + if (!curl_errno($ch)) { + return json_decode($jsonResponse, true); + } else { + return false; + } + } + // PaytmHelper.php start + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Model/EnvAction.php b/Magento_v2.x/app/code/One97/Paytm/Model/EnvAction.php new file mode 100755 index 0000000..25bdd86 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Model/EnvAction.php @@ -0,0 +1,13 @@ + '0', 'label' => __('Staging')], ['value' => '1', 'label' => __('Production')]]; + } + + public function toArray() { + return [0 => __('No'), 1 => __('Yes')]; + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Model/PaymentAction.php b/Magento_v2.x/app/code/One97/Paytm/Model/PaymentAction.php new file mode 100755 index 0000000..d405307 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Model/PaymentAction.php @@ -0,0 +1,13 @@ + 'authorize_capture', 'label' => __('Yes')], ['value' => 'capture', 'label' => __('No')]]; + } + + public function toArray() { + return [0 => __('No'), 1 => __('Yes')]; + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Model/Paytm.php b/Magento_v2.x/app/code/One97/Paytm/Model/Paytm.php new file mode 100755 index 0000000..069cb6a --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Model/Paytm.php @@ -0,0 +1,199 @@ +helper = $helper; + parent::__construct( + $context, + $registry, + $extensionFactory, + $customAttributeFactory, + $paymentData, + $scopeConfig, + $logger + ); + $this->_minAmount = "0.50"; + $this->_maxAmount = "1000000"; + $this->urlBuilder = $urlBuilder; + } + + public function initialize($paymentAction, $stateObject) { + $payment = $this->getInfoInstance(); + $order = $payment->getOrder(); + $order->setCanSendNewEmailFlag(false); + $stateObject->setState(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT); + $stateObject->setStatus('pending_payment'); + $stateObject->setIsNotified(false); + } + + /* this function check ammount limit */ + public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { + if ($quote && ( + $quote->getBaseGrandTotal() < $this->_minAmount || ($this->_maxAmount && $quote->getBaseGrandTotal() > $this->_maxAmount)) + ) { + return false; + } + return parent::isAvailable($quote); + } + + /* this function for currency check*/ + public function canUseForCurrency($currencyCode) { + if (!in_array($currencyCode, $this->_supportedCurrencyCodes)) { + return false; + } + return true; + } + + /* this function return Paytm redirect form post */ + public function buildPaytmRequest($order) { + $paytmOrderId=$magentoOrderId=$order->getRealOrderId(); + if($this->helper::APPEND_TIMESTAMP){ + $paytmOrderId=$magentoOrderId.'_'.time(); + } + + if($this->helper::SAVE_PAYTM_RESPONSE){ + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + + $objDate = $objectManager->create('Magento\Framework\Stdlib\DateTime\DateTime'); + $date = $objDate->gmtDate(); + + $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $connection = $resource->getConnection(); + + $tableName = $resource->getTableName('paytm_order_data'); + if(!$connection->isTableExists($tableName)){ + $sql = "CREATE TABLE ".$tableName."(id INT(11) PRIMARY KEY AUTO_INCREMENT, order_id TEXT NOT NULL, paytm_order_id TEXT NOT NULL, transaction_id TEXT, status TINYINT(1) DEFAULT '0', paytm_response TEXT, date_added DATETIME, date_modified DATETIME )"; + $connection->query($sql); + } + $tableName = $resource->getTableName('paytm_order_data'); + $sql = "INSERT INTO ".$tableName."(order_id, paytm_order_id, date_added, date_modified) VALUES ('".$magentoOrderId."', '".$paytmOrderId."', '".$date."', '".$date."')"; + $connection->query($sql); + } + + $callBackUrl=$this->urlBuilder->getUrl('paytm/Standard/Response', ['_secure' => true]); + if($this->helper::CUSTOM_CALLBACK_URL!=''){ + $callBackUrl=$this->helper::CUSTOM_CALLBACK_URL; + } + if($this->getConfigData("custom_callbackurl")=='1'){ + $callBackUrl=$this->getConfigData("callback_url")!=''?$this->getConfigData("callback_url"):$callBackUrl; + } + $params = array( + 'MID' => trim($this->getConfigData("MID")), + 'TXN_AMOUNT' => round($order->getGrandTotal(), 2), + 'CHANNEL_ID' => $this->helper::CHANNEL_ID, + 'INDUSTRY_TYPE_ID' => trim($this->getConfigData("Industry_id")), + 'WEBSITE' => trim($this->getConfigData("Website")), + 'CUST_ID' => $order->getCustomerEmail(), + 'ORDER_ID' => $paytmOrderId, + 'EMAIL' => $order->getCustomerEmail(), + 'CALLBACK_URL' => trim($callBackUrl) + ); + if(isset($order->paytmPromoCode)){ + $params['PROMO_CAMP_ID']=$order->paytmPromoCode; + } + $checksum = $this->helper->generateSignature($params, $this->getConfigData("merchant_key")); + $params['CHECKSUMHASH'] = $checksum; + + $version = $this->getLastUpdate(); + $params['X-REQUEST-ID']=$this->helper::X_REQUEST_ID.str_replace('|', '_', str_replace(' ', '-', $version)); + $inputForm=''; + foreach ($params as $key => $value) { + $inputForm.=""; + } + return $inputForm; + } + + /* this function for checksum validation */ + public function validateResponse($res,$order_id) { + $checksum = @$res["CHECKSUMHASH"]; + unset($res["CHECKSUMHASH"]); + if ($this->helper->verifySignature($res,$this->getConfigData("merchant_key"),$checksum)) { + $result = true; + } else { + $result = false; + } + return $result; + } + + /* this function for php curl version */ + public function getcURLversion() { + return $this->helper->getcURLversion(); + } + + /* this function for php curl version */ + public function getpluginversion() { + return $this->helper::PLUGIN_VERSION; + } + + /* this function for genrating checksum */ + public function generateStatusChecksum($requestParamList) { + $result = $this->helper->generateSignature($requestParamList,$this->getConfigData("merchant_key")); + return $result; + } + + /* this function for return MID */ + public function getMID() { + return $this->getConfigData("MID"); + } + + public function autoInvoiceGen() { + $result = $this->getConfigData("payment_action"); + return $result; + } + + /* this function return transaction URL from admin config */ + public function getRedirectUrl() { + return $this->helper->getTransactionURL($this->getConfigData('environment')); + } + + /* this function return transaction status URL from admin config */ + public function getNewStatusQueryUrl() { + return $this->helper->getTransactionStatusURL($this->getConfigData('environment')); + } + + /* this function return success order status */ + public function getSuccessOrderStatus() { + return $this->getConfigData("success_order_status"); + } + + /* this function return fail order status */ + public function getFailOrderStatus() { + return $this->getConfigData("fail_order_status"); + } + + /* this function return Magento version and last update date of plugin */ + public function getLastUpdate(){ + $objectManagerVs = \Magento\Framework\App\ObjectManager::getInstance(); + $productMetadata = $objectManagerVs->get('Magento\Framework\App\ProductMetadataInterface'); + $version = $productMetadata->getVersion(); + + $lastUpdated=date('d M Y',strtotime($this->helper::LAST_UPDATED)); + return $version."|".$lastUpdated; + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Model/PaytmConfigProvider.php b/Magento_v2.x/app/code/One97/Paytm/Model/PaytmConfigProvider.php new file mode 100755 index 0000000..79f3e3d --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Model/PaytmConfigProvider.php @@ -0,0 +1,27 @@ +method = $paymentHelper->getMethodInstance($this->methodCode); + $this->urlBuilder = $urlBuilder; + } + + public function getConfig() { + return $this->method->isAvailable() ? [ + 'payment' => [ + 'paytm' => [ + 'redirectUrl' => $this->urlBuilder->getUrl('paytm/Standard/Redirect', ['_secure' => true]) + ] + ] + ] : []; + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Model/SuccessFailStatus.php b/Magento_v2.x/app/code/One97/Paytm/Model/SuccessFailStatus.php new file mode 100755 index 0000000..97e6591 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Model/SuccessFailStatus.php @@ -0,0 +1,19 @@ +statusCollectionFactory = $statusCollectionFactory; + } + + public function toOptionArray() { + $options = $this->statusCollectionFactory->create()->toOptionArray(); + return $options; + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Observer/SendMailOnOrderSuccess.php b/Magento_v2.x/app/code/One97/Paytm/Observer/SendMailOnOrderSuccess.php new file mode 100755 index 0000000..8cf5b37 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Observer/SendMailOnOrderSuccess.php @@ -0,0 +1,29 @@ +orderModel = $orderModel; + $this->orderSender = $orderSender; + $this->checkoutSession = $checkoutSession; + } + + public function execute(\Magento\Framework\Event\Observer $observer) { + $orderIds = $observer->getEvent()->getOrderIds(); + if(count($orderIds)) { + $this->checkoutSession->setForceOrderMailSentOnSuccess(true); + $order = $this->orderModel->create()->load($orderIds[0]); + $this->orderSender->send($order, true); + } + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Plugin/Sales/Order/Email/Container/OrderIdentityPlugin.php b/Magento_v2.x/app/code/One97/Paytm/Plugin/Sales/Order/Email/Container/OrderIdentityPlugin.php new file mode 100755 index 0000000..cff67d7 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Plugin/Sales/Order/Email/Container/OrderIdentityPlugin.php @@ -0,0 +1,26 @@ +checkoutSession = $checkoutSession; + } + + public function aroundIsEnabled(\Magento\Sales\Model\Order\Email\Container\OrderIdentity $subject, callable $proceed) { + $returnValue = $proceed(); + $forceOrderMailSentOnSuccess = $this->checkoutSession->getForceOrderMailSentOnSuccess(); + if(isset($forceOrderMailSentOnSuccess) && $forceOrderMailSentOnSuccess) { + if($returnValue) + $returnValue = false; + else + $returnValue = true; + $this->checkoutSession->unsForceOrderMailSentOnSuccess(); + } + return $returnValue; + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/Setup/InstallSchema.php b/Magento_v2.x/app/code/One97/Paytm/Setup/InstallSchema.php new file mode 100755 index 0000000..60c1644 --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/Setup/InstallSchema.php @@ -0,0 +1,78 @@ +startSetup(); + $conn = $setup->getConnection(); + $tableName = $setup->getTable('paytm_order_data'); + if($conn->isTableExists($tableName) != true){ + $table = $conn->newTable($tableName) + ->addColumn( + 'id', + Table::TYPE_INTEGER, + null, + ['identity'=>true,'unsigned'=>true,'nullable'=>false,'primary'=>true], + 'ID' + ) + ->addColumn( + 'order_id', + Table::TYPE_TEXT, + null, + ['nullable'=>false,'default'=>''], + 'Magento OrderId' + ) + ->addColumn( + 'paytm_order_id', + Table::TYPE_TEXT, + null, + ['nullable'=>false,'default'=>''], + 'Paytm OrderId' + ) + ->addColumn( + 'transaction_id', + Table::TYPE_TEXT, + null, + ['nullable'=>false,'default'=>''], + 'Paytm TransactionId' + ) + ->addColumn( + 'status', + Table::TYPE_BOOLEAN, + null, + ['nullable'=>false,'default'=>'0'], + 'Transaction Status' + ) + ->addColumn( + 'paytm_response', + Table::TYPE_TEXT, + null, + ['nullable'=>false,'default'=>''], + 'Paytm Response' + ) + ->addColumn( + 'date_added', + Table::TYPE_DATETIME, + null, + ['nullable'=>false,'default'=>'0000-00-00 00:00:00'], + 'Created Dtae' + ) + ->addColumn( + 'date_modified', + Table::TYPE_DATETIME, + null, + ['nullbale'=>false,'default'=>'0000-00-00 00:00:00'], + 'Modified Date' + ) + ->setOption('charset','utf8'); + $conn->createTable($table); + } + $setup->endSetup(); + } + } +?> \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/etc/adminhtml/system.xml b/Magento_v2.x/app/code/One97/Paytm/etc/adminhtml/system.xml new file mode 100755 index 0000000..ddc47ba --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/etc/adminhtml/system.xml @@ -0,0 +1,84 @@ + + +
+ + + + Developer Docs +
+ | + | + | + + ]]> +
+ + + Magento\Config\Model\Config\Source\Yesno + payment/paytm/active + paytmEnbDrpDwn + + + + payment/paytm/title + + + + One97\Paytm\Model\PaymentAction + payment/paytm/payment_action + + + + One97\Paytm\Model\EnvAction + payment/paytm/environment + + + + Provided By Paytm + payment/paytm/MID + + + + Provided By Paytm + payment/paytm/merchant_key + + + + Provided By Paytm + payment/paytm/Industry_id + + + + Provided By Paytm + payment/paytm/Website + + + + One97\Paytm\Model\SuccessFailStatus + payment/paytm/success_order_status + + + + One97\Paytm\Model\SuccessFailStatus + payment/paytm/fail_order_status + + + + validate-number + payment/paytm/sort_order + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/paytm/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/paytm/specificcountry + +
+
+
+
\ No newline at end of file diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/config.xml b/Magento_v2.x/app/code/One97/Paytm/etc/config.xml old mode 100644 new mode 100755 similarity index 68% rename from Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/config.xml rename to Magento_v2.x/app/code/One97/Paytm/etc/config.xml index cc5fc1b..9db8df4 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/config.xml +++ b/Magento_v2.x/app/code/One97/Paytm/etc/config.xml @@ -4,23 +4,19 @@ One97\Paytm\Model\Paytm + 0 Paytm Wallet authorize_capture - 0 - pending_payment MID merchant_key 0 - - + Industry_id - WEB Website + processing + canceled 0 - 0 - 0 - diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/frontend/di.xml b/Magento_v2.x/app/code/One97/Paytm/etc/frontend/di.xml old mode 100644 new mode 100755 similarity index 97% rename from Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/frontend/di.xml rename to Magento_v2.x/app/code/One97/Paytm/etc/frontend/di.xml index 2672f37..cdae513 --- a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/frontend/di.xml +++ b/Magento_v2.x/app/code/One97/Paytm/etc/frontend/di.xml @@ -7,4 +7,4 @@ - + \ No newline at end of file diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/frontend/events.xml b/Magento_v2.x/app/code/One97/Paytm/etc/frontend/events.xml old mode 100644 new mode 100755 similarity index 100% rename from Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/frontend/events.xml rename to Magento_v2.x/app/code/One97/Paytm/etc/frontend/events.xml diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/frontend/routes.xml b/Magento_v2.x/app/code/One97/Paytm/etc/frontend/routes.xml old mode 100644 new mode 100755 similarity index 100% rename from Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/frontend/routes.xml rename to Magento_v2.x/app/code/One97/Paytm/etc/frontend/routes.xml diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/module.xml b/Magento_v2.x/app/code/One97/Paytm/etc/module.xml old mode 100644 new mode 100755 similarity index 100% rename from Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/module.xml rename to Magento_v2.x/app/code/One97/Paytm/etc/module.xml diff --git a/Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/payment.xml b/Magento_v2.x/app/code/One97/Paytm/etc/payment.xml old mode 100644 new mode 100755 similarity index 100% rename from Magento_v2.x/Magento Plugin V2.0/app/code/One97/Paytm/etc/payment.xml rename to Magento_v2.x/app/code/One97/Paytm/etc/payment.xml diff --git a/Magento_v2.x/app/code/One97/Paytm/registration.php b/Magento_v2.x/app/code/One97/Paytm/registration.php new file mode 100755 index 0000000..981e72b --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/registration.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/Magento_v2.x/app/code/One97/Paytm/view/adminhtml/layout/adminhtml_system_config_edit.xml b/Magento_v2.x/app/code/One97/Paytm/view/adminhtml/layout/adminhtml_system_config_edit.xml new file mode 100755 index 0000000..168995f --- /dev/null +++ b/Magento_v2.x/app/code/One97/Paytm/view/adminhtml/layout/adminhtml_system_config_edit.xml @@ -0,0 +1,14 @@ + + + + +