Version Notes
Payment methods can be enabled for selected IPs though Methods are disabled in backend.
Download this release
Release Info
Developer | Emizen Tech Private Limited |
Extension | Emizen_Restrictmethod |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Emizen/Restrictmethod/Helper/Data.php +5 -0
- app/code/local/Emizen/Restrictmethod/Model/Methods.php +25 -0
- app/code/local/Emizen/Restrictmethod/Model/Observer.php +35 -0
- app/code/local/Emizen/Restrictmethod/etc/adminhtml.xml +23 -0
- app/code/local/Emizen/Restrictmethod/etc/config.xml +32 -0
- app/code/local/Emizen/Restrictmethod/etc/system.xml +59 -0
- app/etc/modules/Emizen_Restrictmethod.xml +10 -0
- package.xml +25 -0
app/code/local/Emizen/Restrictmethod/Helper/Data.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Emizen_Restrictmethod_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
5 |
+
|
app/code/local/Emizen/Restrictmethod/Model/Methods.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Emizen_Restrictmethod_Model_Methods{
|
4 |
+
|
5 |
+
//protected $_options;
|
6 |
+
|
7 |
+
public function toOptionArray()
|
8 |
+
{
|
9 |
+
|
10 |
+
$payments = Mage::getSingleton('payment/config')->getAllMethods();
|
11 |
+
|
12 |
+
$methods = array(array('value'=>'', 'label'=>Mage::helper('adminhtml')->__('--Please Select--')));
|
13 |
+
|
14 |
+
foreach ($payments as $paymentCode=>$paymentModel) {
|
15 |
+
$paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
|
16 |
+
$methods[$paymentCode] = array(
|
17 |
+
'label' => $paymentTitle,
|
18 |
+
'value' => $paymentCode,
|
19 |
+
);
|
20 |
+
}
|
21 |
+
|
22 |
+
|
23 |
+
return $methods;
|
24 |
+
}
|
25 |
+
}
|
app/code/local/Emizen/Restrictmethod/Model/Observer.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Emizen_Restrictmethod_Model_Observer {
|
5 |
+
|
6 |
+
|
7 |
+
public function paymentMethod($event) {
|
8 |
+
|
9 |
+
if(!Mage::getStoreConfig('restrictmethod/emizen/general')) // if not enable extension return false
|
10 |
+
return;
|
11 |
+
$method = $event->getMethodInstance();
|
12 |
+
$result = $event->getResult();
|
13 |
+
$allowedMethods = Mage::getStoreConfig('restrictmethod/emizen/methods');
|
14 |
+
|
15 |
+
Mage::log($method->getCode(),null,'test.log');
|
16 |
+
|
17 |
+
if($method->getCode()==$allowedMethods){
|
18 |
+
$userIpAddress = $_SERVER['REMOTE_ADDR'];
|
19 |
+
$ipAddress = Mage::getStoreConfig('restrictmethod/emizen/ipaddress');
|
20 |
+
Mage::log($ipAddress,null,'test.log');
|
21 |
+
Mage::log($userIpAddress,null,'test.log');
|
22 |
+
if(empty($ipAddress)) {
|
23 |
+
return;
|
24 |
+
} else {
|
25 |
+
$ipAddress = explode(',',$ipAddress);
|
26 |
+
if(in_array($userIpAddress,$ipAddress)) {
|
27 |
+
// Mage::throwException('not allowed');
|
28 |
+
$result->isAvailable = true;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
return $result;
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
app/code/local/Emizen/Restrictmethod/etc/adminhtml.xml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<system>
|
8 |
+
<children>
|
9 |
+
<config>
|
10 |
+
<children>
|
11 |
+
<restrictmethod translate="title" module="restrictmethod">
|
12 |
+
<title>General Section</title>
|
13 |
+
<sort_order>0</sort_order>
|
14 |
+
</restrictmethod>
|
15 |
+
</children>
|
16 |
+
</config>
|
17 |
+
</children>
|
18 |
+
</system>
|
19 |
+
</children>
|
20 |
+
</admin>
|
21 |
+
</resources>
|
22 |
+
</acl>
|
23 |
+
</config>
|
app/code/local/Emizen/Restrictmethod/etc/config.xml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Emizen_Restrictmethod>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Emizen_Restrictmethod>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<helpers>
|
10 |
+
<restrictmethod>
|
11 |
+
<class>Emizen_Restrictmethod_Helper</class>
|
12 |
+
</restrictmethod>
|
13 |
+
</helpers>
|
14 |
+
<models>
|
15 |
+
<restrictmethod>
|
16 |
+
<class>Emizen_Restrictmethod_Model</class>
|
17 |
+
</restrictmethod>
|
18 |
+
</models>
|
19 |
+
</global>
|
20 |
+
<frontend>
|
21 |
+
<events>
|
22 |
+
<payment_method_is_active>
|
23 |
+
<observers>
|
24 |
+
<restrictmethod>
|
25 |
+
<class>restrictmethod/observer</class>
|
26 |
+
<method>paymentMethod</method>
|
27 |
+
</restrictmethod>
|
28 |
+
</observers>
|
29 |
+
</payment_method_is_active>
|
30 |
+
</events>
|
31 |
+
</frontend>
|
32 |
+
</config>
|
app/code/local/Emizen/Restrictmethod/etc/system.xml
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<emizen translate="label" module="restrictmethod">
|
5 |
+
<label>Emizen</label>
|
6 |
+
<sort_order>0</sort_order>
|
7 |
+
</emizen>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<restrictmethod translate="label" module="restrictmethod">
|
11 |
+
<label>Enable IP Based Payment Method</label>
|
12 |
+
<tab>emizen</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>0</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<emizen translate="label">
|
20 |
+
<label>Enable IP Based Payment Method</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>0</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>1</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
<fields>
|
27 |
+
<general translate="label">
|
28 |
+
<label>Enable</label>
|
29 |
+
<frontend_type>select</frontend_type>
|
30 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
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 |
+
</general>
|
36 |
+
<ipaddress translate="label">
|
37 |
+
<label>IP To Allow Payment Method</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 |
+
<comment>Add multiple IPs comma seprated</comment>
|
44 |
+
</ipaddress>
|
45 |
+
<methods translate="label">
|
46 |
+
<label>Payment Methods</label>
|
47 |
+
<frontend_type>select</frontend_type>
|
48 |
+
<source_model>restrictmethod/methods</source_model>
|
49 |
+
<sort_order>14</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
+
</methods>
|
54 |
+
</fields>
|
55 |
+
</emizen>
|
56 |
+
</groups>
|
57 |
+
</restrictmethod>
|
58 |
+
</sections>
|
59 |
+
</config>
|
app/etc/modules/Emizen_Restrictmethod.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Emizen_Restrictmethod>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
<version>0.1.0</version>
|
8 |
+
</Emizen_Restrictmethod>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Emizen_Restrictmethod</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>Payment methods can be enabled for selected IPs though Methods are disabled in backend.</summary>
|
10 |
+
<description><p>By using this extension you can enable any payment method for your selected IPs, you just need to put your IP in backend and select your desired payment method. 
|
11 |
+
<p />This will be useful for developers who working on checkout and want to test full order process, with the help of this extension developer can select his desired payment method and put his IP in backend, it will enable accordingly. </p>
|
12 |
+
<h1>Features:-</h1>
|
13 |
+
<ul>
|
14 |
+
<li>1. Enable payment method without knowing the world, you are testing something.</li>
|
15 |
+
<li>2. Can save multiple IPs comma separated.</li>
|
16 |
+
<li>3. Can be enable/disable from backend</li>
|
17 |
+
</ul></description>
|
18 |
+
<notes>Payment methods can be enabled for selected IPs though Methods are disabled in backend.</notes>
|
19 |
+
<authors><author><name>Emizen Tech Private Limited</name><user>emizen</user><email>info@emizentech.com</email></author></authors>
|
20 |
+
<date>2015-08-04</date>
|
21 |
+
<time>07:58:57</time>
|
22 |
+
<contents><target name="magelocal"><dir><dir name="Emizen"><dir name="Restrictmethod"><dir><dir name="Helper"><file name="Data.php" hash="9aeffcc1bead875f9d7a4dd35870c182"/></dir><dir name="Model"><file name="Methods.php" hash="47aa6b588f27cfb473d8d30c8754e663"/><file name="Observer.php" hash="f7c5aeb3877f932a82994a9e510f1f16"/></dir><dir name="etc"><file name="adminhtml.xml" hash="b83b5015254b8f6747ad7abac04a63fd"/><file name="config.xml" hash="1216b2072922169337863bc17b114900"/><file name="system.xml" hash="6282fad6790ddb33050631d76f62ee1d"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Emizen_Restrictmethod.xml" hash="8afbc09d3c0fdbbdaf5a8441444cda17"/></dir></dir></target></contents>
|
23 |
+
<compatible/>
|
24 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
25 |
+
</package>
|