NewHavenSoftware_CMSAPI - Version 9.0.1.12

Version Notes

9.0.1.12 01/20/2014

Updated Saved CC support. Added framework for storing extension data in the Magento database. Depricated the cmsapiCustomFields method. Added the cmsapiCustomFieldsObject method for more advanced usage of custom field data and nested arrays

9.0.1.11 01/08/2014

Updated custom fields to better support 3rd party classes. The third party class needs to support the info method accepting an order increment id as the only parameter

9.0.1.10 11/12/2013

Updated support for size and color products. This update is required for any size and/or color products. Also in this version is a fix for blank screens or errors when attempting to configure roles.

Download this release

Release Info

Developer Jason Morrison
Extension NewHavenSoftware_CMSAPI
Version 9.0.1.12
Comparing to
See all releases


Code changes from version 9.0.1.11 to 9.0.1.12

app/code/community/NewHavenSoftware/CMSAPI/Helper/Data.php CHANGED
@@ -1,6 +1,3 @@
1
  <?php
2
  class NewHavenSoftware_CMSAPI_Helper_Data extends Mage_Core_Helper_Abstract {
3
- function _helperTest() {
4
- Return true;
5
- }
6
  }
1
  <?php
2
  class NewHavenSoftware_CMSAPI_Helper_Data extends Mage_Core_Helper_Abstract {
 
 
 
3
  }
app/code/community/NewHavenSoftware/CMSAPI/Model/Custom/Api/V2.php CHANGED
@@ -1,6 +1,24 @@
1
  <?php
2
  class NewHavenSoftware_CMSAPI_Model_Custom_Api_V2 extends Mage_Api_Model_Resource_Abstract {
3
  public function CustomFields($orderIncrementId,$storeId) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  try {
5
 
6
  /**
@@ -10,8 +28,7 @@ class NewHavenSoftware_CMSAPI_Model_Custom_Api_V2 extends Mage_Api_Model_Resourc
10
  * For the class call to work, the class must accept an order increment ID and have an info method
11
  *
12
  */
13
-
14
- $results = '';
15
  //The path is always in the section/group/field
16
  $customFields = Mage::getStoreConfig('cmsapi/config/customfields',$storeId);
17
  // comma separated list of section.fields for instance
@@ -27,36 +44,68 @@ class NewHavenSoftware_CMSAPI_Model_Custom_Api_V2 extends Mage_Api_Model_Resourc
27
  ->addAttributeToFilter('increment_id', $orderIncrementId)
28
  ->getFirstItem();
29
  foreach ($fields as $field) {
 
30
  $field = trim($field);
31
  if($field <> "") {
32
  if (strpos($field,'=') !== false) {
33
- // we have a global assignment use this value
34
- $results .= $field . ',';
 
 
35
  } else {
36
- if (md5($field) == '59e0b38e37da9ccacccbed1029498761') {
37
- $results .= $field . "=((sales/order)) " . print_r($object,true) . ',';
 
 
 
38
  continue; //skip to next field
39
- }
40
  $objectValue = $this->getCustomFieldValue($object,$field,$orderIncrementId);
41
- $results .= $this->getFieldName($field) . "=" . $objectValue . ',';
 
42
  }
43
  }
44
  }
45
-
46
- $results = rtrim($results, ", \t\n\r\0\x0B"); //Clean up the last comma and any spaces
47
-
48
  return $results;
49
-
50
  } catch (Exception $e) {
51
- return "error=" . $e->getMessage();
 
 
 
52
  }
53
  }
54
- public function getPaymentInfo($paymentId,$process) {
 
 
 
 
55
  $_payment = Mage::getModel('sales/order_payment')->load($paymentId);
56
- if ($_payment->cc_number_enc <> '' && $process === true) {
57
- $_payment->cc_number_enc = Mage::helper('core')->decrypt($_payment->cc_number_enc);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
59
- return $_payment->cc_number_enc;
 
60
  }
61
 
62
  private function getCustomFieldValue($obj,$field,$orderIncID,$delim = '/') {
@@ -127,5 +176,51 @@ class NewHavenSoftware_CMSAPI_Model_Custom_Api_V2 extends Mage_Api_Model_Resourc
127
  return $result;
128
  }
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  }
131
  ?>
1
  <?php
