Version Notes
PayU is the fastest growing payment system in India! PayU focuses on flexible, effective and user friendly payment solutions for extreme competitive prices.
Download this release
Release Info
| Developer | Site Clue |
| Extension | PayU-India-Basic |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/community/SiteClue/PayuCheckout/Block/Shared/Canceled.php +29 -0
- app/code/community/SiteClue/PayuCheckout/Block/Shared/Failure.php +30 -0
- app/code/community/SiteClue/PayuCheckout/Block/Shared/Form.php +15 -0
- app/code/community/SiteClue/PayuCheckout/Block/Shared/Redirect.php +32 -0
- app/code/community/SiteClue/PayuCheckout/Controller/Abstract.php +68 -0
- app/code/community/SiteClue/PayuCheckout/Helper/Data.php +12 -0
- app/code/community/SiteClue/PayuCheckout/Model/Api/Debug.php +16 -0
- app/code/community/SiteClue/PayuCheckout/Model/Mysql4/Api/Debug.php +15 -0
- app/code/community/SiteClue/PayuCheckout/Model/Mysql4/Api/Debug/Collection.php +15 -0
- app/code/community/SiteClue/PayuCheckout/Model/Mysql4/Setup.php +12 -0
- app/code/community/SiteClue/PayuCheckout/Model/Shared.php +411 -0
- app/code/community/SiteClue/PayuCheckout/Model/Source/DemoModes.php +18 -0
- app/code/community/SiteClue/PayuCheckout/Model/Source/DirectReturn.php +18 -0
- app/code/community/SiteClue/PayuCheckout/Model/Source/PaymentRoutines.php +18 -0
- app/code/community/SiteClue/PayuCheckout/controllers/SharedController.php +53 -0
- app/code/community/SiteClue/PayuCheckout/etc/config.xml +120 -0
- app/code/community/SiteClue/PayuCheckout/etc/system.xml +82 -0
- app/code/community/SiteClue/PayuCheckout/sql/payucheckout_setup/mysql4-install-0.1.0.php +8 -0
- app/code/community/SiteClue/PayuCheckout/sql/payucheckout_setup/mysql4-upgrade-0.1.0-1.0.0.php +22 -0
- app/code/local/SiteClue/Payuorder/Model/Cron.php +204 -0
- app/code/local/SiteClue/Payuorder/etc/config.xml +24 -0
- app/design/frontend/base/default/layout/payucheckout.xml +43 -0
- app/design/frontend/base/default/template/payucheckout/form.phtml +1 -0
- app/design/frontend/base/default/template/payucheckout/info.phtml +0 -0
- app/design/frontend/base/default/template/payucheckout/shared/canceled.phtml +6 -0
- app/design/frontend/base/default/template/payucheckout/shared/failure.phtml +6 -0
- app/design/frontend/base/default/template/payucheckout/shared/form.phtml +9 -0
- app/etc/modules/SiteClue_PayuCheckout.xml +12 -0
- app/etc/modules/SiteClue_Payuorder.xml +9 -0
- package.xml +18 -0
app/code/community/SiteClue/PayuCheckout/Block/Shared/Canceled.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
class SiteClue_PayuCheckout_Block_Shared_Canceled extends Mage_Core_Block_Template
|
| 9 |
+
{
|
| 10 |
+
/**
|
| 11 |
+
* Return Error message
|
| 12 |
+
*
|
| 13 |
+
* @return string
|
| 14 |
+
*/
|
| 15 |
+
public function getErrorMessage ()
|
| 16 |
+
{
|
| 17 |
+
$msg = Mage::getSingleton('checkout/session')->getPayuCheckoutErrorMessage();
|
| 18 |
+
Mage::getSingleton('checkout/session')->unsPayuCheckoutErrorMessage();
|
| 19 |
+
return $msg;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Get continue shopping url
|
| 24 |
+
*/
|
| 25 |
+
public function getContinueShoppingUrl()
|
| 26 |
+
{
|
| 27 |
+
return Mage::getUrl('checkout/cart');
|
| 28 |
+
}
|
| 29 |
+
}
|
app/code/community/SiteClue/PayuCheckout/Block/Shared/Failure.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class SiteClue_PayuCheckout_Block_Shared_Failure extends Mage_Core_Block_Template
|
| 10 |
+
{
|
| 11 |
+
/**
|
| 12 |
+
* Return Error message
|
| 13 |
+
*
|
| 14 |
+
* @return string
|
| 15 |
+
*/
|
| 16 |
+
public function getErrorMessage ()
|
| 17 |
+
{
|
| 18 |
+
$msg = Mage::getSingleton('checkout/session')->getPayuCheckoutErrorMessage();
|
| 19 |
+
Mage::getSingleton('checkout/session')->unsPayuCheckoutErrorMessage();
|
| 20 |
+
return $msg;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Get continue shopping url
|
| 25 |
+
*/
|
| 26 |
+
public function getContinueShoppingUrl()
|
| 27 |
+
{
|
| 28 |
+
return Mage::getUrl('checkout/cart');
|
| 29 |
+
}
|
| 30 |
+
}
|
app/code/community/SiteClue/PayuCheckout/Block/Shared/Form.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
class SiteClue_PayuCheckout_Block_Shared_Form extends Mage_Payment_Block_Form
|
| 9 |
+
{
|
| 10 |
+
protected function _construct()
|
| 11 |
+
{
|
| 12 |
+
$this->setTemplate('payucheckout/shared/form.phtml');
|
| 13 |
+
parent::_construct();
|
| 14 |
+
}
|
| 15 |
+
}
|
app/code/community/SiteClue/PayuCheckout/Block/Shared/Redirect.php
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
class SiteClue_PayuCheckout_Block_Shared_Redirect extends Mage_Core_Block_Abstract
|
| 9 |
+
{
|
| 10 |
+
protected function _toHtml()
|
| 11 |
+
{
|
| 12 |
+
$shared = $this->getOrder()->getPayment()->getMethodInstance();
|
| 13 |
+
|
| 14 |
+
$form = new Varien_Data_Form();
|
| 15 |
+
$form->setAction($shared->getPayuCheckoutSharedUrl())
|
| 16 |
+
->setId('payucheckout_shared_checkout')
|
| 17 |
+
->setName('payucheckout_shared_checkout')
|
| 18 |
+
->setMethod('POST')
|
| 19 |
+
->setUseContainer(true);
|
| 20 |
+
foreach ($shared->getFormFields() as $field=>$value) {
|
| 21 |
+
$form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
$html = '<html><body>';
|
| 25 |
+
$html.= $this->__('You will be redirected to PayuCheckout in a few seconds.');
|
| 26 |
+
$html.= $form->toHtml();
|
| 27 |
+
$html.= '<script type="text/javascript">document.getElementById("payucheckout_shared_checkout").submit();</script>';
|
| 28 |
+
$html.= '</body></html>';
|
| 29 |
+
|
| 30 |
+
return $html;
|
| 31 |
+
}
|
| 32 |
+
}
|
app/code/community/SiteClue/PayuCheckout/Controller/Abstract.php
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
abstract class SiteClue_PayuCheckout_Controller_Abstract extends Mage_Core_Controller_Front_Action
|
| 10 |
+
{
|
| 11 |
+
protected function _expireAjax()
|
| 12 |
+
{
|
| 13 |
+
if (!$this->getCheckout()->getQuote()->hasItems()) {
|
| 14 |
+
$this->getResponse()->setHeader('HTTP/1.1','403 Session Expired');
|
| 15 |
+
exit;
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
protected $_redirectBlockType;
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Get singleton of Checkout Session Model
|
| 24 |
+
*
|
| 25 |
+
* @return Mage_Checkout_Model_Session
|
| 26 |
+
*/
|
| 27 |
+
public function getCheckout()
|
| 28 |
+
{
|
| 29 |
+
return Mage::getSingleton('checkout/session');
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
public function redirectAction()
|
| 34 |
+
{
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
$session = $this->getCheckout();
|
| 38 |
+
$quoteId = $session->getQuoteId();
|
| 39 |
+
if($quoteId = ""){
|
| 40 |
+
$quoteId = $session->getLastQuoteId();
|
| 41 |
+
}
|
| 42 |
+
if(!empty($quoteId)) {
|
| 43 |
+
$session->setPayuCheckoutQuoteId($quoteId);
|
| 44 |
+
$session->setPayuCheckoutRealOrderId($session->getLastRealOrderId());
|
| 45 |
+
|
| 46 |
+
$order = Mage::getModel('sales/order');
|
| 47 |
+
$order->loadByIncrementId($session->getLastRealOrderId());
|
| 48 |
+
$order->addStatusToHistory($order->getStatus(), Mage::helper('payucheckout')->__('Customer was redirected to payu.'));
|
| 49 |
+
$order->save();
|
| 50 |
+
|
| 51 |
+
$this->getResponse()->setBody(
|
| 52 |
+
$this->getLayout()
|
| 53 |
+
->createBlock($this->_redirectBlockType)
|
| 54 |
+
->setOrder($order)
|
| 55 |
+
->toHtml()
|
| 56 |
+
);
|
| 57 |
+
$session->unsQuoteId();
|
| 58 |
+
$session->unsLastRealOrderId();
|
| 59 |
+
} else {
|
| 60 |
+
$this->_redirect('checkout/cart');
|
| 61 |
+
return;
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
}
|
app/code/community/SiteClue/PayuCheckout/Helper/Data.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class SiteClue_PayuCheckout_Helper_Data extends Mage_Core_Helper_Abstract
|
| 10 |
+
{
|
| 11 |
+
|
| 12 |
+
}
|
app/code/community/SiteClue/PayuCheckout/Model/Api/Debug.php
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class SiteClue_PayuCheckout_Model_Api_Debug extends Mage_Core_Model_Abstract
|
| 10 |
+
{
|
| 11 |
+
protected function _construct()
|
| 12 |
+
{
|
| 13 |
+
|
| 14 |
+
$this->_init('payucheckout/api_debug');
|
| 15 |
+
}
|
| 16 |
+
}
|
app/code/community/SiteClue/PayuCheckout/Model/Mysql4/Api/Debug.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class SiteClue_PayuCheckout_Model_Mysql4_Api_Debug extends Mage_Core_Model_Mysql4_Abstract
|
| 10 |
+
{
|
| 11 |
+
protected function _construct()
|
| 12 |
+
{
|
| 13 |
+
$this->_init('payucheckout/api_debug', 'debug_id');
|
| 14 |
+
}
|
| 15 |
+
}
|
app/code/community/SiteClue/PayuCheckout/Model/Mysql4/Api/Debug/Collection.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class SiteClue_PayuCheckout_Model_Mysql4_Api_Debug_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 10 |
+
{
|
| 11 |
+
protected function _construct()
|
| 12 |
+
{
|
| 13 |
+
$this->_init('payucheckout/api_debug');
|
| 14 |
+
}
|
| 15 |
+
}
|
app/code/community/SiteClue/PayuCheckout/Model/Mysql4/Setup.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class SiteClue_PayuCheckout_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
|
| 10 |
+
{
|
| 11 |
+
|
| 12 |
+
}
|
app/code/community/SiteClue/PayuCheckout/Model/Shared.php
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class SiteClue_PayuCheckout_Model_Shared extends Mage_Payment_Model_Method_Abstract
|
| 10 |
+
{
|
| 11 |
+
protected $_code = 'payucheckout_shared';
|
| 12 |
+
|
| 13 |
+
protected $_isGateway = false;
|
| 14 |
+
protected $_canAuthorize = false;
|
| 15 |
+
protected $_canCapture = true;
|
| 16 |
+
protected $_canCapturePartial = false;
|
| 17 |
+
protected $_canRefund = false;
|
| 18 |
+
protected $_canVoid = false;
|
| 19 |
+
protected $_canUseInternal = false;
|
| 20 |
+
protected $_canUseCheckout = true;
|
| 21 |
+
protected $_canUseForMultishipping = false;
|
| 22 |
+
|
| 23 |
+
protected $_formBlockType = 'payucheckout/shared_form';
|
| 24 |
+
protected $_paymentMethod = 'shared';
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
protected $_order;
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
public function cleanString($string) {
|
| 31 |
+
|
| 32 |
+
$string_step1 = strip_tags($string);
|
| 33 |
+
$string_step2 = nl2br($string_step1);
|
| 34 |
+
$string_step3 = str_replace("<br />","<br>",$string_step2);
|
| 35 |
+
$cleaned_string = str_replace("\""," inch",$string_step3);
|
| 36 |
+
return $cleaned_string;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* Get checkout session namespace
|
| 42 |
+
*
|
| 43 |
+
* @return Mage_Checkout_Model_Session
|
| 44 |
+
*/
|
| 45 |
+
public function getCheckout()
|
| 46 |
+
{
|
| 47 |
+
return Mage::getSingleton('checkout/session');
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* Get current quote
|
| 52 |
+
*
|
| 53 |
+
* @return Mage_Sales_Model_Quote
|
| 54 |
+
*/
|
| 55 |
+
public function getQuote()
|
| 56 |
+
{
|
| 57 |
+
return $this->getCheckout()->getQuote();
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Get order model
|
| 63 |
+
*
|
| 64 |
+
* @return Mage_Sales_Model_Order
|
| 65 |
+
*/
|
| 66 |
+
public function getOrder()
|
| 67 |
+
{
|
| 68 |
+
if (!$this->_order) {
|
| 69 |
+
$paymentInfo = $this->getInfoInstance();
|
| 70 |
+
$this->_order = Mage::getModel('sales/order')
|
| 71 |
+
->loadByIncrementId($paymentInfo->getOrder()->getRealOrderId());
|
| 72 |
+
}
|
| 73 |
+
return $this->_order;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
public function getCustomerId()
|
| 78 |
+
{
|
| 79 |
+
return Mage::getStoreConfig('payment/' . $this->getCode() . '/customer_id');
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
public function getAccepteCurrency()
|
| 83 |
+
{
|
| 84 |
+
return Mage::getStoreConfig('payment/' . $this->getCode() . '/currency');
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
public function getOrderPlaceRedirectUrl()
|
| 91 |
+
{
|
| 92 |
+
return Mage::getUrl('payucheckout/shared/redirect');
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* prepare params array to send it to gateway page via POST
|
| 97 |
+
*
|
| 98 |
+
* @return array
|
| 99 |
+
*/
|
| 100 |
+
public function getFormFields()
|
| 101 |
+
{
|
| 102 |
+
|
| 103 |
+
$billing = $this->getOrder()->getBillingAddress();
|
| 104 |
+
$coFields = array();
|
| 105 |
+
$items = $this->getQuote()->getAllItems();
|
| 106 |
+
|
| 107 |
+
if ($items) {
|
| 108 |
+
$i = 1;
|
| 109 |
+
foreach($items as $item){
|
| 110 |
+
if ($item->getParentItem()) {
|
| 111 |
+
continue;
|
| 112 |
+
}
|
| 113 |
+
$coFields['c_prod_'.$i] = $this->cleanString($item->getSku());
|
| 114 |
+
$coFields['c_name_'.$i] = $this->cleanString($item->getName());
|
| 115 |
+
$coFields['c_description_'.$i] = $this->cleanString($item->getDescription());
|
| 116 |
+
$coFields['c_price_'.$i] = number_format($item->getPrice(), 2, '.', '');
|
| 117 |
+
$i++;
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
$request = '';
|
| 122 |
+
foreach ($coFields as $k=>$v) {
|
| 123 |
+
$request .= '<' . $k . '>' . $v . '</' . $k . '>';
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
$key=Mage::getStoreConfig('payment/payucheckout_shared/key');
|
| 128 |
+
$salt=Mage::getStoreConfig('payment/payucheckout_shared/salt');
|
| 129 |
+
$debug_mode=Mage::getStoreConfig('payment/payucheckout_shared/debug_mode');
|
| 130 |
+
|
| 131 |
+
$orderId = $this->getOrder()->getRealOrderId();
|
| 132 |
+
$mode=Mage::getStoreConfig('payment/payucheckout_shared/demo_mode');
|
| 133 |
+
if($mode!='')
|
| 134 |
+
{
|
| 135 |
+
$txnid = $orderId."_".rand();
|
| 136 |
+
}
|
| 137 |
+
else
|
| 138 |
+
$txnid = $orderId;
|
| 139 |
+
|
| 140 |
+
$coFields['key'] = $key;
|
| 141 |
+
$coFields['txnid'] = $txnid;
|
| 142 |
+
|
| 143 |
+
$coFields['amount'] = number_format($this->getOrder()->getBaseGrandTotal(),0,'','');
|
| 144 |
+
$coFields['productinfo'] = 'Prpduct Information';
|
| 145 |
+
$coFields['firstname'] = $billing->getFirstname();
|
| 146 |
+
$coFields['Lastname'] = $billing->getLastname();
|
| 147 |
+
$coFields['City'] = $billing->getCity();
|
| 148 |
+
$coFields['State'] = $billing->getRegion();
|
| 149 |
+
$coFields['Country'] = $billing->getCountry();
|
| 150 |
+
$coFields['Zipcode'] = $billing->getPostcode();
|
| 151 |
+
$coFields['email'] = $this->getOrder()->getCustomerEmail();
|
| 152 |
+
$coFields['phone'] = $billing->getTelephone();
|
| 153 |
+
|
| 154 |
+
$coFields['surl'] = Mage::getBaseUrl().'payucheckout/shared/success/';
|
| 155 |
+
$coFields['furl'] = Mage::getBaseUrl().'payucheckout/shared/failure/';
|
| 156 |
+
//$coFields['curl'] = Mage::getBaseUrl().'payucheckout/shared/canceled/id/'.$this->getOrder()->getRealOrderId();
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
$coFields['Pg'] = 'CC';
|
| 162 |
+
$debugId='';
|
| 163 |
+
|
| 164 |
+
if ($debug_mode==1) {
|
| 165 |
+
|
| 166 |
+
$requestInfo= $key.'|'.$coFields['txnid'].'|'.$coFields['amount'].'|'.
|
| 167 |
+
$coFields['productinfo'].'|'.$coFields['firstname'].'|'.$coFields['email'].'|'.$debugId.'||||||||||'.$salt;
|
| 168 |
+
$debug = Mage::getModel('payucheckout/api_debug')
|
| 169 |
+
->setRequestBody($requestInfo)
|
| 170 |
+
->save();
|
| 171 |
+
|
| 172 |
+
$debugId = $debug->getId();
|
| 173 |
+
|
| 174 |
+
$coFields['udf1']=$debugId;
|
| 175 |
+
$coFields['Hash'] = hash('sha512', $key.'|'.$coFields['txnid'].'|'.$coFields['amount'].'|'.
|
| 176 |
+
$coFields['productinfo'].'|'.$coFields['firstname'].'|'.$coFields['email'].'|'.$debugId.'||||||||||'.$salt);
|
| 177 |
+
}
|
| 178 |
+
else
|
| 179 |
+
{
|
| 180 |
+
$coFields['Hash'] = strtolower(hash('sha512', $key.'|'.$coFields['txnid'].'|'.$coFields['amount'].'|'.
|
| 181 |
+
$coFields['productinfo'].'|'.$coFields['firstname'].'|'.$coFields['email'].'|||||||||||'.$salt));
|
| 182 |
+
}
|
| 183 |
+
return $coFields;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
/**
|
| 187 |
+
* Get url of Payu payment
|
| 188 |
+
*
|
| 189 |
+
* @return string
|
| 190 |
+
*/
|
| 191 |
+
public function getPayuCheckoutSharedUrl()
|
| 192 |
+
{
|
| 193 |
+
$mode=Mage::getStoreConfig('payment/payucheckout_shared/demo_mode');
|
| 194 |
+
|
| 195 |
+
$url='https://test.payu.in/_payment.php';
|
| 196 |
+
|
| 197 |
+
if($mode=='')
|
| 198 |
+
{
|
| 199 |
+
$url='https://secure.payu.in/_payment.php';
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
return $url;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
/**
|
| 207 |
+
* Get debug flag
|
| 208 |
+
*
|
| 209 |
+
* @return string
|
| 210 |
+
*/
|
| 211 |
+
public function getDebug()
|
| 212 |
+
{
|
| 213 |
+
return Mage::getStoreConfig('payment/' . $this->getCode() . '/debug_flag');
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
public function capture(Varien_Object $payment, $amount)
|
| 217 |
+
{
|
| 218 |
+
$payment->setStatus(self::STATUS_APPROVED)
|
| 219 |
+
->setLastTransId($this->getTransactionId());
|
| 220 |
+
|
| 221 |
+
return $this;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
public function cancel(Varien_Object $payment)
|
| 225 |
+
{
|
| 226 |
+
$payment->setStatus(self::STATUS_DECLINED)
|
| 227 |
+
->setLastTransId($this->getTransactionId());
|
| 228 |
+
|
| 229 |
+
return $this;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
/**
|
| 233 |
+
* parse response POST array from gateway page and return payment status
|
| 234 |
+
*
|
| 235 |
+
* @return bool
|
| 236 |
+
*/
|
| 237 |
+
public function parseResponse()
|
| 238 |
+
{
|
| 239 |
+
|
| 240 |
+
return true;
|
| 241 |
+
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
/**
|
| 245 |
+
* Return redirect block type
|
| 246 |
+
*
|
| 247 |
+
* @return string
|
| 248 |
+
*/
|
| 249 |
+
public function getRedirectBlockType()
|
| 250 |
+
{
|
| 251 |
+
return $this->_redirectBlockType;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
/**
|
| 255 |
+
* Return payment method type string
|
| 256 |
+
*
|
| 257 |
+
* @return string
|
| 258 |
+
*/
|
| 259 |
+
public function getPaymentMethodType()
|
| 260 |
+
{
|
| 261 |
+
return $this->_paymentMethod;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
public function getResponseOperation($response)
|
| 266 |
+
{
|
| 267 |
+
|
| 268 |
+
$order = Mage::getModel('sales/order');
|
| 269 |
+
$debug_mode=Mage::getStoreConfig('payment/payucheckout_shared/debug_mode');
|
| 270 |
+
$key=Mage::getStoreConfig('payment/payucheckout_shared/key');
|
| 271 |
+
$salt=Mage::getStoreConfig('payment/payucheckout_shared/salt');
|
| 272 |
+
if(isset($response['status']))
|
| 273 |
+
{
|
| 274 |
+
$txnid=$response['txnid'];
|
| 275 |
+
$mode=Mage::getStoreConfig('payment/payucheckout_shared/demo_mode');
|
| 276 |
+
if($mode!='')
|
| 277 |
+
{
|
| 278 |
+
$txnid_split = explode("_", $txnid);
|
| 279 |
+
$orderid = $txnid_split[0];
|
| 280 |
+
}
|
| 281 |
+
else
|
| 282 |
+
$orderid=$txnid;
|
| 283 |
+
|
| 284 |
+
if($response['status']=='success')
|
| 285 |
+
{
|
| 286 |
+
$status=$response['status'];
|
| 287 |
+
$order->loadByIncrementId($orderid);
|
| 288 |
+
$billing = $order->getBillingAddress();
|
| 289 |
+
$amount = $response['amount'];
|
| 290 |
+
$productinfo = $response['productinfo'];
|
| 291 |
+
$firstname = $response['firstname'];
|
| 292 |
+
$email = $response['email'];
|
| 293 |
+
$keyString='';
|
| 294 |
+
$Udf1 = $response['udf1'];
|
| 295 |
+
$Udf2 = $response['udf2'];
|
| 296 |
+
$Udf3 = $response['udf3'];
|
| 297 |
+
$Udf4 = $response['udf4'];
|
| 298 |
+
$Udf5 = $response['udf5'];
|
| 299 |
+
$Udf6 = $response['udf6'];
|
| 300 |
+
$Udf7 = $response['udf7'];
|
| 301 |
+
$Udf8 = $response['udf8'];
|
| 302 |
+
$Udf9 = $response['udf9'];
|
| 303 |
+
$Udf10 = $response['udf10'];
|
| 304 |
+
if($debug_mode==1)
|
| 305 |
+
{
|
| 306 |
+
$keyString = $key.'|'.$txnid.'|'.$amount.'|'.$productinfo.'|'.$firstname.'|'.$email.'|'.$Udf1.'|'.$Udf2.'|'.$Udf3.'|'.$Udf4.'|'.$Udf5.'|'.$Udf6.'|'.$Udf7.'|'.$Udf8.'|'.$Udf9.'|'.$Udf10;
|
| 307 |
+
}
|
| 308 |
+
else
|
| 309 |
+
{
|
| 310 |
+
$keyString = $key.'|'.$txnid.'|'.$amount.'|'.$productinfo.'|'.$firstname.'|'.$email.'|'.$Udf1.'|'.$Udf2.'|'.$Udf3.'|'.$Udf4.'|'.$Udf5.'|'.$Udf6.'|'.$Udf7.'|'.$Udf8.'|'.$Udf9.'|'.$Udf10;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
$keyArray = explode("|",$keyString);
|
| 314 |
+
$reverseKeyArray = array_reverse($keyArray);
|
| 315 |
+
$reverseKeyString=implode("|",$reverseKeyArray);
|
| 316 |
+
$saltString = $salt.'|'.$status.'|'.$reverseKeyString;
|
| 317 |
+
$sentHashString = strtolower(hash('sha512', $saltString));
|
| 318 |
+
$responseHashString=$_REQUEST['hash'];
|
| 319 |
+
if($sentHashString==$responseHashString)
|
| 320 |
+
{
|
| 321 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
|
| 322 |
+
$order->save();
|
| 323 |
+
$order->sendNewOrderEmail();
|
| 324 |
+
|
| 325 |
+
}
|
| 326 |
+
else
|
| 327 |
+
{
|
| 328 |
+
$order->setState(Mage_Sales_Model_Order::STATE_NEW, true);
|
| 329 |
+
$order->cancel()->save();
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
if ($debug_mode==1) {
|
| 333 |
+
$debugId=$response['udf1'];
|
| 334 |
+
$data = array('response_body'=>implode(",",$response));
|
| 335 |
+
$model = Mage::getModel('payucheckout/api_debug')->load($debugId)->addData($data);
|
| 336 |
+
$model->setId($id)->save();
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
if($response['status']=='failure')
|
| 341 |
+
{
|
| 342 |
+
$order->loadByIncrementId($orderid);
|
| 343 |
+
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true);
|
| 344 |
+
// Inventory updated
|
| 345 |
+
$this->updateInventory($orderid);
|
| 346 |
+
|
| 347 |
+
$order->cancel()->save();
|
| 348 |
+
|
| 349 |
+
if ($debug_mode==1) {
|
| 350 |
+
$debugId=$response['udf1'];
|
| 351 |
+
$data = array('response_body'=>implode(",",$response));
|
| 352 |
+
$model = Mage::getModel('payucheckout/api_debug')->load($debugId)->addData($data);
|
| 353 |
+
$model->setId($id)->save();
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
}
|
| 357 |
+
else if($response['status']=='pending')
|
| 358 |
+
{
|
| 359 |
+
$order->loadByIncrementId($orderid);
|
| 360 |
+
$order->setState(Mage_Sales_Model_Order::STATE_NEW, true);
|
| 361 |
+
// Inventory updated
|
| 362 |
+
$this->updateInventory($orderid);
|
| 363 |
+
$order->cancel()->save();
|
| 364 |
+
|
| 365 |
+
if ($debug_mode==1) {
|
| 366 |
+
$debugId=$response['udf1'];
|
| 367 |
+
$data = array('response_body'=>implode(",",$response));
|
| 368 |
+
$model = Mage::getModel('payucheckout/api_debug')->load($debugId)->addData($data);
|
| 369 |
+
$model->setId($id)->save();
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
}
|
| 375 |
+
else
|
| 376 |
+
{
|
| 377 |
+
|
| 378 |
+
$order->loadByIncrementId($response['id']);
|
| 379 |
+
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true);
|
| 380 |
+
// Inventory updated
|
| 381 |
+
$order_id=$response['id'];
|
| 382 |
+
$this->updateInventory($order_id);
|
| 383 |
+
|
| 384 |
+
$order->cancel()->save();
|
| 385 |
+
|
| 386 |
+
|
| 387 |
+
}
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
public function updateInventory($order_id)
|
| 391 |
+
{
|
| 392 |
+
|
| 393 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
|
| 394 |
+
$items = $order->getAllItems();
|
| 395 |
+
foreach ($items as $itemId => $item)
|
| 396 |
+
{
|
| 397 |
+
$ordered_quantity = $item->getQtyToInvoice();
|
| 398 |
+
$sku=$item->getSku();
|
| 399 |
+
$product = Mage::getModel('catalog/product')->load($item->getProductId());
|
| 400 |
+
$qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId())->getQty();
|
| 401 |
+
|
| 402 |
+
$updated_inventory=$qtyStock + $ordered_quantity;
|
| 403 |
+
|
| 404 |
+
$stockData = $product->getStockItem();
|
| 405 |
+
$stockData->setData('qty',$updated_inventory);
|
| 406 |
+
$stockData->save();
|
| 407 |
+
|
| 408 |
+
}
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
}
|
app/code/community/SiteClue/PayuCheckout/Model/Source/DemoModes.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class SiteClue_PayuCheckout_Model_Source_DemoModes
|
| 10 |
+
{
|
| 11 |
+
public function toOptionArray()
|
| 12 |
+
{
|
| 13 |
+
return array(
|
| 14 |
+
array('value' => 'Y', 'label' => 'Demo Mode'),
|
| 15 |
+
array('value' => '', 'label' => 'Production Mode'),
|
| 16 |
+
);
|
| 17 |
+
}
|
| 18 |
+
}
|
app/code/community/SiteClue/PayuCheckout/Model/Source/DirectReturn.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class SiteClue_PayuCheckout_Model_Source_DirectReturn
|
| 10 |
+
{
|
| 11 |
+
public function toOptionArray()
|
| 12 |
+
{
|
| 13 |
+
return array(
|
| 14 |
+
array('value' => 'redirect', 'label' => 'Immediately returned to my website '),
|
| 15 |
+
array('value' => 'link', 'label' => 'Given links only back to my website '),
|
| 16 |
+
);
|
| 17 |
+
}
|
| 18 |
+
}
|
app/code/community/SiteClue/PayuCheckout/Model/Source/PaymentRoutines.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class SiteClue_PayuCheckout_Model_Source_PaymentRoutines
|
| 10 |
+
{
|
| 11 |
+
public function toOptionArray()
|
| 12 |
+
{
|
| 13 |
+
return array(
|
| 14 |
+
array('value' => 'multi', 'label' => 'Multi-page Payment Routine'),
|
| 15 |
+
array('value' => 'single', 'label' => 'Single Page Payment Routine'),
|
| 16 |
+
);
|
| 17 |
+
}
|
| 18 |
+
}
|
app/code/community/SiteClue/PayuCheckout/controllers/SharedController.php
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_PayuCheckout
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
class SiteClue_PayuCheckout_SharedController extends SiteClue_PayuCheckout_Controller_Abstract
|
| 10 |
+
{
|
| 11 |
+
|
| 12 |
+
protected $_redirectBlockType = 'payucheckout/shared_redirect';
|
| 13 |
+
protected $_paymentInst = NULL;
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
public function successAction()
|
| 17 |
+
{
|
| 18 |
+
$response = $this->getRequest()->getPost();
|
| 19 |
+
Mage::getModel('payucheckout/shared')->getResponseOperation($response);
|
| 20 |
+
$this->_redirect('checkout/onepage/success');
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
public function failureAction()
|
| 26 |
+
{
|
| 27 |
+
|
| 28 |
+
$arrParams = $this->getRequest()->getPost();
|
| 29 |
+
Mage::getModel('payucheckout/shared')->getResponseOperation($arrParams);
|
| 30 |
+
$this->getCheckout()->clear();
|
| 31 |
+
$this->_redirect('checkout/onepage/failure');
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
public function canceledAction()
|
| 36 |
+
{
|
| 37 |
+
$arrParams = $this->getRequest()->getParams();
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
Mage::getModel('payucheckout/shared')->getResponseOperation($arrParams);
|
| 41 |
+
|
| 42 |
+
$this->getCheckout()->clear();
|
| 43 |
+
$this->loadLayout();
|
| 44 |
+
$this->renderLayout();
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
|
app/code/community/SiteClue/PayuCheckout/etc/config.xml
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<SiteClue_PayuCheckout>
|
| 5 |
+
<version>1.0.0</version>
|
| 6 |
+
</SiteClue_PayuCheckout>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<models>
|
| 10 |
+
<payucheckout>
|
| 11 |
+
<class>SiteClue_PayuCheckout_Model</class>
|
| 12 |
+
<resourceModel>payucheckout_mysql4</resourceModel>
|
| 13 |
+
</payucheckout>
|
| 14 |
+
<payucheckout_mysql4>
|
| 15 |
+
<class>SiteClue_PayuCheckout_Model_Mysql4</class>
|
| 16 |
+
<entities>
|
| 17 |
+
<api_debug>
|
| 18 |
+
<table>siteclue_payucheckout_api_debug</table>
|
| 19 |
+
</api_debug>
|
| 20 |
+
</entities>
|
| 21 |
+
</payucheckout_mysql4>
|
| 22 |
+
</models>
|
| 23 |
+
<helpers>
|
| 24 |
+
<payucheckout>
|
| 25 |
+
<class>SiteClue_PayuCheckout_Helper</class>
|
| 26 |
+
</payucheckout>
|
| 27 |
+
</helpers>
|
| 28 |
+
<resources>
|
| 29 |
+
<payucheckout_setup>
|
| 30 |
+
<setup>
|
| 31 |
+
<module>SiteClue_PayuCheckout</module>
|
| 32 |
+
<class>SiteClue_PayuCheckout_Model_Mysql4_Setup</class>
|
| 33 |
+
</setup>
|
| 34 |
+
<connection>
|
| 35 |
+
<use>core_setup</use>
|
| 36 |
+
</connection>
|
| 37 |
+
</payucheckout_setup>
|
| 38 |
+
<payucheckout_write>
|
| 39 |
+
<connection>
|
| 40 |
+
<use>core_write</use>
|
| 41 |
+
</connection>
|
| 42 |
+
</payucheckout_write>
|
| 43 |
+
<payucheckout_read>
|
| 44 |
+
<connection>
|
| 45 |
+
<use>core_read</use>
|
| 46 |
+
</connection>
|
| 47 |
+
</payucheckout_read>
|
| 48 |
+
</resources>
|
| 49 |
+
<blocks>
|
| 50 |
+
<payucheckout>
|
| 51 |
+
<class>SiteClue_PayuCheckout_Block</class>
|
| 52 |
+
</payucheckout>
|
| 53 |
+
</blocks>
|
| 54 |
+
</global>
|
| 55 |
+
<frontend>
|
| 56 |
+
<secure_url>
|
| 57 |
+
<payucheckout_shared>/payucheckout/shared</payucheckout_shared>
|
| 58 |
+
</secure_url>
|
| 59 |
+
<routers>
|
| 60 |
+
<payucheckout>
|
| 61 |
+
<use>standard</use>
|
| 62 |
+
<args>
|
| 63 |
+
<module>SiteClue_PayuCheckout</module>
|
| 64 |
+
<frontName>payucheckout</frontName>
|
| 65 |
+
</args>
|
| 66 |
+
</payucheckout>
|
| 67 |
+
</routers>
|
| 68 |
+
<translate>
|
| 69 |
+
<modules>
|
| 70 |
+
<SiteClue_PayuCheckout>
|
| 71 |
+
<files>
|
| 72 |
+
<default>SiteClue_PayuCheckout.csv</default>
|
| 73 |
+
</files>
|
| 74 |
+
</SiteClue_PayuCheckout>
|
| 75 |
+
</modules>
|
| 76 |
+
</translate>
|
| 77 |
+
<layout>
|
| 78 |
+
<updates>
|
| 79 |
+
<payucheckout>
|
| 80 |
+
<file>payucheckout.xml</file>
|
| 81 |
+
</payucheckout>
|
| 82 |
+
</updates>
|
| 83 |
+
</layout>
|
| 84 |
+
</frontend>
|
| 85 |
+
<adminhtml>
|
| 86 |
+
<translate>
|
| 87 |
+
<modules>
|
| 88 |
+
<SiteClue_PayuCheckout>
|
| 89 |
+
<files>
|
| 90 |
+
<default>SiteClue_PayuCheckout.csv</default>
|
| 91 |
+
</files>
|
| 92 |
+
</SiteClue_PayuCheckout>
|
| 93 |
+
</modules>
|
| 94 |
+
</translate>
|
| 95 |
+
</adminhtml>
|
| 96 |
+
<default>
|
| 97 |
+
<payment>
|
| 98 |
+
<payucheckout_shared>
|
| 99 |
+
<customer_id backend_model="adminhtml/system_config_backend_encrypted"/>
|
| 100 |
+
<currency>USD</currency>
|
| 101 |
+
<model>payucheckout/shared</model>
|
| 102 |
+
<title>Payu Checkout</title>
|
| 103 |
+
<secret_word>PUT SECRET WORD HERE</secret_word>
|
| 104 |
+
<check_hash>1</check_hash>
|
| 105 |
+
<direct_return>redirect</direct_return>
|
| 106 |
+
<demo_mode></demo_mode>
|
| 107 |
+
<skip_landing>0</skip_landing>
|
| 108 |
+
<order_status>processing</order_status>
|
| 109 |
+
<fraud_wait>holded</fraud_wait>
|
| 110 |
+
<fraud_passed>pending</fraud_passed>
|
| 111 |
+
<fraud_failed>canceled</fraud_failed>
|
| 112 |
+
<invoice_pending></invoice_pending>
|
| 113 |
+
<invoice_deposited></invoice_deposited>
|
| 114 |
+
<invoice_declined>canceled</invoice_declined>
|
| 115 |
+
<refund_issued>canceled</refund_issued>
|
| 116 |
+
<allowspecific>0</allowspecific>
|
| 117 |
+
</payucheckout_shared>
|
| 118 |
+
</payment>
|
| 119 |
+
</default>
|
| 120 |
+
</config>
|
app/code/community/SiteClue/PayuCheckout/etc/system.xml
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<payment>
|
| 5 |
+
<groups>
|
| 6 |
+
<payucheckout_shared translate="label" module="payucheckout">
|
| 7 |
+
<label>PayU Checkout</label>
|
| 8 |
+
<frontend_type>text</frontend_type>
|
| 9 |
+
<sort_order>303</sort_order>
|
| 10 |
+
<show_in_default>1</show_in_default>
|
| 11 |
+
<show_in_website>1</show_in_website>
|
| 12 |
+
<show_in_store>0</show_in_store>
|
| 13 |
+
<fields>
|
| 14 |
+
<active translate="label">
|
| 15 |
+
<label>Enabled</label>
|
| 16 |
+
<frontend_type>select</frontend_type>
|
| 17 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 18 |
+
<sort_order>1</sort_order>
|
| 19 |
+
<show_in_default>1</show_in_default>
|
| 20 |
+
<show_in_website>1</show_in_website>
|
| 21 |
+
<show_in_store>0</show_in_store>
|
| 22 |
+
</active>
|
| 23 |
+
<title translate="label">
|
| 24 |
+
<label>Title</label>
|
| 25 |
+
<comment>This is what the customers will see as the name of the payment option</comment>
|
| 26 |
+
<frontend_type>text</frontend_type>
|
| 27 |
+
<sort_order>2</sort_order>
|
| 28 |
+
<show_in_default>1</show_in_default>
|
| 29 |
+
<show_in_website>1</show_in_website>
|
| 30 |
+
<show_in_store>0</show_in_store>
|
| 31 |
+
</title>
|
| 32 |
+
<key translate="label">
|
| 33 |
+
<label>Merchant Id</label>
|
| 34 |
+
<frontend_type>text</frontend_type>
|
| 35 |
+
<sort_order>3</sort_order>
|
| 36 |
+
<show_in_default>2</show_in_default>
|
| 37 |
+
<show_in_website>2</show_in_website>
|
| 38 |
+
<show_in_store>0</show_in_store>
|
| 39 |
+
</key>
|
| 40 |
+
>
|
| 41 |
+
<salt translate="label">
|
| 42 |
+
<label>Salt</label>
|
| 43 |
+
<comment>This is salt hash key provided by Payu</comment>
|
| 44 |
+
<frontend_type>text</frontend_type>
|
| 45 |
+
<sort_order>4</sort_order>
|
| 46 |
+
<show_in_default>3</show_in_default>
|
| 47 |
+
<show_in_website>3</show_in_website>
|
| 48 |
+
<show_in_store>0</show_in_store>
|
| 49 |
+
</salt>
|
| 50 |
+
<demo_mode translate="label">
|
| 51 |
+
<label>Transaction Mode?</label>
|
| 52 |
+
<frontend_type>select</frontend_type>
|
| 53 |
+
<source_model>payucheckout/source_DemoModes</source_model>
|
| 54 |
+
<sort_order>55</sort_order>
|
| 55 |
+
<show_in_default>1</show_in_default>
|
| 56 |
+
<show_in_website>1</show_in_website>
|
| 57 |
+
<show_in_store>0</show_in_store>
|
| 58 |
+
</demo_mode>
|
| 59 |
+
<order_status translate="label">
|
| 60 |
+
<label>New order status</label>
|
| 61 |
+
<frontend_type>select</frontend_type>
|
| 62 |
+
<source_model>adminhtml/system_config_source_order_status</source_model>
|
| 63 |
+
<sort_order>6</sort_order>
|
| 64 |
+
<show_in_default>1</show_in_default>
|
| 65 |
+
<show_in_website>1</show_in_website>
|
| 66 |
+
<show_in_store>0</show_in_store>
|
| 67 |
+
</order_status>
|
| 68 |
+
<debug_mode translate="label">
|
| 69 |
+
<label>Debug Mode</label>
|
| 70 |
+
<frontend_type>select</frontend_type>
|
| 71 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 72 |
+
<sort_order>10</sort_order>
|
| 73 |
+
<show_in_default>1</show_in_default>
|
| 74 |
+
<show_in_website>1</show_in_website>
|
| 75 |
+
<show_in_store>0</show_in_store>
|
| 76 |
+
</debug_mode>
|
| 77 |
+
</fields>
|
| 78 |
+
</payucheckout_shared>
|
| 79 |
+
</groups>
|
| 80 |
+
</payment>
|
| 81 |
+
</sections>
|
| 82 |
+
</config>
|
app/code/community/SiteClue/PayuCheckout/sql/payucheckout_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
$installer = $this;
|
| 5 |
+
|
| 6 |
+
$installer->startSetup();
|
| 7 |
+
|
| 8 |
+
$installer->endSetup();
|
app/code/community/SiteClue/PayuCheckout/sql/payucheckout_setup/mysql4-upgrade-0.1.0-1.0.0.php
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
$installer = $this;
|
| 5 |
+
|
| 6 |
+
$installer->startSetup();
|
| 7 |
+
|
| 8 |
+
$installer->run("
|
| 9 |
+
|
| 10 |
+
-- DROP TABLE IF EXISTS `{$this->getTable('payucheckout/api_debug')}`;
|
| 11 |
+
CREATE TABLE `{$this->getTable('payucheckout/api_debug')}` (
|
| 12 |
+
`debug_id` int(10) unsigned NOT NULL auto_increment,
|
| 13 |
+
`debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
| 14 |
+
`request_body` text,
|
| 15 |
+
`response_body` text,
|
| 16 |
+
PRIMARY KEY (`debug_id`),
|
| 17 |
+
KEY `debug_at` (`debug_at`)
|
| 18 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 19 |
+
|
| 20 |
+
");
|
| 21 |
+
|
| 22 |
+
$installer->endSetup();
|
app/code/local/SiteClue/Payuorder/Model/Cron.php
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SiteClue
|
| 4 |
+
* @package SiteClue_Payuorder
|
| 5 |
+
* @copyright Copyright (c) 2015-2016 SiteClue. (http://www.siteclue.com)
|
| 6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 7 |
+
*/
|
| 8 |
+
class SiteClue_Payuorder_Model_Cron {
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
private $_merchant_key;
|
| 12 |
+
|
| 13 |
+
private $_merchant_salt;
|
| 14 |
+
|
| 15 |
+
private $_ws_url;
|
| 16 |
+
|
| 17 |
+
private $_command;
|
| 18 |
+
|
| 19 |
+
private $_query_string;
|
| 20 |
+
|
| 21 |
+
private $_order_id;
|
| 22 |
+
|
| 23 |
+
private $_output;
|
| 24 |
+
|
| 25 |
+
public function updateOderStatus() {
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
//Magento Order Collection Model
|
| 29 |
+
$orderCollection = Mage::getResourceModel('sales/order_collection');
|
| 30 |
+
$time = time();
|
| 31 |
+
$to = date('Y-m-d H:i:s', $time-3600);
|
| 32 |
+
$lastTime = $time - 604800; // 60*60*24
|
| 33 |
+
$from = date('Y-m-d H:i:s', $lastTime);
|
| 34 |
+
//Fetching the Orders
|
| 35 |
+
$orderCollection
|
| 36 |
+
->addFieldToFilter('state', 'new') // Where state is new
|
| 37 |
+
->addFieldToFilter('status', 'pending') // And status is pending
|
| 38 |
+
->addAttributeToFilter('created_at', array('from' => $from, 'to' => $to))
|
| 39 |
+
->getSelect();
|
| 40 |
+
|
| 41 |
+
foreach ($orderCollection->getItems() as $order) {
|
| 42 |
+
|
| 43 |
+
//Magento Order Model
|
| 44 |
+
$orderModel = Mage::getModel('sales/order');
|
| 45 |
+
//Loading current order into memory by its id
|
| 46 |
+
$orderModel->load($order->getId());
|
| 47 |
+
$increment_id = $order->getIncrementId();
|
| 48 |
+
$payu_order_id = $increment_id;
|
| 49 |
+
//Fetching the MihPayId for the current upprocessed order
|
| 50 |
+
|
| 51 |
+
$verifyPayment = $this->verifyPayment($payu_order_id)->toArray();
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
$payu_order_id = '' . $payu_order_id;
|
| 56 |
+
$count = count($verifyPayment['transaction_details'][$payu_order_id]);
|
| 57 |
+
$index_count = array_filter($verifyPayment['transaction_details'][$payu_order_id], 'is_array');
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
if ($count == 0 && count($index_count) == 0)
|
| 61 |
+
continue;
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
elseif (isset($verifyPayment['status']) && $verifyPayment['status'] == 1) {
|
| 65 |
+
|
| 66 |
+
if (count($index_count) == 0) {
|
| 67 |
+
|
| 68 |
+
if ($verifyPayment['transaction_details'][$payu_order_id]['unmappedstatus'] == 'captured') {
|
| 69 |
+
|
| 70 |
+
//Set the new status for the current order
|
| 71 |
+
$orderModel->setStatus('Processing');
|
| 72 |
+
//Save the current order
|
| 73 |
+
$orderModel->save();
|
| 74 |
+
} elseif ($verifyPayment['transaction_details'][$payu_order_id]['unmappedstatus'] == 'userCancelled') {
|
| 75 |
+
|
| 76 |
+
//Set the new status for the current order
|
| 77 |
+
$orderModel->setStatus('canceled');
|
| 78 |
+
//Save the current order
|
| 79 |
+
$orderModel->save();
|
| 80 |
+
} else {
|
| 81 |
+
|
| 82 |
+
$orderModel->setStatus('holded');
|
| 83 |
+
//Save the current order
|
| 84 |
+
$orderModel->save();
|
| 85 |
+
}
|
| 86 |
+
} else {
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
foreach ($verifyPayment['transaction_details'][$payu_order_id] as $key => $value) {
|
| 90 |
+
//Check if payment is done for the current Order
|
| 91 |
+
|
| 92 |
+
if ($verifyPayment['transaction_details'][$payu_order_id][$key]['unmappedstatus'] == 'captured') {
|
| 93 |
+
//Set the new status for the current order
|
| 94 |
+
|
| 95 |
+
$orderModel->setStatus('Processing');
|
| 96 |
+
//Save the current order
|
| 97 |
+
$orderModel->save();
|
| 98 |
+
break;
|
| 99 |
+
} elseif ($verifyPayment['transaction_details'][$payu_order_id][$key]['unmappedstatus'] == 'userCancelled') {
|
| 100 |
+
//Set the new status for the current order
|
| 101 |
+
$orderModel->setStatus('canceled');
|
| 102 |
+
|
| 103 |
+
//Save the current order
|
| 104 |
+
$orderModel->save();
|
| 105 |
+
} else {
|
| 106 |
+
|
| 107 |
+
$orderModel->setStatus('holded');
|
| 108 |
+
//Save the current order
|
| 109 |
+
$orderModel->save();
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
public function verifyPayment($order_id) {
|
| 119 |
+
//Set the command varibale to verify payment API
|
| 120 |
+
$this->_command = 'verify_payment';
|
| 121 |
+
//Making HTTP request to PayU Verification service
|
| 122 |
+
$this->_output = $this->_initData()
|
| 123 |
+
->_prepareData($order_id)
|
| 124 |
+
->_curlExecute();
|
| 125 |
+
return $this;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
public function checkPayment($mihpayid) {
|
| 130 |
+
//Set the command varibale to verify payment API
|
| 131 |
+
$this->_command = 'check_payment';
|
| 132 |
+
//Making HTTP request to PayU Verification service
|
| 133 |
+
$this->_output = $this->_initData()
|
| 134 |
+
->_prepareData($mihpayid)
|
| 135 |
+
->_curlExecute();
|
| 136 |
+
return $this;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
private function _initData() {
|
| 141 |
+
//Setting Merchnat Key
|
| 142 |
+
$this->_merchant_key = Mage::getStoreConfig('payment/payucheckout_shared/key');
|
| 143 |
+
//Setting Merchnat Salt
|
| 144 |
+
$this->_merchant_salt = Mage::getStoreConfig('payment/payucheckout_shared/salt');
|
| 145 |
+
//Setting Ws URL
|
| 146 |
+
$this->_ws_url = $this->_get_ws_url();
|
| 147 |
+
return $this;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
private function _prepareData($order_id) {
|
| 152 |
+
//Hash String
|
| 153 |
+
$hash_str = $this->_merchant_key . '|' . $this->_command . '|' . $order_id . '|' . $this->_merchant_salt;
|
| 154 |
+
// Hash
|
| 155 |
+
$hash = strtolower(hash('sha512', $hash_str));
|
| 156 |
+
//Request Parameters
|
| 157 |
+
$r = array('key' => $this->_merchant_key, 'command' => $this->_command, 'hash' => $hash, 'var1' => $order_id);
|
| 158 |
+
//Request Parameter http query string
|
| 159 |
+
$this->_query_string = http_build_query($r);
|
| 160 |
+
return $this;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
private function _curlExecute() {
|
| 165 |
+
//Initalize CURL
|
| 166 |
+
$c = curl_init();
|
| 167 |
+
//Seting CURL Header to make a http request
|
| 168 |
+
curl_setopt($c, CURLOPT_URL, $this->_ws_url);
|
| 169 |
+
curl_setopt($c, CURLOPT_POST, 1);
|
| 170 |
+
curl_setopt($c, CURLOPT_POSTFIELDS, $this->_query_string);
|
| 171 |
+
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 30);
|
| 172 |
+
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
|
| 173 |
+
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
|
| 174 |
+
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
|
| 175 |
+
//Executing CURL
|
| 176 |
+
$o = curl_exec($c);
|
| 177 |
+
//Check if CURL have any error
|
| 178 |
+
if (curl_errno($c)) {
|
| 179 |
+
$sad = curl_error($c);
|
| 180 |
+
throw new Exception($sad);
|
| 181 |
+
}
|
| 182 |
+
//Closing CURL connection
|
| 183 |
+
curl_close($c);
|
| 184 |
+
return $o;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
public function toArray() {
|
| 189 |
+
//Json to Array
|
| 190 |
+
return json_decode(json_encode(json_decode($this->_output)), true);
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
private function _get_ws_url() {
|
| 195 |
+
//PayU getway mode configuration
|
| 196 |
+
$mode = Mage::getStoreConfig('payment/payucheckout_shared/demo_mode');
|
| 197 |
+
if ($mode == '') {
|
| 198 |
+
return "https://info.payu.in/merchant/postservice?form=2";
|
| 199 |
+
} else {
|
| 200 |
+
return "https://test.payu.in/merchant/postservice?form=2";
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
}
|
app/code/local/SiteClue/Payuorder/etc/config.xml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<SiteClue_Payuorder>
|
| 5 |
+
<version>1.0.0</version>
|
| 6 |
+
</SiteClue_Payuorder>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<models>
|
| 10 |
+
<payuorder>
|
| 11 |
+
<class>SiteClue_Payuorder_Model</class>
|
| 12 |
+
<resourceModel>payuorder_mysql4</resourceModel>
|
| 13 |
+
</payuorder>
|
| 14 |
+
</models>
|
| 15 |
+
</global>
|
| 16 |
+
<crontab>
|
| 17 |
+
<jobs>
|
| 18 |
+
<payuorder_updateoderstatus>
|
| 19 |
+
<schedule><cron_expr>* * * * *</cron_expr></schedule>
|
| 20 |
+
<run><model>payuorder/cron::updateOderStatus</model></run>
|
| 21 |
+
</payuorder_updateoderstatus>
|
| 22 |
+
</jobs>
|
| 23 |
+
</crontab>
|
| 24 |
+
</config>
|
app/design/frontend/base/default/layout/payucheckout.xml
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
|
| 3 |
+
<layout version="0.1.0">
|
| 4 |
+
<!-- Payucgeckout Failure Response Review -->
|
| 5 |
+
<payucheckout_shared_failure>
|
| 6 |
+
<reference name="root">
|
| 7 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
| 8 |
+
</reference>
|
| 9 |
+
<reference name="content">
|
| 10 |
+
<block type="payucheckout/shared_failure" name="payucheckout_shared_failure" template="payucheckout/shared/failure.phtml">
|
| 11 |
+
</block>
|
| 12 |
+
|
| 13 |
+
</reference>
|
| 14 |
+
<reference name="content">
|
| 15 |
+
|
| 16 |
+
</reference>
|
| 17 |
+
</payucheckout_shared_failure>
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
<!-- Payucgeckout Cancel Response Review -->
|
| 21 |
+
<payucheckout_shared_canceled>
|
| 22 |
+
<reference name="root">
|
| 23 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
| 24 |
+
</reference>
|
| 25 |
+
<reference name="content">
|
| 26 |
+
<block type="payucheckout/shared_canceled" name="payucheckout_shared_canceled"
|
| 27 |
+
template="payucheckout/shared/canceled.phtml">
|
| 28 |
+
</block>
|
| 29 |
+
|
| 30 |
+
</reference>
|
| 31 |
+
<reference name="content">
|
| 32 |
+
|
| 33 |
+
</reference>
|
| 34 |
+
</payucheckout_shared_canceled>
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
</layout>
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
|
app/design/frontend/base/default/template/payucheckout/form.phtml
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
| 1 |
+
|
app/design/frontend/base/default/template/payucheckout/info.phtml
ADDED
|
File without changes
|
app/design/frontend/base/default/template/payucheckout/shared/canceled.phtml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
<div class="page-head">
|
| 3 |
+
<h3><?php echo $this->__('Payment transaction has been canceled.') ?></h3>
|
| 4 |
+
</div>
|
| 5 |
+
<p><?php //echo $this->getErrorMessage() ?>.</p>
|
| 6 |
+
<p><?php echo $this->__('Please <a href="%s">continue shopping</a>.', $this->getContinueShoppingUrl()) ?></p>
|
app/design/frontend/base/default/template/payucheckout/shared/failure.phtml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
<div class="page-head">
|
| 3 |
+
<h3><?php echo $this->__('Order payment has been failed') ?></h3>
|
| 4 |
+
</div>
|
| 5 |
+
<p><?php echo $this->getErrorMessage() ?>.</p>
|
| 6 |
+
<p><?php echo $this->__('Please <a href="%s">continue shopping</a>.', $this->getContinueShoppingUrl()) ?></p>
|
app/design/frontend/base/default/template/payucheckout/shared/form.phtml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
<fieldset class="form-list">
|
| 3 |
+
<?php $_code=$this->getMethodCode() ?>
|
| 4 |
+
<ul id="payment_form_<?php echo $_code ?>" style="display:none">
|
| 5 |
+
<li>
|
| 6 |
+
<?php echo $this->__('You will be redirected to PayuCheckout website when you place an order.') ?>
|
| 7 |
+
</li>
|
| 8 |
+
</ul>
|
| 9 |
+
</fieldset>
|
app/etc/modules/SiteClue_PayuCheckout.xml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<SiteClue_PayuCheckout>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
<depends>
|
| 8 |
+
<Mage_Payment/>
|
| 9 |
+
</depends>
|
| 10 |
+
</SiteClue_PayuCheckout>
|
| 11 |
+
</modules>
|
| 12 |
+
</config>
|
app/etc/modules/SiteClue_Payuorder.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<SiteClue_Payuorder>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
</SiteClue_Payuorder>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>PayU-India-Basic</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>Academic Free License (AFL)</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>PayU is the fastest growing payment system in India! PayU focuses on flexible, effective and user friendly payment solutions for extreme competitive prices.</summary>
|
| 10 |
+
<description>PayU is the fastest growing payment system in India! PayU focuses on flexible, effective and user friendly payment solutions for extreme competitive prices.</description>
|
| 11 |
+
<notes>PayU is the fastest growing payment system in India! PayU focuses on flexible, effective and user friendly payment solutions for extreme competitive prices.</notes>
|
| 12 |
+
<authors><author><name>SiteClue</name><user>SiteClue</user><email>siteclue@gmail.com</email></author></authors>
|
| 13 |
+
<date>2015-03-05</date>
|
| 14 |
+
<time>18:53:32</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir name="SiteClue"><dir name="PayuCheckout"><dir name="Block"><dir name="Shared"><file name="Canceled.php" hash="5c26b8e7999309204d69156b73e324ed"/><file name="Failure.php" hash="afc0af6bb97802cd7b0d0cfe5eda6ef9"/><file name="Form.php" hash="3c27c29f355864acd559c2abb0359748"/><file name="Redirect.php" hash="537a6425f342a8491d28f01f88a88850"/></dir></dir><dir name="Controller"><file name="Abstract.php" hash="90854a95410f1efeb29931dd4a7906a3"/></dir><dir name="Helper"><file name="Data.php" hash="f4b10a5f3a5b3d6abfc90cb66b32b47a"/></dir><dir name="Model"><dir name="Api"><file name="Debug.php" hash="93dcfbdf54266196d0617aac6bfec27b"/></dir><dir name="Mysql4"><dir name="Api"><dir name="Debug"><file name="Collection.php" hash="1bbb95c5cd69f888db06e99c8d0cd97b"/></dir><file name="Debug.php" hash="56973f1df14449ec9522f98373371161"/></dir><file name="Setup.php" hash="d9b2b1e3c78694bf0f9037b9bb26ad87"/></dir><file name="Shared.php" hash="d635a38477817cbd68958da0c4308484"/><dir name="Source"><file name="DemoModes.php" hash="6f8f337a249d46d85de196effda9edc9"/><file name="DirectReturn.php" hash="b7ee24b67622c87ea6b387717b44b897"/><file name="PaymentRoutines.php" hash="6101be618b57879108f8001a951cf0ef"/></dir></dir><dir name="controllers"><file name="SharedController.php" hash="987a18f8d5b5ac76acbc63e794f4145b"/></dir><dir name="etc"><file name="config.xml" hash="890e74844e4ef3817a6f2b7b041b1698"/><file name="system.xml" hash="ba018756947744682cbdfc390f92f996"/></dir><dir name="sql"><dir name="payucheckout_setup"><file name="mysql4-install-0.1.0.php" hash="358816583b068e30af7f0e3e7181b4a4"/><file name="mysql4-upgrade-0.1.0-1.0.0.php" hash="78983e670d1c6cfd06688402a4bc097a"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="payucheckout.xml" hash="c77d92a6c0a9fe598e61525658382fe6"/></dir><dir name="template"><dir name="payucheckout"><file name="form.phtml" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="info.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/><dir name="shared"><file name="canceled.phtml" hash="bdef89131c08a83d3c1742399d58b433"/><file name="failure.phtml" hash="a54ece778621c5e2b35f4983923bfeb3"/><file name="form.phtml" hash="f8f62958bac1bf15fde40ed24078d97f"/></dir></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="SiteClue"><dir name="Payuorder"><dir name="Model"><file name="Cron.php" hash="adf2ae9ef779938f14b3eae8d326e581"/></dir><dir name="etc"><file name="config.xml" hash="e2d7f81faa8e1502b78baef379837699"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SiteClue_PayuCheckout.xml" hash="2d45a68025a8e43a62ae16b674a73993"/><file name="SiteClue_Payuorder.xml" hash="e2f8505aa989e7c3df63075d156a5629"/></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
+
</package>
|
