Cashu_Paymentmethod - Version 1.0.2

Version Notes

Release version 1.0.2 Cashu Prepaid.

Download this release

Release Info

Developer Moe
Extension Cashu_Paymentmethod
Version 1.0.2
Comparing to
See all releases


Code changes from version 1.0.1 to 1.0.2

app/code/local/Cashu/Paymentmethod/Helper/Data.php DELETED
@@ -1,5 +0,0 @@
1
- <?php
2
- class Cashu_Paymentmethod_Helper_Data extends Mage_Core_Helper_Abstract
3
- {
4
-
5
- }
 
 
 
 
 
app/code/local/Cashu/Paymentmethod/Model/Pay.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- class Cashu_Paymentmethod_Model_Pay extends Mage_Payment_Model_Method_Abstract {
3
- protected $_code = 'paymentmethod';
4
-
5
- protected $_isInitializeNeeded = true;
6
- protected $_canUseInternal = true;
7
- protected $_canUseForMultishipping = false;
8
-
9
- public function getOrderPlaceRedirectUrl() {
10
- return Mage::getUrl('paymentmethod/payment/redirect', array('_secure' => true));
11
- }
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Cashu/Paymentmethod/controllers/PaymentController.php DELETED
@@ -1,126 +0,0 @@
1
- <?php
2
-
3
- class Cashu_Paymentmethod_PaymentController extends Mage_Core_Controller_Front_Action {
4
- // The redirect action is triggered when someone places an order
5
- public function redirectAction() {
6
- $this->loadLayout();
7
- $block = $this->getLayout()->createBlock('Mage_Core_Block_Template','paymentmethod',array('template' => 'cashu/redirect.phtml'));
8
- $this->getLayout()->getBlock('content')->append($block);
9
- $this->renderLayout();
10
- }
11
-
12
- // The response action is triggered when your gateway sends back a response after processing the customer's payment
13
- public function responseAction() {
14
- if($this->getRequest()->isPost()) {
15
-
16
- /*
17
- /* Your gateway's code to make sure the reponse you
18
- /* just got is from the gatway and not from some weirdo.
19
- /* This generally has some checksum or other checks,
20
- /* and is provided by the gateway.
21
- /* For now, we assume that the gateway's response is valid
22
- */
23
-
24
- //extract($_POST);
25
-
26
- $validated = true;
27
- $orderId = $_POST['txt1']; // Generally sent by gateway
28
-
29
- //var_dump($orderId);
30
-
31
- if($validated) {
32
-
33
- // Payment was successful, so update the order's state, send order email and move to the success page
34
- $order = Mage::getModel('sales/order');
35
- $order->loadByIncrementId($orderId);
36
- //$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
37
-
38
- /** trying to create invoice **/
39
- try {
40
-
41
-
42
- if(!$order->canInvoice()):
43
-
44
- //Mage::throwException(Mage::helper('core')->__('cannot create invoice !'));
45
- Mage::throwException(Mage::helper('core')->__('cannot create an invoice !'));
46
-
47
- else:
48
-
49
- /** create invoice **/
50
- //$invoiceId = Mage::getModel('sales/order_invoice_api')->create($order->getIncremenetId(), array());
51
- $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
52
-
53
- if(!$invoice->getTotalQty()):
54
- Mage::throwException(Mage::helper('core')->__('cannot create an invoice without products !'));
55
- endif;
56
-
57
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
58
- $invoice->register();
59
- $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
60
- $transactionSave->save();
61
-
62
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
63
- /** load invoice **/
64
- //$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceId);
65
- /** pay invoice **/
66
- //$invoice->capture()->save();
67
-
68
-
69
-
70
- endif;
71
- }
72
- catch(Mage_Core_Exception $e){
73
- Mage::throwException(Mage::helper('core')->__('cannot create an invoice !'));
74
- }
75
-
76
- $order->sendNewOrderEmail();
77
- $order->setEmailSent(true);
78
-
79
- $order->save();
80
-
81
- //Mage::getSingleton('checkout/session')->unsQuoteId();
82
-
83
- //header('location: http://test.shopgo.me/cashument/payment/success');
84
- //Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
85
- //echo $orderId;
86
- //$this->getLayout()->helper('page/layout')->applyTemplate('two_columns_left');
87
-
88
- $block = $this->getLayout()->createBlock('Mage_Core_Block_Template','paymentmethod_block',array('template' => 'cashu/success.phtml'))->setData('order', $orderId);
89
-
90
-
91
- $this->loadLayout()->getLayout()->getBlock('root')->setTemplate('page/2columns-left.phtml');
92
-
93
-
94
- $this->loadLayout()->getLayout()->getBlock('content')->append($block);
95
-
96
-
97
- $this->renderLayout();
98
-
99
-
100
- }
101
- else {
102
- // There is a problem in the response we got
103
- $this->cancelAction();
104
- Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure'=>true));
105
- }
106
- }
107
- else
108
- Mage_Core_Controller_Varien_Action::_redirect('');
109
- }
110
-
111
- // The cancel action is triggered when an order is to be cancelled
112
- public function cancelAction() {
113
- if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) {
114
- $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
115
- if($order->getId()) {
116
- // Flag the order as 'cancelled' and save it
117
- $order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.')->save();
118
- }
119
- }
120
- }
121
-
122
- public function successAction(){
123
- /**/
124
-
125
- }
126
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Cashu/Paymentmethod/etc/config.xml DELETED
@@ -1,78 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <modules>
4
- <Cashu_Paymentmethod>
5
- <version>1.0.0</version>
6
- </Cashu_Paymentmethod>
7
- </modules>
8
- <global>
9
- <blocks>
10
- <paymentmethod>
11
- <class>Cashu_Paymentmethod_Block</class>
12
- </paymentmethod>
13
- </blocks>
14
- <helpers>
15
- <paymentmethod>
16
- <class>Cashu_Paymentmethod_Helper</class>
17
- </paymentmethod>
18
- </helpers>
19
- <models>
20
- <paymentmethod>
21
- <class>Cashu_Paymentmethod_Model</class>
22
- </paymentmethod>
23
- <paymentmethod_adminhtml>
24
- <class>Cashu_Paymentmethod_Adminhtml_Model</class>
25
- </paymentmethod_adminhtml>
26
- </models>
27
- <resources>
28
- <paymentmethod_setup>
29
- <setup>
30
- <module>Cashu_Paymentmethod</module>
31
- </setup>
32
- <connection>
33
- <use>core_setup</use>
34
- </connection>
35
- </paymentmethod_setup>
36
- <paymentmethod_write>
37
- <connection>
38
- <use>core_write</use>
39
- </connection>
40
- </paymentmethod_write>
41
- <paymentmethod_read>
42
- <connection>
43
- <use>core_read</use>
44
- </connection>
45
- </paymentmethod_read>
46
- </resources>
47
- </global>
48
- <default>
49
- <payment>
50
- <paymentmethod>
51
- <active>1</active>
52
-
53
- <order_status>pending</order_status>
54
-
55
- <model>paymentmethod/pay</model>
56
-
57
- <title>Cashu Payment Method</title>
58
-
59
- <payment_action>sale</payment_action>
60
-
61
- <allowspecific>0</allowspecific>
62
-
63
- <sort_order>1</sort_order>
64
- </paymentmethod>
65
- </payment>
66
- </default>
67
- <frontend>
68
- <routers>
69
- <paymentmethod>
70
- <use>standard</use>
71
- <args>
72
- <module>Cashu_Paymentmethod</module>
73
- <frontName>paymentmethod</frontName>
74
- </args>
75
- </paymentmethod>
76
- </routers>
77
- </frontend>
78
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Cashu/{Paymentmethod → Prepaid}/Adminhtml/Model/System/Config/Source/Currencyoptions.php RENAMED
@@ -1,9 +1,9 @@
1
  <?php
2
 
3
- class Cashu_Paymentmethod_Adminhtml_Model_System_Config_Source_Currencyoptions {
4
- /***/
5
-
6
- /**
7
  * Options getter
8
  *
9
  * @return array
@@ -28,5 +28,5 @@ class Cashu_Paymentmethod_Adminhtml_Model_System_Config_Source_Currencyoptions {
28
  array('value' => 'omr', 'label'=>Mage::helper('adminhtml')->__('OMR')),
29
  );
30
  }
31
-
32
- }
1
  <?php
2
 
3
+ class Cashu_Prepaid_Adminhtml_Model_System_Config_Source_Currencyoptions {
4
+ /***/
5
+
6
+ /**
7
  * Options getter
8
  *
9
  * @return array
28
  array('value' => 'omr', 'label'=>Mage::helper('adminhtml')->__('OMR')),
29
  );
30
  }
31
+
32
+ }
app/code/local/Cashu/{Paymentmethod → Prepaid}/Adminhtml/Model/System/Config/Source/Languageoptions.php RENAMED
@@ -1,9 +1,9 @@
1
  <?php
2
 
3
- class Cashu_Paymentmethod_Adminhtml_Model_System_Config_Source_Languageoptions {
4
- /***/
5
-
6
- /**
7
  * Options getter
8
  *
9
  * @return array
@@ -15,5 +15,5 @@ class Cashu_Paymentmethod_Adminhtml_Model_System_Config_Source_Languageoptions {
15
  array('value' => 'ar', 'label'=>Mage::helper('adminhtml')->__('ar')),
16
  );
17
  }
18
-
19
- }
1
  <?php
2
 
3
+ class Cashu_Prepaid_Adminhtml_Model_System_Config_Source_Languageoptions {
4
+ /***/
5
+
6
+ /**
7
  * Options getter
8
  *
9
  * @return array
15
  array('value' => 'ar', 'label'=>Mage::helper('adminhtml')->__('ar')),
16
  );
17
  }
18
+
19
+ }
app/code/local/Cashu/Prepaid/Block/Onepage/Payment/Methods.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Cashu_Prepaid_Block_Onepage_Payment_Methods extends Mage_Checkout_Block_Onepage_Payment_Methods
3
+ {
4
+
5
+ /**
6
+ * Payment method form html getter
7
+ * @param Mage_Payment_Model_Method_Abstract $method
8
+ */
9
+ public function getPaymentMethodFormHtml(Mage_Payment_Model_Method_Abstract $method)
10
+ {
11
+ switch($method->getCode()):
12
+
13
+ case 'prepaid':
14
+
15
+ return '<ul class="form-list" id="payment_form_' . $method->getCode() . '" style="display: none;"><li class="form-alt">' . $this->__('You will be redirected to the CashU website to complete your payment after placing your order.') . '</li></ul>';
16
+
17
+ break;
18
+
19
+ case 'onecard':
20
+
21
+ return '<ul class="form-list" id="payment_form_' . $method->getCode() . '" style="display: none;"><li class="form-alt">' . $this->__('You will be redirected to the OneCard website to complete your payment after placing your order.') . '</li></ul>';
22
+
23
+ break;
24
+
25
+ default:
26
+
27
+ return $this->getChildHtml('payment.method.' . $method->getCode());
28
+
29
+ endswitch;
30
+
31
+ }
32
+
33
+ }
app/code/local/Cashu/Prepaid/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Cashu_Prepaid_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ }
app/code/local/Cashu/Prepaid/Model/Pay.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Cashu_Prepaid_Model_Pay extends Mage_Payment_Model_Method_Abstract {
3
+ protected $_code = 'cashu_prepaid';
4
+
5
+ protected $_isInitializeNeeded = true;
6
+ protected $_canUseInternal = true;
7
+ protected $_canUseForMultishipping = false;
8
+
9
+ public function getOrderPlaceRedirectUrl() {
10
+ return Mage::getUrl('cashu/payment/redirect', array('_secure' => true));
11
+ }
12
+ }
app/code/local/Cashu/Prepaid/controllers/IndexController.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cashu_Prepaid_IndexController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function indexAction() {
6
+ $this->_redirectUrl(Mage::getBaseUrl());
7
+
8
+ }
9
+
10
+ }
app/code/local/Cashu/Prepaid/controllers/PaymentController.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cashu_Prepaid_PaymentController extends Mage_Core_Controller_Front_Action {
4
+ // The redirect action is triggered when someone places an order
5
+ public function redirectAction() {
6
+ $this->loadLayout();
7
+ $block = $this->getLayout()->createBlock('Mage_Core_Block_Template','cashu_prepaid',array('template' => 'cashu/prepaid/redirect.phtml'));
8
+ $this->getLayout()->getBlock('content')->append($block);
9
+ $this->renderLayout();
10
+ }
11
+
12
+ // The response action is triggered when your gateway sends back a response after processing the customer's payment
13
+ public function responseAction() {
14
+ if($this->getRequest()->isPost()) {
15
+
16
+ /*
17
+ /* Your gateway's code to make sure the reponse you
18
+ /* just got is from the gatway and not from some weirdo.
19
+ /* This generally has some checksum or other checks,
20
+ /* and is provided by the gateway.
21
+ /* For now, we assume that the gateway's response is valid
22
+ */
23
+
24
+ //extract($_POST);
25
+
26
+ $validated = true;
27
+ $orderId = $_POST['txt1']; // Generally sent by gateway
28
+
29
+ //var_dump($orderId);
30
+
31
+ if($validated) {
32
+
33
+ // Payment was successful, so update the order's state, send order email and move to the success page
34
+ $order = Mage::getModel('sales/order');
35
+ $order->loadByIncrementId($orderId);
36
+ //$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
37
+
38
+ /** trying to create invoice **/
39
+ try {
40
+
41
+
42
+ if(!$order->canInvoice()):
43
+
44
+ //Mage::throwException(Mage::helper('core')->__('cannot create invoice !'));
45
+ Mage::throwException(Mage::helper('core')->__('cannot create an invoice !'));
46
+
47
+ else:
48
+
49
+ /** create invoice **/
50
+ //$invoiceId = Mage::getModel('sales/order_invoice_api')->create($order->getIncremenetId(), array());
51
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
52
+
53
+ if(!$invoice->getTotalQty()):
54
+ Mage::throwException(Mage::helper('core')->__('cannot create an invoice without products !'));
55
+ endif;
56
+
57
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
58
+ $invoice->register();
59
+ $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
60
+ $transactionSave->save();
61
+
62
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
63
+ /** load invoice **/
64
+ //$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceId);
65
+ /** pay invoice **/
66
+ //$invoice->capture()->save();
67
+
68
+
69
+
70
+ endif;
71
+ }
72
+ catch(Mage_Core_Exception $e){
73
+ Mage::throwException(Mage::helper('core')->__('cannot create an invoice !'));
74
+ }
75
+
76
+ $order->sendNewOrderEmail();
77
+ $order->setEmailSent(true);
78
+
79
+ $order->save();
80
+
81
+ //Mage::getSingleton('checkout/session')->unsQuoteId();
82
+
83
+ //header('location: http://test.shopgo.me/cashument/payment/success');
84
+ //Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
85
+ //echo $orderId;
86
+ //$this->getLayout()->helper('page/layout')->applyTemplate('two_columns_left');
87
+
88
+ $block = $this->getLayout()->createBlock('Mage_Core_Block_Template','cashu_prepaid_block',array('template' => 'cashu/prepaid/success.phtml'))->setData('order', $orderId);
89
+
90
+
91
+ $this->loadLayout()->getLayout()->getBlock('root')->setTemplate('page/2columns-left.phtml');
92
+
93
+
94
+ $this->loadLayout()->getLayout()->getBlock('content')->append($block);
95
+
96
+
97
+ $this->renderLayout();
98
+
99
+
100
+ }
101
+ else {
102
+ // There is a problem in the response we got
103
+ $this->cancelAction();
104
+ Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure'=>true));
105
+ }
106
+ }
107
+ else
108
+ {
109
+ $this->_redirectUrl(Mage::getBaseUrl());
110
+ }
111
+
112
+
113
+ }
114
+
115
+ // The cancel action is triggered when an order is to be cancelled
116
+ public function cancelAction() {
117
+ if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) {
118
+ $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
119
+ if($order->getId()) {
120
+ // Flag the order as 'cancelled' and save it
121
+ $order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.')->save();
122
+ }
123
+ }
124
+ }
125
+
126
+ public function successAction(){
127
+ /**/
128
+
129
+ }
130
+
131
+ public function nourlAction(){
132
+
133
+ echo 'error : check your configuration';
134
+ }
135
+ }
app/code/local/Cashu/Prepaid/etc/config.xml ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Cashu_Prepaid>
5
+ <version>0.0.1</version>
6
+ </Cashu_Prepaid>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <prepaid>
11
+ <class>Cashu_Prepaid_Block</class>
12
+ </prepaid>
13
+ <checkout>
14
+ <rewrite>
15
+ <onepage_payment_methods>Cashu_Prepaid_Block_Onepage_Payment_Methods</onepage_payment_methods>
16
+ </rewrite>
17
+ </checkout>
18
+ </blocks>
19
+ <helpers>
20
+ <prepaid>
21
+ <class>Cashu_Prepaid_Helper</class>
22
+ </prepaid>
23
+ </helpers>
24
+ <models>
25
+ <prepaid>
26
+ <class>Cashu_Prepaid_Model</class>
27
+ </prepaid>
28
+ <prepaid_adminhtml>
29
+ <class>Cashu_Prepaid_Adminhtml_Model</class>
30
+ </prepaid_adminhtml>
31
+ </models>
32
+ <resources>
33
+ <prepaid_setup>
34
+ <setup>
35
+ <module>Cashu_Prepaid</module>
36
+ </setup>
37
+ <connection>
38
+ <use>core_setup</use>
39
+ </connection>
40
+ </prepaid_setup>
41
+ <prepaid_write>
42
+ <connection>
43
+ <use>core_write</use>
44
+ </connection>
45
+ </prepaid_write>
46
+ <prepaid_read>
47
+ <connection>
48
+ <use>core_read</use>
49
+ </connection>
50
+ </prepaid_read>
51
+ </resources>
52
+ </global>
53
+ <frontend>
54
+ <routers>
55
+ <cashu_prepaid>
56
+ <use>standard</use>
57
+ <args>
58
+ <module>Cashu_Prepaid</module>
59
+ <frontName>cashu</frontName>
60
+ </args>
61
+ </cashu_prepaid>
62
+ </routers>
63
+ <layout>
64
+ <updates>
65
+ <cashu_prepaid>
66
+ <file>cashu/prepaid.xml</file>
67
+ </cashu_prepaid>
68
+ </updates>
69
+ </layout>
70
+ </frontend>
71
+ <default>
72
+ <payment>
73
+ <cashu_prepaid>
74
+ <active>1</active>
75
+
76
+ <order_status>pending</order_status>
77
+
78
+ <model>prepaid/pay</model>
79
+
80
+ <title>Cashu Payment Method</title>
81
+
82
+ <payment_action>sale</payment_action>
83
+
84
+ <allowspecific>0</allowspecific>
85
+
86
+ <sort_order>1</sort_order>
87
+ </cashu_prepaid>
88
+ </payment>
89
+ </default>
90
+ </config>
app/code/local/Cashu/{Paymentmethod → Prepaid}/etc/system.xml RENAMED
@@ -3,8 +3,8 @@
3
  <sections>