2
  class NewHavenSoftware_CMSAPI_Model_Custom_Api_V2 extends Mage_Api_Model_Resource_Abstract {
3
  public function CustomFields($orderIncrementId,$storeId) {
4
+ /**
5
+ * This is for backwards compatibility to changes in 9.0.1.12
6
+ */
7
+ $results = '';
8
+ $_objects = $this->CustomFieldsObject($orderIncrementId,$storeId);
9
+ foreach($_objects as $_Object) {
10
+ foreach ($_Object->value as $_SubObject) {
11
+ $_tempKey = $_Object->key . "_";
12
+ if ($_Object->key == $_SubObject->key) {
13
+ $_tempKey = '';
14
+ }
15
+ $results .= $_tempKey . $_SubObject->key . '="' . $_SubObject->value . '",';
16
+ }
17
+ }
18
+ $results = rtrim($results, ", \t\n\r\0\x0B"); //Clean up the last comma and any spaces
19
+ return $results;
20
+ }
21
+ public function CustomFieldsObject($orderIncrementId,$storeId) {
22
  try {
23
 
24
  /**
28
  * For the class call to work, the class must accept an order increment ID and have an info method
29
  *
30
  */
31
+ $results = array();
 
32
  //The path is always in the section/group/field
33
  $customFields = Mage::getStoreConfig('cmsapi/config/customfields',$storeId);
34
  // comma separated list of section.fields for instance
44
  ->addAttributeToFilter('increment_id', $orderIncrementId)
45
  ->getFirstItem();
46
  foreach ($fields as $field) {
47
+ $_valueArray = array();
48
  $field = trim($field);
49
  if($field <> "") {
50
  if (strpos($field,'=') !== false) {
51
+ // we have a global assignment use this value
52
+ $_keyValue = explode('=',$field,2);
53
+ $results[] = (object) array('key' => $_keyValue[0],
54
+ 'value' => $this->getValueArray($_keyValue[0],$_keyValue[1]));
55
  } else {
56
+ /*if (md5($field) == '59e0b38e37da9ccacccbed1029498761') {
57
+ $results[] = array('key' => $field,
58
+ 'value' => array('key' => $field,
59
+ 'value' => "((sales/order)) " . print_r($object,true)
60
+ ));
61
  continue; //skip to next field
62
+ }*/
63
  $objectValue = $this->getCustomFieldValue($object,$field,$orderIncrementId);
64
+ $results[] = (object) array('key' => $this->getFieldName($field),
65
+ 'value' => $this->getValueArray($this->getFieldName($field),$objectValue));
66
  }
67
  }
68
  }
 
 
 
69
  return $results;
 
70
  } catch (Exception $e) {
71
+ $results = array();
72
+ $results[] = (object) array('key' => 'error',
73
+ 'value' => $this->getValueArray('error',$e->getMessage()));
74
+ return $results;
75
  }
76
  }
77
+
78
+ public function getCustomPaymentInfo($paymentId,$process) {
79
+ $_newPayment = new stdClass();
80
+ $_newPayment->cc_cid = '';
81
+ $_newPayment->cc_number = '';
82
  $_payment = Mage::getModel('sales/order_payment')->load($paymentId);
83
+ // would not need to call the order (or loop through quote payments) if $_payment->quote_payment_id is not blank
84
+ $_order = Mage::getModel('sales/order')->load($_payment->parent_id);
85
+ $_quotePayments = Mage::getModel('sales/quote_payment')->getCollection()
86
+ ->addFieldToFilter('quote_id',array('eq'=>$_order->quote_id));
87
+ foreach($_quotePayments as $_key => $_value) {
88
+ if($_value->decrypt($_value->cc_number_enc) <> $_value->decrypt($_payment->cc_number_enc)) {
89
+ continue; //if there are multiple payments for this quote, look for the matching card
90
+ }
91
+ //Mage::Log(Mage::getStoreConfig('payment/ccsave/useccv'));
92
+ if ($_value->cc_number_enc <> '' && $process === true) {
93
+ if ($_value->cc_cid_enc <> '') {
94
+ $_newPayment->cc_cid = $_value->decrypt($_value->cc_cid_enc);
95
+ // because quotes are session based I was not able to update the quote data unless loading in a session
96
+ // used the api session to do this and loading the payment -- $_key = quote payment id
97
+ Mage::getSingleton('checkout/session')->unsetAll();
98
+ $_quote = Mage::getSingleton('checkout/session')->getQuote();
99
+ $_quotePayment = $_quote->getPayment()->load($_key);
100
+ $_quotePayment->setCcCidEnc(null); // clear the encrypted cid
101
+ $_quotePayment->save();
102
+ }
103
+ $_newPayment->cc_number = $_value->decrypt($_value->cc_number_enc);
104
+ break; // we found the payment -- break out of the loop
105
+ }
106
  }
107
+ $this->clearOldCidData(7); // always attempt to clean old data older than 7 days
108
+ return $_newPayment;
109
  }
110
 
111
  private function getCustomFieldValue($obj,$field,$orderIncID,$delim = '/') {
176
  return $result;
177
  }
178
 
179
+ private function clearOldCidData($days) {
180
+ // this is only to catch situations were the order does not get cleared during download, or is not downloaded.
181
+ $_daysAgo = -1 * abs($days); // always negative, even if we pass in a negative.
182
+ $_to = date('Y-m-d H:i:s', strtotime($_daysAgo . " days"));
183
+ // get payments that are more than $days old with payment method ccsave and cc_cid_enc is not null
184
+ $_payments = Mage::getSingleton('sales/quote_payment')->getCollection()
185
+ ->addFieldToFilter('method',array('eq'=>'ccsave'))
186
+ ->addFieldToFilter('cc_cid_enc',array('notnull'=>true))
187
+ ->addFieldToFilter('created_at',array('to'=>$_to));
188
+ foreach($_payments as $_key => $_value) {
189
+ try {
190
+ Mage::getSingleton('checkout/session')->unsetAll();
191
+ $_quote = Mage::getSingleton('checkout/session')->getQuote();
192
+ $_quotePayment = $_quote->getPayment()->load($_key);
193
+ $_quotePayment->setCcCidEnc(null);
194
+ $_quotePayment->save();
195
+ } catch(Exception $e) {
196
+ Mage::Log(sprintf('Error attempting to clear the cid value from payment id %d: %s',$_key,$e));
197
+ }
198
+ }
199
+ }
200
+
201
+ private function getValueArray($field,$value) {
202
+ $_result = array();
203
+ $_pattern = '/a\:[0-9]+?\:{.*?}/';
204
+ if (preg_match($_pattern,$value) == 1) {
205
+ // we have a serialized array, unserialize
206
+ $_phpValue = unserialize($value);
207
+ foreach($_phpValue as $_key => $_value) {
208
+ $_result[] = (object) array('key' => $_key,
209
+ 'value' => $_value
210
+ );
211
+ }
212
+ } elseif(is_object($value) || is_array($value)) {
213
+ foreach($value as $_key => $_value) {
214
+ $_result[] = (object) array('key' => $_key,
215
+ 'value' => $_value
216
+ );
217
+ }
218
+ } else {
219
+ $_result[] = (object) array('key' => $field,
220
+ 'value' => $value
221
+ );
222
+ }
223
+ return $_result;
224
+ }
225
  }
