Addressvalidator - Version 1.5.2

Version Notes

test notes

Download this release

Release Info

Developer Extensions Store
Extension Addressvalidator
Version 1.5.2
Comparing to
See all releases


Code changes from version 1.4.3 to 1.5.2

Files changed (48) hide show
  1. app/code/community/Aydus/Addressvalidator/Model/Address.php +0 -23
  2. app/code/community/Aydus/Addressvalidator/Model/Observer.php +0 -187
  3. app/code/community/Aydus/Addressvalidator/Model/Resource/Address.php +0 -21
  4. app/code/community/Aydus/Addressvalidator/Model/Resource/Address/Collection.php +0 -21
  5. app/code/community/Aydus/Addressvalidator/Test/Controller/TestController.php +0 -26
  6. app/code/community/Aydus/Addressvalidator/Test/Helper/TestHelper.php +0 -33
  7. app/code/community/Aydus/Addressvalidator/Test/Model/TestModel/fixtures/testModel.yaml +0 -38
  8. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Block/Adminhtml/System/Config/Form/Validexceptions.php +4 -4
  9. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Block/Checkout/Onepage/Billing.php +5 -5
  10. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Helper/Data.php +37 -27
  11. app/code/community/ExtensionsStore/Addressvalidator/Model/Address.php +23 -0
  12. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Adminhtml/System/Config/Source/Addressdoctor/Validcodes.php +4 -4
  13. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Adminhtml/System/Config/Source/Service.php +4 -4
  14. app/code/community/ExtensionsStore/Addressvalidator/Model/Observer.php +208 -0
  15. app/code/community/ExtensionsStore/Addressvalidator/Model/Resource/Address.php +21 -0
  16. app/code/community/ExtensionsStore/Addressvalidator/Model/Resource/Address/Collection.php +21 -0
  17. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Service/Abstract.php +33 -18
  18. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Service/Addressdoctor.php +17 -17
  19. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Service/Fedex.php +49 -17
  20. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Service/Melissadata.php +5 -5
  21. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Service/Ups.php +11 -11
  22. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Service/Usps.php +32 -18
  23. app/code/community/ExtensionsStore/Addressvalidator/Test/Controller/TestController.php +26 -0
  24. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Test/Controller/TestController/fixtures/testController.yaml +0 -0
  25. app/code/community/ExtensionsStore/Addressvalidator/Test/Helper/TestHelper.php +33 -0
  26. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Test/Helper/TestHelper/fixtures/testHelper.yaml +0 -0
  27. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Test/Model/TestModel.php +9 -9
  28. app/code/community/ExtensionsStore/Addressvalidator/Test/Model/TestModel/fixtures/testModel.yaml +38 -0
  29. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/etc/adminhtml.xml +5 -5
  30. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/etc/config.xml +52 -37
  31. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/etc/system.xml +51 -27
  32. app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/readme.md +1 -1
  33. app/code/community/{Aydus/Addressvalidator/sql/aydus_addressvalidator_setup → ExtensionsStore/Addressvalidator/sql/extensions_store_addressvalidator_setup}/install-1.0.0.php +4 -4
  34. app/code/community/{Aydus/Addressvalidator/sql/aydus_addressvalidator_setup → ExtensionsStore/Addressvalidator/sql/extensions_store_addressvalidator_setup}/upgrade-1.3.0-1.4.0.php +4 -4
  35. app/code/community/ExtensionsStore/Addressvalidator/sql/extensions_store_addressvalidator_setup/upgrade-1.4.3-1.5.0.php +49 -0
  36. app/design/frontend/base/default/layout/aydus/addressvalidator.xml +0 -31
  37. app/design/frontend/base/default/layout/extensions_store/addressvalidator.xml +49 -0
  38. app/design/frontend/base/default/template/{aydus → extensions_store}/addressvalidator/popup.phtml +8 -9
  39. app/etc/modules/Aydus_Addressvalidator.xml +0 -18
  40. app/etc/modules/ExtensionsStore_Addressvalidator.xml +18 -0
  41. package.xml +4 -4
  42. skin/frontend/base/default/css/{aydus → extensions_store}/addressvalidator.css +3 -3
  43. skin/frontend/base/default/images/{aydus → extensions_store}/addressvalidator/LOGO_L.gif +0 -0
  44. skin/frontend/base/default/images/{aydus → extensions_store}/addressvalidator/LOGO_S.gif +0 -0
  45. skin/frontend/base/default/js/aydus/addressvalidator.js +0 -329
  46. skin/frontend/base/default/js/aydus/addressvalidator/address.js +0 -110
  47. skin/frontend/base/default/js/extensions_store/addressvalidator.js +439 -0
  48. skin/frontend/base/default/js/extensions_store/addressvalidator/address.js +107 -0
