Version Notes
First public release
Download this release
Release Info
Developer | PayToo Corp. |
Extension | Paytoo_GoPayToo |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Paytoo/GoPayToo/Block/Form.php +32 -0
- app/code/local/Paytoo/GoPayToo/Block/Info.php +36 -0
- app/code/local/Paytoo/GoPayToo/Block/Redirect.php +65 -0
- app/code/local/Paytoo/GoPayToo/Helper/Data.php +25 -0
- app/code/local/Paytoo/GoPayToo/Model/Checkout.php +288 -0
- app/code/local/Paytoo/GoPayToo/Model/Observer.php +80 -0
- app/code/local/Paytoo/GoPayToo/controllers/NotificationController.php +300 -0
- app/code/local/Paytoo/GoPayToo/controllers/RedirectController.php +209 -0
- app/code/local/Paytoo/GoPayToo/etc/config.xml +108 -0
- app/code/local/Paytoo/GoPayToo/etc/system.xml +188 -0
- app/design/frontend/base/default/template/gopaytoo/form.phtml +23 -0
- app/design/frontend/base/default/template/gopaytoo/info.phtml +25 -0
- package.xml +19 -0
app/code/local/Paytoo/GoPayToo/Block/Form.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category PayToo Corp.
|
17 |
+
* @package GoPayToo (gopaytoo.com)
|
18 |
+
* @copyright Copyright (c) 2013 PayToo Corp.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
class Paytoo_GoPayToo_Block_Form extends Mage_Payment_Block_Form
|
23 |
+
{
|
24 |
+
protected function _construct()
|
25 |
+
{
|
26 |
+
parent::_construct();
|
27 |
+
$this->setTemplate('gopaytoo/form.phtml');
|
28 |
+
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
?>
|
app/code/local/Paytoo/GoPayToo/Block/Info.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category PayToo Corp.
|
17 |
+
* @package GoPayToo (gopaytoo.com)
|
18 |
+
* @copyright Copyright (c) 2013 PayToo Corp.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
class Paytoo_GoPayToo_Block_Info extends Mage_Payment_Block_Info {
|
23 |
+
|
24 |
+
protected function _construct() {
|
25 |
+
parent::_construct();
|
26 |
+
$this->setTemplate('gopaytoo/info.phtml');
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getMethodCode()
|
30 |
+
{
|
31 |
+
return $this->getInfo()->getMethodInstance()->getCode();
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
?>
|
app/code/local/Paytoo/GoPayToo/Block/Redirect.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category PayToo Corp.
|
17 |
+
* @package GoPayToo (gopaytoo.com)
|
18 |
+
* @copyright Copyright (c) 2013 PayToo Corp.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
class Paytoo_GoPayToo_Block_Redirect extends Mage_Core_Block_Abstract
|
25 |
+
{
|
26 |
+
protected function _toHtml()
|
27 |
+
{
|
28 |
+
$gopaytoo = Mage::getModel('gopaytoo/checkout');
|
29 |
+
|
30 |
+
$form = new Varien_Data_Form();
|
31 |
+
$form->setAction($gopaytoo->getUrl())
|
32 |
+
->setId('pay')
|
33 |
+
->setName('pay')
|
34 |
+
->setMethod('POST')
|
35 |
+
->setUseContainer(true);
|
36 |
+
$gopaytoo->getFormFields();
|
37 |
+
foreach ($gopaytoo->getFormFields() as $field=>$value) {
|
38 |
+
if (is_array($value)) {
|
39 |
+
foreach ($value as $field2=>$value2) {
|
40 |
+
if (is_array($value2)) {
|
41 |
+
foreach ($value2 as $field3=>$value3) {
|
42 |
+
$form->addField($field.'['.$field2.']'.'['.$field3.']', 'hidden', array('name'=>$field.'['.$field2.']'.'['.$field3.']', 'value'=>$value3, 'size'=>200));
|
43 |
+
}
|
44 |
+
} else {
|
45 |
+
$form->addField($field.'['.$field2.']', 'hidden', array('name'=>$field.'['.$field2.']', 'value'=>$value2, 'size'=>200));
|
46 |
+
}
|
47 |
+
}
|
48 |
+
} else {
|
49 |
+
$form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value, 'size'=>200));
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
$html = '<html><body>';
|
54 |
+
$html.= $gopaytoo->getRedirectMessage();
|
55 |
+
$html.= $form->toHtml();
|
56 |
+
$html.= '<br>';
|
57 |
+
$html.= '<script type="text/javascript">document.getElementById("pay").submit();</script>';
|
58 |
+
$html.= '</body></html>';
|
59 |
+
|
60 |
+
|
61 |
+
return $html;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
?>
|
app/code/local/Paytoo/GoPayToo/Helper/Data.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category PayToo Corp.
|
17 |
+
* @package GoPayToo (gopaytoo.com)
|
18 |
+
* @copyright Copyright (c) 2013 PayToo Corp.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
class Paytoo_GoPayToo_Helper_Data extends Mage_Core_Helper_Abstract
|
23 |
+
{
|
24 |
+
|
25 |
+
}
|
app/code/local/Paytoo/GoPayToo/Model/Checkout.php
ADDED
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category PayToo Corp.
|
17 |
+
* @package GoPayToo (gopaytoo.com)
|
18 |
+
* @copyright Copyright (c) 2013 PayToo Corp.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
class Paytoo_GoPayToo_Model_Checkout extends Mage_Payment_Model_Method_Abstract {
|
23 |
+
|
24 |
+
protected $_code = 'gopaytoo';
|
25 |
+
protected $_paymentMethod = 'shared';
|
26 |
+
|
27 |
+
public function getCheckout() {
|
28 |
+
return Mage::getSingleton('checkout/session');
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getOrderPlaceRedirectUrl() {
|
32 |
+
return Mage::getUrl('gopaytoo/redirect');
|
33 |
+
}
|
34 |
+
|
35 |
+
//get SID
|
36 |
+
public function getSid() {
|
37 |
+
$sid = $this->getConfigData('sid');
|
38 |
+
return $sid;
|
39 |
+
}
|
40 |
+
|
41 |
+
//get Demo Setting
|
42 |
+
public function getDemo() {
|
43 |
+
if ($this->getConfigData('demo') == '1') {
|
44 |
+
return true;
|
45 |
+
} else {
|
46 |
+
return false;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
//get purchase routine URL
|
51 |
+
public function getUrl() {
|
52 |
+
return ($this->getDemo()) ? 'https://merchant.paytoo.info/gateway' : 'https://www.gopaytoo.com/gateway';
|
53 |
+
}
|
54 |
+
|
55 |
+
//get checkout language
|
56 |
+
public function getLanguage() {
|
57 |
+
$lang = $this->getConfigData('checkout_language');
|
58 |
+
return $lang;
|
59 |
+
}
|
60 |
+
|
61 |
+
//get custom checkout message
|
62 |
+
public function getRedirectMessage() {
|
63 |
+
$redirect_message = $this->getConfigData('redirect_message');
|
64 |
+
return $redirect_message;
|
65 |
+
}
|
66 |
+
|
67 |
+
//get order
|
68 |
+
public function getQuote() {
|
69 |
+
$orderIncrementId = $this->getCheckout()->getLastRealOrderId();
|
70 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
71 |
+
return $order;
|
72 |
+
}
|
73 |
+
|
74 |
+
//get product data
|
75 |
+
public function getProductData() {
|
76 |
+
$products = array();
|
77 |
+
$items = $this->getQuote()->getAllItems();
|
78 |
+
if ($items) {
|
79 |
+
$i = 1;
|
80 |
+
foreach($items as $item){
|
81 |
+
if ($item->getParentItem()) {
|
82 |
+
continue;
|
83 |
+
}
|
84 |
+
$products['products'][$i]['name'] = $item->getName();
|
85 |
+
$products['products'][$i]['description'] = $item->getSku();
|
86 |
+
$products['products'][$i]['price'] = number_format($item->getPrice(), 2, '.', '');
|
87 |
+
$products['products'][$i]['sku'] = $item->getSku();
|
88 |
+
$products['products'][$i]['qty'] = $item->getQtyToInvoice();
|
89 |
+
$i++;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
return $products;
|
93 |
+
}
|
94 |
+
|
95 |
+
//get lineitem data
|
96 |
+
public function getLineitemData() {
|
97 |
+
$lineitems = array();
|
98 |
+
$items = $this->getQuote()->getAllItems();
|
99 |
+
$order_id = $this->getCheckout()->getLastRealOrderId();
|
100 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
|
101 |
+
$taxFull = $order->getFullTaxInfo();
|
102 |
+
$ship_method = $order->getShipping_description();
|
103 |
+
$coupon = $order->getCoupon_code();
|
104 |
+
$lineitem_total = 0;
|
105 |
+
$i = 1;
|
106 |
+
//get products
|
107 |
+
if ($items) {
|
108 |
+
foreach($items as $item){
|
109 |
+
if ($item->getParentItem()) {
|
110 |
+
continue;
|
111 |
+
}
|
112 |
+
$lineitems['items'][$i]['type'] = 'product';
|
113 |
+
$lineitems['items'][$i]['product_id'] = $item->getSku();
|
114 |
+
$lineitems['items'][$i]['quantity'] = $item->getQtyToInvoice();
|
115 |
+
$lineitems['items'][$i]['name'] = $item->getName();
|
116 |
+
$lineitems['items'][$i]['description'] = $item->getDescription();
|
117 |
+
$lineitems['items'][$i]['price'] = number_format($item->getPrice(), 2, '.', '');
|
118 |
+
$lineitem_total += number_format($item->getPrice(), 2, '.', '');
|
119 |
+
$i++;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
//get taxes
|
123 |
+
if ($taxFull) {
|
124 |
+
foreach ($taxFull as $rate){
|
125 |
+
$lineitems['items'][$i]['type'] = 'tax';
|
126 |
+
$lineitems['items'][$i]['name'] = $rate['rates']['0']['code'];
|
127 |
+
$lineitems['items'][$i]['price'] = round($rate['amount'], 2);
|
128 |
+
$lineitem_total += round($rate['amount'], 2);
|
129 |
+
$i++;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
//get shipping
|
133 |
+
if ($ship_method) {
|
134 |
+
$lineitems['items'][$i]['type'] = 'shipping';
|
135 |
+
$lineitems['items'][$i]['name'] = $order->getShipping_description();
|
136 |
+
$lineitems['items'][$i]['price'] = round($order->getShippingAmount(), 2);
|
137 |
+
$lineitem_total += round($order->getShippingAmount(), 2);
|
138 |
+
$i++;
|
139 |
+
}
|
140 |
+
//get coupons
|
141 |
+
if ($coupon) {
|
142 |
+
$lineitems['items'][$i]['type'] = 'coupon';
|
143 |
+
$lineitems['items'][$i]['name'] = $order->getCoupon_code();
|
144 |
+
$lineitems['items'][$i]['price'] = trim(round($order->getBase_discount_amount(), 2), '-');
|
145 |
+
$lineitem_total -= trim(round($order->getBase_discount_amount(), 2), '-');
|
146 |
+
$i++;
|
147 |
+
}
|
148 |
+
return $lineitems;
|
149 |
+
}
|
150 |
+
|
151 |
+
//check total
|
152 |
+
public function checkTotal() {
|
153 |
+
$items = $this->getQuote()->getAllItems();
|
154 |
+
$order_id = $this->getCheckout()->getLastRealOrderId();
|
155 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
|
156 |
+
$taxFull = $order->getFullTaxInfo();
|
157 |
+
$ship_method = $order->getShipping_description();
|
158 |
+
$coupon = $order->getCoupon_code();
|
159 |
+
$lineitem_total = 0;
|
160 |
+
$i = 1;
|
161 |
+
//get products
|
162 |
+
if ($items) {
|
163 |
+
foreach($items as $item){
|
164 |
+
if ($item->getParentItem()) {
|
165 |
+
continue;
|
166 |
+
}
|
167 |
+
$lineitem_total += number_format($item->getPrice(), 2, '.', '');
|
168 |
+
}
|
169 |
+
}
|
170 |
+
//get taxes
|
171 |
+
if ($taxFull) {
|
172 |
+
foreach($taxFull as $rate){
|
173 |
+
$lineitem_total += round($rate['amount'], 2);
|
174 |
+
}
|
175 |
+
}
|
176 |
+
//get shipping
|
177 |
+
if ($ship_method) {
|
178 |
+
$lineitem_total += round($order->getShippingAmount(), 2);
|
179 |
+
}
|
180 |
+
//get coupons
|
181 |
+
if ($coupon) {
|
182 |
+
$lineitem_total -= trim(round($order->getBase_discount_amount(), 2), '-');
|
183 |
+
}
|
184 |
+
return $lineitem_total;
|
185 |
+
}
|
186 |
+
|
187 |
+
//get tax data
|
188 |
+
public function getTaxData() {
|
189 |
+
$order_id = $this->getCheckout()->getLastRealOrderId();
|
190 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
|
191 |
+
$taxes = array();
|
192 |
+
$taxFull = $order->getFullTaxInfo();
|
193 |
+
if ($taxFull) {
|
194 |
+
$i = 1;
|
195 |
+
foreach($taxFull as $rate){
|
196 |
+
$taxes['tax'][$i]['id'] = $rate['rates']['0']['code'];
|
197 |
+
$taxes['tax'][$i]['amount'] = round($rate['amount'], 2);
|
198 |
+
$i++;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
return $taxes;
|
202 |
+
}
|
203 |
+
|
204 |
+
//get HTML form data
|
205 |
+
public function getFormFields() {
|
206 |
+
$order_id = $this->getCheckout()->getLastRealOrderId();
|
207 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
|
208 |
+
$amount = round($order->getGrandTotal(), 2);
|
209 |
+
$a = $this->getQuote()->getShippingAddress();
|
210 |
+
$b = $this->getQuote()->getBillingAddress();
|
211 |
+
$country = $b->getCountry();
|
212 |
+
$currency_code = $order->getOrderCurrencyCode();
|
213 |
+
$shipping = round($order->getShippingAmount(), 2);
|
214 |
+
$weight = round($order->getWeight(), 2);
|
215 |
+
$ship_method = $order->getShipping_description();
|
216 |
+
$tax = trim(round($order->getTaxAmount(), 2));
|
217 |
+
$productData = $this->getProductData();
|
218 |
+
$taxData = $this->getTaxData();
|
219 |
+
$cart_order_id = $order_id;
|
220 |
+
$lineitemData = $this->getLineitemData();
|
221 |
+
|
222 |
+
$gopaytooFields = array();
|
223 |
+
|
224 |
+
$gopaytooFields['cart_type'] = 'magento';
|
225 |
+
$gopaytooFields['merchant_id'] = $this->getSid();
|
226 |
+
$gopaytooFields['lang'] = $this->getLanguage();
|
227 |
+
$gopaytooFields['amount'] = $amount;
|
228 |
+
$gopaytooFields['tax'] = $tax;
|
229 |
+
$gopaytooFields['currency'] = $order->getOrderCurrencyCode(); // USD
|
230 |
+
$gopaytooFields['order_ref'] = $order_id;
|
231 |
+
$gopaytooFields['order_description'] = Mage::helper('gopaytoo')->__('Order #%s on %s', $order_id, Mage::app()->getWebsite()->getName());
|
232 |
+
|
233 |
+
$gopaytooFields['sub_account_id'] = '';
|
234 |
+
$gopaytooFields['custom_field1'] = '';
|
235 |
+
$gopaytooFields['custom_field2'] = '';
|
236 |
+
$gopaytooFields['custom_field3'] = '';
|
237 |
+
$gopaytooFields['custom_field4'] = '';
|
238 |
+
$gopaytooFields['custom_field5'] = '';
|
239 |
+
|
240 |
+
$gopaytooFields['lang'] = $this->getLanguage();
|
241 |
+
$gopaytooFields['completed_url'] = Mage::getUrl('gopaytoo/redirect/success', array('_secure' => true));
|
242 |
+
$gopaytooFields['cancelled_url'] = Mage::getUrl('gopaytoo/redirect/cancel', array('_secure' => true));
|
243 |
+
$gopaytooFields['rejected_url'] = Mage::getUrl('gopaytoo/redirect/reject', array('_secure' => true));;
|
244 |
+
$gopaytooFields['esign_url'] = Mage::getUrl('gopaytoo/redirect/esign', array('_secure' => true));;
|
245 |
+
|
246 |
+
$gopaytooFields['user']['email'] = $order->getData('customer_email');
|
247 |
+
$gopaytooFields['user']['firstname'] = $b->getFirstname();
|
248 |
+
$gopaytooFields['user']['lastname'] = $b->getLastname();
|
249 |
+
$gopaytooFields['user']['address'] = $b->getStreet1()." ".$b->getStreet2();
|
250 |
+
$gopaytooFields['user']['zipcode'] = $b->getPostcode();
|
251 |
+
$gopaytooFields['user']['city'] = $b->getCity();
|
252 |
+
$gopaytooFields['user']['country'] = $b->getCountry();
|
253 |
+
$gopaytooFields['user']['state'] = ($gopaytooFields['user']['country']=='US') ? $b->getRegion() : '';
|
254 |
+
$gopaytooFields['user']['cellphone'] = $b->getTelephone();
|
255 |
+
|
256 |
+
if ($a) {
|
257 |
+
$gopaytooFields['shipping']['firstname'] = $a->getFirstname();
|
258 |
+
$gopaytooFields['shipping']['lastname'] = $a->getLastname();
|
259 |
+
$gopaytooFields['shipping']['country'] = $a->getCountry();
|
260 |
+
$gopaytooFields['shipping']['address'] = $a->getStreet1();
|
261 |
+
$gopaytooFields['shipping']['address2'] = $a->getStreet2();
|
262 |
+
$gopaytooFields['shipping']['city'] = $a->getCity();
|
263 |
+
$gopaytooFields['shipping']['state'] = $a->getRegion();
|
264 |
+
$gopaytooFields['shipping']['zip'] = $a->getPostcode();
|
265 |
+
$gopaytooFields['shipping']['cost'] = $shipping;
|
266 |
+
$gopaytooFields['shipping']['weight'] = $weight;
|
267 |
+
$gopaytooFields['shipping']['method'] = $ship_method;
|
268 |
+
}
|
269 |
+
|
270 |
+
$gopaytooFields['recurring']['enabled'] = 'no';
|
271 |
+
$gopaytooFields['recurring']['amount'] = '';
|
272 |
+
$gopaytooFields['recurring']['cycles'] = '';
|
273 |
+
$gopaytooFields['recurring']['periodicity'] = '';
|
274 |
+
$gopaytooFields['recurring']['start_date'] = '';
|
275 |
+
|
276 |
+
// Calculate/Set the hash keys
|
277 |
+
$hashKey = Mage::getStoreConfig('payment/gopaytoo/secret_word');
|
278 |
+
$hash = md5($gopaytooFields['merchant_id'].$gopaytooFields['amount'].$gopaytooFields['currency'].$gopaytooFields['order_ref'].$hashKey);
|
279 |
+
$gopaytooFields['hash'] = $hash;
|
280 |
+
$rhash = md5($gopaytooFields['recurring']['amount'].$gopaytooFields['recurring']['cycles'].$gopaytooFields['recurring']['periodicity'].$gopaytooFields['recurring']['start_date'].$hashKey);
|
281 |
+
$gopaytooFields['recurring']['hash'] = $rhash;
|
282 |
+
|
283 |
+
$result = $gopaytooFields + $lineitemData + $taxData + $productData;
|
284 |
+
|
285 |
+
return $result;
|
286 |
+
}
|
287 |
+
|
288 |
+
}
|
app/code/local/Paytoo/GoPayToo/Model/Observer.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category PayToo Corp.
|
17 |
+
* @package GoPayToo (gopaytoo.com)
|
18 |
+
* @copyright Copyright (c) 2013 PayToo Corp.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
class Paytoo_GoPayToo_Model_Observer {
|
23 |
+
|
24 |
+
public function issue_creditmemo_refund(Varien_Object $payment) {
|
25 |
+
|
26 |
+
$refund = Mage::getStoreConfig('payment/gopaytoo/refund');
|
27 |
+
|
28 |
+
if ($refund == '1') {
|
29 |
+
$sandbox = Mage::getStoreConfig('payment/gopaytoo/demo');
|
30 |
+
$url = ($sandbox=='1') ? 'https://www.paytoo.info/api/merchant?wsdl' : 'https://www.gopaytoo.com/api/merchant?wsdl';
|
31 |
+
|
32 |
+
$creditmemo = $payment->getCreditmemo()->getOrder()->getData();
|
33 |
+
$creditmemo_amount = $payment->getCreditmemo()->getData();
|
34 |
+
$creditmemo_comment = $payment->getCreditmemo()->getCommentsCollection()->toArray();
|
35 |
+
|
36 |
+
if (empty($creditmemo['ext_order_id'])) {
|
37 |
+
return ;
|
38 |
+
}
|
39 |
+
|
40 |
+
if (isset($creditmemo_comment['items'][0]['comment'])){
|
41 |
+
$reason = $creditmemo_comment['items'][0]['comment'];
|
42 |
+
} else {
|
43 |
+
$reason = 'Refund issued by seller';
|
44 |
+
}
|
45 |
+
|
46 |
+
$merchant_id = Mage::getStoreConfig('payment/gopaytoo/sid');
|
47 |
+
$password = Mage::getStoreConfig('payment/gopaytoo/password');
|
48 |
+
$amount = $creditmemo_amount['grand_total'];
|
49 |
+
$request_id = $creditmemo['ext_order_id'];
|
50 |
+
|
51 |
+
$soap = new SoapClient($url);
|
52 |
+
try {
|
53 |
+
// Authentification
|
54 |
+
$response = $soap->auth($merchant_id, $password);
|
55 |
+
if($response->status=='OK') {
|
56 |
+
// Refund
|
57 |
+
// Refund($request_id=null, $tr_id=null, $amount=null, $reason=null)
|
58 |
+
$response = $soap->Refund($request_id, null, $amount, $reason);
|
59 |
+
if ($response->status=='OK') {
|
60 |
+
$log = "Transaction refunded on GoPayToo";
|
61 |
+
} elseif($response->status=='ERROR') {
|
62 |
+
$log = $response->msg;
|
63 |
+
}
|
64 |
+
} else {
|
65 |
+
$log = $response->msg;
|
66 |
+
}
|
67 |
+
} catch (Exception $e) {
|
68 |
+
$log = $e->getMessage();
|
69 |
+
}
|
70 |
+
|
71 |
+
if (!empty($log)) {
|
72 |
+
$order = $payment->getCreditmemo()->getOrder();
|
73 |
+
$order->addStatusHistoryComment($log);
|
74 |
+
$order->save();
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
79 |
+
}
|
80 |
+
?>
|
app/code/local/Paytoo/GoPayToo/controllers/NotificationController.php
ADDED
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category PayToo Corp.
|
17 |
+
* @package GoPayToo (gopaytoo.com)
|
18 |
+
* @copyright Copyright (c) 2013 PayToo Corp.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
class Paytoo_GoPayToo_NotificationController extends Mage_Core_Controller_Front_Action {
|
23 |
+
|
24 |
+
public function indexAction() {
|
25 |
+
$request = $_POST['MerchantApiResponse']['PaytooRequest'];
|
26 |
+
$hash = $_POST['MerchantApiResponse']['hash'];
|
27 |
+
|
28 |
+
/*
|
29 |
+
IPN: array (
|
30 |
+
'request_id' => '10187',
|
31 |
+
'tr_id' => '21310',
|
32 |
+
'order_ref' => '100000014',
|
33 |
+
'w_number' => '',
|
34 |
+
'phone_number' => '',
|
35 |
+
'tr_status' => 'completed',
|
36 |
+
'tr_amount' => '18.5000',
|
37 |
+
'tr_currency' => 'USD',
|
38 |
+
'tr_requested_amount' => '18.5000',
|
39 |
+
'tr_requested_currency' => 'USD',
|
40 |
+
'tr_change_rate' => '',
|
41 |
+
'hash' => '70e0e8afc5cf6e5db0fb0af518774577',
|
42 |
+
'MerchantApiResponse' =>
|
43 |
+
array (
|
44 |
+
'status' => 'OK',
|
45 |
+
'request_id' => '10187',
|
46 |
+
'request_status' => 'completed',
|
47 |
+
'tr_id' => '21310',
|
48 |
+
'sub_account_id' => NULL,
|
49 |
+
'ref_id' => '100000014',
|
50 |
+
'msg' => NULL,
|
51 |
+
'info' => NULL,
|
52 |
+
'phone_number' => NULL,
|
53 |
+
'w_number' => NULL,
|
54 |
+
'PaytooRequest' =>
|
55 |
+
array (
|
56 |
+
'request_id' => '10187',
|
57 |
+
'tr_id' => '21310',
|
58 |
+
'user_id' => '10343',
|
59 |
+
'ref_id' => '100000014',
|
60 |
+
'sub_account_id' => NULL,
|
61 |
+
'date' => '2013-04-11 10:10:13',
|
62 |
+
'refund_date' => NULL,
|
63 |
+
'expiration' => '2013-04-13 10:10:13',
|
64 |
+
'statement_id' => NULL,
|
65 |
+
'refund_statement_id' => NULL,
|
66 |
+
'method' => 'gateway',
|
67 |
+
'type' => 'creditcard',
|
68 |
+
'is_pre_auth' => NULL,
|
69 |
+
'is_recurring' => NULL,
|
70 |
+
'is_a_cycle' => NULL,
|
71 |
+
'recurring_id' => NULL,
|
72 |
+
'currency' => 'USD',
|
73 |
+
'amount' => '18.50',
|
74 |
+
'description' => 'Order #100000014 on PayToo Demo Store',
|
75 |
+
'addinfo' => NULL,
|
76 |
+
'status' => 'completed',
|
77 |
+
'status_infos' => NULL,
|
78 |
+
'recurring_amount' => NULL,
|
79 |
+
'recurring_cycles' => NULL,
|
80 |
+
'recurring_period' => NULL,
|
81 |
+
'recurring_start' => NULL,
|
82 |
+
'recurring_end' => NULL,
|
83 |
+
'recurring_status' => NULL,
|
84 |
+
'recurring_info' => NULL,
|
85 |
+
'transaction' => NULL,
|
86 |
+
'card_present' => NULL,
|
87 |
+
'employee_id' => NULL,
|
88 |
+
'location_id' => NULL,
|
89 |
+
'firstname' => NULL,
|
90 |
+
'lastname' => NULL,
|
91 |
+
'email' => NULL,
|
92 |
+
),
|
93 |
+
'PaytooTransaction' =>
|
94 |
+
array (
|
95 |
+
'tr_id' => '21310',
|
96 |
+
'tr_type' => 'creditcard2merchant',
|
97 |
+
'tr_from_type' => 'creditcard',
|
98 |
+
'tr_from_id' => '241',
|
99 |
+
'tr_from_currency' => 'USD',
|
100 |
+
'tr_to_type' => 'merchant',
|
101 |
+
'tr_to_id' => '12345678',
|
102 |
+
'tr_to_currency' => 'USD',
|
103 |
+
'tr_requested_original' => '18.5000',
|
104 |
+
'tr_requested_currency' => 'USD',
|
105 |
+
'tr_amount_requested' => '18.5000',
|
106 |
+
'tr_amount_transfered' => '18.5000',
|
107 |
+
'tr_amount_total_cost' => '18.5000',
|
108 |
+
'tr_amount_refunded' => NULL,
|
109 |
+
'tr_change_rate' => NULL,
|
110 |
+
'tr_fees' => '0.0000',
|
111 |
+
'tr_fees_currency' => 'USD',
|
112 |
+
'tr_fees_type' => 'fixed',
|
113 |
+
'tr_fees_rate_fixed' => '0.0000',
|
114 |
+
'tr_fees_rate_percent' => '0.0000',
|
115 |
+
'tr_fees_level' => '0',
|
116 |
+
'tr_date_created' => '2013-04-11 10:10:13',
|
117 |
+
'tr_date_updated' => '2013-04-11 10:10:13',
|
118 |
+
'tr_date_completed' => '2013-04-11 10:10:13',
|
119 |
+
'tr_date_refunded' => NULL,
|
120 |
+
'tr_notif_sender' => 'email',
|
121 |
+
'tr_notif_receiver' => 'none',
|
122 |
+
'tr_status' => 'completed',
|
123 |
+
'tr_status_msg' => NULL,
|
124 |
+
'pay_infos' => '13962045',
|
125 |
+
),
|
126 |
+
'PaytooAccount' =>
|
127 |
+
array (
|
128 |
+
'user_id' => '10343',
|
129 |
+
'wallet' => '02416039',
|
130 |
+
'currency' => 'USD',
|
131 |
+
'balance' => NULL,
|
132 |
+
'registered_phone' => false,
|
133 |
+
'max_pin' => false,
|
134 |
+
'sim_phonenumber' => false,
|
135 |
+
'prepaidcard' => false,
|
136 |
+
'email' => 'cedric@mayol.biz',
|
137 |
+
'password' => NULL,
|
138 |
+
'gender' => 'm',
|
139 |
+
'firstname' => 'C̩dric',
|
140 |
+
'middlename' => '',
|
141 |
+
'lastname' => 'Mayol',
|
142 |
+
'address' => '13 rue des ch̻nes ',
|
143 |
+
'city' => 'Cr̩py en Valois',
|
144 |
+
'zipcode' => '60800',
|
145 |
+
'country' => 'FR',
|
146 |
+
'state' => '',
|
147 |
+
'phone' => '33679555985',
|
148 |
+
'birthday' => '1979-10-02',
|
149 |
+
'security_code' => NULL,
|
150 |
+
'level' => NULL,
|
151 |
+
'question1' => '1',
|
152 |
+
'answer1' => 'Campione',
|
153 |
+
'question2' => '2',
|
154 |
+
'answer2' => 'Bozo',
|
155 |
+
'question3' => '3',
|
156 |
+
'answer3' => 'Buzz',
|
157 |
+
'citizenship' => '',
|
158 |
+
'id_type' => 'Passport',
|
159 |
+
'id_issued_by_country' => 'FR',
|
160 |
+
'id_issued_by_state' => '',
|
161 |
+
'id_number' => '012345678',
|
162 |
+
'id_expiration' => '2013-03-07',
|
163 |
+
'dist_id' => NULL,
|
164 |
+
'res_id' => NULL,
|
165 |
+
'document1' => NULL,
|
166 |
+
'document2' => NULL,
|
167 |
+
'document3' => NULL,
|
168 |
+
'custom_field1' => NULL,
|
169 |
+
'custom_field2' => NULL,
|
170 |
+
'custom_field3' => NULL,
|
171 |
+
'custom_field4' => NULL,
|
172 |
+
'custom_field5' => NULL,
|
173 |
+
),
|
174 |
+
'hash' => '763e67ba7807f9d0a0732c01f446dc71',
|
175 |
+
),
|
176 |
+
)
|
177 |
+
*/
|
178 |
+
|
179 |
+
if (empty($request) || empty($request['request_id']) || empty($request['ref_id']) || empty($request['amount']) || empty($request['status']) || empty($hash)) {
|
180 |
+
die("Missing parameters");
|
181 |
+
return ;
|
182 |
+
}
|
183 |
+
|
184 |
+
$order = Mage::getModel('sales/order');
|
185 |
+
$order->loadByIncrementId($request['ref_id']);
|
186 |
+
$invoice_on_fraud = Mage::getStoreConfig('payment/gopaytoo/invoice_on_fraud');
|
187 |
+
$invoice_on_order = Mage::getStoreConfig('payment/gopaytoo/invoice_on_order');
|
188 |
+
|
189 |
+
$hashKey = Mage::getStoreConfig('payment/gopaytoo/secret_word');
|
190 |
+
$myhash = md5($request['request_id'].$request['amount'].$request['currency'].$request['status'].$hashKey);
|
191 |
+
|
192 |
+
if ($myhash != $hash) {
|
193 |
+
$order->addStatusHistoryComment('Hash did not match! Expected: '.$myhash.' Received: '.$hash);
|
194 |
+
$order->save();
|
195 |
+
return ;
|
196 |
+
}
|
197 |
+
|
198 |
+
if ($request['status']=='cancelled' || $request['status']=='rejected' || $request['status']=='error' || $request['status']=='expired') {
|
199 |
+
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->addStatusHistoryComment('Payment rejected or cancelled.')->save();
|
200 |
+
if (!empty($request['status_infos']))
|
201 |
+
$order->addStatusHistoryComment($request['status_infos']);
|
202 |
+
$order->save();
|
203 |
+
return ;
|
204 |
+
}
|
205 |
+
|
206 |
+
if ($request['status']=='accepted') {
|
207 |
+
// Pending for signature
|
208 |
+
if($order->canHold()) {
|
209 |
+
$order->hold();
|
210 |
+
$order->setStatus('holded');
|
211 |
+
$order->addStatusHistoryComment('Payment on hold for signature.');
|
212 |
+
$order->save();
|
213 |
+
}
|
214 |
+
return ;
|
215 |
+
}
|
216 |
+
|
217 |
+
if ($request['status']=='chargeback' || $request['status']=='unpaid') {
|
218 |
+
// Chargeback or Unpaid notification
|
219 |
+
// TODO: do something automatically
|
220 |
+
$order->addStatusHistoryComment("Payment has been unpaid (".$request['status'].") - no action taken");
|
221 |
+
if (!empty($request['status_infos']))
|
222 |
+
$order->addStatusHistoryComment($request['status_infos']);
|
223 |
+
$order->save();
|
224 |
+
return ;
|
225 |
+
}
|
226 |
+
|
227 |
+
if ($request['status']=='refunded') {
|
228 |
+
// Refund notification
|
229 |
+
// TODO: do something automatically
|
230 |
+
$order->addStatusHistoryComment("Payment has been refunded - no action taken");
|
231 |
+
if (!empty($request['status_infos']))
|
232 |
+
$order->addStatusHistoryComment($request['status_infos']);
|
233 |
+
$order->save();
|
234 |
+
}
|
235 |
+
|
236 |
+
if ($request['status']!='completed') {
|
237 |
+
$order->addStatusHistoryComment("Invalid IPN status: ".$request['status']." - not treated");
|
238 |
+
if (!empty($request['status_infos']))
|
239 |
+
$order->addStatusHistoryComment($request['status_infos']);
|
240 |
+
$order->save();
|
241 |
+
return ;
|
242 |
+
}
|
243 |
+
|
244 |
+
// Below this it is only 'completed' payment notification
|
245 |
+
$order->setData('ext_order_id', $request['request_id']);
|
246 |
+
$order->save();
|
247 |
+
|
248 |
+
$expected_amount = $order->getBaseGrandTotal();
|
249 |
+
if ($expected_amount != $request['amount']) {
|
250 |
+
//TODO: check currency
|
251 |
+
$order->addStatusHistoryComment('Amount received is not the one expected! Expected: '.$expected_amount.' Received: '.$request['amount']);
|
252 |
+
$order->save();
|
253 |
+
return ;
|
254 |
+
}
|
255 |
+
|
256 |
+
$payment = $order->getPayment();
|
257 |
+
|
258 |
+
$payment->setTransactionId($request['request_id'])
|
259 |
+
->setPreparedMessage($request['status_infos'])
|
260 |
+
->setParentTransactionId(null)
|
261 |
+
->setShouldCloseParentTransaction(true)
|
262 |
+
->setIsTransactionClosed(0)
|
263 |
+
->registerCaptureNotification($request['amount']);
|
264 |
+
|
265 |
+
$order->save();
|
266 |
+
|
267 |
+
$order->sendNewOrderEmail();
|
268 |
+
|
269 |
+
$state = $order->getState();
|
270 |
+
if ($state!=Mage_Sales_Model_Order::STATE_PROCESSING) {
|
271 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
|
272 |
+
}
|
273 |
+
|
274 |
+
/*
|
275 |
+
if ($invoice_on_order == '1') {
|
276 |
+
try {
|
277 |
+
if(!$order->canInvoice()) {
|
278 |
+
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
|
279 |
+
}
|
280 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
281 |
+
if (!$invoice->getTotalQty()) {
|
282 |
+
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
|
283 |
+
}
|
284 |
+
|
285 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
|
286 |
+
$invoice->register();
|
287 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
288 |
+
->addObject($invoice)
|
289 |
+
->addObject($invoice->getOrder());
|
290 |
+
$transactionSave->save();
|
291 |
+
} catch (Mage_Core_Exception $e) {
|
292 |
+
echo $e;
|
293 |
+
}
|
294 |
+
}
|
295 |
+
*/
|
296 |
+
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
?>
|
app/code/local/Paytoo/GoPayToo/controllers/RedirectController.php
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category PayToo Corp.
|
17 |
+
* @package GoPayToo (gopaytoo.com)
|
18 |
+
* @copyright Copyright (c) 2013 PayToo Corp.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
class Paytoo_GoPayToo_RedirectController extends Mage_Core_Controller_Front_Action {
|
23 |
+
|
24 |
+
public function getCheckout() {
|
25 |
+
return Mage::getSingleton('checkout/session');
|
26 |
+
}
|
27 |
+
|
28 |
+
protected $order;
|
29 |
+
|
30 |
+
protected function _expireAjax() {
|
31 |
+
if (!Mage::getSingleton('checkout/session')->getQuote()->hasItems()) {
|
32 |
+
$this->getResponse()->setHeader('HTTP/1.1','403 Session Expired');
|
33 |
+
exit;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
public function indexAction() {
|
38 |
+
$this->getResponse()
|
39 |
+
->setHeader('Content-type', 'text/html; charset=utf8')
|
40 |
+
->setBody($this->getLayout()
|
41 |
+
->createBlock('gopaytoo/redirect')
|
42 |
+
->toHtml());
|
43 |
+
}
|
44 |
+
|
45 |
+
public function successAction() {
|
46 |
+
$request = $_POST['MerchantApiResponse']['PaytooRequest'];
|
47 |
+
$hash = $_POST['MerchantApiResponse']['hash'];
|
48 |
+
$post = $this->getRequest()->getPost();
|
49 |
+
|
50 |
+
$session = Mage::getSingleton('checkout/session');
|
51 |
+
$session->setQuoteId($post['order_ref']);
|
52 |
+
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
53 |
+
$order = Mage::getModel('sales/order');
|
54 |
+
$order->loadByIncrementId($session->getLastRealOrderId());
|
55 |
+
|
56 |
+
if (empty($request) || empty($hash) || empty($request['status'])) {
|
57 |
+
$this->_redirect('checkout/onepage/success');
|
58 |
+
$order->addStatusHistoryComment('Missing parameters. Order cannot be verified.');
|
59 |
+
$order->save();
|
60 |
+
return ;
|
61 |
+
}
|
62 |
+
|
63 |
+
$hashKey = Mage::getStoreConfig('payment/gopaytoo/secret_word');
|
64 |
+
$myhash = md5($request['request_id'].$request['amount'].$request['currency'].$request['status'].$hashKey);
|
65 |
+
|
66 |
+
if ($myhash == $hash) {
|
67 |
+
//TODO: check currency
|
68 |
+
$expected_amount = $order->getBaseGrandTotal();
|
69 |
+
if ($request['status']!='completed' && $request['status']!='accepted') {
|
70 |
+
$this->rejectAction();
|
71 |
+
} elseif ($expected_amount==$request['amount']) {
|
72 |
+
$this->_redirect('checkout/onepage/success');
|
73 |
+
$order->setData('ext_order_id', $request['request_id']);
|
74 |
+
$order->save();
|
75 |
+
/*
|
76 |
+
* IPN will do that
|
77 |
+
* */
|
78 |
+
/* $state = $order->getState();
|
79 |
+
if ($state!=Mage_Sales_Model_Order::STATE_PROCESSING) {
|
80 |
+
$payment = $order->getPayment();
|
81 |
+
$payment->setTransactionId($request['request_id'])
|
82 |
+
->setPreparedMessage($request['status_infos'])
|
83 |
+
->setParentTransactionId(null)
|
84 |
+
->setShouldCloseParentTransaction(true)
|
85 |
+
->setIsTransactionClosed(0)
|
86 |
+
->registerCaptureNotification($request['amount']);
|
87 |
+
$order->save();
|
88 |
+
|
89 |
+
$order->sendNewOrderEmail();
|
90 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
|
91 |
+
} */
|
92 |
+
} else {
|
93 |
+
$this->_redirect('checkout/onepage/success');
|
94 |
+
$order->addStatusHistoryComment($request['amount']);
|
95 |
+
$order->addStatusHistoryComment('Received amount differ from requested amount.');
|
96 |
+
$order->save();
|
97 |
+
}
|
98 |
+
} else {
|
99 |
+
$this->_redirect('checkout/onepage/success');
|
100 |
+
$order->addStatusHistoryComment($hashTotal);
|
101 |
+
$order->addStatusHistoryComment('Hash did not match, check secret word.');
|
102 |
+
$order->save();
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* When a customer cancel payment from PayToo.
|
108 |
+
*/
|
109 |
+
public function cancelAction() {
|
110 |
+
$post = $this->getRequest()->getPost();
|
111 |
+
|
112 |
+
$session = Mage::getSingleton('checkout/session');
|
113 |
+
$session->setQuoteId($post['order_ref']);
|
114 |
+
|
115 |
+
$lastQuoteId = $session->getLastQuoteId();
|
116 |
+
$lastOrderId = $session->getLastOrderId();
|
117 |
+
|
118 |
+
if($lastQuoteId && $lastOrderId) {
|
119 |
+
$orderModel = Mage::getModel('sales/order')->load($lastOrderId);
|
120 |
+
if($orderModel->canCancel()) {
|
121 |
+
$quote = Mage::getModel('sales/quote')->load($lastQuoteId);
|
122 |
+
$quote->setIsActive(true)->save();
|
123 |
+
$orderModel->cancel();
|
124 |
+
$orderModel->setStatus('canceled');
|
125 |
+
$orderModel->addStatusHistoryComment('Order cancelled on PayToo Gateway.');
|
126 |
+
$orderModel->save();
|
127 |
+
Mage::getSingleton('core/session')->setFailureMsg('order_failed');
|
128 |
+
Mage::getSingleton('checkout/session')->setFirstTimeChk('0');
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
$this->_redirect('checkout/cart');
|
133 |
+
return;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* When a payment is rejected from PayToo.
|
138 |
+
*/
|
139 |
+
public function rejectAction() {
|
140 |
+
$post = $this->getRequest()->getPost();
|
141 |
+
|
142 |
+
$session = Mage::getSingleton('checkout/session');
|
143 |
+
$session->setQuoteId($post['order_ref']);
|
144 |
+
|
145 |
+
$lastQuoteId = $session->getLastQuoteId();
|
146 |
+
$lastOrderId = $session->getLastOrderId();
|
147 |
+
|
148 |
+
if($lastQuoteId && $lastOrderId) {
|
149 |
+
$orderModel = Mage::getModel('sales/order')->load($lastOrderId);
|
150 |
+
if($orderModel->canCancel()) {
|
151 |
+
$quote = Mage::getModel('sales/quote')->load($lastQuoteId);
|
152 |
+
$quote->setIsActive(true)->save();
|
153 |
+
$orderModel->cancel();
|
154 |
+
$orderModel->setStatus('closed');
|
155 |
+
$orderModel->addStatusHistoryComment('Payment rejected on PayToo Gateway.');
|
156 |
+
$orderModel->save();
|
157 |
+
Mage::getSingleton('core/session')->setFailureMsg('order_failed');
|
158 |
+
Mage::getSingleton('checkout/session')->setFirstTimeChk('0');
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
$this->_redirect('checkout/cart');
|
163 |
+
return;
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* When a payment is pending for signature from PayToo.
|
168 |
+
*/
|
169 |
+
public function esignAction() {
|
170 |
+
$post = $this->getRequest()->getPost();
|
171 |
+
$request = $_POST['MerchantApiResponse']['PaytooRequest'];
|
172 |
+
$hash = $_POST['MerchantApiResponse']['hash'];
|
173 |
+
|
174 |
+
$session = Mage::getSingleton('checkout/session');
|
175 |
+
$session->setQuoteId($post['order_ref']);
|
176 |
+
|
177 |
+
$lastQuoteId = $session->getLastQuoteId();
|
178 |
+
$lastOrderId = $session->getLastOrderId();
|
179 |
+
|
180 |
+
if($lastQuoteId && $lastOrderId && ($request['status']=='accepted' || $request['status']=='completed')) {
|
181 |
+
$orderModel = Mage::getModel('sales/order')->load($lastOrderId);
|
182 |
+
|
183 |
+
$hashKey = Mage::getStoreConfig('payment/gopaytoo/secret_word');
|
184 |
+
$myhash = md5($request['request_id'].$request['amount'].$request['currency'].$request['status'].$hashKey);
|
185 |
+
|
186 |
+
if ($myhash == $hash) {
|
187 |
+
if($orderModel->canHold()) {
|
188 |
+
$quote = Mage::getModel('sales/quote')->load($lastQuoteId);
|
189 |
+
$quote->setIsActive(true)->save();
|
190 |
+
$orderModel->hold();
|
191 |
+
$orderModel->setStatus('holded');
|
192 |
+
$orderModel->addStatusHistoryComment('Payment on hold for signature.');
|
193 |
+
$orderModel->save();
|
194 |
+
}
|
195 |
+
} else {
|
196 |
+
$this->_redirect('checkout/onepage/success');
|
197 |
+
$order->addStatusHistoryComment($hashTotal);
|
198 |
+
$order->addStatusHistoryComment('Hash did not match, check secret word.');
|
199 |
+
$order->save();
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
$this->_redirect('checkout/onepage/success');
|
204 |
+
return;
|
205 |
+
}
|
206 |
+
|
207 |
+
}
|
208 |
+
|
209 |
+
?>
|
app/code/local/Paytoo/GoPayToo/etc/config.xml
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<!--
|
4 |
+
/**
|
5 |
+
* Magento
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://opensource.org/licenses/osl-3.0.php
|
13 |
+
* If you did not receive a copy of the license and are unable to
|
14 |
+
* obtain it through the world-wide-web, please send an email
|
15 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
16 |
+
*
|
17 |
+
* @category PayToo Corp.
|
18 |
+
* @package GoPayToo (gopaytoo.com)
|
19 |
+
* @copyright Copyright (c) 2013 PayToo Corp.
|
20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
+
*/
|
22 |
+
-->
|
23 |
+
|
24 |
+
<config>
|
25 |
+
<modules>
|
26 |
+
<Paytoo_GoPayToo>
|
27 |
+
<version>1.0.0</version>
|
28 |
+
</Paytoo_GoPayToo>
|
29 |
+
</modules>
|
30 |
+
<global>
|
31 |
+
<models>
|
32 |
+
<gopaytoo>
|
33 |
+
<class>Paytoo_GoPayToo_Model</class>
|
34 |
+
</gopaytoo>
|
35 |
+
</models>
|
36 |
+
<helpers>
|
37 |
+
<gopaytoo>
|
38 |
+
<class>Paytoo_GoPayToo_Helper</class>
|
39 |
+
</gopaytoo>
|
40 |
+
</helpers>
|
41 |
+
<blocks>
|
42 |
+
<gopaytoo>
|
43 |
+
<class>Paytoo_GoPayToo_Block</class>
|
44 |
+
</gopaytoo>
|
45 |
+
</blocks>
|
46 |
+
<resources>
|
47 |
+
<gopaytoo_setup>
|
48 |
+
<setup>
|
49 |
+
<module>Paytoo_GoPayToo</module>
|
50 |
+
</setup>
|
51 |
+
<connection>
|
52 |
+
<use>directory_setup</use>
|
53 |
+
</connection>
|
54 |
+
</gopaytoo_setup>
|
55 |
+
<gopaytoo_write>
|
56 |
+
<connection>
|
57 |
+
<use>local_write</use>
|
58 |
+
</connection>
|
59 |
+
</gopaytoo_write>
|
60 |
+
<gopaytoo_read>
|
61 |
+
<connection>
|
62 |
+
<use>local_read</use>
|
63 |
+
</connection>
|
64 |
+
</gopaytoo_read>
|
65 |
+
</resources>
|
66 |
+
<events>
|
67 |
+
<sales_order_creditmemo_refund>
|
68 |
+
<observers>
|
69 |
+
<issue_creditmemo_refund>
|
70 |
+
<type>singleton</type>
|
71 |
+
<class>Paytoo_GoPayToo_Model_Observer</class>
|
72 |
+
<method>issue_creditmemo_refund</method>
|
73 |
+
</issue_creditmemo_refund>
|
74 |
+
</observers>
|
75 |
+
</sales_order_creditmemo_refund>
|
76 |
+
|
77 |
+
</events>
|
78 |
+
</global>
|
79 |
+
<frontend>
|
80 |
+
<routers>
|
81 |
+
<gopaytoo>
|
82 |
+
<use>standard</use>
|
83 |
+
<args>
|
84 |
+
<module>Paytoo_GoPayToo</module>
|
85 |
+
<frontName>gopaytoo</frontName>
|
86 |
+
</args>
|
87 |
+
</gopaytoo>
|
88 |
+
</routers>
|
89 |
+
<secure_url>
|
90 |
+
<gopaytoo_redirect>/gopaytoo/redirect/</gopaytoo_redirect>
|
91 |
+
</secure_url>
|
92 |
+
</frontend>
|
93 |
+
<default>
|
94 |
+
<payment>
|
95 |
+
<gopaytoo>
|
96 |
+
<active>1</active>
|
97 |
+
<submit_url>1</submit_url>
|
98 |
+
<model>gopaytoo/checkout</model>
|
99 |
+
<title>PayToo (credit/debit cards and PayToo wallet)</title>
|
100 |
+
<sid>Enter your GoPayToo Merchant ID</sid>
|
101 |
+
<secret_word>Enter your secret hash key</secret_word>
|
102 |
+
<submit_url>1</submit_url>
|
103 |
+
<demo>0</demo>
|
104 |
+
<sort_order>1</sort_order>
|
105 |
+
</gopaytoo>
|
106 |
+
</payment>
|
107 |
+
</default>
|
108 |
+
</config>
|
app/code/local/Paytoo/GoPayToo/etc/system.xml
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<!--
|
4 |
+
/**
|
5 |
+
* Magento
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://opensource.org/licenses/osl-3.0.php
|
13 |
+
* If you did not receive a copy of the license and are unable to
|
14 |
+
* obtain it through the world-wide-web, please send an email
|
15 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
16 |
+
*
|
17 |
+
* @category PayToo Corp.
|
18 |
+
* @package GoPayToo (gopaytoo.com)
|
19 |
+
* @copyright Copyright (c) 2013 PayToo Corp.
|
20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
+
*/
|
22 |
+
-->
|
23 |
+
|
24 |
+
<config>
|
25 |
+
<sections>
|
26 |
+
<payment>
|
27 |
+
<groups>
|
28 |
+
<gopaytoo translate="label">
|
29 |
+
<label>PayToo</label>
|
30 |
+
<frontend_type>text</frontend_type>
|
31 |
+
<sort_order>0</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>1</show_in_website>
|
34 |
+
<show_in_store>1</show_in_store>
|
35 |
+
<fields>
|
36 |
+
<title translate="label">
|
37 |
+
<label>Title</label>
|
38 |
+
<frontend_type>text</frontend_type>
|
39 |
+
<sort_order>1</sort_order>
|
40 |
+
<show_in_default>1</show_in_default>
|
41 |
+
<show_in_website>1</show_in_website>
|
42 |
+
<show_in_store>1</show_in_store>
|
43 |
+
</title>
|
44 |
+
<active translate="label">
|
45 |
+
<label>Enabled</label>
|
46 |
+
<frontend_type>select</frontend_type>
|
47 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
48 |
+
<sort_order>2</sort_order>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>1</show_in_website>
|
51 |
+
<show_in_store>0</show_in_store>
|
52 |
+
</active>
|
53 |
+
<sid translate="label">
|
54 |
+
<label>GoPayToo Merchant ID</label>
|
55 |
+
<comment>**Required**</comment>
|
56 |
+
<frontend_type>text</frontend_type>
|
57 |
+
<sort_order>3</sort_order>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>1</show_in_website>
|
60 |
+
<show_in_store>0</show_in_store>
|
61 |
+
</sid>
|
62 |
+
<!--
|
63 |
+
<username translate="label">
|
64 |
+
<label>API Username</label>
|
65 |
+
<comment>Required if 'Live Refunds' is set to 'Yes'.</comment>
|
66 |
+
<frontend_type>text</frontend_type>
|
67 |
+
<sort_order>4</sort_order>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>1</show_in_website>
|
70 |
+
<show_in_store>0</show_in_store>
|
71 |
+
</username>
|
72 |
+
//-->
|
73 |
+
<password translate="label">
|
74 |
+
<label>API Password</label>
|
75 |
+
<comment>Required if 'Live Refunds' is set to 'Yes'.</comment>
|
76 |
+
<frontend_type>text</frontend_type>
|
77 |
+
<sort_order>5</sort_order>
|
78 |
+
<show_in_default>1</show_in_default>
|
79 |
+
<show_in_website>1</show_in_website>
|
80 |
+
<show_in_store>0</show_in_store>
|
81 |
+
</password>
|
82 |
+
<secret_word translate="label">
|
83 |
+
<label>Hash key</label>
|
84 |
+
<comment>**Required** Please enter the same value that you set on your GoPayToo settings page.</comment>
|
85 |
+
<frontend_type>text</frontend_type>
|
86 |
+
<sort_order>6</sort_order>
|
87 |
+
<show_in_default>1</show_in_default>
|
88 |
+
<show_in_website>1</show_in_website>
|
89 |
+
<show_in_store>0</show_in_store>
|
90 |
+
</secret_word>
|
91 |
+
<refund translate="label">
|
92 |
+
<label>Live Refunds</label>
|
93 |
+
<comment>**IMPORTANT** Requires API Username and Password. Select 'Yes' to enable live refunds through PayToo when sending credit memos in Magento. This will actually issue refunds for the credit memo amount.</comment>
|
94 |
+
<frontend_type>select</frontend_type>
|
95 |
+
<sort_order>9</sort_order>
|
96 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
97 |
+
<show_in_default>1</show_in_default>
|
98 |
+
<show_in_website>1</show_in_website>
|
99 |
+
<show_in_store>0</show_in_store>
|
100 |
+
</refund>
|
101 |
+
<demo translate="label">
|
102 |
+
<label>GoPayToo Sandbox Mode</label>
|
103 |
+
<frontend_type>select</frontend_type>
|
104 |
+
<sort_order>10</sort_order>
|
105 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
106 |
+
<show_in_default>1</show_in_default>
|
107 |
+
<show_in_website>1</show_in_website>
|
108 |
+
<show_in_store>0</show_in_store>
|
109 |
+
</demo>
|
110 |
+
<!--
|
111 |
+
<invoice_on_fraud translate="label">
|
112 |
+
<label>Invoice Automatically After PayToo Fraud
|
113 |
+
Review</label>
|
114 |
+
<comment>Automatically issues magento invoice after
|
115 |
+
PayToo fraud review passes. If you are
|
116 |
+
offering downloadable products this would
|
117 |
+
enable downloads.</comment>
|
118 |
+
<frontend_type>select</frontend_type>
|
119 |
+
<sort_order>11</sort_order>
|
120 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
121 |
+
<show_in_default>1</show_in_default>
|
122 |
+
<show_in_website>1</show_in_website>
|
123 |
+
<show_in_store>0</show_in_store>
|
124 |
+
</invoice_on_fraud>
|
125 |
+
//-->
|
126 |
+
<!--<invoice_on_order translate="label">
|
127 |
+
<label>Invoice Automatically on Instant Payment Notification</label>
|
128 |
+
<comment>Automatically issues magento invoice
|
129 |
+
when sale is processed by PayToo. If you are
|
130 |
+
offering downloadable products this would
|
131 |
+
enable downloads</comment>
|
132 |
+
<frontend_type>select</frontend_type>
|
133 |
+
<sort_order>12</sort_order>
|
134 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
135 |
+
<show_in_default>1</show_in_default>
|
136 |
+
<show_in_website>1</show_in_website>
|
137 |
+
<show_in_store>0</show_in_store>
|
138 |
+
</invoice_on_order>//-->
|
139 |
+
<allowspecific translate="label">
|
140 |
+
<label>Payment Applicable From</label>
|
141 |
+
<frontend_type>select</frontend_type>
|
142 |
+
<sort_order>13</sort_order>
|
143 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
144 |
+
<show_in_default>1</show_in_default>
|
145 |
+
<show_in_website>1</show_in_website>
|
146 |
+
<show_in_store>0</show_in_store>
|
147 |
+
</allowspecific>
|
148 |
+
<specificcountry translate="label">
|
149 |
+
<label>Countries Payment Applicable From</label>
|
150 |
+
<frontend_type>multiselect</frontend_type>
|
151 |
+
<sort_order>14</sort_order>
|
152 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
153 |
+
<show_in_default>1</show_in_default>
|
154 |
+
<show_in_website>1</show_in_website>
|
155 |
+
<show_in_store>0</show_in_store>
|
156 |
+
</specificcountry>
|
157 |
+
<checkout_language translate="label">
|
158 |
+
<label>Checkout Language Code</label>
|
159 |
+
<comment>**Defaults to auto-detect** Enter your preferred PayToo language code to translate the checkout page.</comment>
|
160 |
+
<frontend_type>text</frontend_type>
|
161 |
+
<sort_order>15</sort_order>
|
162 |
+
<show_in_default>1</show_in_default>
|
163 |
+
<show_in_website>1</show_in_website>
|
164 |
+
<show_in_store>0</show_in_store>
|
165 |
+
</checkout_language>
|
166 |
+
<redirect_message translate="label">
|
167 |
+
<label>Redirect Message</label>
|
168 |
+
<comment>You will be redirected to the PayToo gateway in a few seconds.</comment>
|
169 |
+
<frontend_type>text</frontend_type>
|
170 |
+
<sort_order>15</sort_order>
|
171 |
+
<show_in_default>1</show_in_default>
|
172 |
+
<show_in_website>1</show_in_website>
|
173 |
+
<show_in_store>0</show_in_store>
|
174 |
+
</redirect_message>
|
175 |
+
<sort_order translate="label">
|
176 |
+
<label>Sort order</label>
|
177 |
+
<frontend_type>text</frontend_type>
|
178 |
+
<sort_order>16</sort_order>
|
179 |
+
<show_in_default>1</show_in_default>
|
180 |
+
<show_in_website>1</show_in_website>
|
181 |
+
<show_in_store>0</show_in_store>
|
182 |
+
</sort_order>
|
183 |
+
</fields>
|
184 |
+
</gopaytoo>
|
185 |
+
</groups>
|
186 |
+
</payment>
|
187 |
+
</sections>
|
188 |
+
</config>
|
app/design/frontend/base/default/template/gopaytoo/form.phtml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category PayToo Corp.
|
17 |
+
* @package GoPayToo (gopaytoo.com)
|
18 |
+
* @copyright Copyright (c) 2013 PayToo Corp.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
echo $this->__('You will be redirected to the PayToo Gateway to complete your order.')
|
23 |
+
?>
|
app/design/frontend/base/default/template/gopaytoo/info.phtml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category PayToo Corp.
|
17 |
+
* @package GoPayToo (gopaytoo.com)
|
18 |
+
* @copyright Copyright (c) 2013 PayToo Corp.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
echo $this->__('PayToo (Credit Card, Debit Card, PayToo Wallet, GreenDot, Ukash)');
|
23 |
+
?>
|
24 |
+
|
25 |
+
|
package.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Paytoo_GoPayToo</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>PayToo Payment Gateway - Accept Credit Cards and PayToo wallet payment with your GoPayToo merchant account</summary>
|
10 |
+
<description>This OFFICIAL extension from PayToo Corp. utilizes GoPayToo gateway, API and instant notifications to provide you with the ability to do all of your sales management from Magento.
|
11 |
+
It has been extensivly tested, is used by many GoPayToo merchants and is updated with each Magento community release.</description>
|
12 |
+
<notes>First public release</notes>
|
13 |
+
<authors><author><name>PayToo Corp.</name><user>paytoo</user><email>rd@paytoo.com</email></author></authors>
|
14 |
+
<date>2013-04-11</date>
|
15 |
+
<time>19:24:14</time>
|
16 |
+
<contents><target name="magelocal"><dir name="Paytoo"><dir name="GoPayToo"><dir name="Block"><file name="Form.php" hash="ce22217339260448b49d9f9762525f7a"/><file name="Info.php" hash="f8c8d7ec386f335f9d68e7567053a027"/><file name="Redirect.php" hash="2f10a254eee580dce7ab743d69227fb3"/></dir><dir name="Helper"><file name="Data.php" hash="37fcfff77a6821c2d36a12e057b73412"/></dir><dir name="Model"><file name="Checkout.php" hash="57861d52391b5bab5adc3c0fc97f3ae3"/><file name="Observer.php" hash="51b94d4ebf566651f975a9f0dcac6684"/></dir><dir name="controllers"><file name="NotificationController.php" hash="204a0a6d469b288f2b40d077f6a65637"/><file name="RedirectController.php" hash="c6ddb74172f7d0c1fbd154ef3e7b9b4a"/></dir><dir name="etc"><file name="config.xml" hash="13632ee28f052d494afe189686aa2bf0"/><file name="system.xml" hash="ffed7d64f3e2521d9500cda139b0dd95"/></dir></dir></dir></target><target name="mageetc"><dir name="."><file name="Paytoo_GoPayToo.xml" hash=""/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="gopaytoo"><file name="form.phtml" hash="7b31b8ad5f1a197eaf19dc5e6e25d1a5"/><file name="info.phtml" hash="ee403495047553eb6efa979b012bab96"/></dir></dir></dir></dir></dir></target></contents>
|
17 |
+
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
+
</package>
|