226
  ?>
app/code/community/NewHavenSoftware/CMSAPI/Model/Observer.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class NewHavenSoftware_CMSAPI_Model_Observer {
3
+ public function processOrderQueue($observer) {
4
+ }
5
+ }
app/code/community/NewHavenSoftware/CMSAPI/Model/Payment/Method/Ccsave.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class NewHavenSoftware_CMSAPI_Model_Payment_Method_Ccsave extends Mage_Payment_Model_Method_Ccsave {
3
+ public function prepareSave()
4
+ {
5
+ $_canSaveCid = ($this->getConfigData('useccv') == 1);
6
+ //Mage::Log(Mage::getStoreConfig('payment/ccsave/useccv'));
7
+ $info = $this->getInfoInstance();
8
+ if ($this->_canSaveCc && $_canSaveCid) {
9
+ $info->setCcCidEnc($info->encrypt($info->getCcCid())); // this is deleted during download or after 7 days
10
+ $info->setCcCid(null); //do not store the plain text version
11
+ }
12
+ $result = parent::prepareSave();
13
+ return $result;
14
+ }
15
+ }
app/code/community/NewHavenSoftware/CMSAPI/Model/Queue.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class NewHavenSoftware_CMSAPI_Model_Queue extends Mage_Core_Model_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('cmsapi/queue');
7
+ }
8
+ }
app/code/community/NewHavenSoftware/CMSAPI/Model/Resource/Queue.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ class NewHavenSoftware_CMSAPI_Model_Resource_Queue extends Mage_Core_Model_Resource_Db_Abstract{
3
+ protected function _construct()
4
+ {
5
+ $this->_init('cmsapi/queue', 'queue_id');
6
+ }
7
+ }
app/code/community/NewHavenSoftware/CMSAPI/Model/Resource/Setup.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ class NewHavenSoftware_CMSAPI_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
3
+ }
app/code/community/NewHavenSoftware/CMSAPI/Model/Sales/Order/Api/V2.php CHANGED
@@ -10,4 +10,191 @@ class NewHavenSoftware_CMSAPI_Model_Sales_Order_Api_V2 extends Mage_Sales_Model_
10
  }
11
  return $result;
12
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
10
  }
11
  return $result;
12
  }