4
  <payment>
5
  <groups>
6
- <paymentmethod translate="label" module="paygate">
7
- <label>Cashu Payment Method</label>
8
  <sort_order>670</sort_order>
9
  <show_in_default>1</show_in_default>
10
  <show_in_website>1</show_in_website>
@@ -47,7 +47,7 @@
47
  <currency translate="label">
48
  <label>currency</label>
49
  <frontend_type>select</frontend_type>
50
- <source_model>paymentmethod_adminhtml/system_config_source_currencyoptions</source_model>
51
  <sort_order>4</sort_order>
52
  <show_in_default>1</show_in_default>
53
  <show_in_website>1</show_in_website>
@@ -56,7 +56,7 @@
56
  <language translate="label">
57
  <label>language</label>
58
  <frontend_type>select</frontend_type>
59
- <source_model>paymentmethod_adminhtml/system_config_source_languageoptions</source_model>
60
  <sort_order>5</sort_order>
61
  <show_in_default>1</show_in_default>
62
  <show_in_website>1</show_in_website>
@@ -70,14 +70,23 @@
70
  <show_in_website>1</show_in_website>
71
  <show_in_store>0</show_in_store>
72
  </display_text>-->
73
- <payment_gateway_url translate="label">
74
  <label>payment gateway url (staging or live)</label>
