Fraudagency_Paymentapi - Version 0.3.8

Version Notes

E-Mail simplification.

Download this release

Release Info

Developer FRAUD.AGENCY
Extension Fraudagency_Paymentapi
Version 0.3.8
Comparing to
See all releases


Code changes from version 0.3.4 to 0.3.8

app/code/community/Fraudagency/Paymentapi/Block/Adminhtml/System/Config/Form/Button.php CHANGED
File without changes
app/code/community/Fraudagency/Paymentapi/Helper/Data.php CHANGED
File without changes
app/code/community/Fraudagency/Paymentapi/Model/Observer.php CHANGED
@@ -1,173 +1,174 @@
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
- 'domain' => substr(strrchr($this->_email, "@"), 1),
66
- 'phone' => $shipPhone,
67
- 'emailmd5' => md5(strtolower($this->_email)),
68
- 'passwordmd5' => NULL,
69
- 'order_amount' => $grandtotal,
70
  'order_currency' => $currency,
71
  'order_id' => $quoteid,
72
- 'cc_num' => NULL,
73
- 'cc_b_name' => NULL,
74
- 'cc_bin_phone' => NULL,
75
- 'cc_avs_result' => NULL,
76
- 'cc_ccv_result' => NULL,
77
- 'sessionid' => $session_id,
78
- 'ip' => $_SERVER['REMOTE_ADDR'],
79
- 'user_agent' => $_SERVER['HTTP_USER_AGENT'],
80
- 'accept_language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'],
81
- 'forwardedip' => ((!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : NULL)
82
- );
83
- $allAvailablePaymentMethods = Mage::getModel('payment/config')->getAllMethods();
84
- $ActivePaymentMethods = Mage::getSingleton('payment/config')->getActiveMethods();
85
- foreach ($ActivePaymentMethods as $Code=>$payment) {
86
- $Activemethods[] = $Code;
87
- }
88
- $store = Mage::app()->getStore();
89
- foreach ($allAvailablePaymentMethods as $paymentCode=>$paymentModel) {
90
- $active = Mage::getStoreConfigFlag('payment/'.$paymentCode.'/active', $store);
91
- if($active) {
92
- $status = $active;
93
- } else {
94
- $status = '0';
95
- }
96
- $paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
97
- $array_with_payment_methods[] = array(
98
  'payment_method' => $paymentCode,
99
  'payment_method_txt' => $paymentTitle,
100
  'status' => $status
101
- );
102
- }
103
- $array = array(
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
- if (empty($response['err_msg']) && $response['call']==1) {
111
- foreach ($response['accepted_payment_method'] as $key => $value) {
112
- if (in_array($value['payment_method'], $Activemethods)) {
113
- $this->_pmethods[] = $value['payment_method'];
114
- }
115
- }
116
- Mage::getSingleton('core/session')->setPaymentMethods($this->_pmethods);
117
- }
118
- }
119
- }
120
- }
121
- } elseif($action == 'saveOrder') {
122
- Mage::getSingleton('core/session')->setPaymentMethods('');
123
- }
124
- }
125
- public function paymentMethodActive(Varien_Event_Observer $observer) {
126
- $event = $observer->getEvent();
127
- $method = $event->getMethodInstance();
128
- $result = $event->getResult();
129
- $getPaymentMethods = Mage::getSingleton('core/session')->getPaymentMethods();
130
- if(count($getPaymentMethods) > 0) {
131
- if (!in_array($method->getCode(),$getPaymentMethods)) {
132
- $result->isAvailable = false;
133
- }
134
- }
135
- }
136
- public function handle_adminSystemConfigChangedSection() {
137
- $enablePaymentapi = Mage::getStoreConfig('paymentapi/general/activate_fraudagency_paymentapi_enable');
138
- $enablePaymentapi = intval($enablePaymentapi);
139
- $allAvailablePaymentMethods = Mage::getModel('payment/config')->getAllMethods();
140
- $store = Mage::app()->getStore();
141
- foreach ($allAvailablePaymentMethods as $paymentCode=>$paymentModel) {
142
- $active = Mage::getStoreConfigFlag('payment/'.$paymentCode.'/active', $store);
143
- if($active) {
144
- $status = $active;
145
- } else {
146
- $status = '0';
147
- }
148
- $paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
149
- $array_with_payment_methods[] = array(
150
- 'payment_method' => $paymentCode,
151
- 'payment_method_txt' => $paymentTitle,
152
- 'status' => $status
153
- );
154
- }
155
- if($enablePaymentapi) {
156
- $license_key = Mage::getStoreConfig('paymentapi/general/apikey_fraudagency_paymentapi_apikey');
157
- $array = array(
158
- 'key' => $license_key,
159
- 'query' => 'init_license_key',
160
- 'payment_method' => $array_with_payment_methods
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
- $session = Mage::getSingleton('core/session');
164
- if (empty($response['err_msg']) && $response['call']==1) {
165
- $session->addSuccess('License key is valid and active');
166
- } else {
167
- $session->addError('License key is not valid');
168
- throw new Exception("stop");
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
+ 'shopsystem' => 'magento',
53
+ 'appversion' => '0.3.8',
54
  'customer' => $customerID,
55
  'name' => $this->_billingname,
56
+ 'address' => $this->_billingaddress,
57
+ 'city' => $this->_billingcity,
58
+ 'state' => $this->_billingstate,
59
+ 'zip' => $this->_billingzip,
60
+ 'country' => $this->_billingcountry,
61
+ 'shipname' => $shipname,
62
+ 'shipaddr' => $shipaddress,
63
+ 'shipcity' => $shipCity,
64
+ 'shipstate' => $shipRegion,
65
+ 'shipzip' => $shipPostcode,
66
+ 'shipcountry' => $shipCountry,
67
+ 'phone' => $shipPhone,
68
+ 'email' => strtolower($this->_email),
69
+ 'passwordmd5' => NULL,
70
+ 'order_amount' => $grandtotal,
 
71
  'order_currency' => $currency,
72
  'order_id' => $quoteid,
73
+ 'cc_num' => NULL,
74
+ 'cc_b_name' => NULL,
75
+ 'cc_bin_phone' => NULL,
76
+ 'cc_avs_result' => NULL,
77
+ 'cc_ccv_result' => NULL,
78
+ 'sessionid' => $session_id,
79
+ 'ip' => $_SERVER['REMOTE_ADDR'],
80
+ 'user_agent' => $_SERVER['HTTP_USER_AGENT'],
81
+ 'accept_language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'],
82
+ 'forwardedip' => ((!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : NULL)
83
+ );
84
+ $allAvailablePaymentMethods = Mage::getModel('payment/config')->getAllMethods();
85
+ $ActivePaymentMethods = Mage::getSingleton('payment/config')->getActiveMethods();
86
+ foreach ($ActivePaymentMethods as $Code=>$payment) {
87
+ $Activemethods[] = $Code;
88
+ }
89
+ $store = Mage::app()->getStore();
90
+ foreach ($allAvailablePaymentMethods as $paymentCode=>$paymentModel) {
91
+ $active = Mage::getStoreConfigFlag('payment/'.$paymentCode.'/active', $store);
92
+ if($active) {
93
+ $status = $active;
94
+ } else {
95
+ $status = '0';
96
+ }
97
+ $paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
98
+ $array_with_payment_methods[] = array(
99
  'payment_method' => $paymentCode,
100
  'payment_method_txt' => $paymentTitle,
101
  'status' => $status
102
+ );
103
+ }
104
+ $array = array(
105
  'key' => $license_key,
106
  'query' => 'check_order',
107
  'payment_method' => $array_with_payment_methods,
108
  'order' => $array_with_order_information
109
+ );
110
+ $response = json_decode(file_get_contents(('https://api.fraud.agency/?q='. urlencode(json_encode($array))), 0, stream_context_create(array('https' => array('timeout' => 5)))), 1);
111
+ if (empty($response['err_msg']) && $response['call']==1) {
112
+ foreach ($response['accepted_payment_method'] as $key => $value) {
113
+ if (in_array($value['payment_method'], $Activemethods)) {
114
+ $this->_pmethods[] = $value['payment_method'];
115
+ }
116
+ }
117
+ Mage::getSingleton('core/session')->setPaymentMethods($this->_pmethods);
118
+ }
119
+ }
120
+ }
121
+ }
122
+ } elseif($action == 'saveOrder') {
123
+ Mage::getSingleton('core/session')->setPaymentMethods('');
124
+ }
125
+ }
126
+ public function paymentMethodActive(Varien_Event_Observer $observer) {
127
+ $event = $observer->getEvent();
128
+ $method = $event->getMethodInstance();
129
+ $result = $event->getResult();
130
+ $getPaymentMethods = Mage::getSingleton('core/session')->getPaymentMethods();
131
+ if(count($getPaymentMethods) > 0) {
132
+ if (!in_array($method->getCode(),$getPaymentMethods)) {
133
+ $result->isAvailable = false;
134
+ }
135
+ }
136
+ }
137
+ public function handle_adminSystemConfigChangedSection() {
138
+ $enablePaymentapi = Mage::getStoreConfig('paymentapi/general/activate_fraudagency_paymentapi_enable');
139
+ $enablePaymentapi = intval($enablePaymentapi);
140
+ $allAvailablePaymentMethods = Mage::getModel('payment/config')->getAllMethods();
141
+ $store = Mage::app()->getStore();
142
+ foreach ($allAvailablePaymentMethods as $paymentCode=>$paymentModel) {
143
+ $active = Mage::getStoreConfigFlag('payment/'.$paymentCode.'/active', $store);
144
+ if($active) {
145
+ $status = $active;
146
+ } else {
147
+ $status = '0';
148
+ }
149
+ $paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
150
+ $array_with_payment_methods[] = array(
151
+ 'payment_method' => $paymentCode,
152
+ 'payment_method_txt' => $paymentTitle,
153
+ 'status' => $status
154
+ );
155
+ }
156
+ if($enablePaymentapi) {
157
+ $license_key = Mage::getStoreConfig('paymentapi/general/apikey_fraudagency_paymentapi_apikey');
158
+ $array = array(
159
+ 'key' => $license_key,
160
+ 'query' => 'init_license_key',
161
+ 'payment_method' => $array_with_payment_methods
162
+ );
163
+ $response = json_decode(file_get_contents(('https://api.fraud.agency/?q='. urlencode(json_encode($array))), 0, stream_context_create(array('https' => array('timeout' => 5)))), 1);
164
+ $session = Mage::getSingleton('core/session');
165
+ if (empty($response['err_msg']) && $response['call']==1) {
166
+ $session->addSuccess('License key is valid and active');
167
+ } else {
168
+ $session->addError('License key is not valid');
169
+ throw new Exception("stop");
170
+ }
171
+ }
172
+ }
173
  }
174
  ?>
app/code/community/Fraudagency/Paymentapi/controllers/Adminhtml/PaymentapiController.php CHANGED
File without changes
app/code/community/Fraudagency/Paymentapi/etc/adminhtml.xml CHANGED
File without changes
app/code/community/Fraudagency/Paymentapi/etc/config.xml CHANGED
File without changes
app/code/community/Fraudagency/Paymentapi/etc/system.xml CHANGED
File without changes
app/design/adminhtml/default/default/template/paymentapi/system/config/button.phtml CHANGED
File without changes
app/etc/modules/Fraudagency_Paymentapi.xml CHANGED
File without changes
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Fraudagency_Paymentapi</name>
4
- <version>0.3.4</version>
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:&#xD;
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.&#xD;
16
  &#xD;
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>Added cart recognition.</notes>
19
  <authors><author><name>FRAUD.AGENCY</name><user>x15_eu</user><email>info@fraud.agency</email></author></authors>
20
- <date>2014-08-19</date>
21
- <time>06:10:33</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="1f9aecc75647316602639b1dad3cf87f"/></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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Fraudagency_Paymentapi</name>
4
+ <version>0.3.8</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.&#xD;
16
  &#xD;
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.6.0</max></php></required></dependencies>
25
  </package>