13
+
14
+
15
+ private $_storeId = '1';
16
+ private $_groupId = '1';
17
+ private $_sendConfirmation = '0';
18
+ private $orderData = array();
19
+ private $_product;
20
+ private $_sourceCustomer;
21
+ //private $_sourceOrder;
22
+
23
+ //public function setOrderInfo(Varien_Object $sourceOrder, Mage_Customer_Model_Customer $sourceCustomer)
24
+ public function create($orderData,$customerEmail,$websiteId)
25
+ {
26
+ $this->_sourceCustomer = Mage::getModel('customer/customer')->setWebsiteId($websiteId);
27
+ $this->_sourceCustomer->loadByEmail($customerEmail);
28
+ //You can extract/refactor this if you have more than one product, etc.
29
+ $this->_product = Mage::getModel('catalog/product')->getCollection()
30
+ ->addAttributeToFilter('sku', 'Some value here...')
31
+ ->addAttributeToSelect('*')
32
+ ->getFirstItem();
33
+ //Load full product data to product object
34
+ $this->_product->load($this->_product->getId());
35
+ $this->orderData = array(
36
+ 'session' => array(
37
+ 'customer_id' => $this->_sourceCustomer->getId(),
38
+ 'store_id' => $this->_storeId,
39
+ ),
40
+ 'payment' => array(
41
+ 'method' => 'checkmo',
42
+ ),
43
+ 'add_products' =>array(
44
+ $this->_product->getId() => array('qty' => 1),
45
+ ),
46
+ 'order' => array(
47
+ 'currency' => 'USD',
48
+ 'account' => array(
49
+ 'group_id' => $this->_groupId,
50
+ 'email' => $this->_sourceCustomer->getEmail()
51
+ ),
52
+ 'billing_address' => array(
53
+ 'customer_address_id' => $this->_sourceCustomer->getCustomerAddressId(),
54
+ 'prefix' => '',
55
+ 'firstname' => $this->_sourceCustomer->getFirstname(),
56
+ 'middlename' => '',
57
+ 'lastname' => $this->_sourceCustomer->getLastname(),
58
+ 'suffix' => '',
59
+ 'company' => '',
60
+ 'street' => array($this->_sourceCustomer->getStreet(),''),
61
+ 'city' => $this->_sourceCustomer->getCity(),
62
+ 'country_id' => $this->_sourceCustomer->getCountryId(),
63
+ 'region' => '',
64
+ 'region_id' => $this->_sourceCustomer->getRegionId(),
65
+ 'postcode' => $this->_sourceCustomer->getPostcode(),
66
+ 'telephone' => $this->_sourceCustomer->getTelephone(),
67
+ 'fax' => '',
68
+ ),
69
+ 'shipping_address' => array(
70
+ 'customer_address_id' => $this->_sourceCustomer->getCustomerAddressId(),
71
+ 'prefix' => '',
72
+ 'firstname' => $this->_sourceCustomer->getFirstname(),
73
+ 'middlename' => '',
74
+ 'lastname' => $this->_sourceCustomer->getLastname(),
75
+ 'suffix' => '',
76
+ 'company' => '',
77
+ 'street' => array($this->_sourceCustomer->getStreet(),''),
78
+ 'city' => $this->_sourceCustomer->getCity(),
79
+ 'country_id' => $this->_sourceCustomer->getCountryId(),
80
+ 'region' => '',
81
+ 'region_id' => $this->_sourceCustomer->getRegionId(),
82
+ 'postcode' => $this->_sourceCustomer->getPostcode(),
83
+ 'telephone' => $this->_sourceCustomer->getTelephone(),
84
+ 'fax' => '',
85
+ ),
86
+ 'shipping_method' => 'flatrate_flatrate',
87
+ 'comment' => array(
88
+ 'customer_note' => 'Imported Order',
89
+ ),
90
+ 'send_confirmation' => $this->_sendConfirmation
91
+ ),
92
+ );
93
+ $this->createImportedOrder();
94
+ }
95
+ /**
96
+ * Retrieve order create model
97
+ *
98
+ * @return Mage_Adminhtml_Model_Sales_Order_Create
99
+ */
100
+ protected function _getOrderCreateModel()
101
+ {
102
+ return Mage::getSingleton('adminhtml/sales_order_create');
103
+ }
104
+ /**
105
+ * Retrieve session object
106
+ *
107
+ * @return Mage_Adminhtml_Model_Session_Quote
108
+ */
109
+ protected function _getSession()
110
+ {
111
+ return Mage::getSingleton('adminhtml/session_quote');
112
+ }
113
+ /**
114
+ * Initialize order creation session data
115
+ *
116
+ * @param array $data
117
+ * @return Mage_Adminhtml_Sales_Order_CreateController
118
+ */
119
+ protected function _initSession($data)
120
+ {
121
+ /* Get/identify customer */
122
+ if (!empty($data['customer_id'])) {
123
+ $this->_getSession()->setCustomerId((int) $data['customer_id']);
124
+ }
125
+ /* Get/identify store */
126
+ if (!empty($data['store_id'])) {
127
+ $this->_getSession()->setStoreId((int) $data['store_id']);
128
+ }
129
+ return $this;
130
+ }
131
+ /**
132
+ * Creates order
133
+ */
134
+ public function createImportedOrder()
135
+ {
136
+ $orderData = $this->orderData;
137
+ if (!empty($orderData)) {
138
+ $this->_initSession($orderData['session']);
139
+ try {
140
+ $this->_processQuote($orderData);
141
+ if (!empty($orderData['payment'])) {
142
+ $this->_getOrderCreateModel()->setPaymentData($orderData['payment']);
143
+ $this->_getOrderCreateModel()->getQuote()->getPayment()->addData($orderData['payment']);
144
+ }
145
+ $item = $this->_getOrderCreateModel()->getQuote()->getItemByProduct($this->_product);
146
+ $item->addOption(new Varien_Object(
147
+ array(
148
+ 'product' => $this->_product,
149
+ 'code' => 'option_ids',
150
+ 'value' => '5' /* Option id goes here. If more options, then comma separate */
151
+ )
152
+ ));
153
+ $item->addOption(new Varien_Object(
154
+ array(
155
+ 'product' => $this->_product,
156
+ 'code' => 'option_5',
157
+ 'value' => 'Some value here'
158
+ )
159
+ ));
160
+ Mage::app()->getStore()->setConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_ENABLED, "0");
161
+ $_order = $this->_getOrderCreateModel()
162
+ ->importPostData($orderData['order'])
163
+ ->createOrder();
164
+ $this->_getSession()->clear();
165
+ Mage::unregister('rule_data');
166
+ return $_order;
167
+ }
168
+ catch (Exception $e){
169
+ Mage::log("Order save error...");
170
+ }
171
+ }
172
+ return null;
173
+ }
174
+ protected function _processQuote($data = array())
175
+ {
176
+ /* Saving order data */
177
+ if (!empty($data['order'])) {
178
+ $this->_getOrderCreateModel()->importPostData($data['order']);
179
+ }
180
+ $this->_getOrderCreateModel()->getBillingAddress();
181
+ $this->_getOrderCreateModel()->setShippingAsBilling(true);
182
+ /* Just like adding products from Magento admin grid */
183
+ if (!empty($data['add_products'])) {
184
+ $this->_getOrderCreateModel()->addProducts($data['add_products']);
185
+ }
186
+ /* Collect shipping rates */
187
+ $this->_getOrderCreateModel()->collectShippingRates();
188
+ /* Add payment data */
189
+ if (!empty($data['payment'])) {
190
+ $this->_getOrderCreateModel()->getQuote()->getPayment()->addData($data['payment']);
191
+ }
192
+ $this->_getOrderCreateModel()
193
+ ->initRuleData()
194
+ ->saveQuote();
195
+ if (!empty($data['payment'])) {
196
+ $this->_getOrderCreateModel()->getQuote()->getPayment()->addData($data['payment']);
197
+ }
198
+ return $this;
199
+ }
200
  }
app/code/community/NewHavenSoftware/CMSAPI/etc/api.xml CHANGED
@@ -14,7 +14,7 @@
14
  </nhsInstalled>
15
  <version translate="title" module="cmsapi">
16
  <title>Return the extension version</title>
17
- <acl>cmsapi/version</acl>
18
  <method>getExtensionVersion</method>
19
  </version>
20
  </methods>
@@ -29,10 +29,15 @@
29
  <acl>cmsapi/fields</acl>
30
  <method>CustomFields</method>
31
  </fields>
 
 
 
 
 
32
  <payment>
33
  <title>Given a payment id will return payment info</title>
34
  <acl>cmsapi/payment</acl>
35
- <method>getPaymentInfo</method>
36
  </payment>
