Version Notes
E-Mail simplification.
Download this release
Release Info
Developer | FRAUD.AGENCY |
Extension | Fraudagency_Paymentapi |
Version | 0.3.5 |
Comparing to | |
See all releases |
Code changes from version 0.3.4 to 0.3.5
app/code/community/Fraudagency/Paymentapi/Model/Observer.php
CHANGED
@@ -1,173 +1,172 @@
|
|
1 |
<?php
|
2 |
class Fraudagency_Paymentapi_Model_Observer {
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
$customerData = Mage::getSingleton('customer/session')->getCustomer();
|
38 |
$customerID = $customerData->getId();
|
39 |
}
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
'customer' => $customerID,
|
53 |
'name' => $this->_billingname,
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
'order_amount' => $grandtotal,
|
70 |
'order_currency' => $currency,
|
71 |
'order_id' => $quoteid,
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
'payment_method' => $paymentCode,
|
99 |
'payment_method_txt' => $paymentTitle,
|
100 |
'status' => $status
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
'key' => $license_key,
|
105 |
'query' => 'check_order',
|
106 |
'payment_method' => $array_with_payment_methods,
|
107 |
'order' => $array_with_order_information
|
108 |
-
|
109 |
$response = json_decode(file_get_contents(('https://fraud.agency/api/?q='. urlencode(json_encode($array))), 0, stream_context_create(array('https' => array('timeout' => 5)))), 1);
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
$response = json_decode(file_get_contents(('https://fraud.agency/api/?q='. urlencode(json_encode($array))), 0, stream_context_create(array('https' => array('timeout' => 5)))), 1);
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
}
|
173 |
?>
|
1 |
<?php
|
2 |
class Fraudagency_Paymentapi_Model_Observer {
|
3 |
+
protected $_pmethods = array();
|
4 |
+
private $_email = '';
|
5 |
+
private $_billingname = '';
|
6 |
+
private $_billingaddress = '';
|
7 |
+
private $_billingzip = '';
|
8 |
+
private $_billingcity = '';
|
9 |
+
private $_billingstate = '';
|
10 |
+
private $_billingcountry = '';
|
11 |
+
public function paymentApi($observer) {
|
12 |
+
$action_name = $observer->getEvent()->getControllerAction()->getFullActionName();
|
13 |
+
$pos = strrpos($action_name, "_");
|
14 |
+
$action = substr($action_name,$pos+1);
|
15 |
+
$param_billing = Mage::app()->getFrontController()->getRequest()->getParam('billing', array());
|
16 |
+
if( ($action == 'saveBilling' && $param_billing['use_for_shipping'] == 1) || $action == 'saveShipping') {
|
17 |
+
$enablePaymentapi = Mage::getStoreConfig('paymentapi/general/activate_fraudagency_paymentapi_enable');
|
18 |
+
$enablePaymentapi = intval($enablePaymentapi);
|
19 |
+
if($enablePaymentapi) {
|
20 |
+
$license_key = Mage::getStoreConfig('paymentapi/general/apikey_fraudagency_paymentapi_apikey');
|
21 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
22 |
+
$quoteid = $quote->getId();
|
23 |
+
if($quoteid) {
|
24 |
+
$address=$quote->getBillingAddress();
|
25 |
+
if($address->getAddressType() == 'billing') {
|
26 |
+
$this->_email = $address->getData('email');
|
27 |
+
$this->_billingname = $address->getData("firstname").' '.$address->getData("lastname");
|
28 |
+
$this->_billingaddress = $address->getData("street").' '.$address->getStreet(2);
|
29 |
+
$this->_billingzip = $address->getData("postcode");
|
30 |
+
$this->_billingcity = $address->getData("city");
|
31 |
+
$this->_billingstate = $address->getRegionCode();
|
32 |
+
$this->_billingcountry = $address->getCountry();
|
33 |
+
}
|
34 |
+
$address=$quote->getShippingAddress();
|
35 |
+
if($address->getAddressType()=='shipping') {
|
36 |
+
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
|
37 |
$customerData = Mage::getSingleton('customer/session')->getCustomer();
|
38 |
$customerID = $customerData->getId();
|
39 |
}
|
40 |
+
$shipname = $address->getData("firstname").' '.$address->getData("lastname");
|
41 |
+
$shipaddress = $address->getStreet(1).' '.$address->getStreet(2);
|
42 |
+
$shipPostcode = $address->getData("postcode");
|
43 |
+
$shipCity = $address->getData("city");
|
44 |
+
$shipRegion = $address->getRegionCode();
|
45 |
+
$shipCountry = $address->getCountry();
|
46 |
+
$shipPhone = $address->getData("telephone");
|
47 |
+
$session_id = Mage::getModel("core/session")->getEncryptedSessionId();
|
48 |
+
$order_total = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
|
49 |
+
$grandtotal = $order_total["grand_total"]->getValue();
|
50 |
+
$currency = Mage::getSingleton('checkout/session')->getQuote()->getQuoteCurrencyCode();
|
51 |
+
$array_with_order_information = array(
|
52 |
'customer' => $customerID,
|
53 |
'name' => $this->_billingname,
|
54 |
+
'address' => $this->_billingaddress,
|
55 |
+
'city' => $this->_billingcity,
|
56 |
+
'state' => $this->_billingstate,
|
57 |
+
'zip' => $this->_billingzip,
|
58 |
+
'country' => $this->_billingcountry,
|
59 |
+
'shipname' => $shipname,
|
60 |
+
'shipaddr' => $shipaddress,
|
61 |
+
'shipcity' => $shipCity,
|
62 |
+
'shipstate' => $shipRegion,
|
63 |
+
'shipzip' => $shipPostcode,
|
64 |
+
'shipcountry' => $shipCountry,
|
65 |
+
'phone' => $shipPhone,
|
66 |
+
'email' => strtolower($this->_email),
|
67 |
+
'passwordmd5' => NULL,
|
68 |
+
'order_amount' => $grandtotal,
|
|
|
69 |
'order_currency' => $currency,
|
70 |
'order_id' => $quoteid,
|
71 |
+
'cc_num' => NULL,
|
72 |
+
'cc_b_name' => NULL,
|
73 |
+
'cc_bin_phone' => NULL,
|
74 |
+
'cc_avs_result' => NULL,
|
75 |
+
'cc_ccv_result' => NULL,
|
76 |
+
'sessionid' => $session_id,
|
77 |
+
'ip' => $_SERVER['REMOTE_ADDR'],
|
78 |
+
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
|
79 |
+
'accept_language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'],
|
80 |
+
'forwardedip' => ((!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : NULL)
|
81 |
+
);
|
82 |
+
$allAvailablePaymentMethods = Mage::getModel('payment/config')->getAllMethods();
|
83 |
+
$ActivePaymentMethods = Mage::getSingleton('payment/config')->getActiveMethods();
|
84 |
+
foreach ($ActivePaymentMethods as $Code=>$payment) {
|
85 |
+
$Activemethods[] = $Code;
|
86 |
+
}
|
87 |
+
$store = Mage::app()->getStore();
|
88 |
+
foreach ($allAvailablePaymentMethods as $paymentCode=>$paymentModel) {
|
89 |
+
$active = Mage::getStoreConfigFlag('payment/'.$paymentCode.'/active', $store);
|
90 |
+
if($active) {
|
91 |
+
$status = $active;
|
92 |
+
} else {
|
93 |
+
$status = '0';
|
94 |
+
}
|
95 |
+
$paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
|
96 |
+
$array_with_payment_methods[] = array(
|
97 |
'payment_method' => $paymentCode,
|
98 |
'payment_method_txt' => $paymentTitle,
|
99 |
'status' => $status
|
100 |
+
);
|
101 |
+
}
|
102 |
+
$array = array(
|
103 |
'key' => $license_key,
|
104 |
'query' => 'check_order',
|
105 |
'payment_method' => $array_with_payment_methods,
|
106 |
'order' => $array_with_order_information
|
107 |
+
);
|
108 |
$response = json_decode(file_get_contents(('https://fraud.agency/api/?q='. urlencode(json_encode($array))), 0, stream_context_create(array('https' => array('timeout' => 5)))), 1);
|
109 |
+
if (empty($response['err_msg']) && $response['call']==1) {
|
110 |
+
foreach ($response['accepted_payment_method'] as $key => $value) {
|
111 |
+
if (in_array($value['payment_method'], $Activemethods)) {
|
112 |
+
$this->_pmethods[] = $value['payment_method'];
|
113 |
+
}
|
114 |
+
}
|
115 |
+
Mage::getSingleton('core/session')->setPaymentMethods($this->_pmethods);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
} elseif($action == 'saveOrder') {
|
121 |
+
Mage::getSingleton('core/session')->setPaymentMethods('');
|
122 |
+
}
|
123 |
+
}
|
124 |
+
public function paymentMethodActive(Varien_Event_Observer $observer) {
|
125 |
+
$event = $observer->getEvent();
|
126 |
+
$method = $event->getMethodInstance();
|
127 |
+
$result = $event->getResult();
|
128 |
+
$getPaymentMethods = Mage::getSingleton('core/session')->getPaymentMethods();
|
129 |
+
if(count($getPaymentMethods) > 0) {
|
130 |
+
if (!in_array($method->getCode(),$getPaymentMethods)) {
|
131 |
+
$result->isAvailable = false;
|
132 |
+
}
|
133 |
+
}
|
134 |
+
}
|
135 |
+
public function handle_adminSystemConfigChangedSection() {
|
136 |
+
$enablePaymentapi = Mage::getStoreConfig('paymentapi/general/activate_fraudagency_paymentapi_enable');
|
137 |
+
$enablePaymentapi = intval($enablePaymentapi);
|
138 |
+
$allAvailablePaymentMethods = Mage::getModel('payment/config')->getAllMethods();
|
139 |
+
$store = Mage::app()->getStore();
|
140 |
+
foreach ($allAvailablePaymentMethods as $paymentCode=>$paymentModel) {
|
141 |
+
$active = Mage::getStoreConfigFlag('payment/'.$paymentCode.'/active', $store);
|
142 |
+
if($active) {
|
143 |
+
$status = $active;
|
144 |
+
} else {
|
145 |
+
$status = '0';
|
146 |
+
}
|
147 |
+
$paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
|
148 |
+
$array_with_payment_methods[] = array(
|
149 |
+
'payment_method' => $paymentCode,
|
150 |
+
'payment_method_txt' => $paymentTitle,
|
151 |
+
'status' => $status
|
152 |
+
);
|
153 |
+
}
|
154 |
+
if($enablePaymentapi) {
|
155 |
+
$license_key = Mage::getStoreConfig('paymentapi/general/apikey_fraudagency_paymentapi_apikey');
|
156 |
+
$array = array(
|
157 |
+
'key' => $license_key,
|
158 |
+
'query' => 'init_license_key',
|
159 |
+
'payment_method' => $array_with_payment_methods
|
160 |
+
);
|
161 |
$response = json_decode(file_get_contents(('https://fraud.agency/api/?q='. urlencode(json_encode($array))), 0, stream_context_create(array('https' => array('timeout' => 5)))), 1);
|
162 |
+
$session = Mage::getSingleton('core/session');
|
163 |
+
if (empty($response['err_msg']) && $response['call']==1) {
|
164 |
+
$session->addSuccess('License key is valid and active');
|
165 |
+
} else {
|
166 |
+
$session->addError('License key is not valid');
|
167 |
+
throw new Exception("stop");
|
168 |
+
}
|
169 |
+
}
|
170 |
+
}
|
171 |
}
|
172 |
?>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Fraudagency_Paymentapi</name>
|
4 |
-
<version>0.3.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
|
7 |
<channel>community</channel>
|
@@ -15,11 +15,11 @@ How it works:
|
|
15 |
We gather information about the customer before the payment methods are displayed. Then we delivery your Magento-shop a list of payment methods which will be available for the customer.
|
16 |

|
17 |
Please note that you need a license-key to use our service. Visit our website for more information: https://fraud.agency</description>
|
18 |
-
<notes>
|
19 |
<authors><author><name>FRAUD.AGENCY</name><user>x15_eu</user><email>info@fraud.agency</email></author></authors>
|
20 |
-
<date>2014-
|
21 |
-
<time>
|
22 |
-
<contents><target name="magecommunity"><dir name="Fraudagency"><dir name="Paymentapi"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="a0e7a4bb70f428e90839712a06ec0cc5"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="a97f541415729338cb3fb591399af67e"/></dir><dir name="Model"><file name="Observer.php" hash="
|
23 |
<compatible/>
|
24 |
<dependencies><required><php><min>5.0.0</min><max>5.5.12</max></php></required></dependencies>
|
25 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Fraudagency_Paymentapi</name>
|
4 |
+
<version>0.3.5</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
|
7 |
<channel>community</channel>
|
15 |
We gather information about the customer before the payment methods are displayed. Then we delivery your Magento-shop a list of payment methods which will be available for the customer.
|
16 |

|
17 |
Please note that you need a license-key to use our service. Visit our website for more information: https://fraud.agency</description>
|
18 |
+
<notes>E-Mail simplification.</notes>
|
19 |
<authors><author><name>FRAUD.AGENCY</name><user>x15_eu</user><email>info@fraud.agency</email></author></authors>
|
20 |
+
<date>2014-09-18</date>
|
21 |
+
<time>16:46:45</time>
|
22 |
+
<contents><target name="magecommunity"><dir name="Fraudagency"><dir name="Paymentapi"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="a0e7a4bb70f428e90839712a06ec0cc5"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="a97f541415729338cb3fb591399af67e"/></dir><dir name="Model"><file name="Observer.php" hash="f85bf873a9f399b03d0b4a73c55586e2"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PaymentapiController.php" hash="fac8a7e2bafd68705f0e39493fd9756e"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="79cd9aaf297d5ab176b7bb80df941fdd"/><file name="config.xml" hash="ef9cd943deadb9167a6867afcdc5247e"/><file name="system.xml" hash="08c92615822b047e0997a9e8ee52db16"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Fraudagency_Paymentapi.xml" hash="d5b931b7c46b3f64646f2802015f225f"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="paymentapi"><dir name="system"><dir name="config"><file name="button.phtml" hash="239cb1c998aefad8b1aaf89c15146669"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
23 |
<compatible/>
|
24 |
<dependencies><required><php><min>5.0.0</min><max>5.5.12</max></php></required></dependencies>
|
25 |
</package>
|