75
  <frontend_type>text</frontend_type>
76
  <sort_order>7</sort_order>
77
  <show_in_default>1</show_in_default>
78
  <show_in_website>1</show_in_website>
79
  <show_in_store>0</show_in_store>
80
- </payment_gateway_url>
 
 
 
 
 
 
 
 
 
81
  <encryption_keyword translate="label">
82
  <label>encryption keyword</label>
83
  <frontend_type>text</frontend_type>
@@ -87,7 +96,7 @@
87
  <show_in_store>0</show_in_store>
88
  </encryption_keyword>
89
  <return_url>
90
- <label>Note : you need to specify your Return URL http://example.com/paymentmethod/payment/response</label>
91
  <frontend_type>label</frontend_type>
92
  <sort_order>9</sort_order>
93
  <show_in_default>1</show_in_default>
@@ -95,7 +104,7 @@
95
  <show_in_store>0</show_in_store>
96
  </return_url>
97
  </fields>
98
- </paymentmethod>
99
  </groups>
100
  </payment>
101
  </sections>
3
  <sections>
4
  <payment>
5
  <groups>
6
+ <cashu_prepaid translate="label">
7
+ <label>Cashu Payment Method ( prepaid )</label>
8
  <sort_order>670</sort_order>
9
  <show_in_default>1</show_in_default>