37
  </methods>
38
  </cmsapi_custom>
@@ -123,7 +128,7 @@
123
  <fields translate="title" module="cmsapi">
124
  <title>Custom Fields</title>
125
  </fields>
126
- <payment>
127
  <title>Extended Payment Info</title>
128
  </payment>
129
  <info translate="title" module="cmsapi">
14
  </nhsInstalled>
15
  <version translate="title" module="cmsapi">
16
  <title>Return the extension version</title>
17
+ <acl>cmsapi/version</acl>custom
18
  <method>getExtensionVersion</method>
19
  </version>
20
  </methods>
29
  <acl>cmsapi/fields</acl>
30
  <method>CustomFields</method>
31
  </fields>
32
+ <fieldsObject translate="title" module="cmsapi">
33
+ <title>This will return the custom fields in an array object</title>
34
+ <acl>cmsapi/fields</acl>
35
+ <method>CustomFieldsObject</method>
36
+ </fieldsObject>
37
  <payment>
38
  <title>Given a payment id will return payment info</title>
39
  <acl>cmsapi/payment</acl>
40
+ <method>getCustomPaymentInfo</method>
41
  </payment>
42
  </methods>
43
  </cmsapi_custom>
128
  <fields translate="title" module="cmsapi">
129
  <title>Custom Fields</title>
130
  </fields>
131
+ <payment translate="title" module="cmsapi">
132
  <title>Extended Payment Info</title>
133
  </payment>
134
  <info translate="title" module="cmsapi">
app/code/community/NewHavenSoftware/CMSAPI/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
  <config>
4
  <modules>
5
  <NewHavenSoftware_CMSAPI>
6
- <version>9.0.1.11</version>
7
  </NewHavenSoftware_CMSAPI>
8
  </modules>
9
  <adminhtml>
@@ -31,7 +31,16 @@
31
  <models>
32
  <cmsapi>
33
  <class>NewHavenSoftware_CMSAPI_Model</class>
 
34
  </cmsapi>
 
 
 
 
 
 
 
 
35
  <catalog>
36
  <rewrite>
37
  <product_api_v2>NewHavenSoftware_CMSAPI_Model_Catalog_Product_Api_V2</product_api_v2>
@@ -42,11 +51,36 @@
42
  <order_api_v2>NewHavenSoftware_CMSAPI_Model_Sales_Order_Api_V2</order_api_v2>
43
  </rewrite>
44
  </sales>
 
 
 
 
 
45
  </models>
46
- <helpers>
47
- <cmsapi>
48
- <class>NewHavenSoftware_CMSAPI_Helper</class>
49
- </cmsapi>
50
- </helpers>
 
 
 
 
 
 
 
 
51
  </global>
 
 
 
 
 
 
 
 
 
 
 
 
52
  </config>
3
  <config>
4
  <modules>
5
  <NewHavenSoftware_CMSAPI>
6
+ <version>9.0.1.12</version>
7
  </NewHavenSoftware_CMSAPI>
8
  </modules>
9
  <adminhtml>
31
  <models>
32
  <cmsapi>
33
  <class>NewHavenSoftware_CMSAPI_Model</class>
34
+ <resourceModel>cmsapi_resource</resourceModel>
35
  </cmsapi>
36
+ <cmsapi_resource>
37
+ <class>NewHavenSoftware_CMSAPI_Model_Resource</class>
38
+ <entities>
39
+ <queue>
40
+ <table>cmsapi_queue</table>
41
+ </queue>
42
+ </entities>
43
+ </cmsapi_resource>
44
  <catalog>
45
  <rewrite>
46
  <product_api_v2>NewHavenSoftware_CMSAPI_Model_Catalog_Product_Api_V2</product_api_v2>
51
  <order_api_v2>NewHavenSoftware_CMSAPI_Model_Sales_Order_Api_V2</order_api_v2>
52
  </rewrite>
53
  </sales>
54
+ <payment>
55
+ <rewrite>
56
+ <method_ccsave>NewHavenSoftware_CMSAPI_Model_Payment_Method_Ccsave</method_ccsave>
57
+ </rewrite>
58
+ </payment>
59
  </models>
60
+ <helpers>
61
+ <cmsapi>
62
+ <class>NewHavenSoftware_CMSAPI_Helper</class>
63
+ </cmsapi>
64
+ </helpers>
65
+ <resources>
66
+ <cmsapi_setup>
67
+ <setup>
68
+ <module>NewHavenSoftware_CMSAPI</module>
69
+ <class>NewHavenSoftware_CMSAPI_Model_Resource_Setup</class>
70
+ </setup>
71
+ </cmsapi_setup>
72
+ </resources>
73
  </global>
74
+ <crontab>
75
+ <jobs>
76
+ <NewHavenSoftware_CMSAPI>
77
+ <schedule>
78
+ <cron_expr>0 0 * * 0</cron_expr>
79
+ </schedule>
80
+ <run>
81
+ <model>cmsapi/observer::processOrderQueue</model>
82
+ </run>
83
+ </NewHavenSoftware_CMSAPI>
84
+ </jobs>
85
+ </crontab>
86
  </config>
app/code/community/NewHavenSoftware/CMSAPI/etc/wsdl.xml CHANGED
@@ -33,6 +33,19 @@ name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}" xmlns:ns0="urn:
33
  </restriction>
34
  </complexContent>
35
  </complexType>
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  <complexType name="catalogProductConfigurableAttributeArray">
37
  <complexContent>
38
  <restriction base="soapenc:Array">
@@ -66,6 +79,12 @@ name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}" xmlns:ns0="urn:
66
  <element name="message" type="xsd:string" />
