Ip_Based_Payment_Method - Version 0.1.0

Version Notes

Initial Release

Download this release

Release Info

Developer Cueblocks
Extension Ip_Based_Payment_Method
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/Codewix/IpbasedMethods/Helper/Data.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Codewix_IPbasedMethoda
4
+ * @author Ravinder <codewix@gmail.com>
5
+ */
6
+ class Codewix_IpbasedMethods_Helper_Data extends Mage_Core_Helper_Abstract {
7
+
8
+ }
app/code/community/Codewix/IpbasedMethods/Model/Observer.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Codewix_IPbasedMethods
4
+ * @author Ravinder <codewix@gmail.com>
5
+ */
6
+
7
+ class Codewix_IpbasedMethods_Model_Observer {
8
+
9
+ /*
10
+ * Method will restrict payment methods 'checkmo','cashondelivery','purchaseorder' based on customer IP address
11
+ * */
12
+
13
+ public function paymentMethod($event) {
14
+
15
+ $method = $event->getMethodInstance();
16
+ $result = $event->getResult();
17
+ $allowedMethods = array('checkmo','cashondelivery','purchaseorder');
18
+ if(in_array($method->getCode(),$allowedMethods)){
19
+ $userIpAddress = $_SERVER['REMOTE_ADDR'];
20
+ $ipAddress = Mage::getStoreConfig('payment/'.$method->getCode().'/ip');
21
+ if(empty($ipAddress)) {
22
+ return;
23
+ } else {
24
+ $ipAddress = explode(',',$ipAddress);
25
+ if(!in_array($userIpAddress,$ipAddress)) {
26
+ $result->isAvailable = false;
27
+ }
28
+ }
29
+ }
30
+
31
+ }
32
+
33
+ }
app/code/community/Codewix/IpbasedMethods/etc/config.xml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Codewix_IpbasedMethods>
5
+ <version>0.1.0</version>
6
+ </Codewix_IpbasedMethods>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <ipbasedmethods>
11
+ <class>Codewix_IpbasedMethods_Model</class>
12
+ </ipbasedmethods>
13
+ </models>
14
+ <blocks>
15
+ <ipbasedmethods>
16
+ <class>Codewix_IpbasedMethods_Block</class>
17
+ </ipbasedmethods>
18
+ </blocks>
19
+ <helpers>
20
+ <ipbasedmethods>
21
+ <class>Codewix_IpbasedMethods_Helper</class>
22
+ </ipbasedmethods>
23
+ </helpers>
24
+ </global>
25
+ <frontend>
26
+ <events>
27
+ <payment_method_is_active>
28
+ <observers>
29
+ <ipbasedpaymentmethod>
30
+ <class>ipbasedmethods/observer</class>
31
+ <method>paymentMethod</method>
32
+ </ipbasedpaymentmethod>
33
+ </observers>
34
+ </payment_method_is_active>
35
+ </events>
36
+ </frontend>
37
+ </config>
app/code/community/Codewix/IpbasedMethods/etc/system.xml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <sections>
3
+ <payment>
4
+ <groups>
5
+ <checkmo>
6
+ <fields>
7
+ <ip translate="label">
8
+ <label>Allowed IP Address</label>
9
+ <frontend_type>textarea</frontend_type>
10
+ <comment>Separate by comma in case of multiple values and leave it empty if you want to
11
+ allow method for all ip addresses
12
+ </comment>
13
+ <sort_order>11</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>0</show_in_store>
17
+ </ip>
18
+ </fields>
19
+ </checkmo>
20
+ <purchaseorder>
21
+ <fields>
22
+ <ip translate="label">
23
+ <label>Allowed IP Address</label>
24
+ <frontend_type>textarea</frontend_type>
25
+ <comment>Separate by comma in case of multiple values and leave it empty if you want to
26
+ allow method for all ip addresses
27
+ </comment>
28
+ <sort_order>11</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>0</show_in_store>
32
+ </ip>
33
+ </fields>
34
+ </purchaseorder>
35
+ <cashondelivery>
36
+ <fields>
37
+ <ip translate="label">
38
+ <label>Allowed IP Address</label>
39
+ <frontend_type>textarea</frontend_type>
40
+ <comment>Separate by comma in case of multiple values and leave it empty if you want to
41
+ allow method for all ip addresses
42
+ </comment>
43
+ <sort_order>11</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>0</show_in_store>
47
+ </ip>
48
+ </fields>
49
+ </cashondelivery>
50
+ </groups>
51
+ </payment>
52
+ </sections>
53
+ </config>
app/etc/modules/Codewix_IpbasedMethods.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Codewix_IpbasedMethods>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Codewix_IpbasedMethods>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Ip_Based_Payment_Method</name>
4
+ <version>0.1.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>Module will allow to restrict payment methods based on customers Ip address.So It will be very useful in case you testing checkout process and need method like 'Check/Money Order' for you.</summary>
10
+ <description>This Module will be very useful to enable any of below payment method only for you i.e only for your IP address :&#xD;
11
+ &#xD;
12
+ 'check money order'&#xD;
13
+ 'cashondelivery'&#xD;
14
+ 'purchaseorder'&#xD;
15
+ &#xD;
16
+ A practical example of usefulness of this module will be :&#xD;
17
+ &#xD;
18
+ You want to test checkout process of website and you have payment methods available which require you to make live payment.&#xD;
19
+ &#xD;
20
+ So in that case you will need payment method like 'Check Money Order' to avoid live payment and place order.</description>
21
+ <notes>Initial Release</notes>
22
+ <authors><author><name>CueBlocks</name><user>Ravinder</user><email>ravinder.singh@cueblocks.com</email></author></authors>
23
+ <date>2014-07-03</date>
24
+ <time>17:41:57</time>
25
+ <contents><target name="magecommunity"><dir name="Codewix"><dir name="IpbasedMethods"><dir name="Helper"><file name="Data.php" hash="246718790e7962b0b8c0c088689cfdc1"/></dir><dir name="Model"><file name="Observer.php" hash="b4ca92640ad177498947db0ea0e0ceb2"/></dir><dir name="etc"><file name="config.xml" hash="5a77bada0524e39c11387b2258e316df"/><file name="system.xml" hash="41901642ab6ca0c81eaf8073d8f05a49"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Codewix_IpbasedMethods.xml" hash="d9a54cdfdfcc4f8d051ae007fe2c5149"/></dir></target></contents>
26
+ <compatible/>
27
+ <dependencies><required><php><min>5.0.2</min><max>6.0.0</max></php></required></dependencies>
28
+ </package>