10
  <show_in_website>1</show_in_website>
47
  <currency translate="label">
48
  <label>currency</label>
49
  <frontend_type>select</frontend_type>
50
+ <source_model>prepaid_adminhtml/system_config_source_currencyoptions</source_model>
51
  <sort_order>4</sort_order>
52
  <show_in_default>1</show_in_default>
53
  <show_in_website>1</show_in_website>
56
  <language translate="label">
57
  <label>language</label>
58
  <frontend_type>select</frontend_type>
59
+ <source_model>prepaid_adminhtml/system_config_source_languageoptions</source_model>
60
  <sort_order>5</sort_order>
61
  <show_in_default>1</show_in_default>
62
  <show_in_website>1</show_in_website>
70
  <show_in_website>1</show_in_website>
71
  <show_in_store>0</show_in_store>
72
  </display_text>-->
73
+ <!--<payment_gateway_url translate="label">
74
  <label>payment gateway url (staging or live)</label>
75
  <frontend_type>text</frontend_type>
76
  <sort_order>7</sort_order>
77
  <show_in_default>1</show_in_default>
78
  <show_in_website>1</show_in_website>
79
  <show_in_store>0</show_in_store>
80
+ </payment_gateway_url>-->
81
+ <test translate="label">
82
+ <label>Staging (test mode)</label>
83
+ <frontend_type>select</frontend_type>
84
+ <source_model>adminhtml/system_config_source_yesno</source_model>
85
+ <sort_order>1</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>0</show_in_store>
89
+ </test>
90
  <encryption_keyword translate="label">