67
  </all>
68
  </complexType>
 
 
 
 
 
 
69
  </schema>
70
  </types>
71
  <message name="cmsapiCustomFieldsRequest">
@@ -76,13 +95,21 @@ name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}" xmlns:ns0="urn:
76
  <message name="cmsapiCustomFieldsResponse">
77
  <part name="result" type="xsd:string"/>
78
  </message>
 
 
 
 
 
 
 
 
79
  <message name="cmsapiCustomPaymentRequest">
80
  <part name="sessionId" type="xsd:string"/>
81
  <part name="paymentId" type="xsd:string"/>
82
  <part name="process" type="xsd:boolean"/>
83
  </message>
84
  <message name="cmsapiCustomPaymentResponse">
85
- <part name="result" type="xsd:string"/>
86
  </message>
87
  <message name="cmsapiGiftMessageInfoRequest">
88
  <part name="sessionId" type="xsd:string"/>
@@ -119,6 +146,11 @@ name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}" xmlns:ns0="urn:
119
  <input name="cmsapiCustomFieldsRequest" message="typens:cmsapiCustomFieldsRequest"/>
120
  <output name="cmsapiCustomFieldsResponse" message="typens:cmsapiCustomFieldsResponse"/>
121
  </operation>
 
 
 
 
 
122
  <operation name="cmsapiCustomPayment">
123
  <documentation>This will return a custom payment entity</documentation>
124
  <input name="cmsapiCustomPaymentRequest" message="typens:cmsapiCustomPaymentRequest"/>
@@ -159,6 +191,15 @@ name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}" xmlns:ns0="urn:
159
  <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
160
  </output>
161
  </operation>
 
 
 
 
 
 
 
 
 
162
  <operation name="cmsapiCustomPayment">
163
  <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
164
  <input>
33
  </restriction>
34
  </complexContent>
35
  </complexType>
36
+ <complexType name="associativeNestedEntity">
37
+ <all>
38
+ <element name="key" type="xsd:string" />
39
+ <element name="value" type="typens:associativeArray" />
40
+ </all>
41
+ </complexType>
42
+ <complexType name="associativeNestedArray">
43
+ <complexContent>
44
+ <restriction base="soapenc:Array">
45
+ <attribute ref="soapenc:arrayType" wsdl:arrayType="typens:associativeNestedEntity[]" />
46
+ </restriction>
47
+ </complexContent>
48
+ </complexType>
49
  <complexType name="catalogProductConfigurableAttributeArray">
50
  <complexContent>
51
  <restriction base="soapenc:Array">
79
  <element name="message" type="xsd:string" />
80
  </all>
81
  </complexType>
82
+ <complexType name="cmsapiPaymentEntity">
83
+ <all>
84
+ <element name="cc_cid" type="xsd:string" />
85
+ <element name="cc_number" type="xsd:string" />
86
+ </all>
87
+ </complexType>
88
  </schema>
89
  </types>
90
  <message name="cmsapiCustomFieldsRequest">
95
  <message name="cmsapiCustomFieldsResponse">
96
  <part name="result" type="xsd:string"/>
97
  </message>
98
+ <message name="cmsapiCustomFieldsObjectRequest">
99
+ <part name="sessionId" type="xsd:string"/>
100
+ <part name="orderIncrementId" type="xsd:string"/>
101
+ <part name="storeId" type="xsd:string"/>
102
+ </message>
103
+ <message name="cmsapiCustomFieldsObjectResponse">
104
+ <part name="result" type="typens:associativeNestedArray"/>
105
+ </message>
106
  <message name="cmsapiCustomPaymentRequest">
107
  <part name="sessionId" type="xsd:string"/>
108
  <part name="paymentId" type="xsd:string"/>
109
  <part name="process" type="xsd:boolean"/>
110
  </message>
111
  <message name="cmsapiCustomPaymentResponse">
112
+ <part name="result" type="typens:cmsapiPaymentEntity"/>
113
  </message>
114
  <message name="cmsapiGiftMessageInfoRequest">
115
  <part name="sessionId" type="xsd:string"/>
146
  <input name="cmsapiCustomFieldsRequest" message="typens:cmsapiCustomFieldsRequest"/>
147
  <output name="cmsapiCustomFieldsResponse" message="typens:cmsapiCustomFieldsResponse"/>
148
  </operation>
149
+ <operation name="cmsapiCustomFieldsObject">
150
+ <documentation>This will return the custom fields in an array object</documentation>
151
+ <input name="cmsapiCustomFieldsObjectRequest" message="typens:cmsapiCustomFieldsObjectRequest"/>
152
+ <output name="cmsapiCustomFieldsObjectResponse" message="typens:cmsapiCustomFieldsObjectResponse"/>
153
+ </operation>
154
  <operation name="cmsapiCustomPayment">
155
  <documentation>This will return a custom payment entity</documentation>
156
  <input name="cmsapiCustomPaymentRequest" message="typens:cmsapiCustomPaymentRequest"/>
191
  <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
192
  </output>
193
  </operation>
194
+ <operation name="cmsapiCustomFieldsObject">
195
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
196
+ <input>
197
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
198
+ </input>
199
+ <output>
200
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
201
+ </output>
202
+ </operation>
203
  <operation name="cmsapiCustomPayment">
204
  <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
205
  <input>