app/code/community/Aydus/Addressvalidator/Model/Address.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Address model
5
- *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
- */
10
-
11
- class Aydus_Addressvalidator_Model_Address extends Mage_Core_Model_Abstract
12
- {
13
- /**
14
- * Initialize resource model
15
- */
16
- protected function _construct()
17
- {
18
- parent::_construct();
19
-
20
- $this->_init('aydus_addressvalidator/address');
21
- }
22
-
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Aydus/Addressvalidator/Model/Observer.php DELETED
@@ -1,187 +0,0 @@
1
- <?php
2
-
3
- /**
4
- *
5
- * Address Validator observer
6
- *
7
- * @category Aydus
8
- * @package Aydus_Addressvalidator
9
- * @author Aydus <davidt@aydus.com>
10
- */
11
- class Aydus_Addressvalidator_Model_Observer extends Mage_Core_Model_Abstract {
12
-
13
- /**
14
- * Validate address using configured service, rewrite response if suggestions available
15
- *
16
- * @param Varien_Event_Observer $observer
17
- * @return Varien_Event_Observer $observer
18
- */
19
- public function validateAddress($observer) {
20
-
21
- $helper = Mage::helper('addressvalidator');
22
- $request = Mage::app()->getRequest();
23
- $event = $observer->getEvent();
24
- $controller = $event->getControllerAction();
25
- $response = $controller->getResponse();
26
- $store = Mage::app()->getStore();
27
- $storeId = $store->getId();
28
- $quote = Mage::getSingleton('checkout/session')->getQuote();
29
-
30
- if ($event->getName() == 'controller_action_postdispatch_checkout_onepage_saveBilling') {
31
-
32
- $address = $quote->getBillingAddress();
33
- } else {
34
-
35
- $address = $quote->getShippingAddress();
36
- }
37
-
38
- //save validated address
39
- $addressValidated = $request->getParam('address_validated');
40
- if ($addressValidated) {
41
- if ($address->getAddressType()=='billing'){
42
- $postData = $request->getParam('billing');
43
- } else {
44
- $postData = $request->getParam('shipping');
45
- }
46
- $postData['customer_address_id'] = $addressValidated;
47
- $helper->setAddressData($address, $postData, true);
48
- return $observer;
49
- }
50
-
51
- //customer elected to skip validation
52
- $skipValidation = (int)$request->getParam('skip_validation');
53
- if ($skipValidation){
54
- return $observer;
55
- }
56
-
57
- //skip validation if customer address has already been validated
58
- $addressId = $request->getParam('billing_address_id');
59
- if (!$addressId){
60
- $addressId = $request->getParam('shipping_address_id');
61
- }
62
- $validatedAddress = Mage::getModel('aydus_addressvalidator/address');
63
- $validatedAddress->load($addressId, 'address_id');
64
-
65
- if ($validatedAddress->getId() && $validatedAddress->getValidated()){
66
- return $observer;
67
- }
68
-
69
- if ($helper->tooManyAttempts()) {
70
-
71
- $result = array();
72
- $result['validate'] = true;
73
- $result['error'] = true;
74
- $tooManyAttemptsUrl = Mage::getStoreConfig('aydus_addressvalidator/configuration/too_many_attempts_url',$storeId);
75
- $result['data'] = Mage::getUrl($tooManyAttemptsUrl);
76
- $result['message'] = $helper->getMessaging('too_many_attempts');
77
-
78
- $response->setBody(Mage::helper('core')->jsonEncode($result));
79
- return $this;
80
- }
81
-
82
- $validateStore = $helper->validateStore($store);
83
-
84
- if ($validateStore) {
85
-
86
- $international = ($address->getCountryId() && Mage::getStoreConfig('general/country/default') != $address->getCountryId()) ? true : false;
87
- $service = $helper->getService($storeId, $international);
88
- $returned = array('error' => true);
89
-
90
- try {
91
- $returned = $service->getResults($address);
92
- } catch (Exception $e) {
93
- $returned['data'] = $e->getMessage();
94
- Mage::log($e->getMessage(), null, 'aydus_addressvalidator.log');
95
- }
96
-
97
- if ($returned['error'] === false) {
98
-
99
- $responseCode = ($helper->isDebug() && isset($returned['response_code']) && $returned['response_code']) ? ' (' . $returned['response_code'] . ')' : '';
100
- $result = array();
101
- $result['validate'] = true;
102
- $result['error'] = false;
103
-
104
- if (is_array($returned['data']) && count($returned['data']) > 0) {
105
-
106
- $result['data'] = json_encode($returned['data']);
107
- $result['message'] = $helper->getMessaging('matches_available') . $responseCode;
108
-
109
- $autoPopulate = (int)Mage::getStoreConfig('aydus_addressvalidator/configuration/auto_populate', $storeId);
110
-
111
- if ($autoPopulate){
112
- $helper->setAddressData($address, $returned['data'][0], true);
113
- $observer->setResult($result);
114
- return $observer;
115
- }
116
-
117
- } else {
118
-
119
- $result['error'] = true;
120
- $result['data'] = $returned['data'];
121
- $result['message'] = $helper->getMessaging('invalid_address') . $responseCode;
122
- }
123
-
124
- $rates = null;
125
-
126
- if ($address->getAddressType()=='billing'){
127
-
128
- $billing = $request->getParam('billing');
129
-
130
- if ($billing['use_for_shipping']){
131
- $rates = $quote->getShippingAddress()->collectShippingRates()->getGroupedAllShippingRates();
132
- }
133
- }
134
-
135
- if (is_array($rates) && count($rates)>0){
136
- $response->setBody(Mage::helper('core')->jsonEncode($result));
137
- }
138
-
139
- $observer->setResult($result);
140
- }
141
- }
142
-
143
- return $observer;
144
- }
145
-
146
- /**
147
- * Unflag customer address previously validated
148
- *
149
- * @see customer_address_save_after
150
- * @param Varien_Event_Observer $observer
151
- * @return Varien_Event_Observer $observer
152
- */
153
- public function updateAddressValidated($observer)
154
- {
155
- $customerAddress = $observer->getCustomerAddress();
156
- $request = Mage::app()->getRequest();
157
- $moduleName = $request->getModuleName();
158
-
159
- if ($customerAddress->getId() && $moduleName != 'checkout'){
160
-
161
- $validatedAddress = Mage::getModel('aydus_addressvalidator/address');
162
- $validatedAddress->load($customerAddress->getId(), 'address_id');
163
-
164
- $datetime = date('Y-m-d H:i:s');
165
- $validatedAddress->setAddressId($customerAddress->getId());
166
- $validatedAddress->setValidated(0);
167
-
168
- if (!$validatedAddress->getId()){
169
- $validatedAddress->setDateCreated($datetime);
170
- }
171
- $validatedAddress->setDateUpdated($datetime);
172
-
173
- try {
174
-
175
- $validatedAddress->save();
176
-
177
- }catch (Exception $e){
178
-
179
- Mage::log($e->getMessage(),null,'aydus_addressvalidator.log');
180
- }
181
-
182
- }
183
-
184
- return $observer;
185
- }
186
-
187
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Aydus/Addressvalidator/Model/Resource/Address.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Address resource model
5
- *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
- */
10
-
11
-
12
- class Aydus_Addressvalidator_Model_Resource_Address extends Mage_Core_Model_Resource_Db_Abstract
13
- {
14
-
15
- protected function _construct()
16
- {
17
- $this->_init('aydus_addressvalidator/address', 'id');
18
- }
19
-
20
- }
21
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Aydus/Addressvalidator/Model/Resource/Address/Collection.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Address resource collection
5
- *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
- */
10
-
11
-
12
- class Aydus_Addressvalidator_Model_Resource_Address_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
13
- {
14
-
15
- protected function _construct()
16
- {
17
- parent::_construct();
18
- $this->_init('aydus_addressvalidator/address');
19
- }
20
-
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Aydus/Addressvalidator/Test/Controller/TestController.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Controller test
5
- *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
- */
10
-
11
- class Aydus_Addressvalidator_Test_Controller_TestController extends EcomDev_PHPUnit_Test_Case_Controller
12
- {
13
-
14
- /**
15
- *
16
- * @test
17
- * @loadFixture
18
- */
19
- public function testController()
20
- {
21
- echo "\nAydus_Addressavalidator controller test started";
22
-
23
- echo "\nAydus_Addressavalidator controller test completed";
24
- }
25
-
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Aydus/Addressvalidator/Test/Helper/TestHelper.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Helper test
5
- *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
- */
10
-
11
- class Aydus_Addressvalidator_Test_Helper_TestHelper extends EcomDev_PHPUnit_Test_Case_Config
12
- {
13
-
14
- /**
15
- *
16
- * @test
17
- * @loadFixture testHelper.yaml
18
- */
19
- public function testHelper()
20
- {
21
- echo "\nAydus_Addressavalidator helper test started..";
22
-
23
- $helper = Mage::helper('addressvalidator');
24
-
25
- $_SERVER['HTTP_HOST'] = 'local.example.com';
26
- $isDebug = $helper->isDebug();
27
- $this->assertTrue($isDebug);
28
-
29
- echo "\nAydus_Addressavalidator helper test completed";
30
-
31
- }
32
-
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Aydus/Addressvalidator/Test/Model/TestModel/fixtures/testModel.yaml DELETED
@@ -1,38 +0,0 @@
1
- config:
2
- default/aydus_addressvalidator/configuration/enabled: 1
3
- default/aydus_addressvalidator/configuration/service: ups
4
- default/aydus_addressvalidator/configuration/auto_populate: 1
5
- default/aydus_addressvalidator/ups/url: https://wwwcie.ups.com/ups.app/xml/XAV
6
- default/aydus_addressvalidator/ups/access_license_number: 0:2:e2cd3e4a74601245:tAidQ8JX9KvWSgxZfOSnEQ==
7
- default/aydus_addressvalidator/ups/user_id: 0:2:08671d15853f22a6:n07IpZghnz9TPpUI6GHEUQ==
8
- default/aydus_addressvalidator/ups/password: 0:2:33180f60423a87fd:rXXk7EZq4vwAsuN+qYiCUg==
9
- tables:
10
- sales/quote:
11
- - entity_id: 1
12
- store_id: 1
13
- is_active: 1
14
- created_at: 2015-07-15 12:00:01
15
- updated_at: 2015-07-15 12:00:01
16
- customer_email: davidt@aydus.com
17
- - entity_id: 2
18
- - entity_id: 3
19
- sales/quote_address:
20
- - address_id: 1
21
- quote_id: 1
22
- address_type: billing
23
- street: 47 Anderson
24
- city: Staten Isl
25
- region: New York
26
- region_id: 43
27
- postcode: 1030
28
- country_id: US
29
- - address_id: 2
30
- quote_id: 1
31
- address_type: shipping
32
- street: 919 Bard
33
- city: Stat
34
- region: New York
35
- region_id: 43
36
- postcode: 1030
37
- country_id: US
38
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Block/Adminhtml/System/Config/Form/Validexceptions.php RENAMED
@@ -3,11 +3,11 @@
3
  /**
4
  * Valid exceptions for countries
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
- class Aydus_Addressvalidator_Block_Adminhtml_System_Config_Form_Validexceptions extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
11
  {
12
 
13
  public function __construct()
3
  /**
4
  * Valid exceptions for countries
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
+ class ExtensionsStore_Addressvalidator_Block_Adminhtml_System_Config_Form_Validexceptions extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
11
  {
12
 
13
  public function __construct()
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Block/Checkout/Onepage/Billing.php RENAMED
@@ -3,12 +3,12 @@
3
  /**
4
  * Checkout Onepage billing override
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
 
11
- class Aydus_Addressvalidator_Block_Checkout_Onepage_Billing extends Mage_Checkout_Block_Onepage_Billing
12
  {
13
  /**
14
  * Insert script tag before billing step, to add nextStep overrides to Billing and Shipping objects
@@ -18,7 +18,7 @@ class Aydus_Addressvalidator_Block_Checkout_Onepage_Billing extends Mage_Checkou
18
  */
19
  protected function _afterToHtml($html)
20
  {
21
- $html = '<script type="text/javascript" src="'. $this->getSkinUrl('js/aydus/addressvalidator/address.js').'"></script>'.$html;
22
 
23
  return $html;
24
  }
3
  /**
4
  * Checkout Onepage billing override
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
 
11
+ class ExtensionsStore_Addressvalidator_Block_Checkout_Onepage_Billing extends Mage_Checkout_Block_Onepage_Billing
12
  {
13
  /**
14
  * Insert script tag before billing step, to add nextStep overrides to Billing and Shipping objects
18
  */
19
  protected function _afterToHtml($html)
20
  {
21
+ $html = '<script type="text/javascript" src="'. $this->getSkinUrl('js/extensions_store/addressvalidator/address.js').'"></script>'.$html;
22
 
23
  return $html;
24
  }
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Helper/Data.php RENAMED
@@ -3,11 +3,11 @@
3
  /**
4
  * Address Validator helper
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
- class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
11
 
12
  const MIN_ATTEMPTS = 1;
13
  const DEFAULT_ATTEMPTS = 3;
@@ -23,7 +23,7 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
23
  * Popup messaging nodes
24
  */
25
  public function __construct() {
26
- $messagingNodes = Mage::getConfig()->getNode('default/aydus_addressvalidator/messaging');
27
  $this->_messaging = json_decode(json_encode((array) $messagingNodes), true);
28
  }
29
 
@@ -46,7 +46,7 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
46
  * @return boolean
47
  */
48
  public function tooManyAttempts() {
49
- $numAttempts = (int) Mage::getStoreConfig('aydus_addressvalidator/configuration/num_attempts');
50
  $numAttempts = ($numAttempts >= self::MIN_ATTEMPTS && $numAttempts <= self::MAX_ATTEMPTS) ? $numAttempts : self::DEFAULT_ATTEMPTS;
51
  $numAttempts = ($this->isDebug()) ? 200 : $numAttempts;
52
 
@@ -65,7 +65,7 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
65
  public function getMessaging($messageKey) {
66
  if (in_array($messageKey, array_keys($this->_messaging))) {
67
 
68
- $message = Mage::getStoreConfig("aydus_addressvalidator/messaging/$messageKey");
69
  return $message;
70
  }
71
 
@@ -81,7 +81,7 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
81
  public function validateStore($store) {
82
  $storeId = $store->getId();
83
 
84
- $validateStore = Mage::getStoreConfig('aydus_addressvalidator/configuration/enabled', $storeId);
85
 
86
  return $validateStore;
87
  }
@@ -91,17 +91,24 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
91
  *
92
  * @param int $storeId
93
  * @param bool $international
94
- * @return Aydus_Addressvalidator_Model_Service_Abstract
95
  */
96
- public function getService($storeId, $international=false) {
97
 
98
- $service = ($international) ? 'service_international' : 'service';
99
- $configService = Mage::getStoreConfig('aydus_addressvalidator/configuration/'.$service, $storeId);
 
100
  $configService = ($configService) ? $configService : 'usps';
101
- $alias = 'aydus_addressvalidator/service_' . $configService;
102
- $serviceModel = Mage::getModel($alias);
 
 
 
 
 
 
103
 
104
- return $serviceModel;
105
  }
106
 
107
  /**
@@ -152,12 +159,15 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
152
  * Create object from XML
153
  *
154
  * @param string $xmlString
 
155
  * @return stdClass
156
  */
157
- public function xmlToObject($xmlString) {
158
- //replace namespaces
159
- $xmlString = preg_replace('/xmlns[^=]*="[^"]*"\s*/i', '', $xmlString);
160
- $xmlString = preg_replace("/(<\/?)([^:]+):([^>]*>)/", "$1$3", $xmlString);
 
 
161
 
162
  $xml = simplexml_load_string($xmlString);
163
  $xmlJsonStr = json_encode($xml);
@@ -175,7 +185,7 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
175
  $storeId = Mage::app()->getStore()->getId();
176
 
177
  $international = ($address->getCountryId() && Mage::getStoreConfig('general/country/default') != $address->getCountryId()) ? true : false;
178
- $service = $this->getService($storeId, $international);
179
 
180
  $return = array('error' => true);
181
 
@@ -183,7 +193,7 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
183
  $return = $service->getResults($address);
184
  } catch (Exception $e) {
185
  $return['data'] = $e->getMessage();
186
- Mage::log($e->getMessage(), null, 'aydus_addressvalidator.log');
187
  }
188
 
189
  return $return;
@@ -216,9 +226,9 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
216
 
217
  if ($regionId && $regionId != @$data['region_id']){
218
 
219
- Mage::log('Posted region is not the same as validated region.', null, 'aydus_addressvalidator.log');
220
- Mage::log($postData,null,'aydus_addressvalidator.log');
221
- Mage::log($data,null,'aydus_addressvalidator.log');
222
  return false;
223
  }
224
 
@@ -244,7 +254,7 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
244
 
245
  $datetime = date('Y-m-d H:i:s');
246
 
247
- $validatedAddress = Mage::getModel('aydus_addressvalidator/address');
248
  $validatedAddress->load($customerAddress->getId(), 'address_id');
249
  $validatedAddress->setAddressId($customerAddress->getId());
250
  $validatedAddress->setAddressType($customerAddress->getAddressType());
@@ -282,7 +292,7 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
282
 
283
  $datetime = date('Y-m-d H:i:s');
284
 
285
- $validatedShippingAddress = Mage::getModel('aydus_addressvalidator/address');
286
  $validatedShippingAddress->load($customerShippingAddress->getId(), 'address_id');
287
  $validatedShippingAddress->setAddressId($customerShippingAddress->getId());
288
  $validatedShippingAddress->setAddressType($customerShippingAddress->getAddressType());
@@ -301,7 +311,7 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
301
  }
302
 
303
  } catch(Exception $e){
304
- Mage::log($e->getMessage(),null, 'aydus_addressvalidator.log');
305
  return false;
306
  }
307
 
3
  /**
4
  * Address Validator helper
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
+ class ExtensionsStore_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
11
 
12
  const MIN_ATTEMPTS = 1;
13
  const DEFAULT_ATTEMPTS = 3;
23
  * Popup messaging nodes
24
  */
25
  public function __construct() {
26
+ $messagingNodes = Mage::getConfig()->getNode('default/extensions_store_addressvalidator/messaging');
27
  $this->_messaging = json_decode(json_encode((array) $messagingNodes), true);
28
  }
29
 
46
  * @return boolean
47
  */
48
  public function tooManyAttempts() {
49
+ $numAttempts = (int) Mage::getStoreConfig('extensions_store_addressvalidator/configuration/num_attempts');
50
  $numAttempts = ($numAttempts >= self::MIN_ATTEMPTS && $numAttempts <= self::MAX_ATTEMPTS) ? $numAttempts : self::DEFAULT_ATTEMPTS;
51
  $numAttempts = ($this->isDebug()) ? 200 : $numAttempts;
52
 
65
  public function getMessaging($messageKey) {
66
  if (in_array($messageKey, array_keys($this->_messaging))) {
67
 
68
+ $message = Mage::getStoreConfig("extensions_store_addressvalidator/messaging/$messageKey");
69
  return $message;
70
  }
71
 
81
  public function validateStore($store) {
82
  $storeId = $store->getId();
83
 
84
+ $validateStore = Mage::getStoreConfig('extensions_store_addressvalidator/configuration/enabled', $storeId);
85
 
86
  return $validateStore;
87
  }
91
  *
92
  * @param int $storeId
93
  * @param bool $international
94
+ * @return array
95
  */
96
+ public function getServices($storeId, $international=false) {
97
 
98
+ $services = array();
99
+ $service = ($international) ? 'service_international' : 'service';
100
+ $configService = Mage::getStoreConfig('extensions_store_addressvalidator/configuration/'.$service, $storeId);
101
  $configService = ($configService) ? $configService : 'usps';
102
+ $alias = 'extensions_store_addressvalidator/service_' . $configService;
103
+ $services['service'] = Mage::getModel($alias);
104
+
105
+ if (Mage::getStoreConfig('extensions_store_addressvalidator/configuration/service2', $storeId)){
106
+ $configService2 = Mage::getStoreConfig('extensions_store_addressvalidator/configuration/service2', $storeId);
107
+ $alias = 'extensions_store_addressvalidator/service_' . $configService2;
108
+ $services['service2'] = Mage::getModel($alias);
109
+ }
110
 
111
+ return $services;
112
  }
113
 
114
  /**
159
  * Create object from XML
160
  *
161
  * @param string $xmlString
162
+ * @param bool $replaceNamespaces
163
  * @return stdClass
164
  */
165
+ public function xmlToObject($xmlString, $replaceNamespaces=true) {
166
+ if ($replaceNamespaces){
167
+ //replace namespaces
168
+ $xmlString = preg_replace('/xmlns[^=]*="[^"]*"\s*/i', '', $xmlString);
169
+ $xmlString = preg_replace("/(<\/?)([^:]+):([^>]*>)/", "$1$3", $xmlString);
170
+ }
171
 
172
  $xml = simplexml_load_string($xmlString);
173
  $xmlJsonStr = json_encode($xml);
185
  $storeId = Mage::app()->getStore()->getId();
186
 
187
  $international = ($address->getCountryId() && Mage::getStoreConfig('general/country/default') != $address->getCountryId()) ? true : false;
188
+ $service = $this->getServices($storeId, $international);
189
 
190
  $return = array('error' => true);
191
 
193
  $return = $service->getResults($address);
194
  } catch (Exception $e) {
195
  $return['data'] = $e->getMessage();
196
+ Mage::log($e->getMessage(), null, 'extensions_store_addressvalidator.log');
197
  }
198
 
199
  return $return;
226
 
227
  if ($regionId && $regionId != @$data['region_id']){
228
 
229
+ Mage::log('Posted region is not the same as validated region.', null, 'extensions_store_addressvalidator.log');
230
+ Mage::log($postData,null,'extensions_store_addressvalidator.log');
231
+ Mage::log($data,null,'extensions_store_addressvalidator.log');
232
  return false;
233
  }
234
 
254
 
255
  $datetime = date('Y-m-d H:i:s');
256
 
257
+ $validatedAddress = Mage::getModel('extensions_store_addressvalidator/address');
258
  $validatedAddress->load($customerAddress->getId(), 'address_id');
259
  $validatedAddress->setAddressId($customerAddress->getId());
260
  $validatedAddress->setAddressType($customerAddress->getAddressType());
292
 
293
  $datetime = date('Y-m-d H:i:s');
294
 
295
+ $validatedShippingAddress = Mage::getModel('extensions_store_addressvalidator/address');
296
  $validatedShippingAddress->load($customerShippingAddress->getId(), 'address_id');
297
  $validatedShippingAddress->setAddressId($customerShippingAddress->getId());
298
  $validatedShippingAddress->setAddressType($customerShippingAddress->getAddressType());
311
  }
312
 
313
  } catch(Exception $e){
314
+ Mage::log($e->getMessage(),null, 'extensions_store_addressvalidator.log');
315
  return false;
316
  }
317
 
app/code/community/ExtensionsStore/Addressvalidator/Model/Address.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Address model
5
+ *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
+ */
10
+
11
+ class ExtensionsStore_Addressvalidator_Model_Address extends Mage_Core_Model_Abstract
12
+ {
13
+ /**
14
+ * Initialize resource model
15
+ */
16
+ protected function _construct()
17
+ {
18
+ parent::_construct();
19
+
20
+ $this->_init('extensions_store_addressvalidator/address');
21
+ }
22
+
23
+ }
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Adminhtml/System/Config/Source/Addressdoctor/Validcodes.php RENAMED
@@ -3,11 +3,11 @@
3
  /**
4
  * Valid codes for Address Doctor
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
- class Aydus_Addressvalidator_Model_Adminhtml_System_Config_Source_Addressdoctor_Validcodes {
11
 
12
  public function toOptionArray() {
13
  $options = array();
3
  /**
4
  * Valid codes for Address Doctor
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
+ class ExtensionsStore_Addressvalidator_Model_Adminhtml_System_Config_Source_Addressdoctor_Validcodes {
11
 
12
  public function toOptionArray() {
13
  $options = array();
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Adminhtml/System/Config/Source/Service.php RENAMED
@@ -3,11 +3,11 @@
3
  /**
4
  * Service sources
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
- class Aydus_Addressvalidator_Model_Adminhtml_System_Config_Source_Service {
11
 
12
  public function toOptionArray() {
13
  $options = array();
3
  /**
4
  * Service sources
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
+ class ExtensionsStore_Addressvalidator_Model_Adminhtml_System_Config_Source_Service {
11
 
12
  public function toOptionArray() {
13
  $options = array();
app/code/community/ExtensionsStore/Addressvalidator/Model/Observer.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * Address Validator observer
6
+ *
7
+ * @category ExtensionsStore
8
+ * @package ExtensionsStore_Addressvalidator
9
+ * @author Extensions Store <admin@extensions-store.com>
10
+ */
11
+ class ExtensionsStore_Addressvalidator_Model_Observer extends Mage_Core_Model_Abstract {
12
+
13
+ /**
14
+ * Validate address using configured service, rewrite response if suggestions available
15
+ *
16
+ * @param Varien_Event_Observer $observer
17
+ * @return Varien_Event_Observer $observer
18
+ */
19
+ public function validateAddress($observer) {
20
+
21
+ $helper = Mage::helper('addressvalidator');
22
+ $request = Mage::app()->getRequest();
23
+ $event = $observer->getEvent();
24
+ $controller = $event->getControllerAction();
25
+ $response = $controller->getResponse();
26
+ $store = Mage::app()->getStore();
27
+ $storeId = $store->getId();
28
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
29
+ $formId = $request->getParam('form_id');
30
+ $oneStepCheckout = ($formId == 'billing_address' || $formId == 'shipping_address') ? true : false;
31
+
32
+ if (strtolower($event->getName()) == 'controller_action_postdispatch_checkout_onepage_savebilling' ||
33
+ ($event->getName() == 'controller_action_postdispatch_onestepcheckout_ajax_save_billing') &&
34
+ $formId == 'billing_address') {
35
+
36
+ $address = $quote->getBillingAddress();
37
+ } else {
38
+
39
+ $address = $quote->getShippingAddress();
40
+ }
41
+
42
+ //save validated address
43
+ if ($address->getAddressType()=='billing'){
44
+ $postData = $request->getParam('billing');
45
+ } else {
46
+ $postData = $request->getParam('shipping');
47
+ }
48
+ $addressValidated = @$postData['address_validated'];
49
+ if ($addressValidated) {
50
+ $postData['customer_address_id'] = $addressValidated;
51
+ $helper->setAddressData($address, $postData, true);
52
+ return $observer;
53
+ }
54
+
55
+ //customer elected to skip validation
56
+ $skipValidation = (int)$request->getParam('skip_validation');
57
+ if ($skipValidation){
58
+ return $observer;
59
+ }
60
+
61
+ //skip validation if customer address has already been validated
62
+ $addressId = $request->getParam('billing_address_id');
63
+ if (!$addressId){
64
+ $addressId = $request->getParam('shipping_address_id');
65
+ }
66
+ $validatedAddress = Mage::getModel('extensions_store_addressvalidator/address');
67
+ $validatedAddress->load($addressId, 'address_id');
68
+
69
+ if ($validatedAddress->getId() && $validatedAddress->getValidated()){
70
+ return $observer;
71
+ }
72
+
73
+ if ($helper->tooManyAttempts()) {
74
+
75
+ $allowBypass = (int)Mage::getStoreConfig('extensions_store_addressvalidator/configuration/allow_bypass', $storeId);
76
+
77
+ if ($allowBypass){
78
+ $result = array();
79
+ $result['validate'] = true;
80
+ $result['error'] = true;
81
+ $tooManyAttemptsUrl = Mage::getStoreConfig('extensions_store_addressvalidator/configuration/too_many_attempts_url',$storeId);
82
+ $result['data'] = Mage::getUrl($tooManyAttemptsUrl);
83
+ $result['message'] = $helper->getMessaging('too_many_attempts');
84
+
85
+ $body = $response->getBody();
86
+ $responseBody = json_decode($body, true);
87
+ $responseBody = (is_array($responseBody)) ? $responseBody : array();
88
+ unset($responseBody['goto_section']);
89
+ $responseBody['address_validator'] = $result;
90
+
91
+ $response->setBody(Mage::helper('core')->jsonEncode($responseBody));
92
+ }
93
+
94
+ return $observer;
95
+ }
96
+
97
+ $validateStore = $helper->validateStore($store);
98
+
99
+ if ($validateStore) {
100
+
101
+ $international = ($address->getCountryId() && Mage::getStoreConfig('general/country/default') != $address->getCountryId()) ? true : false;
102
+ $services = $helper->getServices($storeId, $international);
103
+ $returns = array();
104
+
105
+ try {
106
+ foreach ($services as $key=>$service){
107
+ $returns[$key] = $service->getResults($address);
108
+ }
109
+ } catch (Exception $e) {
110
+ Mage::log($e->getMessage(), null, 'extensions_store_addressvalidator.log');
111
+ }
112
+
113
+ if (count($returns)>0){
114
+
115
+ $returned = $returns['service'];
116
+ $returned2 = (isset($returns['service2'])) ? $returns['service2'] : array('error' => true);
117
+
118
+ $result = array();
119
+ if (!$formId){
120
+ $formId = 'co-'.$address->getAddressType().'-form';
121
+ }
122
+ $result['form_id'] = $formId;
123
+ $result['validate'] = true;
124
+ $result['error'] = $returned['error'];
125
+ $responseCode = ($helper->isDebug() && isset($returned['response_code']) && $returned['response_code']) ? ' (' . $returned['response_code'] . ')' : '';
126
+
127
+ if (is_array($returned['data']) && count($returned['data']) > 0) {
128
+
129
+ if ($returned2['error'] === false && is_array($returned2['data']) && count($returned2['data']) > 0 && $returned['data'] != $returned2['data']){
130
+ $returned['data'] = array_merge($returned['data'], $returned2['data']);
131
+ }
132
+
133
+ $result['data'] = json_encode($returned['data']);
134
+ $result['message'] = $helper->getMessaging('matches_available') . $responseCode;
135
+
136
+ $autoPopulate = (int)Mage::getStoreConfig('extensions_store_addressvalidator/configuration/auto_populate', $storeId);
137
+
138
+ if ($autoPopulate){
139
+ $helper->setAddressData($address, $returned['data'][0], true);
140
+ $result['validate'] = false;
141
+ }
142
+
143
+ } else {
144
+
145
+ $result['error'] = true;
146
+ $result['data'] = $returned['data'];
147
+ $result['message'] = (($returned['data']) ? $returned['data'] : $helper->getMessaging('invalid_address')) . $responseCode;
148
+ }
149
+
150
+ $body = $response->getBody();
151
+ $responseBody = json_decode($body, true);
152
+ $responseBody = (is_array($responseBody)) ? $responseBody : array();
153
+ unset($responseBody['goto_section']);
154
+ $responseBody['address_validator'] = $result;
155
+
156
+ $response->setBody(Mage::helper('core')->jsonEncode($responseBody));
157
+
158
+ $observer->setResult($result);
159
+
160
+ }
161
+
162
+ }
163
+
164
+ return $observer;
165
+ }
166
+
167
+ /**
168
+ * Unflag customer address previously validated
169
+ *
170
+ * @see customer_address_save_after
171
+ * @param Varien_Event_Observer $observer
172
+ * @return Varien_Event_Observer $observer
173
+ */
174
+ public function updateAddressValidated($observer)
175
+ {
176
+ $customerAddress = $observer->getCustomerAddress();
177
+ $request = Mage::app()->getRequest();
178
+ $moduleName = $request->getModuleName();
179
+
180
+ if ($customerAddress->getId() && $moduleName != 'checkout'){
181
+
182
+ $validatedAddress = Mage::getModel('extensions_store_addressvalidator/address');
183
+ $validatedAddress->load($customerAddress->getId(), 'address_id');
184
+
185
+ $datetime = date('Y-m-d H:i:s');
186
+ $validatedAddress->setAddressId($customerAddress->getId());
187
+ $validatedAddress->setValidated(0);
188
+
189
+ if (!$validatedAddress->getId()){
190
+ $validatedAddress->setDateCreated($datetime);
191
+ }
192
+ $validatedAddress->setDateUpdated($datetime);
193
+
194
+ try {
195
+
196
+ $validatedAddress->save();
197
+
198
+ }catch (Exception $e){
199
+
200
+ Mage::log($e->getMessage(),null,'extensions_store_addressvalidator.log');
201
+ }
202
+
203
+ }
204
+
205
+ return $observer;
206
+ }
207
+
208
+ }
app/code/community/ExtensionsStore/Addressvalidator/Model/Resource/Address.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Address resource model
5
+ *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
+ */
10
+
11
+
12
+ class ExtensionsStore_Addressvalidator_Model_Resource_Address extends Mage_Core_Model_Resource_Db_Abstract
13
+ {
14
+
15
+ protected function _construct()
16
+ {
17
+ $this->_init('extensions_store_addressvalidator/address', 'id');
18
+ }
19
+
20
+ }
21
+
app/code/community/ExtensionsStore/Addressvalidator/Model/Resource/Address/Collection.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Address resource collection
5
+ *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
+ */
10
+
11
+
12
+ class ExtensionsStore_Addressvalidator_Model_Resource_Address_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
13
+ {
14
+
15
+ protected function _construct()
16
+ {
17
+ parent::_construct();
18
+ $this->_init('extensions_store_addressvalidator/address');
19
+ }
20
+
21
+ }
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Service/Abstract.php RENAMED
@@ -3,11 +3,11 @@
3
  /**
4
  * Abstract Service
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
- abstract class Aydus_Addressvalidator_Model_Service_Abstract extends Mage_Core_Model_Abstract {
11
 
12
  /**
13
  * Database
@@ -55,7 +55,7 @@ abstract class Aydus_Addressvalidator_Model_Service_Abstract extends Mage_Core_M
55
  protected $_country;
56
 
57
  public function _construct() {
58
- $this->_numResults = Mage::getStoreConfig('aydus_addressvalidator/configuration/num_results', 0);
59
  $resource = Mage::getSingleton('core/resource');
60
  $this->_read = $resource->getConnection('core_read');
61
  $this->_write = $resource->getConnection('core_write');
@@ -70,7 +70,7 @@ abstract class Aydus_Addressvalidator_Model_Service_Abstract extends Mage_Core_M
70
  $return = array();
71
  $return['error'] = true;
72
  $prefix = Mage::getConfig()->getTablePrefix();
73
- $table = $prefix . 'aydus_addressvalidator_responses';
74
 
75
  //get soap request message for customer address
76
  $message = $this->_getMessage($customerAddress);
@@ -85,14 +85,15 @@ abstract class Aydus_Addressvalidator_Model_Service_Abstract extends Mage_Core_M
85
  //process response, extracting results
86
  $processedResponse = $this->_processResponse($response);
87
 
88
- if (!$processedResponse['error']) {
89
 
90
  $return['error'] = false;
91
 
92
  if (isset($processedResponse['response_code']) && $processedResponse['response_code']) {
93
  $responseCode = $processedResponse['response_code'];
94
  $return['response_code'] = $responseCode;
95
- $this->_write->query("UPDATE $table SET response_code = '$responseCode' WHERE hash = '{$this->_hash}'");
 
96
  }
97
 
98
  $resultsData = $processedResponse['data']; //empty if invalid address
@@ -110,9 +111,13 @@ abstract class Aydus_Addressvalidator_Model_Service_Abstract extends Mage_Core_M
110
 
111
  $return['data'] = self::NO_RESULTS;
112
  }
113
- } else {
114
 
115
- $return['data'] = self::INVALID_ADDRESS;
 
 
 
 
116
  }
117
  } else {
118
 
@@ -158,15 +163,13 @@ abstract class Aydus_Addressvalidator_Model_Service_Abstract extends Mage_Core_M
158
  $hash = md5($message);
159
  $this->_hash = $hash;
160
  $prefix = Mage::getConfig()->getTablePrefix();
161
- $table = $prefix . 'aydus_addressvalidator_responses';
162
 
163
  $response = $this->_read->fetchOne("SELECT UNCOMPRESS(response) FROM $table WHERE hash = '$hash'");
164
 
165
  if (!$response) {
166
 
167
  $ch = curl_init();
168
- //log curl errors
169
- $f = fopen('var/log/aydus_addressvalidator.log', 'w');
170
 
171
  curl_setopt($ch, CURLOPT_URL, $this->_url);
172
  $headers = array(
@@ -185,7 +188,6 @@ abstract class Aydus_Addressvalidator_Model_Service_Abstract extends Mage_Core_M
185
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
186
 
187
  $response = curl_exec($ch);
188
- fclose($f);
189
  curl_close($ch);
190
 
191
  if ($response) {
@@ -206,14 +208,27 @@ abstract class Aydus_Addressvalidator_Model_Service_Abstract extends Mage_Core_M
206
  "country_id" => $country_id,
207
  "telephone" => $telephone,
208
  );
209
-
210
  $service = $this->_service;
211
  $addressFields = implode(',', array_keys($address));
212
- $addressValues = implode("','", $address);
 
 
 
 
 
 
 
213
  $dateCreated = date('Y-m-d H:i:s');
214
  $storeId = Mage::app()->getStore()->getId();
215
- $this->_write->query("REPLACE INTO $table (hash, response, service, $addressFields, store_id, date_created) VALUES('$hash', COMPRESS('$response'), '$service', '$addressValues', '$storeId', '$dateCreated')");
216
- }
 
 
 
 
 
 
 
217
  }
218
 
219
  return $response;
3
  /**
4
  * Abstract Service
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
+ abstract class ExtensionsStore_Addressvalidator_Model_Service_Abstract extends Mage_Core_Model_Abstract {
11
 
12
  /**
13
  * Database
55
  protected $_country;
56
 
57
  public function _construct() {
58
+ $this->_numResults = Mage::getStoreConfig('extensions_store_addressvalidator/configuration/num_results', 0);
59
  $resource = Mage::getSingleton('core/resource');
60
  $this->_read = $resource->getConnection('core_read');
61
  $this->_write = $resource->getConnection('core_write');
70
  $return = array();
71
  $return['error'] = true;
72
  $prefix = Mage::getConfig()->getTablePrefix();
73
+ $table = $prefix . 'extensions_store_addressvalidator_responses';
74
 
75
  //get soap request message for customer address
76
  $message = $this->_getMessage($customerAddress);
85
  //process response, extracting results
86
  $processedResponse = $this->_processResponse($response);
87
 
88
+ if (!$processedResponse['error']) { //means internal error
89
 
90
  $return['error'] = false;
91
 
92
  if (isset($processedResponse['response_code']) && $processedResponse['response_code']) {
93
  $responseCode = $processedResponse['response_code'];
94
  $return['response_code'] = $responseCode;
95
+ $values = array( 'responsecode' => $responseCode, 'hash' => $this->_hash );
96
+ $this->_write->query("UPDATE $table SET response_code = :responsecode WHERE hash = :hash", $values);
97
  }
98
 
99
  $resultsData = $processedResponse['data']; //empty if invalid address
111
 
112
  $return['data'] = self::NO_RESULTS;
113
  }
114
+ } else if (is_string($resultsData)) {
115
 
116
+ $return['data'] = $resultsData;
117
+
118
+ } else {
119
+
120
+ $return['data'] = self::INVALID_ADDRESS;
121
  }
122
  } else {
123
 
163
  $hash = md5($message);
164
  $this->_hash = $hash;
165
  $prefix = Mage::getConfig()->getTablePrefix();
166
+ $table = $prefix . 'extensions_store_addressvalidator_responses';
167
 
168
  $response = $this->_read->fetchOne("SELECT UNCOMPRESS(response) FROM $table WHERE hash = '$hash'");
169
 
170
  if (!$response) {
171
 
172
  $ch = curl_init();
 
 
173
 
174
  curl_setopt($ch, CURLOPT_URL, $this->_url);
175
  $headers = array(
188
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
189
 
190
  $response = curl_exec($ch);
 
191
  curl_close($ch);
192
 
193
  if ($response) {
208
  "country_id" => $country_id,
209
  "telephone" => $telephone,
210
  );
 
211
  $service = $this->_service;
212
  $addressFields = implode(',', array_keys($address));
213
+ //$addressValues = implode("','", $address);
214
+ $addressValues = array();
215
+ foreach( $address as $key => &$value ) {
216
+ $addressValues[] = ':' . $key;
217
+ if( $value === null )
218
+ $value = '';
219
+ }
220
+ $addressValues = implode(",", $addressValues);
221
  $dateCreated = date('Y-m-d H:i:s');
222
  $storeId = Mage::app()->getStore()->getId();
223
+
224
+ $values = array( 'hash' => $hash, 'response' => $response, 'service' => $service, 'storeId' => $storeId, 'dateCreated' => $dateCreated );
225
+ $values = array_merge( $values, $address );
226
+
227
+ $this->_write->query("REPLACE INTO $table (hash, response, service, $addressFields, store_id, date_created) VALUES(:hash, COMPRESS(:response), :service, $addressValues, :storeId, :dateCreated)", $values );
228
+ } else {
229
+ $errorMessage = curl_error($ch);
230
+ Mage::log($errorMessage, Zend_log::ERR, 'extensions_store_addressvalidator.log');
231
+ }
232
  }
233
 
234
  return $response;
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Service/Addressdoctor.php RENAMED
@@ -3,11 +3,11 @@
3
  /**
4
  * Address Doctor service
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
- class Aydus_Addressvalidator_Model_Service_Addressdoctor extends Aydus_Addressvalidator_Model_Service_Abstract {
11
 
12
  /**
13
  * Service
@@ -34,7 +34,7 @@ class Aydus_Addressvalidator_Model_Service_Addressdoctor extends Aydus_Addressva
34
 
35
  if (!is_array($validStatuses) || count($validStatuses) == 0) {
36
 
37
- $validExceptions = Mage::getStoreConfig('aydus_addressvalidator/addressdoctor/valid_exceptions');
38
 
39
  if ($validExceptions) {
40
 
@@ -78,9 +78,9 @@ class Aydus_Addressvalidator_Model_Service_Addressdoctor extends Aydus_Addressva
78
  * @return string
79
  */
80
  protected function _getMessage($customerAddress) {
81
- $customerId = Mage::getStoreConfig('aydus_addressvalidator/addressdoctor/customer_id');
82
- $password = Mage::helper('core')->decrypt(Mage::getStoreConfig('aydus_addressvalidator/addressdoctor/password'));
83
- $testMode = (int) Mage::getStoreConfig('aydus_addressvalidator/addressdoctor/test_mode');
84
  $test = ($testMode) ? 'TEST' : '';
85
 
86
  $extractableArray = $this->_getExtractableAddressArray($customerAddress);
@@ -104,7 +104,7 @@ class Aydus_Addressvalidator_Model_Service_Addressdoctor extends Aydus_Addressva
104
  <!--Optional:-->
105
  <v1:JobToken></v1:JobToken>
106
  <!--Optional:-->
107
- <v1:CampaignId>Aydus Cosmetics</v1:CampaignId>
108
  <!--Optional:-->
109
  <v1:ReservedXml></v1:ReservedXml>
110
  <!--Optional:-->
@@ -272,11 +272,11 @@ class Aydus_Addressvalidator_Model_Service_Addressdoctor extends Aydus_Addressva
272
  }
273
  } else {
274
  //internal error
275
- Mage::log($message, null, 'aydus_addressvalidator.log');
276
  }
277
  } else {
278
 
279
- Mage::log($statusCode . '-' . $statusMessage, null, 'aydus_addressvalidator.log');
280
  }
281
 
282
  return $return;
@@ -290,7 +290,7 @@ class Aydus_Addressvalidator_Model_Service_Addressdoctor extends Aydus_Addressva
290
  */
291
  protected function _processStatus($processStatus) {
292
  $return = 0;
293
- $validCodes = Mage::getStoreConfig('aydus_addressvalidator/addressdoctor/valid_codes');
294
  if ($validCodes) {
295
 
296
  $validCodes = explode(',', $validCodes);
@@ -316,7 +316,7 @@ class Aydus_Addressvalidator_Model_Service_Addressdoctor extends Aydus_Addressva
316
  $return = 2;
317
  break;
318
  //V2 - Input data correct but some elements could not be verified because of incomplete reference data
319
- //V1 - Input data correct but the user standardization has deteriorated deliverability (wrong element user standardization for example, postcode length chosen is too short). Not set by validation
320
  case 2 : case 1 :
321
  $return = 1;
322
  break;
@@ -350,7 +350,7 @@ class Aydus_Addressvalidator_Model_Service_Addressdoctor extends Aydus_Addressva
350
 
351
  switch ($grade) {
352
 
353
- //Q3 - Suggestions are available complete address
354
  case 3 :
355
  $return = 2;
356
  break;
@@ -370,8 +370,8 @@ class Aydus_Addressvalidator_Model_Service_Addressdoctor extends Aydus_Addressva
370
 
371
  switch ($grade) {
372
 
373
- //I4 - Data could not be corrected completely, but is very likely to be deliverable single match (e.g. HNO is wrong but only 1 HNO is found in reference data)
374
- //I3 - Data could not be corrected completely, but is very likely to be deliverable multiple matches (e.g. HNO is wrong but more than 1 HNO is found in reference data)
375
  case 4 : case 3 :
376
  $return = 2;
377
  break;
@@ -455,7 +455,7 @@ class Aydus_Addressvalidator_Model_Service_Addressdoctor extends Aydus_Addressva
455
  'postcode' => $postcode,
456
  );
457
  } catch (Exception $e) {
458
- Mage::log($e->getMessage(), null, 'aydus_addressvalidator.log');
459
  }
460
  }
461
 
3
  /**
4
  * Address Doctor service
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
+ class ExtensionsStore_Addressvalidator_Model_Service_Addressdoctor extends ExtensionsStore_Addressvalidator_Model_Service_Abstract {
11
 
12
  /**
13
  * Service
34
 
35
  if (!is_array($validStatuses) || count($validStatuses) == 0) {
36
 
37
+ $validExceptions = Mage::getStoreConfig('extensions_store_addressvalidator/addressdoctor/valid_exceptions');
38
 
39
  if ($validExceptions) {
40
 
78
  * @return string
79
  */
80
  protected function _getMessage($customerAddress) {
81
+ $customerId = Mage::getStoreConfig('extensions_store_addressvalidator/addressdoctor/customer_id');
82
+ $password = Mage::helper('core')->decrypt(Mage::getStoreConfig('extensions_store_addressvalidator/addressdoctor/password'));
83
+ $testMode = (int) Mage::getStoreConfig('extensions_store_addressvalidator/addressdoctor/test_mode');
84
  $test = ($testMode) ? 'TEST' : '';
85
 
86
  $extractableArray = $this->_getExtractableAddressArray($customerAddress);
104
  <!--Optional:-->
105
  <v1:JobToken></v1:JobToken>
106
  <!--Optional:-->
107
+ <v1:CampaignId>ExtensionsStore Cosmetics</v1:CampaignId>
108
  <!--Optional:-->
109
  <v1:ReservedXml></v1:ReservedXml>
110
  <!--Optional:-->
272
  }
273
  } else {
274
  //internal error
275
+ Mage::log($message, null, 'extensions_store_addressvalidator.log');
276
  }
277
  } else {
278
 
279
+ Mage::log($statusCode . '-' . $statusMessage, null, 'extensions_store_addressvalidator.log');
280
  }
281
 
282
  return $return;
290
  */
291
  protected function _processStatus($processStatus) {
292
  $return = 0;
293
+ $validCodes = Mage::getStoreConfig('extensions_store_addressvalidator/addressdoctor/valid_codes');
294
  if ($validCodes) {
295
 
296
  $validCodes = explode(',', $validCodes);
316
  $return = 2;
317
  break;
318
  //V2 - Input data correct but some elements could not be verified because of incomplete reference data
319
+ //V1 - Input data correct but the user standardization has deteriorated deliverability (wrong element user standardization ��� for example, postcode length chosen is too short). Not set by validation
320
  case 2 : case 1 :
321
  $return = 1;
322
  break;
350
 
351
  switch ($grade) {
352
 
353
+ //Q3 - Suggestions are available ��� complete address
354
  case 3 :
355
  $return = 2;
356
  break;
370
 
371
  switch ($grade) {
372
 
373
+ //I4 - Data could not be corrected completely, but is very likely to be deliverable ��� single match (e.g. HNO is wrong but only 1 HNO is found in reference data)
374
+ //I3 - Data could not be corrected completely, but is very likely to be deliverable ��� multiple matches (e.g. HNO is wrong but more than 1 HNO is found in reference data)
375
  case 4 : case 3 :
376
  $return = 2;
377
  break;
455
  'postcode' => $postcode,
456
  );
457
  } catch (Exception $e) {
458
+ Mage::log($e->getMessage(), null, 'extensions_store_addressvalidator.log');
459
  }
460
  }
461
 
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Service/Fedex.php RENAMED
@@ -3,11 +3,11 @@
3
  /**
4
  * Fedex service
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
- class Aydus_Addressvalidator_Model_Service_Fedex extends Aydus_Addressvalidator_Model_Service_Abstract {
11
 
12
  /**
13
  * Service
@@ -20,6 +20,9 @@ class Aydus_Addressvalidator_Model_Service_Fedex extends Aydus_Addressvalidator_
20
  public function _construct() {
21
  parent::_construct();
22
 
 
 
 
23
  }
24
 
25
  /**
@@ -72,12 +75,14 @@ class Aydus_Addressvalidator_Model_Service_Fedex extends Aydus_Addressvalidator_
72
  </ns1:Options>
73
  <ns1:AddressesToValidate>
74
  <ns1:AddressId>1</ns1:AddressId>
75
- <ns1:Address>
76
- <ns1:StreetLines>'.$street1.'</ns1:StreetLines>
77
- <ns1:City>'.$city.'</ns1:City>
78
- <ns1:StateOrProvinceCode>'.$state.'</ns1:StateOrProvinceCode>
79
- <ns1:PostalCode>'.$postcode.'</ns1:PostalCode>
80
- <ns1:CountryCode>'.$countryId.'</ns1:CountryCode>
 
 
81
  </ns1:Address>
82
  </ns1:AddressesToValidate>
83
  </ns1:AddressValidationRequest>
@@ -109,15 +114,41 @@ class Aydus_Addressvalidator_Model_Service_Fedex extends Aydus_Addressvalidator_
109
 
110
  if ($highestSeverity == 'SUCCESS') {
111
 
112
- $addresses = $addressValidationReply->AddressResults;
113
- $addresses = (!is_array($addresses)) ? array($addresses) : $addresses;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
  $return['error'] = false;
116
- $return['data'] = $addresses;
117
 
118
  } else {
119
 
120
- Mage::log($statusCode . '-' . $statusMessage, null, 'aydus_addressvalidator.log');
121
  }
122
 
123
  return $return;
@@ -143,15 +174,16 @@ class Aydus_Addressvalidator_Model_Service_Fedex extends Aydus_Addressvalidator_
143
 
144
  $proposedAddressDetails = @$result->ProposedAddressDetails;
145
  $score = (int)@$proposedAddressDetails->Score;
 
146
 
147
- if ($score > 50){
148
 
149
  $addressData = @$proposedAddressDetails->Address;
150
 
151
  $countryId = $addressData->CountryCode;
152
  $country = $addressData->CountryCode;
153
  $street = array($addressData->StreetLines);
154
- $city = $addressData->v2City;
155
  $regionModel = Mage::getModel('directory/region');
156
  $regionModel->loadByCode($addressData->StateOrProvinceCode, $countryId);
157
  $regionName = $regionModel->getName();
@@ -171,7 +203,7 @@ class Aydus_Addressvalidator_Model_Service_Fedex extends Aydus_Addressvalidator_
171
 
172
 
173
  } catch (Exception $e) {
174
- Mage::log($e->getMessage(), null, 'aydus_addressvalidator.log');
175
  }
176
  }
177
 
3
  /**
4
  * Fedex service
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
+ class ExtensionsStore_Addressvalidator_Model_Service_Fedex extends ExtensionsStore_Addressvalidator_Model_Service_Abstract {
11
 
12
  /**
13
  * Service
20
  public function _construct() {
21
  parent::_construct();
22
 
23
+ if (Mage::getStoreConfig('carriers/fedex/sandbox_mode', Mage::app()->getStore()->getId())){
24
+ $this->_url = 'https://wsbeta.fedex.com:443/web-services';
25
+ }
26
  }
27
 
28
  /**
75
  </ns1:Options>
76
  <ns1:AddressesToValidate>
77
  <ns1:AddressId>1</ns1:AddressId>
78
+ <ns1:CompanyName><![CDATA['.@$company.']]></ns1:CompanyName>
79
+ <ns1:Address>
80
+ <ns1:StreetLines><![CDATA['.$street1.']]></ns1:StreetLines>
81
+ <ns1:StreetLines><![CDATA['.@$street2.']]></ns1:StreetLines>
82
+ <ns1:City><![CDATA['.$city.']]></ns1:City>
83
+ <ns1:StateOrProvinceCode><![CDATA['.$state.']]></ns1:StateOrProvinceCode>
84
+ <ns1:PostalCode><![CDATA['.$postcode.']]></ns1:PostalCode>
85
+ <ns1:CountryCode><![CDATA['.$countryId.']]></ns1:CountryCode>
86
  </ns1:Address>
87
  </ns1:AddressesToValidate>
88
  </ns1:AddressValidationRequest>
114
 
115
  if ($highestSeverity == 'SUCCESS') {
116
 
117
+ $addressResults = $addressValidationReply->AddressResults;
118
+ $proposedAddressDetails = @$addressResults->ProposedAddressDetails;
119
+ $deliveryPointValidation = @$proposedAddressDetails->DeliveryPointValidation;
120
+
121
+ if ($deliveryPointValidation && $deliveryPointValidation == 'UNCONFIRMED'){
122
+
123
+ $changes = $proposedAddressDetails->Changes;
124
+ $apartmentNumberRequired = false;
125
+ $apartmentNumberNotFound = false;
126
+ if (is_array($changes) && count($changes)>0){
127
+ foreach ($changes as $change){
128
+ if ($change == 'APARTMENT_NUMBER_REQUIRED'){
129
+ $apartmentNumberRequired = true;
130
+ break;
131
+ }
132
+ if ($change == 'APARTMENT_NUMBER_NOT_FOUND'){
133
+ $apartmentNumberNotFound = true;
134
+ break;
135
+ }
136
+ }
137
+ }
138
+
139
+ $data = ($apartmentNumberRequired) ? Mage::helper('addressvalidator')->getMessaging('apartment_required') : $change;
140
+ $data = ($apartmentNumberNotFound) ? Mage::helper('addressvalidator')->getMessaging('apartment_not_found') : $data;
141
+
142
+ } else {
143
+ $data = (!is_array($addressResults)) ? array($addressResults) : $addressResults;
144
+ }
145
 
146
  $return['error'] = false;
147
+ $return['data'] = $data;
148
 
149
  } else {
150
 
151
+ Mage::log($statusCode . '-' . $statusMessage, null, 'extensions_store_addressvalidator.log');
152
  }
153
 
154
  return $return;
174
 
175
  $proposedAddressDetails = @$result->ProposedAddressDetails;
176
  $score = (int)@$proposedAddressDetails->Score;
177
+ $deliveryPointValidation = @$proposedAddressDetails->DeliveryPointValidation;
178
 
179
+ if ($score > 50 && $deliveryPointValidation == 'CONFIRMED'){
180
 
181
  $addressData = @$proposedAddressDetails->Address;
182
 
183
  $countryId = $addressData->CountryCode;
184
  $country = $addressData->CountryCode;
185
  $street = array($addressData->StreetLines);
186
+ $city = ($addressData->v2City) ? $addressData->v2City : $addressData->City;
187
  $regionModel = Mage::getModel('directory/region');
188
  $regionModel->loadByCode($addressData->StateOrProvinceCode, $countryId);
189
  $regionName = $regionModel->getName();
203
 
204
 
205
  } catch (Exception $e) {
206
+ Mage::log($e->getMessage(), null, 'extensions_store_addressvalidator.log');
207
  }
208
  }
209
 
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Service/Melissadata.php RENAMED
@@ -3,12 +3,12 @@
3
  /**
4
  * Melissa Data service
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
 
11
- class Aydus_Addressvalidator_Model_Service_Melissadata extends Aydus_Addressvalidator_Model_Service_Abstract
12
  {
13
  /**
14
  * Service
@@ -37,7 +37,7 @@ class Aydus_Addressvalidator_Model_Service_Melissadata extends Aydus_Addressvali
37
  */
38
  protected function _getMessage($customerAddress)
39
  {
40
- $customerId = Mage::getStoreConfig('aydus_addressvalidator/melissadata/customer_id');
41
 
42
  $extractableArray = $this->_getExtractableAddressArray($customerAddress);
43
  extract($extractableArray);
3
  /**
4
  * Melissa Data service
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
 
11
+ class ExtensionsStore_Addressvalidator_Model_Service_Melissadata extends ExtensionsStore_Addressvalidator_Model_Service_Abstract
12
  {
13
  /**
14
  * Service
37
  */
38
  protected function _getMessage($customerAddress)
39
  {
40
+ $customerId = Mage::getStoreConfig('extensions_store_addressvalidator/melissadata/customer_id');
41
 
42
  $extractableArray = $this->_getExtractableAddressArray($customerAddress);
43
  extract($extractableArray);
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Service/Ups.php RENAMED
@@ -3,11 +3,11 @@
3
  /**
4
  * Ups service
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
- class Aydus_Addressvalidator_Model_Service_Ups extends Aydus_Addressvalidator_Model_Service_Abstract {
11
 
12
  /**
13
  * Service
@@ -20,7 +20,7 @@ class Aydus_Addressvalidator_Model_Service_Ups extends Aydus_Addressvalidator_Mo
20
  public function _construct() {
21
  parent::_construct();
22
  $storeId = Mage::app()->getStore()->getId();
23
- $url = Mage::getStoreConfig('aydus_addressvalidator/ups/url',$storeId);
24
  if ($url){
25
  $this->_url = $url;
26
  }
@@ -35,9 +35,9 @@ class Aydus_Addressvalidator_Model_Service_Ups extends Aydus_Addressvalidator_Mo
35
  protected function _getMessage($customerAddress) {
36
 
37
  $storeId = Mage::app()->getStore()->getId();
38
- $accessLicenseNumber = Mage::helper('core')->decrypt(Mage::getStoreConfig('aydus_addressvalidator/ups/access_license_number',$storeId));
39
- $userId = Mage::helper('core')->decrypt(Mage::getStoreConfig('aydus_addressvalidator/ups/user_id',$storeId));
40
- $password = Mage::helper('core')->decrypt(Mage::getStoreConfig('aydus_addressvalidator/ups/password',$storeId));
41
 
42
  $extractableArray = $this->_getExtractableAddressArray($customerAddress);
43
  extract($extractableArray);
@@ -105,7 +105,7 @@ class Aydus_Addressvalidator_Model_Service_Ups extends Aydus_Addressvalidator_Mo
105
  $message = $error->ErrorCode.'-'.$error->ErrorDescription;
106
  }
107
 
108
- Mage::log($message, null, 'aydus_addressvalidator.log');
109
  $return['error'] = false;
110
  $return['data'] = $message;
111
  }
@@ -133,7 +133,7 @@ class Aydus_Addressvalidator_Model_Service_Ups extends Aydus_Addressvalidator_Mo
133
 
134
  $countryId = $addressData->CountryCode;
135
  $country = $addressData->CountryCode;
136
- $street = array($addressData->AddressLine);
137
  $city = $addressData->PoliticalDivision2;
138
  $regionModel = Mage::getModel('directory/region');
139
  $regionModel->loadByCode($addressData->PoliticalDivision1, $countryId);
@@ -151,7 +151,7 @@ class Aydus_Addressvalidator_Model_Service_Ups extends Aydus_Addressvalidator_Mo
151
  'postcode' => $postcode,
152
  );
153
  } catch (Exception $e) {
154
- Mage::log($e->getMessage(), null, 'aydus_addressvalidator.log');
155
  }
156
  }
157
 
3
  /**
4
  * Ups service
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
+ class ExtensionsStore_Addressvalidator_Model_Service_Ups extends ExtensionsStore_Addressvalidator_Model_Service_Abstract {
11
 
12
  /**
13
  * Service
20
  public function _construct() {
21
  parent::_construct();
22
  $storeId = Mage::app()->getStore()->getId();
23
+ $url = Mage::getStoreConfig('extensions_store_addressvalidator/ups/url',$storeId);
24
  if ($url){
25
  $this->_url = $url;
26
  }
35
  protected function _getMessage($customerAddress) {
36
 
37
  $storeId = Mage::app()->getStore()->getId();
38
+ $accessLicenseNumber = Mage::helper('core')->decrypt(Mage::getStoreConfig('extensions_store_addressvalidator/ups/access_license_number',$storeId));
39
+ $userId = Mage::helper('core')->decrypt(Mage::getStoreConfig('extensions_store_addressvalidator/ups/user_id',$storeId));
40
+ $password = Mage::helper('core')->decrypt(Mage::getStoreConfig('extensions_store_addressvalidator/ups/password',$storeId));
41
 
42
  $extractableArray = $this->_getExtractableAddressArray($customerAddress);
43
  extract($extractableArray);
105
  $message = $error->ErrorCode.'-'.$error->ErrorDescription;
106
  }
107
 
108
+ Mage::log($message, null, 'extensions_store_addressvalidator.log');
109
  $return['error'] = false;
110
  $return['data'] = $message;
111
  }
133
 
134
  $countryId = $addressData->CountryCode;
135
  $country = $addressData->CountryCode;
136
+ $street = (!is_array($addressData->AddressLine)) ? array($addressData->AddressLine) : $addressData->AddressLine;
137
  $city = $addressData->PoliticalDivision2;
138
  $regionModel = Mage::getModel('directory/region');
139
  $regionModel->loadByCode($addressData->PoliticalDivision1, $countryId);
151
  'postcode' => $postcode,
152
  );
153
  } catch (Exception $e) {
154
+ Mage::log($e->getMessage(), null, 'extensions_store_addressvalidator.log');
155
  }
156
  }
157
 
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Model/Service/Usps.php RENAMED
@@ -3,11 +3,11 @@
3
  /**
4
  * Usps service
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
- class Aydus_Addressvalidator_Model_Service_Usps extends Aydus_Addressvalidator_Model_Service_Abstract {
11
 
12
  /**
13
  * Service
@@ -52,13 +52,13 @@ class Aydus_Addressvalidator_Model_Service_Usps extends Aydus_Addressvalidator_M
52
  $xml = '<?xml version="1.0" encoding="UTF-8"?>
53
  <AddressValidateRequest USERID="'.$userId.'">
54
  <Address>
55
- <FirmName>'.$company.'</FirmName>
56
- <Address1>'.$street2.'</Address1>
57
- <Address2>'.$street1.'</Address2>
58
- <City>'.$city.'</City>
59
- <State>'.$state.'</State>
60
- <Zip5>'.$zip5.'</Zip5>
61
- <Zip4>'.$zip4.'</Zip4>
62
  </Address>
63
  </AddressValidateRequest>';
64
 
@@ -76,22 +76,36 @@ class Aydus_Addressvalidator_Model_Service_Usps extends Aydus_Addressvalidator_M
76
  */
77
  protected function _processResponse($response) {
78
  $return = array();
79
- $return['error'] = true;
80
 
81
- $responseJson = Mage::helper('addressvalidator')->xmlToObject($response);
82
 
83
  $address = @$responseJson->Address;
84
- $error = (@$address->Error) ? true : false;
85
 
86
  if (!$error) {
87
 
88
- $return['error'] = false;
89
  $return['data'] = (!is_array($address)) ? array($address) : $address;
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  } else {
92
 
93
- Mage::log($address->Error->Number . '-' . $address->Error->Description, null, 'aydus_addressvalidator.log');
94
- $return['error'] = false;
95
  $return['data'] = $address->Error->Description;
96
  }
97
 
@@ -152,7 +166,7 @@ class Aydus_Addressvalidator_Model_Service_Usps extends Aydus_Addressvalidator_M
152
  'postcode' => $postcode,
153
  );
154
  } catch (Exception $e) {
155
- Mage::log($e->getMessage(), null, 'aydus_addressvalidator.log');
156
  }
157
  }
158
 
3
  /**
4
  * Usps service
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
+ class ExtensionsStore_Addressvalidator_Model_Service_Usps extends ExtensionsStore_Addressvalidator_Model_Service_Abstract {
11
 
12
  /**
13
  * Service
52
  $xml = '<?xml version="1.0" encoding="UTF-8"?>
53
  <AddressValidateRequest USERID="'.$userId.'">
54
  <Address>
55
+ <FirmName><![CDATA['.$company.']]></FirmName>
56
+ <Address1><![CDATA['.$street2.']]></Address1>
57
+ <Address2><![CDATA['.$street1.']]></Address2>
58
+ <City><![CDATA['.$city.']]></City>
59
+ <State><![CDATA['.$state.']]></State>
60
+ <Zip5><![CDATA['.$zip5.']]></Zip5>
61
+ <Zip4><![CDATA['.$zip4.']]></Zip4>
62
  </Address>
63
  </AddressValidateRequest>';
64
 
76
  */
77
  protected function _processResponse($response) {
78
  $return = array();
79
+ $return['error'] = false;
80
 
81
+ $responseJson = Mage::helper('addressvalidator')->xmlToObject($response, false);
82
 
83
  $address = @$responseJson->Address;
84
+ $error = (@$address->Error || @$address->ReturnText) ? true : false;
85
 
86
  if (!$error) {
87
 
 
88
  $return['data'] = (!is_array($address)) ? array($address) : $address;
89
 
90
+ } else if (@$address->ReturnText){
91
+
92
+ if (preg_match('/apartment/',$address->ReturnText)){
93
+
94
+ if (isset($this->_requestData['street2']) && strlen($this->_requestData['street2'])>0){
95
+ $data = Mage::helper('addressvalidator')->getMessaging('apartment_not_found');
96
+ } else {
97
+ $data = Mage::helper('addressvalidator')->getMessaging('apartment_required');
98
+ }
99
+
100
+ $return['data'] = ($data) ? $data : $address->ReturnText;
101
+
102
+ }else {
103
+ $return['data'] = $address->ReturnText;
104
+ }
105
  } else {
106
 
107
+ $return['error'] = true;
108
+ Mage::log($address->Error->Number . '-' . $address->Error->Description, null, 'extensions_store_addressvalidator.log');
109
  $return['data'] = $address->Error->Description;
110
  }
111
 
166
  'postcode' => $postcode,
167
  );
168
  } catch (Exception $e) {
169
+ Mage::log($e->getMessage(), null, 'extensions_store_addressvalidator.log');
170
  }
171
  }
172
 
app/code/community/ExtensionsStore/Addressvalidator/Test/Controller/TestController.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Controller test
5
+ *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
+ */
10
+
11
+ class ExtensionsStore_Addressvalidator_Test_Controller_TestController extends EcomDev_PHPUnit_Test_Case_Controller
12
+ {
13
+
14
+ /**
15
+ *
16
+ * @test
17
+ * @loadFixture
18
+ */
19
+ public function testController()
20
+ {
21
+ echo "\nExtensionsStore_Addressavalidator controller test started";
22
+
23
+ echo "\nExtensionsStore_Addressavalidator controller test completed";
24
+ }
25
+
26
+ }
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Test/Controller/TestController/fixtures/testController.yaml RENAMED
File without changes
app/code/community/ExtensionsStore/Addressvalidator/Test/Helper/TestHelper.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Helper test
5
+ *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
+ */
10
+
11
+ class ExtensionsStore_Addressvalidator_Test_Helper_TestHelper extends EcomDev_PHPUnit_Test_Case_Config
12
+ {
13
+
14
+ /**
15
+ *
16
+ * @test
17
+ * @loadFixture testHelper.yaml
18
+ */
19
+ public function testHelper()
20
+ {
21
+ echo "\nExtensionsStore_Addressavalidator helper test started..";
22
+
23
+ $helper = Mage::helper('addressvalidator');
24
+
25
+ $_SERVER['HTTP_HOST'] = 'local.example.com';
26
+ $isDebug = $helper->isDebug();
27
+ $this->assertTrue($isDebug);
28
+
29
+ echo "\nExtensionsStore_Addressavalidator helper test completed";
30
+
31
+ }
32
+
33
+ }
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Test/Helper/TestHelper/fixtures/testHelper.yaml RENAMED
File without changes
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/Test/Model/TestModel.php RENAMED
@@ -3,12 +3,12 @@
3
  /**
4
  * Model test
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
 
11
- class Aydus_Addressvalidator_Test_Model_TestModel extends EcomDev_PHPUnit_Test_Case_Config
12
  {
13
  protected $_numAttempted = 0;
14
 
@@ -53,10 +53,10 @@ class Aydus_Addressvalidator_Test_Model_TestModel extends EcomDev_PHPUnit_Test_C
53
  */
54
  public function testObserver()
55
  {
56
- echo "\nAydus_Addressavalidator model test started..";
57
  $this->_mockQuote();
58
  $quote = Mage::getSingleton('checkout/session')->getQuote();
59
- $observerModel = Mage::getModel('aydus_addressvalidator/observer');
60
  $observer = new Varien_Event_Observer();
61
  $event = new Varien_Event();
62
  $controller = Mage::app()->getFrontController();
@@ -67,7 +67,7 @@ class Aydus_Addressvalidator_Test_Model_TestModel extends EcomDev_PHPUnit_Test_C
67
 
68
  //validate billing address
69
  $this->assertEventObserverDefined(
70
- 'frontend', 'controller_action_postdispatch_checkout_onepage_saveBilling', 'aydus_addressvalidator/observer', 'validateAddress'
71
  );
72
  $event->setName('controller_action_postdispatch_checkout_onepage_saveBilling');
73
 
@@ -91,7 +91,7 @@ class Aydus_Addressvalidator_Test_Model_TestModel extends EcomDev_PHPUnit_Test_C
91
 
92
  //validate shipping address
93
  $this->assertEventObserverDefined(
94
- 'frontend', 'controller_action_postdispatch_checkout_onepage_saveShipping', 'aydus_addressvalidator/observer', 'validateAddress'
95
  );
96
  $event->setName('controller_action_postdispatch_checkout_onepage_saveShipping');
97
  $shippingAddress = $quote->getShippingAddress();
@@ -121,7 +121,7 @@ class Aydus_Addressvalidator_Test_Model_TestModel extends EcomDev_PHPUnit_Test_C
121
  */
122
  public function testService()
123
  {
124
- echo "\nAydus_Addressavalidator model test completed";
125
 
126
  }
127
 
3
  /**
4
  * Model test
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
 
11
+ class ExtensionsStore_Addressvalidator_Test_Model_TestModel extends EcomDev_PHPUnit_Test_Case_Config
12
  {
13
  protected $_numAttempted = 0;
14
 
53
  */
54
  public function testObserver()
55
  {
56
+ echo "\nExtensionsStore_Addressavalidator model test started..";
57
  $this->_mockQuote();
58
  $quote = Mage::getSingleton('checkout/session')->getQuote();
59
+ $observerModel = Mage::getModel('extensions_store_addressvalidator/observer');
60
  $observer = new Varien_Event_Observer();
61
  $event = new Varien_Event();
62
  $controller = Mage::app()->getFrontController();
67
 
68
  //validate billing address
69
  $this->assertEventObserverDefined(
70
+ 'frontend', 'controller_action_postdispatch_checkout_onepage_saveBilling', 'extensions_store_addressvalidator/observer', 'validateAddress'
71
  );
72
  $event->setName('controller_action_postdispatch_checkout_onepage_saveBilling');
73
 
91
 
92
  //validate shipping address
93
  $this->assertEventObserverDefined(
94
+ 'frontend', 'controller_action_postdispatch_checkout_onepage_saveShipping', 'extensions_store_addressvalidator/observer', 'validateAddress'
95
  );
96
  $event->setName('controller_action_postdispatch_checkout_onepage_saveShipping');
97
  $shippingAddress = $quote->getShippingAddress();
121
  */
122
  public function testService()
123
  {
124
+ echo "\nExtensionsStore_Addressavalidator model test completed";
125
 
126
  }
127
 
app/code/community/ExtensionsStore/Addressvalidator/Test/Model/TestModel/fixtures/testModel.yaml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ config:
2
+ default/extensions_store_addressvalidator/configuration/enabled: 1
3
+ default/extensions_store_addressvalidator/configuration/service: ups
4
+ default/extensions_store_addressvalidator/configuration/auto_populate: 1
5
+ default/extensions_store_addressvalidator/ups/url: https://wwwcie.ups.com/ups.app/xml/XAV
6
+ default/extensions_store_addressvalidator/ups/access_license_number: 0:2:78ee717cfcf3fa8e:1xmpKTR4+3APi7EBtaxLog==
7
+ default/extensions_store_addressvalidator/ups/user_id: 0:2:eb878ede3d65c5b8:8OFKw7QgFadiN+T1XnpOcQ==
8
+ default/extensions_store_addressvalidator/ups/password: 0:2:e819a45554351821:INHMBBm9mn5ki2OuAL8HQA==
9
+ tables:
10
+ sales/quote:
11
+ - entity_id: 1
12
+ store_id: 1
13
+ is_active: 1
14
+ created_at: 2015-07-15 12:00:01
15
+ updated_at: 2015-07-15 12:00:01
16
+ customer_email: admin@extensions-store.com
17
+ - entity_id: 2
18
+ - entity_id: 3
19
+ sales/quote_address:
20
+ - address_id: 1
21
+ quote_id: 1
22
+ address_type: billing
23
+ street: 47 Anderson
24
+ city: Staten Isl
25
+ region: New York
26
+ region_id: 43
27
+ postcode: 1030
28
+ country_id: US
29
+ - address_id: 2
30
+ quote_id: 1
31
+ address_type: shipping
32
+ street: 919 Bard
33
+ city: Stat
34
+ region: New York
35
+ region_id: 43
36
+ postcode: 1030
37
+ country_id: US
38
+
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/etc/adminhtml.xml RENAMED
@@ -3,9 +3,9 @@
3
  /**
4
  * Addressvalidator acl
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
  -->
11
  <config>
@@ -17,9 +17,9 @@
17
  <children>
18
  <config>
19
  <children>
20
- <aydus_addressvalidator translate="title">
21
  <title>Address Validator Settings</title>
22
- </aydus_addressvalidator>
23
  </children>
24
  </config>
25
  </children>
3
  /**
4
  * Addressvalidator acl
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author ExtensionsStore <admin@extensions-store.com>
9
  */
10
  -->
11
  <config>
17
  <children>
18
  <config>
19
  <children>
20
+ <extensions_store_addressvalidator translate="title">
21
  <title>Address Validator Settings</title>
22
+ </extensions_store_addressvalidator>
23
  </children>
24
  </config>
25
  </children>
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/etc/config.xml RENAMED
@@ -3,21 +3,21 @@
3
  /**
4
  * Address Validator
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
  -->
11
  <config>
12
  <modules>
13
- <Aydus_Addressvalidator>
14
- <version>1.4.3</version>
15
- </Aydus_Addressvalidator>
16
  </modules>
17
  <phpunit>
18
  <suite>
19
  <modules>
20
- <Aydus_Addressvalidator />
21
  </modules>
22
  </suite>
23
  </phpunit>
@@ -26,7 +26,7 @@
26
  <controller_action_postdispatch_checkout_onepage_saveBilling>
27
           <observers>
28
              <addressvalidator_checkaddress>
29
-                 <class>aydus_addressvalidator/observer</class>
30
                  <method>validateAddress</method>
31
              </addressvalidator_checkaddress>
32
          </observers>
@@ -34,17 +34,25 @@
34
  <controller_action_postdispatch_checkout_onepage_saveShipping>
35
           <observers>
36
              <addressvalidator_checkaddress>
37
-                 <class>aydus_addressvalidator/observer</class>
38
                  <method>validateAddress</method>
39
              </addressvalidator_checkaddress>
40
          </observers>
41
  </controller_action_postdispatch_checkout_onepage_saveShipping>
 
 
 
 
 
 
 
 
42
  </events>
43
  <layout>
44
  <updates>
45
- <aydus_addressvalidator>
46
- <file>aydus/addressvalidator.xml</file>
47
- </aydus_addressvalidator>
48
  </updates>
49
  </layout>
50
  </frontend>
@@ -53,65 +61,72 @@
53
  <customer_address_save_after>
54
  <observers>
55
  <addressvalidator_update_address_validated>
56
- <class>aydus_addressvalidator/observer</class>
57
  <method>updateAddressValidated</method>
58
  </addressvalidator_update_address_validated>
59
  </observers>
60
  </customer_address_save_after>
61
  </events>
62
  <blocks>
63
- <aydus_addressvalidator>
64
- <class>Aydus_Addressvalidator_Block</class>
65
- </aydus_addressvalidator>
 
 
 
 
 
66
  </blocks>
67
  <models>
68
- <aydus_addressvalidator>
69
- <class>Aydus_Addressvalidator_Model</class>
70
- <resourceModel>aydus_addressvalidator_resource</resourceModel>
71
- </aydus_addressvalidator>
72
- <aydus_addressvalidator_resource>
73
- <class>Aydus_Addressvalidator_Model_Resource</class>
74
  <entities>
75
  <address>
76
- <table>aydus_addressvalidator_addresses</table>
77
  </address>
78
  </entities>
79
- </aydus_addressvalidator_resource>
80
  </models>
81
  <helpers>
82
- <aydus_addressvalidator>
83
- <class>Aydus_Addressvalidator_Helper</class>
84
- </aydus_addressvalidator>
85
  <addressvalidator>
86
- <class>Aydus_Addressvalidator_Helper</class>
87
  </addressvalidator>
88
  </helpers>
89
  <resources>
90
- <aydus_addressvalidator_setup>
91
  <setup>
92
- <module>Aydus_Addressvalidator</module>
93
  </setup>
94
  <connection>
95
  <use>core_setup</use>
96
  </connection>
97
- </aydus_addressvalidator_setup>
98
  </resources>
99
  </global>
100
  <default>
101
- <aydus_addressvalidator>
102
  <configuration>
103
  <service>usps</service>
104
  <num_results>5</num_results>
105
  <num_attempts>3</num_attempts>
106
- <too_many_attempts_url>contact-us</too_many_attempts_url>
107
  </configuration>
108
  <ups>
109
  <url>https://onlinetools.ups.com/ups.app/xml/XAV</url>
110
  </ups>
111
  <messaging>
112
- <too_many_attempts>We're sorry, but we are unable to verify your address after several attempts. Please contact Customer Service.</too_many_attempts>
113
- <matches_available>Address Verification: Please click a verified address below, or click Back to edit your information.</matches_available>
114
- <invalid_address>Address Verification: No match found; please click Back to edit your information.</invalid_address>
 
 
115
  </messaging>
116
  <usps>
117
  <gateway_url><![CDATA[http://production.shippingapis.com/ShippingAPI.dll]]></gateway_url>
@@ -119,6 +134,6 @@
119
  <addressdoctor>
120
  <valid_exceptions><![CDATA[a:4:{i:0;a:14:{s:12:"country_name";s:6:"Jordan";s:9:"iso3_code";s:3:"JOR";s:2:"V4";i:1;s:2:"V3";i:1;s:2:"V2";i:1;s:2:"V1";i:0;s:2:"C4";i:1;s:2:"C3";i:1;s:2:"C2";i:1;s:2:"C1";i:0;s:2:"I4";i:1;s:2:"I3";i:1;s:2:"I2";i:0;s:2:"I1";i:0;}i:1;a:14:{s:12:"country_name";s:11:"New Zealand";s:9:"iso3_code";s:3:"NZL";s:2:"V4";i:1;s:2:"V3";i:1;s:2:"V2";i:1;s:2:"V1";i:0;s:2:"C4";i:1;s:2:"C3";i:1;s:2:"C2";i:0;s:2:"C1";i:0;s:2:"I4";i:1;s:2:"I3";i:1;s:2:"I2";i:0;s:2:"I1";i:0;}i:2;a:14:{s:12:"country_name";s:12:"Saudi Arabia";s:9:"iso3_code";s:3:"SAU";s:2:"V4";i:1;s:2:"V3";i:1;s:2:"V2";i:1;s:2:"V1";i:0;s:2:"C4";i:1;s:2:"C3";i:1;s:2:"C2";i:1;s:2:"C1";i:0;s:2:"I4";i:1;s:2:"I3";i:1;s:2:"I2";i:0;s:2:"I1";i:0;}i:3;a:14:{s:12:"country_name";s:20:"United Arab Emirates";s:9:"iso3_code";s:3:"ARE";s:2:"V4";i:1;s:2:"V3";i:1;s:2:"V2";i:1;s:2:"V1";i:0;s:2:"C4";i:1;s:2:"C3";i:1;s:2:"C2";i:1;s:2:"C1";i:0;s:2:"I4";i:1;s:2:"I3";i:1;s:2:"I2";i:0;s:2:"I1";i:0;}}]]></valid_exceptions>
121
  </addressdoctor>
122
- </aydus_addressvalidator>
123
  </default>
124
  </config>
3
  /**
4
  * Address Validator
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
  -->
11
  <config>
12
  <modules>
13
+ <ExtensionsStore_Addressvalidator>
14
+ <version>1.5.2</version>
15
+ </ExtensionsStore_Addressvalidator>
16
  </modules>
17
  <phpunit>
18
  <suite>
19
  <modules>
20
+ <ExtensionsStore_Addressvalidator />
21
  </modules>
22
  </suite>
23
  </phpunit>
26
  <controller_action_postdispatch_checkout_onepage_saveBilling>
27
           <observers>
28
              <addressvalidator_checkaddress>
29
+                 <class>extensions_store_addressvalidator/observer</class>
30
                  <method>validateAddress</method>
31
              </addressvalidator_checkaddress>
32
          </observers>
34
  <controller_action_postdispatch_checkout_onepage_saveShipping>
35
           <observers>
36
              <addressvalidator_checkaddress>
37
+                 <class>extensions_store_addressvalidator/observer</class>
38
                  <method>validateAddress</method>
39
              </addressvalidator_checkaddress>
40
          </observers>
41
  </controller_action_postdispatch_checkout_onepage_saveShipping>
42
+ <controller_action_postdispatch_onestepcheckout_ajax_save_billing>
43
+          <observers>
44
+             <addressvalidator_checkaddress>
45
+                 <class>extensions_store_addressvalidator/observer</class>
46
+                 <method>validateAddress</method>
47
+             </addressvalidator_checkaddress>
48
+         </observers>
49
+ </controller_action_postdispatch_onestepcheckout_ajax_save_billing>
50
  </events>
51
  <layout>
52
  <updates>
53
+ <extensions_store_addressvalidator>
54
+ <file>extensions_store/addressvalidator.xml</file>
55
+ </extensions_store_addressvalidator>
56
  </updates>
57
  </layout>
58
  </frontend>
61
  <customer_address_save_after>
62
  <observers>
63
  <addressvalidator_update_address_validated>
64
+ <class>extensions_store_addressvalidator/observer</class>
65
  <method>updateAddressValidated</method>
66
  </addressvalidator_update_address_validated>
67
  </observers>
68
  </customer_address_save_after>
69
  </events>
70
  <blocks>
71
+ <extensions_store_addressvalidator>
72
+ <class>ExtensionsStore_Addressvalidator_Block</class>
73
+ </extensions_store_addressvalidator>
74
+ <checkout>
75
+ <rewrite>
76
+ <onepage_billing>ExtensionsStore_Addressvalidator_Block_Checkout_Onepage_Billing</onepage_billing>
77
+ </rewrite>
78
+ </checkout>
79
  </blocks>
80
  <models>
81
+ <extensions_store_addressvalidator>
82
+ <class>ExtensionsStore_Addressvalidator_Model</class>
83
+ <resourceModel>extensions_store_addressvalidator_resource</resourceModel>
84
+ </extensions_store_addressvalidator>
85
+ <extensions_store_addressvalidator_resource>
86
+ <class>ExtensionsStore_Addressvalidator_Model_Resource</class>
87
  <entities>
88
  <address>
89
+ <table>extensions_store_addressvalidator_addresses</table>
90
  </address>
91
  </entities>
92
+ </extensions_store_addressvalidator_resource>
93
  </models>
94
  <helpers>
95
+ <extensions_store_addressvalidator>
96
+ <class>ExtensionsStore_Addressvalidator_Helper</class>
97
+ </extensions_store_addressvalidator>
98
  <addressvalidator>
99
+ <class>ExtensionsStore_Addressvalidator_Helper</class>
100
  </addressvalidator>
101
  </helpers>
102
  <resources>
103
+ <extensions_store_addressvalidator_setup>
104
  <setup>
105
+ <module>ExtensionsStore_Addressvalidator</module>
106
  </setup>
107
  <connection>
108
  <use>core_setup</use>
109
  </connection>
110
+ </extensions_store_addressvalidator_setup>
111
  </resources>
112
  </global>
113
  <default>
114
+ <extensions_store_addressvalidator>
115
  <configuration>
116
  <service>usps</service>
117
  <num_results>5</num_results>
118
  <num_attempts>3</num_attempts>
119
+ <too_many_attempts_url>contacts</too_many_attempts_url>
120
  </configuration>
121
  <ups>
122
  <url>https://onlinetools.ups.com/ups.app/xml/XAV</url>
123
  </ups>
124
  <messaging>
125
+ <too_many_attempts><![CDATA[We're sorry, but we are unable to verify your address after several attempts. Please contact Customer Service.]]></too_many_attempts>
126
+ <matches_available><![CDATA[Address Verification: Please click a verified address below, or click Back to edit your information.]]></matches_available>
127
+ <invalid_address><![CDATA[Address Verification: No match found; please click Back to edit your information.]]></invalid_address>
128
+ <apartment_required><![CDATA[Apartment, room, box or suite number is required. Please enter on Address Line 2.]]></apartment_required>
129
+ <apartment_not_found><![CDATA[Please enter a valid apartment, room, box or suite number on Address Line 2.]]></apartment_not_found>
130
  </messaging>
131
  <usps>
132
  <gateway_url><![CDATA[http://production.shippingapis.com/ShippingAPI.dll]]></gateway_url>
134
  <addressdoctor>
135
  <valid_exceptions><![CDATA[a:4:{i:0;a:14:{s:12:"country_name";s:6:"Jordan";s:9:"iso3_code";s:3:"JOR";s:2:"V4";i:1;s:2:"V3";i:1;s:2:"V2";i:1;s:2:"V1";i:0;s:2:"C4";i:1;s:2:"C3";i:1;s:2:"C2";i:1;s:2:"C1";i:0;s:2:"I4";i:1;s:2:"I3";i:1;s:2:"I2";i:0;s:2:"I1";i:0;}i:1;a:14:{s:12:"country_name";s:11:"New Zealand";s:9:"iso3_code";s:3:"NZL";s:2:"V4";i:1;s:2:"V3";i:1;s:2:"V2";i:1;s:2:"V1";i:0;s:2:"C4";i:1;s:2:"C3";i:1;s:2:"C2";i:0;s:2:"C1";i:0;s:2:"I4";i:1;s:2:"I3";i:1;s:2:"I2";i:0;s:2:"I1";i:0;}i:2;a:14:{s:12:"country_name";s:12:"Saudi Arabia";s:9:"iso3_code";s:3:"SAU";s:2:"V4";i:1;s:2:"V3";i:1;s:2:"V2";i:1;s:2:"V1";i:0;s:2:"C4";i:1;s:2:"C3";i:1;s:2:"C2";i:1;s:2:"C1";i:0;s:2:"I4";i:1;s:2:"I3";i:1;s:2:"I2";i:0;s:2:"I1";i:0;}i:3;a:14:{s:12:"country_name";s:20:"United Arab Emirates";s:9:"iso3_code";s:3:"ARE";s:2:"V4";i:1;s:2:"V3";i:1;s:2:"V2";i:1;s:2:"V1";i:0;s:2:"C4";i:1;s:2:"C3";i:1;s:2:"C2";i:1;s:2:"C1";i:0;s:2:"I4";i:1;s:2:"I3";i:1;s:2:"I2";i:0;s:2:"I1";i:0;}}]]></valid_exceptions>
136
  </addressdoctor>
137
+ </extensions_store_addressvalidator>
138
  </default>
139
  </config>
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/etc/system.xml RENAMED
@@ -3,14 +3,14 @@
3
  /**
4
  * Addressvalidator system config
5
  *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
  */
10
  -->
11
  <config>
12
  <sections>
13
- <aydus_addressvalidator translate="label" module="aydus_addressvalidator">
14
  <label>Address Validator</label>
15
  <tab>sales</tab>
16
  <frontend_type>text</frontend_type>
@@ -19,7 +19,7 @@
19
  <show_in_website>1</show_in_website>
20
  <show_in_store>1</show_in_store>
21
  <groups>
22
- <configuration translate="label" module="aydus_addressvalidator">
23
  <label>Settings</label>
24
  <frontend_type>text</frontend_type>
25
  <sort_order>10</sort_order>
@@ -31,7 +31,7 @@
31
  <label>Enabled</label>
32
  <frontend_type>select</frontend_type>
33
  <source_model>adminhtml/system_config_source_yesno</source_model>
34
- <sort_order>1</sort_order>
35
  <show_in_default>1</show_in_default>
36
  <show_in_website>1</show_in_website>
37
  <show_in_store>1</show_in_store>
@@ -40,14 +40,14 @@
40
  <num_results translate="label">
41
  <label>Number of Results</label>
42
  <frontend_type>text</frontend_type>
43
- <sort_order>2</sort_order>
44
  <show_in_default>1</show_in_default>
45
  <comment><![CDATA[Select the number of results to show.]]></comment>
46
  </num_results>
47
  <num_attempts translate="label">
48
  <label>Number of Attempts Allowed</label>
49
  <frontend_type>text</frontend_type>
50
- <sort_order>3</sort_order>
51
  <show_in_default>1</show_in_default>
52
  <show_in_website>1</show_in_website>
53
  <show_in_store>1</show_in_store>
@@ -56,7 +56,7 @@
56
  <too_many_attempts_url translate="label">
57
  <label>Customer Service URL</label>
58
  <frontend_type>text</frontend_type>
59
- <sort_order>4</sort_order>
60
  <show_in_default>1</show_in_default>
61
  <comment><![CDATA[Specify url to redirect customer to after too many validation attempts; i.e. contact-us.]]></comment>
62
  </too_many_attempts_url>
@@ -64,7 +64,7 @@
64
  <label>Allow Bypass</label>
65
  <frontend_type>select</frontend_type>
66
  <source_model>adminhtml/system_config_source_yesno</source_model>
67
- <sort_order>5</sort_order>
68
  <show_in_default>1</show_in_default>
69
  <show_in_website>1</show_in_website>
70
  <show_in_store>1</show_in_store>
@@ -74,7 +74,7 @@
74
  <label>Auto Populate</label>
75
  <frontend_type>select</frontend_type>
76
  <source_model>adminhtml/system_config_source_yesno</source_model>
77
- <sort_order>6</sort_order>
78
  <show_in_default>1</show_in_default>
79
  <show_in_website>1</show_in_website>
80
  <show_in_store>1</show_in_store>
@@ -83,18 +83,28 @@
83
  <service translate="label">
84
  <label>Service</label>
85
  <frontend_type>select</frontend_type>
86
- <source_model>aydus_addressvalidator/adminhtml_system_config_source_service</source_model>
87
- <sort_order>7</sort_order>
88
  <show_in_default>1</show_in_default>
89
  <show_in_website>1</show_in_website>
90
  <show_in_store>1</show_in_store>
91
  <comment><![CDATA[Select the service provider for address validation.]]></comment>
92
  </service>
 
 
 
 
 
 
 
 
 
 
93
  <service_international translate="label">
94
  <label>International Service</label>
95
  <frontend_type>select</frontend_type>
96
- <source_model>aydus_addressvalidator/adminhtml_system_config_source_service</source_model>
97
- <sort_order>8</sort_order>
98
  <show_in_default>1</show_in_default>
99
  <show_in_website>1</show_in_website>
100
  <show_in_store>1</show_in_store>
@@ -102,7 +112,7 @@
102
  </service_international>
103
  </fields>
104
  </configuration>
105
- <messaging translate="label" module="aydus_addressvalidator">
106
  <label>Popup Messaging</label>
107
  <frontend_type>text</frontend_type>
108
  <sort_order>20</sort_order>
@@ -111,27 +121,41 @@
111
  <too_many_attempts translate="label">
112
  <label>Too Many Attempts Message</label>
113
  <frontend_type>textarea</frontend_type>
114
- <sort_order>1</sort_order>
115
  <show_in_default>1</show_in_default>
116
  <comment><![CDATA[Popup message on too many validation attempts.]]></comment>
117
  </too_many_attempts>
118
  <matches_available translate="label">
119
  <label>Matches Available</label>
120
  <frontend_type>textarea</frontend_type>
121
- <sort_order>2</sort_order>
122
  <show_in_default>1</show_in_default>
123
  <comment><![CDATA[Messaging asking user to select a match found.]]></comment>
124
  </matches_available>
125
  <invalid_address translate="label">
126
  <label>No match found, invalid address</label>
127
  <frontend_type>textarea</frontend_type>
128
- <sort_order>2</sort_order>
129
  <show_in_default>1</show_in_default>
130
  <comment><![CDATA[Message notifying user of too many validation attempts and to contact Customer Support.]]></comment>
131
- </invalid_address>
132
- </fields>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  </messaging>
134
- <ups translate="label" module="aydus_addressvalidator">
135
  <label>UPS</label>
136
  <frontend_type>text</frontend_type>
137
  <sort_order>25</sort_order>
@@ -170,7 +194,7 @@
170
  </password>
171
  </fields>
172
  </ups>
173
- <addressdoctor translate="label" module="aydus_addressvalidator">
174
  <label>Address Doctor</label>
175
  <frontend_type>text</frontend_type>
176
  <sort_order>30</sort_order>
@@ -203,14 +227,14 @@
203
  <valid_codes translate="label">
204
  <label>Valid Codes</label>
205
  <frontend_type>multiselect</frontend_type>
206
- <source_model>aydus_addressvalidator/adminhtml_system_config_source_addressdoctor_validcodes</source_model>
207
  <sort_order>4</sort_order>
208
  <show_in_default>1</show_in_default>
209
  <comment><![CDATA[Select AD Response codes that are valid]]></comment>
210
  </valid_codes>
211
  <valid_exceptions translate="label">
212
  <label>Valid Exceptions</label>
213
- <frontend_model>aydus_addressvalidator/adminhtml_system_config_form_validexceptions</frontend_model>
214
  <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
215
  <sort_order>5</sort_order>
216
  <show_in_default>1</show_in_default>
@@ -218,7 +242,7 @@
218
  </valid_exceptions>
219
  </fields>
220
  </addressdoctor>
221
- <melissadata translate="label" module="aydus_addressvalidator">
222
  <label>Melissa Data</label>
223
  <frontend_type>text</frontend_type>
224
  <sort_order>40</sort_order>
@@ -234,7 +258,7 @@
234
  </fields>
235
  </melissadata>
236
  </groups>
237
- </aydus_addressvalidator>
238
  </sections>
239
  </config>
240
 
3
  /**
4
  * Addressvalidator system config
5
  *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
  */
10
  -->
11
  <config>
12
  <sections>
13
+ <extensions_store_addressvalidator translate="label" module="extensions_store_addressvalidator">
14
  <label>Address Validator</label>
15
  <tab>sales</tab>
16
  <frontend_type>text</frontend_type>
19
  <show_in_website>1</show_in_website>
20
  <show_in_store>1</show_in_store>
21
  <groups>
22
+ <configuration translate="label" module="extensions_store_addressvalidator">
23
  <label>Settings</label>
24
  <frontend_type>text</frontend_type>
25
  <sort_order>10</sort_order>
31
  <label>Enabled</label>
32
  <frontend_type>select</frontend_type>
33
  <source_model>adminhtml/system_config_source_yesno</source_model>
34
+ <sort_order>10</sort_order>
35
  <show_in_default>1</show_in_default>
36
  <show_in_website>1</show_in_website>
37
  <show_in_store>1</show_in_store>
40
  <num_results translate="label">
41
  <label>Number of Results</label>
42
  <frontend_type>text</frontend_type>
43
+ <sort_order>20</sort_order>
44
  <show_in_default>1</show_in_default>
45
  <comment><![CDATA[Select the number of results to show.]]></comment>
46
  </num_results>
47
  <num_attempts translate="label">
48
  <label>Number of Attempts Allowed</label>
49
  <frontend_type>text</frontend_type>
50
+ <sort_order>30</sort_order>
51
  <show_in_default>1</show_in_default>
52
  <show_in_website>1</show_in_website>
53
  <show_in_store>1</show_in_store>
56
  <too_many_attempts_url translate="label">
57
  <label>Customer Service URL</label>
58
  <frontend_type>text</frontend_type>
59
+ <sort_order>40</sort_order>
60
  <show_in_default>1</show_in_default>
61
  <comment><![CDATA[Specify url to redirect customer to after too many validation attempts; i.e. contact-us.]]></comment>
62
  </too_many_attempts_url>
64
  <label>Allow Bypass</label>
65
  <frontend_type>select</frontend_type>
66
  <source_model>adminhtml/system_config_source_yesno</source_model>
67
+ <sort_order>50</sort_order>
68
  <show_in_default>1</show_in_default>
69
  <show_in_website>1</show_in_website>
70
  <show_in_store>1</show_in_store>
74
  <label>Auto Populate</label>
75
  <frontend_type>select</frontend_type>
76
  <source_model>adminhtml/system_config_source_yesno</source_model>
77
+ <sort_order>60</sort_order>
78
  <show_in_default>1</show_in_default>
79
  <show_in_website>1</show_in_website>
80
  <show_in_store>1</show_in_store>
83
  <service translate="label">
84
  <label>Service</label>
85
  <frontend_type>select</frontend_type>
86
+ <source_model>extensions_store_addressvalidator/adminhtml_system_config_source_service</source_model>
87
+ <sort_order>70</sort_order>
88
  <show_in_default>1</show_in_default>
89
  <show_in_website>1</show_in_website>
90
  <show_in_store>1</show_in_store>
91
  <comment><![CDATA[Select the service provider for address validation.]]></comment>
92
  </service>
93
+ <service2 translate="label">
94
+ <label>Secondary Service</label>
95
+ <frontend_type>select</frontend_type>
96
+ <source_model>extensions_store_addressvalidator/adminhtml_system_config_source_service</source_model>
97
+ <sort_order>80</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>1</show_in_store>
101
+ <comment><![CDATA[If selected, results from both services will be combined.]]></comment>
102
+ </service2>
103
  <service_international translate="label">
104
  <label>International Service</label>
105
  <frontend_type>select</frontend_type>
106
+ <source_model>extensions_store_addressvalidator/adminhtml_system_config_source_service</source_model>
107
+ <sort_order>100</sort_order>
108
  <show_in_default>1</show_in_default>
109
  <show_in_website>1</show_in_website>
110
  <show_in_store>1</show_in_store>
112
  </service_international>
113
  </fields>
114
  </configuration>
115
+ <messaging translate="label" module="extensions_store_addressvalidator">
116
  <label>Popup Messaging</label>
117
  <frontend_type>text</frontend_type>
118
  <sort_order>20</sort_order>
121
  <too_many_attempts translate="label">
122
  <label>Too Many Attempts Message</label>
123
  <frontend_type>textarea</frontend_type>
124
+ <sort_order>10</sort_order>
125
  <show_in_default>1</show_in_default>
126
  <comment><![CDATA[Popup message on too many validation attempts.]]></comment>
127
  </too_many_attempts>
128
  <matches_available translate="label">
129
  <label>Matches Available</label>
130
  <frontend_type>textarea</frontend_type>
131
+ <sort_order>20</sort_order>
132
  <show_in_default>1</show_in_default>
133
  <comment><![CDATA[Messaging asking user to select a match found.]]></comment>
134
  </matches_available>
135
  <invalid_address translate="label">
136
  <label>No match found, invalid address</label>
137
  <frontend_type>textarea</frontend_type>
138
+ <sort_order>30</sort_order>
139
  <show_in_default>1</show_in_default>
140
  <comment><![CDATA[Message notifying user of too many validation attempts and to contact Customer Support.]]></comment>
141
+ </invalid_address>
142
+ <apartment_required translate="label">
143
+ <label>Apartment Required Message</label>
144
+ <frontend_type>textarea</frontend_type>
145
+ <sort_order>40</sort_order>
146
+ <show_in_default>1</show_in_default>
147
+ <comment><![CDATA[Message indicating apartment number is required on Address Line 2.]]></comment>
148
+ </apartment_required>
149
+ <apartment_not_found translate="label">
150
+ <label>Apartment Required Message</label>
151
+ <frontend_type>textarea</frontend_type>
152
+ <sort_order>40</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <comment><![CDATA[Message indicating apartment number is invalid and to enter on Address Line 2.]]></comment>
155
+ </apartment_not_found>
156
+ </fields>
157
  </messaging>
158
+ <ups translate="label" module="extensions_store_addressvalidator">
159
  <label>UPS</label>
160
  <frontend_type>text</frontend_type>
161
  <sort_order>25</sort_order>
194
  </password>
195
  </fields>
196
  </ups>
197
+ <addressdoctor translate="label" module="extensions_store_addressvalidator">
198
  <label>Address Doctor</label>
199
  <frontend_type>text</frontend_type>
200
  <sort_order>30</sort_order>
227
  <valid_codes translate="label">
228
  <label>Valid Codes</label>
229
  <frontend_type>multiselect</frontend_type>
230
+ <source_model>extensions_store_addressvalidator/adminhtml_system_config_source_addressdoctor_validcodes</source_model>
231
  <sort_order>4</sort_order>
232
  <show_in_default>1</show_in_default>
233
  <comment><![CDATA[Select AD Response codes that are valid]]></comment>
234
  </valid_codes>
235
  <valid_exceptions translate="label">
236
  <label>Valid Exceptions</label>
237
+ <frontend_model>extensions_store_addressvalidator/adminhtml_system_config_form_validexceptions</frontend_model>
238
  <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
239
  <sort_order>5</sort_order>
240
  <show_in_default>1</show_in_default>
242
  </valid_exceptions>
243
  </fields>
244
  </addressdoctor>
245
+ <melissadata translate="label" module="extensions_store_addressvalidator">
246
  <label>Melissa Data</label>
247
  <frontend_type>text</frontend_type>
248
  <sort_order>40</sort_order>
258
  </fields>
259
  </melissadata>
260
  </groups>
261
+ </extensions_store_addressvalidator>
262
  </sections>
263
  </config>
264
 
app/code/community/{Aydus → ExtensionsStore}/Addressvalidator/readme.md RENAMED
@@ -2,4 +2,4 @@ Address Validator
2
  =================
3
  Validate billing and shipping addresses in the One Page Checkout.
4
 
5
- https://github.com/aydus/Addressvalidator
2
  =================
3
  Validate billing and shipping addresses in the One Page Checkout.
4
 
5
+ https://github.com/ExtensionsStore/Addressvalidator
app/code/community/{Aydus/Addressvalidator/sql/aydus_addressvalidator_setup → ExtensionsStore/Addressvalidator/sql/extensions_store_addressvalidator_setup}/install-1.0.0.php RENAMED
@@ -2,14 +2,14 @@
2
  /**
3
  * Address Validator setup
4
  *
5
- * @category Aydus
6
- * @package Aydus_Addressvalidator
7
- * @author Aydus <davidt@aydus.com>
8
  */
9
 
10
  $this->startSetup();
11
 
12
- $this->run("CREATE TABLE IF NOT EXISTS {$this->getTable('aydus_addressvalidator_responses')} (
13
  `hash` VARCHAR(32) NOT NULL,
14
  `response` BLOB NOT NULL,
15
  `response_code` VARCHAR(20) NOT NULL,
2
  /**
3
  * Address Validator setup
4
  *
5
+ * @category ExtensionsStore
6
+ * @package ExtensionsStore_Addressvalidator
7
+ * @author Extensions Store <admin@extensions-store.com>
8
  */
9
 
10
  $this->startSetup();
11
 
12
+ $this->run("CREATE TABLE IF NOT EXISTS {$this->getTable('extensions_store_addressvalidator_responses')} (
13
  `hash` VARCHAR(32) NOT NULL,
14
  `response` BLOB NOT NULL,
15
  `response_code` VARCHAR(20) NOT NULL,
app/code/community/{Aydus/Addressvalidator/sql/aydus_addressvalidator_setup → ExtensionsStore/Addressvalidator/sql/extensions_store_addressvalidator_setup}/upgrade-1.3.0-1.4.0.php RENAMED
@@ -2,14 +2,14 @@
2
  /**
3
  * 1.4.0 upgrade
4
  *
5
- * @category Aydus
6
- * @package Aydus_Addressvalidator
7
- * @author Aydus <davidt@aydus.com>
8
  */
9
 
10
  $this->startSetup();
11
 
12
- $this->run("CREATE TABLE IF NOT EXISTS {$this->getTable('aydus_addressvalidator_addresses')} (
13
  `id` INT(11) NOT NULL AUTO_INCREMENT,
14
  `address_id` INT(11) NOT NULL,
15
  `address_type` ENUM('billing','shipping') NOT NULL,
2
  /**
3
  * 1.4.0 upgrade
4
  *
5
+ * @category ExtensionsStore
6
+ * @package ExtensionsStore_Addressvalidator
7
+ * @author Extensions Store <admin@extensions-store.com>
8
  */
9
 
10
  $this->startSetup();
11
 
12
+ $this->run("CREATE TABLE IF NOT EXISTS {$this->getTable('extensions_store_addressvalidator_addresses')} (
13
  `id` INT(11) NOT NULL AUTO_INCREMENT,
14
  `address_id` INT(11) NOT NULL,
15
  `address_type` ENUM('billing','shipping') NOT NULL,
app/code/community/ExtensionsStore/Addressvalidator/sql/extensions_store_addressvalidator_setup/upgrade-1.4.3-1.5.0.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * 1.5.0 upgrade
4
+ *
5
+ * @category ExtensionsStore
6
+ * @package ExtensionsStore_Addressvalidator
7
+ * @author Extensions Store <admin@extensions-store.com>
8
+ */
9
+
10
+ $this->startSetup();
11
+
12
+ $oldAddressesTable = $this->getTable('aydus_addressvalidator_addresses');
13
+ $newAddressesTable = $this->getTable('extensions_store_addressvalidator_addresses');
14
+ $oldResponsesTable = $this->getTable('aydus_addressvalidator_responses');
15
+ $newResponsesTable = $this->getTable('extensions_store_addressvalidator_responses');
16
+ $connection = $this->getConnection();
17
+
18
+ if ($connection->isTableExists($oldAddressesTable)){
19
+
20
+ if (!$connection->isTableExists($newAddressesTable)){
21
+ $sql = "CREATE TABLE {$newAddressesTable} LIKE {$oldAddressesTable}";
22
+ $this->run($sql);
23
+ }
24
+ $sql = "INSERT {$newAddressesTable} SELECT * FROM {$oldAddressesTable}";
25
+ $this->run($sql);
26
+ $sql = "DROP TABLE {$oldAddressesTable}";
27
+ $this->run($sql);
28
+ }
29
+
30
+ if ($connection->isTableExists($oldResponsesTable)){
31
+
32
+ if (!$connection->isTableExists($newResponsesTable)){
33
+ $sql = "CREATE TABLE {$newResponsesTable} LIKE {$oldResponsesTable}";
34
+ $this->run($sql);
35
+ }
36
+ $sql = "INSERT {$newResponsesTable} SELECT * FROM {$oldResponsesTable}";
37
+ $this->run($sql);
38
+ $sql = "DROP TABLE {$oldResponsesTable}";
39
+ $this->run($sql);
40
+ }
41
+
42
+ $coreResource = $this->getTable('core_resource');
43
+ $sql = "DELETE FROM {$coreResource} WHERE code = 'aydus_addressvalidator_setup' AND version ='1.4.3' AND data_version = '1.4.3'";
44
+ $this->run($sql);
45
+
46
+ $coreConfigData = $this->getTable('core_config_data');
47
+ $sql = "UPDATE $coreConfigData SET path = REPLACE(path, 'aydus', 'extensions_store') WHERE path like 'aydus_addressvalidator%'";
48
+
49
+ $this->endSetup();
app/design/frontend/base/default/layout/aydus/addressvalidator.xml DELETED
@@ -1,31 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * Address Validator
5
- *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
- */
10
- -->
11
- <layout version="0.1.0">
12
-
13
- <checkout_onepage_index>
14
-
15
- <reference name="head">
16
- <action method="addCss">
17
- <stylesheet>css/aydus/addressvalidator.css</stylesheet>
18
- </action>
19
- <action method="addItem">
20
- <type>skin_js</type>
21
- <name>js/aydus/addressvalidator.js</name>
22
- </action>
23
- </reference>
24
-
25
- <reference name="before_body_end">
26
- <block type="core/template" name="addressvalidator.popup" template ="aydus/addressvalidator/popup.phtml" />
27
- </reference>
28
-
29
- </checkout_onepage_index>
30
-
31
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/layout/extensions_store/addressvalidator.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Address Validator
5
+ *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
+ */
10
+ -->
11
+ <layout version="0.1.0">
12
+
13
+ <checkout_onepage_index>
14
+
15
+ <reference name="head">
16
+ <action method="addCss" ifconfig="extensions_store_addressvalidator/configuration/enabled">
17
+ <stylesheet>css/extensions_store/addressvalidator.css</stylesheet>
18
+ </action>
19
+ <action method="addItem" ifconfig="extensions_store_addressvalidator/configuration/enabled">
20
+ <type>skin_js</type>
21
+ <name>js/extensions_store/addressvalidator.js</name>
22
+ </action>
23
+ </reference>
24
+
25
+ <block type="core/template" name="addressvalidator.popup" template ="extensions_store/addressvalidator/popup.phtml" />
26
+ <reference name="before_body_end">
27
+ <action method="append" ifconfig="extensions_store_addressvalidator/configuration/enabled"><block>addressvalidator.popup</block></action>
28
+ </reference>
29
+
30
+ </checkout_onepage_index>
31
+
32
+ <onestepcheckout_index_index>
33
+ <reference name="head">
34
+ <action method="addCss" ifconfig="extensions_store_addressvalidator/configuration/enabled">
35
+ <stylesheet>css/extensions_store/addressvalidator.css</stylesheet>
36
+ </action>
37
+ <action method="addItem" ifconfig="extensions_store_addressvalidator/configuration/enabled">
38
+ <type>skin_js</type>
39
+ <name>js/extensions_store/addressvalidator.js</name>
40
+ </action>
41
+ </reference>
42
+
43
+ <block type="core/template" name="addressvalidator.popup" template ="extensions_store/addressvalidator/popup.phtml" />
44
+ <reference name="before_body_end">
45
+ <action method="append" ifconfig="extensions_store_addressvalidator/configuration/enabled"><block>addressvalidator.popup</block></action>
46
+ </reference>
47
+ </onestepcheckout_index_index>
48
+
49
+ </layout>
app/design/frontend/base/default/template/{aydus → extensions_store}/addressvalidator/popup.phtml RENAMED
@@ -2,13 +2,13 @@
2
  /**
3
  * Address Validator select
4
  *
5
- * @category Aydus
6
- * @package Aydus_Addressvalidator
7
- * @author Aydus <davidt@aydus.com>
8
  */
9
 
10
  $storeId = Mage::app()->getStore()->getId();
11
- $tooManyAttemptsUrl = Mage::getStoreConfig('aydus_addressvalidator/configuration/too_many_attempts_url',$storeId);
12
  $customerServiceUrl = $this->getUrl($tooManyAttemptsUrl);
13
  ?>
14
 
@@ -18,7 +18,7 @@ $customerServiceUrl = $this->getUrl($tooManyAttemptsUrl);
18
  <div id="av-popup-content">
19
  <form>
20
  <input type="hidden" id="address-form" name="address_form" value="" />
21
- <h4></h4>
22
 
23
  <ul class='radios'>
24
  </ul>
@@ -28,7 +28,7 @@ $customerServiceUrl = $this->getUrl($tooManyAttemptsUrl);
28
  <span><span><?php echo $this->__('Back') ?></span></span>
29
  </button>
30
 
31
- <button class="button select disabled">
32
  <span><span><?php echo $this->__('Select') ?></span></span>
33
  </button>
34
 
@@ -47,10 +47,9 @@ $customerServiceUrl = $this->getUrl($tooManyAttemptsUrl);
47
 
48
 
49
 
50
- <script src="<?php echo $this->getSkinUrl('js/aydus/addressvalidator/address.js') ?>"></script>
51
  <script>
52
  addressValidator.init({
53
- auto_populate: <?php echo (Mage::getStoreConfig('aydus_addressvalidator/configuration/auto_populate')) ? 'true' : 'false' ?>,
54
- allow_bypass: <?php echo (Mage::getStoreConfig('aydus_addressvalidator/configuration/allow_bypass')) ? 'true' : 'false' ?>
55
  });
56
  </script>
2
  /**
3
  * Address Validator select
4
  *
5
+ * @category ExtensionsStore
6
+ * @package ExtensionsStore_Addressvalidator
7
+ * @author Extensions Store <admin@extensions-store.com>
8
  */
9
 
10
  $storeId = Mage::app()->getStore()->getId();
11
+ $tooManyAttemptsUrl = Mage::getStoreConfig('extensions_store_addressvalidator/configuration/too_many_attempts_url',$storeId);
12
  $customerServiceUrl = $this->getUrl($tooManyAttemptsUrl);
13
  ?>
14
 
18
  <div id="av-popup-content">
19
  <form>
20
  <input type="hidden" id="address-form" name="address_form" value="" />
21
+ <div class="av-message"></div>
22
 
23
  <ul class='radios'>
24
  </ul>
28
  <span><span><?php echo $this->__('Back') ?></span></span>
29
  </button>
30
 
31
+ <button class="button select">
32
  <span><span><?php echo $this->__('Select') ?></span></span>
33
  </button>
34
 
47
 
48
 
49
 
 
50
  <script>
51
  addressValidator.init({
52
+ auto_populate: <?php echo (Mage::getStoreConfig('extensions_store_addressvalidator/configuration/auto_populate')) ? 'true' : 'false' ?>,
53
+ allow_bypass: <?php echo (Mage::getStoreConfig('extensions_store_addressvalidator/configuration/allow_bypass')) ? 'true' : 'false' ?>
54
  });
55
  </script>
app/etc/modules/Aydus_Addressvalidator.xml DELETED
@@ -1,18 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * Address Validator module
5
- *
6
- * @category Aydus
7
- * @package Aydus_Addressvalidator
8
- * @author Aydus <davidt@aydus.com>
9
- */
10
- -->
11
- <config>
12
- <modules>
13
- <Aydus_Addressvalidator>
14
- <active>true</active>
15
- <codePool>community</codePool>
16
- </Aydus_Addressvalidator>
17
- </modules>
18
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/ExtensionsStore_Addressvalidator.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Address Validator module
5
+ *
6
+ * @category ExtensionsStore
7
+ * @package ExtensionsStore_Addressvalidator
8
+ * @author Extensions Store <admin@extensions-store.com>
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <ExtensionsStore_Addressvalidator>
14
+ <active>true</active>
15
+ <codePool>community</codePool>
16
+ </ExtensionsStore_Addressvalidator>
17
+ </modules>
18
+ </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Addressvalidator</name>
4
- <version>1.4.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/OSL-3.0">Open Software License</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Validate billing and shipping addresses in the One Page Checkout. Customer submits billing and shipping addresses and is shown a popup of valid addresses to choose from. With support for UPS, USPS, Fedex, Address Doctor and Melissa Data.</description>
11
  <notes>test notes</notes>
12
  <authors><author><name>Extensions Store</name><user>Extension</user><email>admin@extensions-store.com</email></author><author><name>Extensions Store</name><user>Extension</user><email>admin@extensions-store.com</email></author></authors>
13
- <date>2015-08-26</date>
14
- <time>02:11:20</time>
15
- <contents><target name="magecommunity"><dir name="Aydus"><dir name="Addressvalidator"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Validexceptions.php" hash="cc648c12bc605c14f6127638ceddbe2d"/></dir></dir></dir></dir><dir name="Checkout"><dir name="Onepage"><file name="Billing.php" hash="6be15561b9b09a101bf009734c5ee3a1"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="ddeebd105082f4c92032b66c5f7b9a33"/></dir><dir name="Model"><file name="Address.php" hash="1a8180e69fd0ad58b0fa0d3423c490c0"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><dir name="Addressdoctor"><file name="Validcodes.php" hash="fde2d39e5876e12c36857d896cae88c6"/></dir><file name="Service.php" hash="63d35c97530c54ce49deee6a1a746375"/></dir></dir></dir></dir><file name="Observer.php" hash="6880647ac3abdfec539f85450fc01aa0"/><dir name="Resource"><dir name="Address"><file name="Collection.php" hash="f1d88a6e347f83971dd3b41781e8f073"/></dir><file name="Address.php" hash="6638c5f7e07684441c895337c72d6c83"/></dir><dir name="Service"><file name="Abstract.php" hash="281351d7c63b1e92f1cb36f3135f35fb"/><file name="Addressdoctor.php" hash="484ed6246dc1e5ad93cca07d87d76680"/><file name="Fedex.php" hash="1608ae2c935597975816c61dd4a00a90"/><file name="Melissadata.php" hash="629c48b5ab2a40fa177c5a0a2b2e5607"/><file name="Ups.php" hash="9dbcb0dd63eb6bf864b61790fd9d8930"/><file name="Usps.php" hash="f29c986b213806e363a4f51ff19d0c53"/></dir></dir><dir name="Test"><dir name="Controller"><dir name="TestController"><dir name="fixtures"><file name="testController.yaml" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir><file name="TestController.php" hash="b0df7546fc56bd869d805a96e209ee77"/></dir><dir name="Helper"><dir name="TestHelper"><dir name="fixtures"><file name="testHelper.yaml" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir><file name="TestHelper.php" hash="3089d78a75d13084f9482995e807a37f"/></dir><dir name="Model"><dir name="TestModel"><dir name="fixtures"><file name="testModel.yaml" hash="ebcadfcfe7ac7469233f4d5124985792"/></dir></dir><file name="TestModel.php" hash="12609ff92a073dc75d8607482a48c870"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="ec0ecd573275c3b98e98fe85c3d8bbf5"/><file name="config.xml" hash="1c44ced59b4404214278941488d2fbc0"/><file name="system.xml" hash="269708db3262764131ed8410e476257c"/></dir><file name="readme.md" hash="99ee8caa9700fc61ebd943728645896c"/><dir name="sql"><dir name="aydus_addressvalidator_setup"><file name="install-1.0.0.php" hash="a3d556dd3c24a7cc8bad23ed556b61a0"/><file name="upgrade-1.3.0-1.4.0.php" hash="f1d251e2c674b055a991c09dc540ddfb"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="aydus"><file name="addressvalidator.xml" hash="f0610f66ee0426e7b7aff9e4ac90d6da"/></dir></dir><dir name="template"><dir name="aydus"><dir name="addressvalidator"><file name="popup.phtml" hash="b7698d87698e3af70161449c379e6f6b"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Aydus_Addressvalidator.xml" hash="b0a4f06b24da23ad6fe75178e987c89d"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="aydus"><file name="addressvalidator.css" hash="c2499e0b4a71cdd7c5456496aefd502b"/></dir></dir><dir name="images"><dir name="aydus"><dir name="addressvalidator"><file name="LOGO_L.gif" hash="5aa294d5345e5b4cc83e92f8ae443283"/><file name="LOGO_S.gif" hash="0654a9638a3b7787f35495ad17dc7363"/></dir></dir></dir><dir name="js"><dir name="aydus"><dir name="addressvalidator"><file name="address.js" hash="5917b0b84e3bae21c347d692d462a0e7"/></dir><file name="addressvalidator.js" hash="4a297c9c0c3d3f9ddacf9cf80e054d6f"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Addressvalidator</name>
4
+ <version>1.5.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/OSL-3.0">Open Software License</license>
7
  <channel>community</channel>
10
  <description>Validate billing and shipping addresses in the One Page Checkout. Customer submits billing and shipping addresses and is shown a popup of valid addresses to choose from. With support for UPS, USPS, Fedex, Address Doctor and Melissa Data.</description>
11
  <notes>test notes</notes>
12
  <authors><author><name>Extensions Store</name><user>Extension</user><email>admin@extensions-store.com</email></author><author><name>Extensions Store</name><user>Extension</user><email>admin@extensions-store.com</email></author></authors>
13
+ <date>2016-07-16</date>
14
+ <time>18:14:38</time>
15
+ <contents><target name="magecommunity"><dir name="ExtensionsStore"><dir name="Addressvalidator"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Validexceptions.php" hash="2ec7d2066cb6fb7763b8f83fe5c493e4"/></dir></dir></dir></dir><dir name="Checkout"><dir name="Onepage"><file name="Billing.php" hash="52c1658f33153c19d5c65a6e11e999a7"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="5331a8f841d4a151e0c2b13b31555b29"/></dir><dir name="Model"><file name="Address.php" hash="419e41675c8f7974de270c655795a2c6"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><dir name="Addressdoctor"><file name="Validcodes.php" hash="c464cd616dbe3ac2466f20545ddfd9e6"/></dir><file name="Service.php" hash="45536d2d6617a3321d6c848850eabaf6"/></dir></dir></dir></dir><file name="Observer.php" hash="864d782bf2d1edd6c8a96f8126acf348"/><dir name="Resource"><dir name="Address"><file name="Collection.php" hash="be4229bef02d1f556344e9ec1105bb60"/></dir><file name="Address.php" hash="1d5831cf69ce6114a6a0bb68a3f147d3"/></dir><dir name="Service"><file name="Abstract.php" hash="11fb71f58e2241260b7c3e783a35bada"/><file name="Addressdoctor.php" hash="3effc03bb99fc58a1ce5f7c8a487a1ba"/><file name="Fedex.php" hash="1fe513250caca185dcb9ed08cc459c66"/><file name="Melissadata.php" hash="2537f65d24412effdd62934c4890d56c"/><file name="Ups.php" hash="4c3b2e9ce29e3252cc4ab89a626bcfc1"/><file name="Usps.php" hash="cb74e248b2627bffb26a8b12d3c8c914"/></dir></dir><dir name="Test"><dir name="Controller"><dir name="TestController"><dir name="fixtures"><file name="testController.yaml" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir><file name="TestController.php" hash="11748e9c34b4af8ab157be48f2a22408"/></dir><dir name="Helper"><dir name="TestHelper"><dir name="fixtures"><file name="testHelper.yaml" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir><file name="TestHelper.php" hash="a9c52702adb2c6029147c1f61a749e76"/></dir><dir name="Model"><dir name="TestModel"><dir name="fixtures"><file name="testModel.yaml" hash="4799719ed019b0204cea26405138cdec"/></dir></dir><file name="TestModel.php" hash="27c614cac75564f0c322ecd676f3a9fd"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="288f38da8016378e692f06d45d1ce5cf"/><file name="config.xml" hash="7d25f7a79ad4ae17b7e1c0b3c6ec6715"/><file name="system.xml" hash="8fffca6a1ceb2eed74a0955d0e9d58ab"/></dir><file name="readme.md" hash="7133bb4c5c64ff39d274ac6a899bd4ac"/><dir name="sql"><dir name="extensions_store_addressvalidator_setup"><file name="install-1.0.0.php" hash="207f24817ce145ce02a181a51c057afe"/><file name="upgrade-1.3.0-1.4.0.php" hash="60cf0e24346a3cb4d935a17e768f5251"/><file name="upgrade-1.4.3-1.5.0.php" hash="b1e3890630610c92814fa788024209a8"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="extensions_store"><file name="addressvalidator.xml" hash="83c352c9b547df5a6a1af2259f3823f7"/></dir></dir><dir name="template"><dir name="extensions_store"><dir name="addressvalidator"><file name="popup.phtml" hash="c94c1fc51df334e0843659f0d64f8626"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ExtensionsStore_Addressvalidator.xml" hash="e1e782fc61f2091e14be6dc6066eb4c1"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="extensions_store"><file name="addressvalidator.css" hash="7a78d5fd41a876ce2d113329c61e2812"/></dir></dir><dir name="images"><dir name="extensions_store"><dir name="addressvalidator"><file name="LOGO_L.gif" hash="5aa294d5345e5b4cc83e92f8ae443283"/><file name="LOGO_S.gif" hash="0654a9638a3b7787f35495ad17dc7363"/></dir></dir></dir><dir name="js"><dir name="extensions_store"><dir name="addressvalidator"><file name="address.js" hash="ebb3ed94cbd0e21f084a779bf02f7500"/></dir><file name="addressvalidator.js" hash="cd8ee43f384e3c3e603729d338b8ba4e"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
skin/frontend/base/default/css/{aydus → extensions_store}/addressvalidator.css RENAMED
@@ -1,9 +1,9 @@
1
  /**
2
  * Addressvalidator popup
3
  *
4
- * @category Aydus
5
- * @package Aydus_Addressvalidator
6
- * @author Aydus <davidt@aydus.com>
7
  */
8
 
9
  #av-popup-overlay{
1
  /**
2
  * Addressvalidator popup
3
  *
4
+ * @category ExtensionsStore
5
+ * @package ExtensionsStore_Addressvalidator
6
+ * @author Extensions Store <admin@extensions-store.com>
7
  */
8
 
9
  #av-popup-overlay{
skin/frontend/base/default/images/{aydus → extensions_store}/addressvalidator/LOGO_L.gif RENAMED
File without changes
skin/frontend/base/default/images/{aydus → extensions_store}/addressvalidator/LOGO_S.gif RENAMED
File without changes
skin/frontend/base/default/js/aydus/addressvalidator.js DELETED
@@ -1,329 +0,0 @@
1
- /**
2
- * Address Validator js
3
- *
4
- * @category Aydus
5
- * @package Aydus_Addressvalidator
6
- * @author Aydus <davidt@aydus.com>
7
- */
8
-
9
- function AddressValidator($)
10
- {
11
-
12
- var config = {};
13
- var results = [];
14
-
15
- /**
16
- * select match
17
- *
18
- * @param string form id
19
- * @param string message
20
- * @param string resultsJson
21
- */
22
- var validateAddress = function (form, message, resultsJson)
23
- {
24
- //set the popup scope for any js that needs it
25
- $('#address-form').val(form);
26
-
27
- try {
28
- results = JSON.parse(resultsJson);
29
- } catch (e) {
30
- if (typeof console == 'object') {
31
- console.log(e.message);
32
- }
33
- }
34
-
35
- //create list of addresses and show popup
36
- if (results && results.length > 0) {
37
-
38
- //create list of address radio buttons
39
- var radios = '';
40
- $popup = getPopup();
41
- $popup.find('h4').html(message);
42
- //show buttons we hid in editAddress
43
- $popup.find('.select').show();
44
- var $radios = $popup.find('ul.radios');
45
- $radios.empty();
46
-
47
- var length = results.length;
48
-
49
- for (var i = 0; i < length; i++) {
50
-
51
- var address = results[i];
52
-
53
- var street = (typeof address.street !== 'string' && address.street.length > 1) ? address.street.join(', ') : address.street;
54
- var city = (typeof address.city !== 'string' && address.city.length > 1) ? address.city.join(', ') : address.city;
55
-
56
- var addressAr = [street, city, address.region, address.postcode, address.country];
57
- addressAr = addressAr.filter(function (n) {
58
- return n != undefined
59
- });
60
-
61
- var label = addressAr.join(', ');
62
-
63
- radios += '<li><label><input type="radio" class="radio" name="address" value="' + i + '" /> ' + label + '</label></li>';
64
-
65
- }
66
-
67
- //stick into list
68
- $radios.append(radios);
69
-
70
- //enable selection
71
- $('.radio').click(function (e) {
72
- $('#av-popup .select').removeClass('disabled');
73
- });
74
-
75
- //show popup
76
- $('#av-popup').show();
77
-
78
- }
79
-
80
- };
81
-
82
- /**
83
- * No match, edit address
84
- */
85
- var editAddress = function (form, message)
86
- {
87
- //set the popup scope for any js that needs it
88
- $('#address-form').val(form);
89
-
90
- if (config.allow_bypass === true){
91
-
92
- $('#' + form).append('<input type="hidden" class="address-validated" name="address_validated" value="1" />');
93
- gotoNextStep();
94
-
95
- } else {
96
-
97
- //get the popup
98
- $popup = getPopup();
99
- //append message
100
- $popup.find('h4').html(message);
101
- //hide the select button (nothing to select) and skip button (per JM)
102
- $popup.find('.select, .okay').hide();
103
- //show popup
104
- $('#av-popup').show();
105
- }
106
- };
107
-
108
- /**
109
- * Too many attempts, redirect to url
110
- * @param string message
111
- * @param string url
112
- */
113
- var redirectSupport = function (message, url)
114
- {
115
- $popup = getPopup();
116
- $popup.find('h4').html(message);
117
- //hide all buttons except ok
118
- $popup.find('.back, .select, .skip').hide();
119
- $popup.find('.okay').attr('href', url).show();
120
- //show popup
121
- $('#av-popup').show();
122
- };
123
-
124
-
125
- /**
126
- * Get reset popup
127
- */
128
- var getPopup = function ()
129
- {
130
- var $popup = $('#av-popup');
131
- //empty out previous results
132
- var $radios = $popup.find('ul.radios');
133
- $radios.empty();
134
-
135
- return $popup;
136
- };
137
-
138
- var getFormType = function()
139
- {
140
- var form = $('#address-form').val();
141
- var formType;
142
- if (form == 'co-billing-form') {
143
- formType = 'billing';
144
- } else if (form == 'co-shipping-form') {
145
- formType = 'shipping';
146
- }
147
-
148
- return formType;
149
- };
150
-
151
- /**
152
- *
153
- * @param string formType
154
- * @param object address
155
- */
156
- var populate = function(formType, address)
157
- {
158
- //deselect addressbook entry
159
- $('#' + formType + '-new-address-form').show();
160
- var customerAddressId = $('#' + formType + '-address-select').val();
161
- $('#' + formType + '-address-select').val(null);
162
-
163
- $('#' + formType + '\\:street1').val(address.street[0]);
164
-
165
- if (typeof address.street[1] != 'undefined') {
166
- $('#' + formType + '\\:street2').val(address.street[1]);
167
- }
168
- if (typeof address.street[2] != 'undefined') {
169
- var street2 = $('#' + formType + '\\:street2').val();
170
- $('#' + formType + '\\:street2').val(street2 + ' ' + address.street[2]);
171
- }
172
-
173
- var city = (typeof address.city !== 'string' && address.city.length > 1) ? address.city.join(', ') : address.city;
174
-
175
- $('#' + formType + '\\:city').val(city);
176
- $('#' + formType + '\\:region').val(address.region);
177
- $('#' + formType + '\\:region_id').val(address.region_id);
178
- $('#' + formType + '\\:postcode').val(address.postcode);
179
- $('#' + formType + '\\:country_id').val(address.country_id);
180
-
181
- $('#' + formType + '\\:save_in_address_book').attr('checked',true);
182
-
183
- var $addressValidated = $('#co-' + formType + '-form').find('.address-validated');
184
- if ($addressValidated.length > 0) {
185
- $addressValidated.val(customerAddressId);
186
- } else {
187
- $('#co-' + formType + '-form').append('<input type="hidden" class="address-validated" name="address_validated" value="'+customerAddressId+'" />');
188
- }
189
-
190
- };
191
-
192
- /**
193
- * Go to next step
194
- */
195
- var gotoNextStep = function ()
196
- {
197
- var form = $('#address-form').val();
198
-
199
- if (form == 'co-billing-form') {
200
- billing.save();
201
- } else if (form == 'co-shipping-form') {
202
- shipping.save();
203
- }
204
- };
205
-
206
-
207
- return {
208
-
209
- init : function(configObj)
210
- {
211
- config = configObj;
212
-
213
- $(function () {
214
-
215
- $('#co-billing-form input.input-text, #co-billing-form select, #co-shipping-form input.input-text, #co-shipping-form select').change(function (e) {
216
- $(this.form).find('.address-validated').val(0);
217
- });
218
-
219
- //close the popup and stay on the current step
220
- $('#av-popup .back').click(function (e) {
221
-
222
- var form = $('#address-form').val();
223
- e.preventDefault();
224
- e.stopPropagation();
225
- //allow validation
226
- $('#' + form).find('.address-validated').val(0);
227
- $('#av-popup').hide();
228
-
229
- });
230
-
231
-
232
- //handle address selection
233
- $('#av-popup .select').click(function (e) {
234
-
235
- e.preventDefault();
236
- e.stopPropagation();
237
-
238
- var $checkedRadio = $('#av-popup .radio:checked');
239
- var checked = ($checkedRadio.length > 0) ? true : false;
240
-
241
- if (checked) {
242
-
243
- var i = $checkedRadio.val();
244
-
245
- if (!isNaN(i)) {
246
-
247
- var formType = getFormType();
248
-
249
- i = parseInt(i);
250
- var address = results[i];
251
-
252
- //populate form
253
- if (address) {
254
-
255
- populate(formType, address);
256
- }
257
-
258
- $('#av-popup').hide();
259
-
260
- gotoNextStep();
261
-
262
- }
263
- }
264
-
265
- });
266
-
267
- //skip address validation and continue
268
- $('#av-popup .skip').click(function (e) {
269
-
270
- e.preventDefault();
271
- e.stopPropagation();
272
-
273
- var form = $('#address-form').val();
274
- $('#' + form).append('<input type="hidden" class="skip-validation" name="skip_validation" value="1" />');
275
-
276
- gotoNextStep();
277
-
278
- $('#av-popup').hide();
279
- });
280
-
281
- //too many attempts redirect button
282
- $('#av-popup .okay').click(function (e) {
283
-
284
- e.preventDefault();
285
- e.stopPropagation();
286
-
287
- var href = $(this).attr('href');
288
-
289
- if (href.indexOf('http') != -1) {
290
-
291
- window.location.href = href;
292
- } else {
293
-
294
- window.location.href = 'customer-service';
295
- }
296
- });
297
-
298
-
299
- });
300
-
301
- },
302
-
303
- validateAddress : function(form, message, resultsJson)
304
- {
305
- validateAddress(form, message, resultsJson);
306
- },
307
-
308
- editAddress : function(form, message)
309
- {
310
- editAddress(form, message);
311
- },
312
-
313
- redirectSupport : function (message, url)
314
- {
315
- redirectSupport(message, url);
316
- }
317
-
318
- };
319
-
320
- }
321
-
322
- if (!window.jQuery){
323
- document.write('<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js">\x3C/script><script>jQuery.noConflict();</script>');
324
- document.write('<script>var addressValidator = AddressValidator(jQuery);</script>');
325
- } else {
326
- var addressValidator = AddressValidator(jQuery);
327
- }
328
-
329
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
skin/frontend/base/default/js/aydus/addressvalidator/address.js DELETED
@@ -1,110 +0,0 @@
1
- /**
2
- * Address Validator Billing/Shipping prototype overrides
3
- *
4
- * @category Aydus
5
- * @package Aydus_Addressvalidator
6
- * @author Aydus <davidt@aydus.com>
7
- */
8
-
9
- if (window.shipping){
10
-
11
- //replace the nextStep method in the Billing prototype
12
- var replaceBillingNextStepObj = {
13
- nextStep: function (transport) {
14
-
15
- if (transport && transport.responseText) {
16
- try {
17
- response = eval('(' + transport.responseText + ')');
18
- }
19
- catch (e) {
20
- response = {};
21
- }
22
- }
23
-
24
- if (response && response.validate) {
25
- if (!response.error) {
26
-
27
- if (typeof response.data == 'string') {
28
- addressValidator.validateAddress('co-billing-form', response.message, response.data);
29
- }
30
- } else {
31
- if (response.data.indexOf('http') != -1) {
32
- addressValidator.redirectSupport(response.message, response.data);
33
- } else {
34
- addressValidator.editAddress('co-billing-form', response.message);
35
- }
36
- return false;
37
- }
38
- }
39
-
40
- if (response.error) {
41
- if ((typeof response.message) == 'string') {
42
- alert(response.message);
43
- } else {
44
- if (window.billingRegionUpdater) {
45
- billingRegionUpdater.update();
46
- }
47
-
48
- alert(response.message.join("\n"));
49
- }
50
-
51
- return false;
52
- }
53
-
54
- checkout.setStepResponse(response);
55
-
56
- payment.initWhatIsCvvListeners();
57
- }
58
-
59
- };
60
-
61
- Billing.addMethods(replaceBillingNextStepObj);
62
- //replace the nextStep method in the Shipping prototype
63
- var replaceShippingNextStepObj = {
64
- nextStep: function (transport) {
65
-
66
- if (transport && transport.responseText) {
67
- try {
68
- response = eval('(' + transport.responseText + ')');
69
- }
70
- catch (e) {
71
- response = {};
72
- }
73
- }
74
-
75
- if (response && response.validate) {
76
-
77
- if (!response.error) {
78
- if (typeof response.data == 'string') {
79
- addressValidator.validateAddress('co-shipping-form', response.message, response.data);
80
- }
81
- } else {
82
- if (response.data.indexOf('http') != -1) {
83
- addressValidator.redirectSupport(response.message, response.data);
84
- } else {
85
- addressValidator.editAddress('co-shipping-form', response.message);
86
- }
87
- return false;
88
- }
89
- }
90
-
91
- if (response.error) {
92
- if ((typeof response.message) == 'string') {
93
- alert(response.message);
94
- } else {
95
- if (window.shippingRegionUpdater) {
96
- shippingRegionUpdater.update();
97
- }
98
- alert(response.message.join("\n"));
99
- }
100
-
101
- return false;
102
- }
103
-
104
- checkout.setStepResponse(response);
105
- }
106
-
107
- };
108
-
109
- Shipping.addMethods(replaceShippingNextStepObj);
110
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
skin/frontend/base/default/js/extensions_store/addressvalidator.js ADDED
@@ -0,0 +1,439 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Address Validator js
3
+ *
4
+ * @category ExtensionsStore
5
+ * @package ExtensionsStore_Addressvalidator
6
+ * @author Extensions Store <admin@extensions-store.com>
7
+ */
8
+
9
+ function AddressValidator($)
10
+ {
11
+
12
+ var config = {};
13
+ var results = [];
14
+
15
+ /**
16
+ * Initialize popup
17
+ *
18
+ */
19
+ var initialize = function()
20
+ {
21
+ $('#co-billing-form .required-entry, #co-shipping-form .required-entry').change(function (e) {
22
+ $(this.form).find('.address-validated').val(0);
23
+ });
24
+
25
+ //close the popup and stay on the current step
26
+ $('#av-popup .back').click(function (e) {
27
+
28
+ var form = $('#address-form').val();
29
+ e.preventDefault();
30
+ e.stopPropagation();
31
+ //allow validation
32
+ $('#' + form).find('.address-validated').val(0);
33
+ $('#av-popup').hide();
34
+
35
+ });
36
+
37
+ //handle address selection
38
+ $('#av-popup .select').click(function (e) {
39
+
40
+ e.preventDefault();
41
+ e.stopPropagation();
42
+
43
+ var $checkedRadio = $('#av-popup .radio:checked');
44
+ var checked = ($checkedRadio.length > 0) ? true : false;
45
+
46
+ if (checked) {
47
+
48
+ var i = $checkedRadio.val();
49
+
50
+ if (!isNaN(i)) {
51
+
52
+ var formType = getFormType();
53
+
54
+ i = parseInt(i);
55
+ var address = results[i];
56
+
57
+ //populate form
58
+ if (address) {
59
+
60
+ populate(formType, address);
61
+ }
62
+
63
+ $('#av-popup').hide();
64
+
65
+ gotoNextStep();
66
+
67
+ }
68
+ }
69
+
70
+ });
71
+
72
+ //skip address validation and continue
73
+ $('#av-popup .skip').click(function (e) {
74
+
75
+ e.preventDefault();
76
+ e.stopPropagation();
77
+
78
+ var form = $('#address-form').val();
79
+ $('#' + form).append('<input type="hidden" class="skip-validation" name="skip_validation" value="1" />');
80
+
81
+ gotoNextStep();
82
+
83
+ $('#av-popup').hide();
84
+ });
85
+
86
+ //too many attempts redirect button
87
+ $('#av-popup .okay').click(function (e) {
88
+
89
+ e.preventDefault();
90
+ e.stopPropagation();
91
+
92
+ var href = $(this).attr('href');
93
+
94
+ if (href.indexOf('http') != -1) {
95
+
96
+ window.location.href = href;
97
+ } else {
98
+
99
+ window.location.href = 'customer-service';
100
+ }
101
+ });
102
+ };
103
+
104
+ /**
105
+ * Initialize one step checkout
106
+ */
107
+ var initOneStepCheckout = function()
108
+ {
109
+ //onestepcheckout form input change
110
+ $('#billing_address .required-entry').change(function (e) {
111
+ $('#billing_address').find('.address-validated').val(0);
112
+ });
113
+ $('#shipping_address .required-entry').change(function (e) {
114
+ $('#shipping_address').find('.address-validated').val(0);
115
+ });
116
+
117
+ var savingBilling, savingShipping = false;
118
+
119
+ Ajax.Responders.register({
120
+ onCreate : function(req, transport, json){
121
+ if (batriggered || satriggered){
122
+ if (batriggered){
123
+ if (savingBilling){
124
+ transport.abort();
125
+ return;
126
+ }
127
+ batriggered = false;
128
+ savingBilling = true;
129
+ req.url += '?form_id=billing_address';
130
+ } else if (satriggered) {
131
+ if (savingShipping){
132
+ transport.abort();
133
+ return;
134
+ }
135
+ satriggered = false;
136
+ savingShipping = true;
137
+ req.url += '?form_id=shipping_address';
138
+ }
139
+
140
+ }
141
+ },
142
+ onComplete : function(req, res) {
143
+ if (res.readyState == 4 && res.responseText.length > 0) {
144
+ var response = $.parseJSON(res.responseText);
145
+ if (response.hasOwnProperty('address_validator')) {
146
+ var av = response.address_validator;
147
+ if (!av.error) {
148
+ var formId = av.form_id;
149
+ if (savingBilling || savingShipping){
150
+ if (!av.validate){
151
+ var formType = (formId == 'billing_address') ? 'billing' : 'shipping';
152
+ results = JSON.parse(av.data);
153
+ if (results.length > 0){
154
+ populate(formType,results[0]);
155
+ }
156
+ } else {
157
+ validateAddress(formId, av.message, av.data);
158
+ }
159
+ if (formId =='billing_address'){
160
+ savingBilling = false;
161
+ } else {
162
+ savingShipping = false;
163
+ }
164
+ }
165
+ }
166
+ }
167
+ }
168
+ }
169
+ });
170
+ };
171
+
172
+ /**
173
+ * select match
174
+ *
175
+ * @param string form id
176
+ * @param string message
177
+ * @param string resultsJson
178
+ */
179
+ var validateAddress = function (form, message, resultsJson)
180
+ {
181
+ //set the popup scope for any js that needs it
182
+ $('#address-form').val(form);
183
+
184
+ try {
185
+ results = JSON.parse(resultsJson);
186
+ } catch (e) {
187
+ if (typeof console == 'object') {
188
+ console.log(e.message);
189
+ }
190
+ }
191
+
192
+ //create list of addresses and show popup
193
+ if (results && results.length > 0) {
194
+
195
+ //create list of address radio buttons
196
+ var radios = '';
197
+ $popup = getPopup();
198
+ $popup.find('.av-message').html(message);
199
+ //show buttons we hid in editAddress
200
+ $popup.find('.select').show();
201
+ var $radios = $popup.find('ul.radios');
202
+ $radios.empty();
203
+
204
+ var length = results.length;
205
+
206
+ for (var i = 0; i < length; i++) {
207
+
208
+ var address = results[i];
209
+
210
+ var street = (typeof address.street !== 'string' && address.street.length > 1) ? address.street.join(', ') : address.street;
211
+ var city = (typeof address.city !== 'string' && address.city.length > 1) ? address.city.join(', ') : address.city;
212
+
213
+ var addressAr = [street, city, address.region, address.postcode, address.country];
214
+ addressAr = addressAr.filter(function (n) {
215
+ return n != undefined
216
+ });
217
+
218
+ var label = addressAr.join(', ');
219
+
220
+ var checked = (i == 0) ? 'checked="checked"' : '';
221
+
222
+ radios += '<li><label><input type="radio" class="radio" '+checked+' name="address" value="' + i + '" /> ' + label + '</label></li>';
223
+
224
+ }
225
+
226
+ //stick into list
227
+ $radios.append(radios);
228
+
229
+ //show popup
230
+ $('#av-popup').show();
231
+
232
+ }
233
+
234
+ };
235
+
236
+ /**
237
+ * No match, edit address
238
+ */
239
+ var editAddress = function (form, message)
240
+ {
241
+ //set the popup scope for any js that needs it
242
+ $('#address-form').val(form);
243
+
244
+ if (config.allow_bypass === true){
245
+
246
+ $('#' + form).append('<input type="hidden" class="address-validated" name="address_validated" value="1" />');
247
+ gotoNextStep();
248
+
249
+ } else {
250
+
251
+ //get the popup
252
+ $popup = getPopup();
253
+ //append message
254
+ $popup.find('.av-message').html(message);
255
+ //hide the select button (nothing to select) and skip button (per JM)
256
+ $popup.find('.select, .okay').hide();
257
+ //show popup
258
+ $('#av-popup').show();
259
+ }
260
+ };
261
+
262
+ /**
263
+ * Too many attempts, redirect to url
264
+ * @param string message
265
+ * @param string url
266
+ */
267
+ var redirectSupport = function (message, url)
268
+ {
269
+ $popup = getPopup();
270
+ $popup.find('.av-message').html(message);
271
+ //hide all buttons except ok
272
+ $popup.find('.back, .select, .skip').hide();
273
+ $popup.find('.okay').attr('href', url).show();
274
+ //show popup
275
+ $('#av-popup').show();
276
+ };
277
+
278
+
279
+ /**
280
+ * Get reset popup
281
+ */
282
+ var getPopup = function ()
283
+ {
284
+ var $popup = $('#av-popup');
285
+ //empty out previous results
286
+ var $radios = $popup.find('ul.radios');
287
+ $radios.empty();
288
+
289
+ return $popup;
290
+ };
291
+
292
+ var getFormType = function()
293
+ {
294
+ var form = $('#address-form').val();
295
+ var formType;
296
+ if (form == 'co-billing-form' || form == 'billing_address') {
297
+ formType = 'billing';
298
+ } else if (form == 'co-shipping-form' || form == 'shipping_address') {
299
+ formType = 'shipping';
300
+ }
301
+
302
+ return formType;
303
+ };
304
+
305
+ /**
306
+ *
307
+ * @param string formType
308
+ * @param object address
309
+ */
310
+ var populate = function(formType, address)
311
+ {
312
+ //deselect addressbook entry
313
+ $('#' + formType + '-new-address-form').show();
314
+ var customerAddressId = $('#' + formType + '-address-select').val();
315
+ var addressValidated = (customerAddressId) ? customerAddressId : 1;
316
+ $('#' + formType + '-address-select').val(null);
317
+
318
+ var originalStreet1 = $('#' + formType + '\\:street1').val();
319
+ var street1 = address.street[0];
320
+ $('#' + formType + '\\:street1').val(street1);
321
+
322
+ if (typeof address.street[1] != 'undefined') {
323
+ $('#' + formType + '\\:street2').val(address.street[1]);
324
+ } else {
325
+ var originalStreet2 = $('#' + formType + '\\:street2').val();
326
+ //remove line 2 if apt number added to line 1
327
+ if (originalStreet2 && originalStreet1.toUpperCase().indexOf(' APT ') < 0 && street1.toUpperCase().indexOf(' APT ') >= 0){
328
+ $('#' + formType + '\\:street2').val('');
329
+ }
330
+ }
331
+ if (typeof address.street[2] != 'undefined') {
332
+ var street2 = $('#' + formType + '\\:street2').val();
333
+ $('#' + formType + '\\:street2').val(street2 + ' ' + address.street[2]);
334
+ }
335
+
336
+ var city = (typeof address.city !== 'string' && address.city.length > 1) ? address.city.join(', ') : address.city;
337
+
338
+ $('#' + formType + '\\:city').val(city);
339
+ $('#' + formType + '\\:region').val(address.region);
340
+ $('#' + formType + '\\:region_id').val(address.region_id);
341
+ $('#' + formType + '\\:postcode').val(address.postcode);
342
+ var $countryInput = $('#' + formType + '\\:country_id');
343
+ $countryInput.val(address.country_id);
344
+
345
+ $('#' + formType + '\\:save_in_address_book').attr('checked',true);
346
+
347
+ var addressValidatedInput = '<input type="hidden" class="address-validated input-text" name="'+formType+'[address_validated]" value="'+addressValidated+'" />';
348
+ var $form = $('#co-' + formType + '-form');
349
+ if ($form.length>0){
350
+ var $addressValidated = $form.find('.address-validated');
351
+ if ($addressValidated.length > 0) {
352
+ $addressValidated.val(addressValidated);
353
+ } else {
354
+ $form.append(addressValidatedInput);
355
+
356
+ }
357
+ } else {
358
+
359
+ var $addressValidated = $countryInput.next();
360
+ if ($addressValidated.length > 0 && $addressValidated.hasClass('address-validated')){
361
+ $addressValidated.val(addressValidated);
362
+ } else {
363
+ $countryInput.after(addressValidatedInput);
364
+ }
365
+
366
+ }
367
+
368
+ };
369
+
370
+ /**
371
+ * Go to next step
372
+ */
373
+ var gotoNextStep = function ()
374
+ {
375
+ var formId = $('#address-form').val();
376
+
377
+ if (formId == 'co-billing-form') {
378
+ billing.save();
379
+ } else if (formId == 'co-shipping-form') {
380
+ shipping.save();
381
+ }
382
+ };
383
+
384
+
385
+ return {
386
+
387
+ init : function(configObj)
388
+ {
389
+ config = configObj;
390
+
391
+ $(function () {
392
+
393
+ initialize();
394
+ if ($('#onestepcheckout-form').length > 0){
395
+ initOneStepCheckout();
396
+ }
397
+ });
398
+ },
399
+
400
+ validateAddress : function(form, message, resultsJson)
401
+ {
402
+ validateAddress(form, message, resultsJson);
403
+ },
404
+
405
+ populate : function(formType, formId, data)
406
+ {
407
+ if (typeof data == 'string'){
408
+ data = JSON.parse(data);
409
+ }
410
+ if (data.length > 0){
411
+ var address = data[0];
412
+ $('#address-form').val(formId);
413
+ populate(formType, address);
414
+ gotoNextStep();
415
+ }
416
+ },
417
+
418
+ editAddress : function(form, message)
419
+ {
420
+ editAddress(form, message);
421
+ },
422
+
423
+ redirectSupport : function (message, url)
424
+ {
425
+ redirectSupport(message, url);
426
+ }
427
+
428
+ };
429
+
430
+ }
431
+
432
+ if (!window.jQuery){
433
+ document.write('<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js">\x3C/script><script>jQuery.noConflict();</script>');
434
+ document.write('<script>var addressValidator = AddressValidator(jQuery);</script>');
435
+ } else {
436
+ var addressValidator = AddressValidator(jQuery);
437
+ }
438
+
439
+
skin/frontend/base/default/js/extensions_store/addressvalidator/address.js ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Address Validator Billing/Shipping prototype overrides
3
+ *
4
+ * @category ExtensionsStore
5
+ * @package ExtensionsStore_Addressvalidator
6
+ * @author Extensions Store <admin@extensions-store.com>
7
+ */
8
+
9
+ if (Billing){
10
+
11
+ //replace the nextStep method in the Billing prototype
12
+ var replaceBillingNextStepObj = {
13
+ nextStep: function (transport) {
14
+
15
+ if (transport && transport.responseText) {
16
+ try {
17
+ response = eval('(' + transport.responseText + ')');
18
+ }
19
+ catch (e) {
20
+ response = {};
21
+ }
22
+ }
23
+
24
+ var addressValidatorObj = response.address_validator;
25
+
26
+ if (addressValidatorObj) {
27
+ if (addressValidatorObj.hasOwnProperty('validate')){
28
+
29
+ if (addressValidatorObj.validate === true){
30
+
31
+ if (addressValidatorObj.error === false){
32
+ addressValidator.validateAddress('co-billing-form', addressValidatorObj.message, addressValidatorObj.data);
33
+
34
+ } else {
35
+ if (addressValidatorObj.data.indexOf('http') != -1) {
36
+ addressValidator.redirectSupport(addressValidatorObj.message, addressValidatorObj.data);
37
+ } else {
38
+ addressValidator.editAddress('co-billing-form', addressValidatorObj.message);
39
+ }
40
+ return false;
41
+ }
42
+
43
+ } else if (addressValidatorObj.error === false) {
44
+ addressValidator.populate('billing','co-billing-form', addressValidatorObj.data);
45
+ }
46
+
47
+ }
48
+ }
49
+
50
+ checkout.setStepResponse(response);
51
+
52
+ payment.initWhatIsCvvListeners();
53
+ }
54
+
55
+ };
56
+
57
+ Billing.addMethods(replaceBillingNextStepObj);
58
+ }
59
+
60
+ if (Shipping){
61
+
62
+ //replace the nextStep method in the Shipping prototype
63
+ var replaceShippingNextStepObj = {
64
+ nextStep: function (transport) {
65
+
66
+ if (transport && transport.responseText) {
67
+ try {
68
+ response = eval('(' + transport.responseText + ')');
69
+ }
70
+ catch (e) {
71
+ response = {};
72
+ }
73
+ }
74
+
75
+ var addressValidatorObj = response.address_validator;
76
+
77
+ if (addressValidatorObj) {
78
+ if (addressValidatorObj.hasOwnProperty('validate')){
79
+
80
+ if (addressValidatorObj.validate === true){
81
+
82
+ if (addressValidatorObj.error === false){
83
+ addressValidator.validateAddress('co-shipping-form', addressValidatorObj.message, addressValidatorObj.data);
84
+
85
+ } else {
86
+ if (addressValidatorObj.data.indexOf('http') != -1) {
87
+ addressValidator.redirectSupport(addressValidatorObj.message, addressValidatorObj.data);
88
+ } else {
89
+ addressValidator.editAddress('co-shipping-form', addressValidatorObj.message);
90
+ }
91
+ return false;
92
+ }
93
+
94
+ } else if (addressValidatorObj.error === false) {
95
+ addressValidator.populate('shipping','co-shipping-form', addressValidatorObj.data);
96
+ }
97
+
98
+ }
99
+ }
100
+
101
+ checkout.setStepResponse(response);
102
+ }
103
+
104
+ };
105
+
106
+ Shipping.addMethods(replaceShippingNextStepObj);
107
+ }