91
  <label>encryption keyword</label>
92
  <frontend_type>text</frontend_type>
96
  <show_in_store>0</show_in_store>
97
  </encryption_keyword>
98
  <return_url>
99
+ <label>Note : you need to specify your Return URL http://example.com/[ language code ]/cashu/payment/response</label>
100
  <frontend_type>label</frontend_type>
101
  <sort_order>9</sort_order>
102
  <show_in_default>1</show_in_default>
104
  <show_in_store>0</show_in_store>
105
  </return_url>
106
  </fields>
107
+ </cashu_prepaid>
108
  </groups>
109
  </payment>
110
  </sections>
app/design/frontend/base/default/template/cashu/prepaid/redirect.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Retrieve order
3
+ $_order = new Mage_Sales_Model_Order();
4
+ $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
5
+ $_order->loadByIncrementId($orderId);
6
+
7
+ //var_dump($_order->getAllItems());
8
+ $items_description = '';
9
+
10
+ $items = $_order->getAllItems();
11
+
12
+ foreach($items as $item){
13
+
14
+ $items_description .= $item->getName();
15
+
16
+ }
17
+
18
+ //var_dump($items_description);
19
+
20
+ $encryption_keyword = Mage::getStoreConfig('payment/cashu_prepaid/encryption_keyword',Mage::app()->getStore());
21
+
22
+ $payment_gateway_url = 'https://www.cashu.com/cgi-bin/pcashu.cgi';
23
+
24
+ $test_mode = Mage::getStoreConfig('payment/cashu_prepaid/test',Mage::app()->getStore());
25
+
26
+ $language = Mage::getStoreConfig('payment/cashu_prepaid/language',Mage::app()->getStore());
27
+ $currency = Mage::getStoreConfig('payment/cashu_prepaid/currency',Mage::app()->getStore());
28
+ $merchant_id = Mage::getStoreConfig('payment/cashu_prepaid/merchant_id',Mage::app()->getStore());
29
+
30
+ //exit();
31
+ ?>
32
+ <form name="cashupaymentform" action="<?php echo $payment_gateway_url;?>" method="post">
33
+ <input type="hidden" name="merchant_id" value="<?php echo $merchant_id;?>">
34
+ <input type="hidden" name="token" value="<?php echo md5($merchant_id.':'.round($_order->getBaseGrandTotal(),2).':'.$currency.':'.$encryption_keyword);?>">
35
+ <input type="hidden" name="display_text" value="<?php echo $items_description;?>">
36
+ <input type="hidden" name="currency" value="<?php echo $currency;?>">
37
+ <input type="hidden" name="amount" value="<?php echo round($_order->getBaseGrandTotal(),2);?>">
38
+ <input type="hidden" name="language" value="<?php echo $language;?>">
39
+ <input type="hidden" name="test_mode" value="<?php echo $test_mode ?>" />
40
+ <input type="hidden" name="session_id" value="<?php echo $orderId ?>">
41
+ <input type="hidden" name="txt1" value="<?php echo $orderId ?>">
42
+ </form>
43
+ <script type="text/javascript">
44
+ document.cashupaymentform.submit();
45
+ </script>
app/design/frontend/base/default/template/cashu/prepaid/success.phtml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ $_order = new Mage_Sales_Model_Order();
4
+ $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
5
+ $_order->loadByIncrementId($orderId);
6
+ */
7
+ $orderId = $this->getOrder();
8
+ $home_url = Mage::helper('core/url')->getHomeUrl();
9
+
10
+ //$checkout_order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
11
+ $current_order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
12
+
13
+ ?>
14
+ <div class="col-main">
15
+ <div class="page-title">
16
+ <h1>Your order has been received.</h1>
17
+ </div>
18
+ <h2 class="sub-title">Thank you for your purchase!</h2>
19
+ <p>Your order # is: <a href="<?php echo $home_url;?>sales/order/view/order_id/<?php echo $current_order->getId();?>"><?php echo $orderId;?></a>.</p>
20
+ <p>You will receive an order confirmation email with details of your order and a link to track its progress.</p>
21
+ <p>Click <a href="<?php echo $home_url;?>sales/order/print/order_id/<?php echo $current_order->getId();?>" onclick="this.target='_blank'">here to print</a> a copy of your order confirmation. </p>
22
+ <div class="buttons-set">
23
+ <button type="button" class="button" title="Continue Shopping" onclick="window.location='<?php echo $home_url;?>'"><span><span>Continue Shopping</span></span></button>
24
+ </div>
25
+ </div>
app/etc/modules/{Cashu_Paymentmethod.xml → Cashu_Prepaid.xml} RENAMED
@@ -1,12 +1,12 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <config>
3
  <modules>