app/code/community/NewHavenSoftware/CMSAPI/sql/cmsapi_setup/install-9.0.1.12.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ if (!$installer->tableExists($installer->getTable('cmsapi/queue'))) {
5
+ $table = $installer->getConnection()->newTable($installer->getTable('cmsapi/queue'))
6
+ ->addColumn('queue_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
7
+ 'unsigned' => true,
8
+ 'nullable' => false,
9
+ 'primary' => true,
10
+ 'identity' => true,
11
+ ), 'Queue ID')
12
+ ->addColumn('order_increment_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50, array(
13
+ 'nullable' => true,
14
+ ), 'Order Increment ID')
15
+ ->addColumn('data_type', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50, array(
16
+ 'nullable' => true,
17
+ ), 'the data type as defined in the api wsdl')
18
+ ->addColumn('data_serialization_type', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50, array(
19
+ 'nullable' => true,
20
+ ), 'how the data was serialized: json,php,xml,wddx')
21
+ ->addColumn('data_serialized', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
22
+ 'nullable' => true,
23
+ ), 'serialized string of the object see the data serialization type for how it was serialized')
24
+ ->addColumn('date', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
25
+ ), 'Date')
26
+ ->setComment('NewHaven Software CMSAPI queue table for processing objects in cron');
27
+ $installer->getConnection()->createTable($table);
28
+ }
29
+ $installer->endSetup();
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>NewHavenSoftware_CMSAPI</name>
4
- <version>9.0.1.11</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -11,25 +11,26 @@
11
  &#xD;
12
  Adds the following to the v2 API:&#xD;
13
  &lt;ol&gt;&lt;ul&gt;&lt;strong&gt;cmsapiChecknhsInstalled:&lt;/strong&gt; To verify this extension has been added to the API&lt;/ul&gt;&#xD;
14
- &lt;ul&gt;&lt;strong&gt;cmsapiCustomFields:&lt;/strong&gt; This API call is used to get order level data based on the fields entered in System Configuration that may not be published in the v2 API&lt;/ul&gt;&#xD;
 
15
  &lt;ul&gt;&lt;strong&gt;cmsapiGiftMessageInfo:&lt;/strong&gt; This API call is used to gain access to the "To" and "From" fields used in gift messages&lt;/ul&gt;&#xD;
16
  &lt;ul&gt;Extend &lt;strong&gt;catalogProductCreate:&lt;/strong&gt; to allow the passing of additional productdata fields: configurable_products and configurable_attributes (structure documented in the wsdl) &lt;/ul&gt;&#xD;
17
  &lt;ul&gt;Extend &lt;strong&gt;salesProductInfo:&lt;/strong&gt; for items the product_options property was changed to json (from serialized php). This is required for downloading orders containing configurable products&lt;/ul&gt;&#xD;
18
  &lt;/ol&gt;&#xD;
19
  &#xD;
20
  This extension is recommended for integration with the CMS eCMS module.&lt;br /&gt;&lt;br /&gt;</description>
21
- <notes>&lt;strong&gt;9.0.1.11&lt;/strong&gt; 01/08/2014&lt;br /&gt;&#xD;
 
 
 
22
  Updated custom fields to better support 3rd party classes. The third party class needs to support the info method accepting an order increment id as the only parameter&lt;br /&gt;&lt;br /&gt;&#xD;
23
  &#xD;
24
  &lt;strong&gt;9.0.1.10&lt;/strong&gt; 11/12/2013&lt;br /&gt;&#xD;
25
- Updated support for size and color products. This update is required for any size and/or color products. Also in this version is a fix for blank screens or errors when attempting to configure roles. &lt;br /&gt;&lt;br /&gt;&#xD;
26
- &#xD;
27
- &lt;strong&gt;9.0.1.9&lt;/strong&gt; 10/14/2013&lt;br /&gt;&#xD;
28
- In the V2 API changed the salesOrderInfo item.product_options from serialized php to json text for configurable product attribute information used during order download into CMS.&lt;br /&gt;&lt;br /&gt;</notes>
29
  <authors><author><name>Jason Morrison</name><user>nhsjason</user><email>jmorrison@newhavensoftware.com</email></author></authors>
30
- <date>2014-01-08</date>
31
- <time>23:26:33</time>
32
- <contents><target name="magecommunity"><dir name="NewHavenSoftware"><dir name="CMSAPI"><dir name="Helper"><file name="Data.php" hash="d2b766dc9b2531da8a84213dcec33776"/></dir><dir name="Model"><dir name="Catalog"><dir name="Product"><dir name="Api"><file name="V2.php" hash="4bb4f10d96309b7adcf6f5e3cadb0450"/></dir></dir></dir><dir name="Check"><dir name="Api"><file name="V2.php" hash="f589ff6d45ee96855afe53461092813e"/></dir></dir><dir name="Custom"><dir name="Api"><file name="V2.php" hash="ca3413348381782f660ba30eb51a5e4a"/></dir></dir><dir name="Gift"><dir name="Message"><dir name="Api"><file name="V2.php" hash="0a5ffdd3fc3760b311970169858d5475"/></dir></dir></dir><dir name="Sales"><dir name="Order"><dir name="Api"><file name="V2.php" hash="03443ab449fb867f4a5bb08877bea5d6"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="ba4c36dbd3d346c3561fb5822d5fd3b4"/><file name="api.xml" hash="d60a74b7cefdcdcc5ac51f425dc5ce14"/><file name="config.xml" hash="dda40dd87ee3ec3873401d1749b9efb3"/><file name="system.xml" hash="3e71dda77aa28dd02afc40816ecd908e"/><file name="wsdl.xml" hash="d0bc71bbdae1de15040a367396313d70"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="NewHavenSoftware_CMSAPI.xml" hash="4c5fe5d61b389c00a8e54970a29017a0"/></dir></target></contents>
33
  <compatible/>
34
  <dependencies><required><php><min>5.1.0</min><max>5.5.6</max></php></required></dependencies>