4
- <Cashu_Paymentmethod>
5
  <active>true</active>
6
  <codePool>local</codePool>
7
  <depends>
8
  <Mage_Payment />
9
  </depends>
10
- </Cashu_Paymentmethod>
11
  </modules>
12
  </config>
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <config>
3
  <modules>
4
+ <Cashu_Prepaid>
5
  <active>true</active>
6
  <codePool>local</codePool>
7
  <depends>
8
  <Mage_Payment />
9
  </depends>
10
+ </Cashu_Prepaid>
11
  </modules>
12
  </config>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cashu_Paymentmethod</name>
4
- <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Cashu integration for magento</summary>
10
- <description>it allow users to use Cashu payment gateway in magento</description>
11
- <notes>Fix issues related to invoices ( automatically create invoices and change orders states )</notes>
12
  <authors><author><name>Moe</name><user>Ghashim</user><email>moe@shopgo.me</email></author></authors>
13
- <date>2012-08-16</date>
14
- <time>12:52:09</time>
15
- <contents><target name="magelocal"><dir name="Cashu"><dir name="Paymentmethod"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Currencyoptions.php" hash="8dcf73dc698c933a22682b12bff67983"/><file name="Languageoptions.php" hash="4e58fddaae9cccce1850d8dfe2ff28c7"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="627c69e6846849f116c17f179be4bb86"/></dir><dir name="Model"><file name="Pay.php" hash="23ba17975e2836e0e582d4430e4bbab7"/></dir><dir name="controllers"><file name="PaymentController.php" hash="ed7a5f74d5472a23ab48e10e23ae1c9e"/></dir><dir name="etc"><file name="config.xml" hash="2f89ffe89a66e2211efd6892f61a3dcd"/><file name="system.xml" hash="f060d0c076da9b6854c434a2d443672f"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><file name="cashu" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cashu_Paymentmethod.xml" hash="5182f969b96434d61f9047f849443b44"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cashu_Paymentmethod</name>
4
+ <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>This extension will allow your customers to use Cashu payment gateway.</summary>
10
+ <description>This extension adds (Cashu Prepaid) option to your store payment methods. Upon adding this extension to your store, your customers will be able to complete payment through Cashu Gateway. This extension is customizable as you can configure it to meet your needs. Additionally, it allows you to add the requirements settings for your Cashu merchant account.</description>
11
+ <notes>Release version 1.0.2 Cashu Prepaid.</notes>
12
  <authors><author><name>Moe</name><user>Ghashim</user><email>moe@shopgo.me</email></author></authors>
13
+ <date>2013-09-07</date>
14
+ <time>08:07:32</time>
15
+ <contents><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="cashu"><dir name="prepaid"><file name="redirect.phtml" hash="47ddb261c6490d8a54495f37b9d2a656"/><file name="success.phtml" hash="77ffda055051399341705ab03551404b"/></dir></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="Cashu"><dir name="Prepaid"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Currencyoptions.php" hash="b760577a305a9399108ecd49ffeef7a4"/><file name="Languageoptions.php" hash="0c8e797962b559f9eee121b605f7ddf1"/></dir></dir></dir></dir></dir><dir name="Block"><dir name="Onepage"><dir name="Payment"><file name="Methods.php" hash="5a13a81f710a7a1ed82876bffa9adda5"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="65fdcf67427340a53d3ea99e24851fdc"/></dir><dir name="Model"><file name="Pay.php" hash="3497b01efe6453e5e6dd74c24ac68860"/></dir><dir name="controllers"><file name="IndexController.php" hash="1b10fcb45b0f7d345762be34d9c355c5"/><file name="PaymentController.php" hash="33a1e0cc9e123cbd49ea8f4e5bb196b6"/></dir><dir name="etc"><file name="config.xml" hash="6dbafc56764bb6b56bd13d8c54e261c1"/><file name="system.xml" hash="e562265d36d006add836b5788399f67e"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cashu_Prepaid.xml" hash="cd71a8448fa8d15897d1d5bf9a4ecf31"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>