35
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>NewHavenSoftware_CMSAPI</name>
4
+ <version>9.0.1.12</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
11
  &#xD;
12
  Adds the following to the v2 API:&#xD;
13
  &lt;ol&gt;&lt;ul&gt;&lt;strong&gt;cmsapiChecknhsInstalled:&lt;/strong&gt; To verify this extension has been added to the API&lt;/ul&gt;&#xD;
14
+ &lt;ul&gt;&lt;strong&gt;cmsapiCustomFieldsObject:&lt;/strong&gt; This API call is used to get order level data based on the fields entered in System Configuration that may not be published in the v2 API. This function returns an object array of key value pairs.&lt;/ul&gt;&#xD;
15
+ &lt;ul&gt;&lt;strong&gt;cmsapiCustomPayment:&lt;/strong&gt; This API call allows CMS to pull in payments that are using the Saved CC payment method&lt;/ul&gt;&#xD;
16
  &lt;ul&gt;&lt;strong&gt;cmsapiGiftMessageInfo:&lt;/strong&gt; This API call is used to gain access to the "To" and "From" fields used in gift messages&lt;/ul&gt;&#xD;
17
  &lt;ul&gt;Extend &lt;strong&gt;catalogProductCreate:&lt;/strong&gt; to allow the passing of additional productdata fields: configurable_products and configurable_attributes (structure documented in the wsdl) &lt;/ul&gt;&#xD;
18
  &lt;ul&gt;Extend &lt;strong&gt;salesProductInfo:&lt;/strong&gt; for items the product_options property was changed to json (from serialized php). This is required for downloading orders containing configurable products&lt;/ul&gt;&#xD;
19
  &lt;/ol&gt;&#xD;
20
  &#xD;
21
  This extension is recommended for integration with the CMS eCMS module.&lt;br /&gt;&lt;br /&gt;</description>
22
+ <notes>&lt;strong&gt;9.0.1.12&lt;/strong&gt; 01/20/2014&lt;br /&gt;&#xD;
23
+ Updated Saved CC support. Added framework for storing extension data in the Magento database. Depricated the cmsapiCustomFields method. Added the cmsapiCustomFieldsObject method for more advanced usage of custom field data and nested arrays&lt;br /&gt;&lt;br /&gt;&#xD;
24
+ &#xD;
25
+ &lt;strong&gt;9.0.1.11&lt;/strong&gt; 01/08/2014&lt;br /&gt;&#xD;
26
  Updated custom fields to better support 3rd party classes. The third party class needs to support the info method accepting an order increment id as the only parameter&lt;br /&gt;&lt;br /&gt;&#xD;
27
  &#xD;
28
  &lt;strong&gt;9.0.1.10&lt;/strong&gt; 11/12/2013&lt;br /&gt;&#xD;
29
+ Updated support for size and color products. This update is required for any size and/or color products. Also in this version is a fix for blank screens or errors when attempting to configure roles. &lt;br /&gt;&lt;br /&gt;</notes>
 
 
 
30
  <authors><author><name>Jason Morrison</name><user>nhsjason</user><email>jmorrison@newhavensoftware.com</email></author></authors>
31
+ <date>2014-08-28</date>
32
+ <time>18:22:05</time>
33
+ <contents><target name="magecommunity"><dir name="NewHavenSoftware"><dir name="CMSAPI"><dir name="Helper"><file name="Data.php" hash="c0802d9a61543d36c4afea5a24038e99"/></dir><dir name="Model"><dir name="Catalog"><dir name="Product"><dir name="Api"><file name="V2.php" hash="4bb4f10d96309b7adcf6f5e3cadb0450"/></dir></dir></dir><dir name="Check"><dir name="Api"><file name="V2.php" hash="f589ff6d45ee96855afe53461092813e"/></dir></dir><dir name="Custom"><dir name="Api"><file name="V2.php" hash="9fc895c87b6d6f66859d2de0528c778e"/></dir></dir><dir name="Gift"><dir name="Message"><dir name="Api"><file name="V2.php" hash="0a5ffdd3fc3760b311970169858d5475"/></dir></dir></dir><file name="Observer.php" hash="e0dd0d6633c7444e92c0caaed3228ff4"/><dir name="Payment"><dir name="Method"><file name="Ccsave.php" hash="45b452bb026658506b26645b1b0c0cec"/></dir></dir><file name="Queue.php" hash="5a0e876dbd9aff660a9bc1fc83c1ce1a"/><dir name="Resource"><file name="Queue.php" hash="92f454caba9979af5e61eedbf4524cf4"/><file name="Setup.php" hash="42c3233e31ecd255e117d1781d9ed08d"/></dir><dir name="Sales"><dir name="Order"><dir name="Api"><file name="V2.php" hash="86bbc553d3784a7afe4810af21e6a709"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="ba4c36dbd3d346c3561fb5822d5fd3b4"/><file name="api.xml" hash="b85ff9958eaa56058461773b619274c1"/><file name="config.xml" hash="1c4f081cef3b8a0d78eaafcf39345c29"/><file name="system.xml" hash="3e71dda77aa28dd02afc40816ecd908e"/><file name="wsdl.xml" hash="a22c14c3adf8405c96ce53dbbfc7332c"/></dir><dir name="sql"><dir name="cmsapi_setup"><file name="install-9.0.1.12.php" hash="0c411170976bee3cabda7c3699588505"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="NewHavenSoftware_CMSAPI.xml" hash="4c5fe5d61b389c00a8e54970a29017a0"/></dir></target></contents>
34
  <compatible/>
35
  <dependencies><required><php><min>5.1.0</min><max>5.5.6</max></php></required></dependencies>
36
  </package>