nypwidget - Version 2.5.0

Version Notes

Order callback improvements and bugfixes.

Download this release

Release Info

Developer PriceWaiter
Extension nypwidget
Version 2.5.0
Comparing to
See all releases


Code changes from version 2.2.2 to 2.5.0

Files changed (52) hide show
  1. app/code/community/PriceWaiter/NYPWidget/Block/Adminhtml/Link.php +0 -17
  2. app/code/community/PriceWaiter/NYPWidget/Block/Adminhtml/Signup.php +0 -17
  3. app/code/community/PriceWaiter/NYPWidget/Block/Adminhtml/Widget.php +0 -17
  4. app/code/community/PriceWaiter/NYPWidget/Block/Category.php +0 -17
  5. app/code/community/PriceWaiter/NYPWidget/Block/Payment/Info/Pricewaiter.php +101 -0
  6. app/code/community/PriceWaiter/NYPWidget/Block/Widget.php +0 -17
  7. app/code/community/PriceWaiter/NYPWidget/Exception/Abstract.php +36 -0
  8. app/code/community/PriceWaiter/NYPWidget/Exception/ApiKey.php +16 -0
  9. app/code/community/PriceWaiter/NYPWidget/Exception/DuplicateOrder.php +25 -0
  10. app/code/community/PriceWaiter/NYPWidget/Exception/InvalidOrderData.php +17 -0
  11. app/code/community/PriceWaiter/NYPWidget/Exception/InvalidRegion.php +30 -0
  12. app/code/community/PriceWaiter/NYPWidget/Exception/OutOfStock.php +10 -0
  13. app/code/community/PriceWaiter/NYPWidget/Exception/Product/Abstract.php +9 -0
  14. app/code/community/PriceWaiter/NYPWidget/Exception/Product/NotFound.php +10 -0
  15. app/code/community/PriceWaiter/NYPWidget/Exception/Signature.php +11 -0
  16. app/code/community/PriceWaiter/NYPWidget/Helper/Data.php +89 -41
  17. app/code/community/PriceWaiter/NYPWidget/Model/Callback.php +782 -284
  18. app/code/community/PriceWaiter/NYPWidget/Model/Callback/Inventory.php +74 -0
  19. app/code/community/PriceWaiter/NYPWidget/Model/Carrier/ShippingMethod.php +0 -17
  20. app/code/community/PriceWaiter/NYPWidget/Model/Category.php +0 -17
  21. app/code/community/PriceWaiter/NYPWidget/Model/Display/Phrase.php +0 -17
  22. app/code/community/PriceWaiter/NYPWidget/Model/Display/Size.php +0 -17
  23. app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Category.php +0 -17
  24. app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Category/Collection.php +0 -17
  25. app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Order.php +0 -17
  26. app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Order/Collection.php +0 -17
  27. app/code/community/PriceWaiter/NYPWidget/Model/Observer.php +0 -17
  28. app/code/community/PriceWaiter/NYPWidget/Model/Order.php +21 -18
  29. app/code/community/PriceWaiter/NYPWidget/Model/PaymentMethod.php +91 -18
  30. app/code/community/PriceWaiter/NYPWidget/Model/Resource/Eav/Mysql4/Setup.php +0 -17
  31. app/code/community/PriceWaiter/NYPWidget/controllers/Adminhtml/PricewaiterController.php +0 -17
  32. app/code/community/PriceWaiter/NYPWidget/controllers/CallbackController.php +53 -39
  33. app/code/community/PriceWaiter/NYPWidget/controllers/ProductinfoController.php +6 -17
  34. app/code/community/PriceWaiter/NYPWidget/etc/adminhtml.xml +0 -15
  35. app/code/community/PriceWaiter/NYPWidget/etc/config.xml +5 -18
  36. app/code/community/PriceWaiter/NYPWidget/etc/system.xml +25 -17
  37. app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-install-1.0.0.php +0 -16
  38. app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.1.2-1.1.3.php +0 -16
  39. app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.1.7-1.1.8.php +0 -16
  40. app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.2.4-1.2.5.php +0 -16
  41. app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.3.0-1.3.1.php +0 -16
  42. app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-2.1.5-2.2.0.php +0 -16
  43. app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-2.2.0-2.5.0.php +42 -0
  44. app/design/adminhtml/default/default/layout/pricewaiter.xml +0 -15
  45. app/design/adminhtml/default/default/template/pricewaiter/categorytab.phtml +0 -18
  46. app/design/frontend/base/default/layout/pricewaiter.xml +0 -15
  47. app/design/frontend/base/default/template/pricewaiter/widget.phtml +0 -18
  48. app/etc/modules/PriceWaiter_NYPWidget.xml +0 -15
  49. js/pricewaiter/product-pages.js +1 -22
  50. js/pricewaiter/token.js +0 -18
  51. package.xml +7 -7
  52. skin/adminhtml/default/default/pricewaiter.css +0 -16
app/code/community/PriceWaiter/NYPWidget/Block/Adminhtml/Link.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Block_Adminhtml_Link extends Varien_Data_Form_Element_Link implements Varien_Data_Form_Element_Renderer_Interface
21
  {
22
  public function render(Varien_Data_Form_Element_Abstract $element)
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Block_Adminhtml_Link extends Varien_Data_Form_Element_Link implements Varien_Data_Form_Element_Renderer_Interface
4
  {
5
  public function render(Varien_Data_Form_Element_Abstract $element)
app/code/community/PriceWaiter/NYPWidget/Block/Adminhtml/Signup.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Block_Adminhtml_Signup extends Mage_Adminhtml_Block_System_Config_Form_Field
21
  {
22
  protected function _construct()
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Block_Adminhtml_Signup extends Mage_Adminhtml_Block_System_Config_Form_Field
4
  {
5
  protected function _construct()
app/code/community/PriceWaiter/NYPWidget/Block/Adminhtml/Widget.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Block_Adminhtml_Widget extends Mage_Adminhtml_Block_Abstract
21
  {
22
  public function _getHelper()
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Block_Adminhtml_Widget extends Mage_Adminhtml_Block_Abstract
4
  {
5
  public function _getHelper()
app/code/community/PriceWaiter/NYPWidget/Block/Category.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Block_Category extends Mage_Adminhtml_Block_Template
21
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
22
  {
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Block_Category extends Mage_Adminhtml_Block_Template
4
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
5
  {
app/code/community/PriceWaiter/NYPWidget/Block/Payment/Info/Pricewaiter.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Block used to display PriceWaiter payment details.
5
+ */
6
+ class PriceWaiter_NYPWidget_Block_Payment_Info_Pricewaiter extends Mage_Payment_Block_Info
7
+ {
8
+ /**
9
+ * @return String
10
+ */
11
+ public function getCcLast4()
12
+ {
13
+ $info = $this->getInfo();
14
+ return $info ? $info->getCcLast4() : '';
15
+ }
16
+
17
+ /**
18
+ * @return String
19
+ */
20
+ public function getCcTypeName()
21
+ {
22
+ $types = Mage::getSingleton('payment/config')->getCcTypes();
23
+ $ccType = $this->getInfo()->getCcType();
24
+
25
+ if (!$ccType) {
26
+ return '';
27
+ }
28
+
29
+ if (isset($types[$ccType])) {
30
+ return $types[$ccType];
31
+ }
32
+
33
+ return (empty($ccType)) ? Mage::helper('payment')->__('N/A') : $ccType;
34
+ }
35
+
36
+ /**
37
+ * @return String|false The full name of the payment method used on PriceWaiter.
38
+ */
39
+ public function getPriceWaiterPaymentMethodName()
40
+ {
41
+ $payment = $this->getInfo();
42
+
43
+ // HACK: We stash PW payment method information (serialized) in the
44
+ // "additional data" field on payment.
45
+
46
+ $data = $payment->getAdditionalData();
47
+ $data = $data ? @unserialize($data) : $data;
48
+ $data = is_array($data) ? $data : array();
49
+
50
+ if (isset($data['pricewaiter_payment_method_nice'])) {
51
+ return $data['pricewaiter_payment_method_nice'];
52
+ }
53
+
54
+ if (isset($data['pricewaiter_payment_method'])) {
55
+ return ucfirst($data['pricewaiter_payment_method']);
56
+ }
57
+
58
+ return false;
59
+ }
60
+
61
+ /**
62
+ * Prepare credit card related payment info
63
+ *
64
+ * @param Varien_Object|array $transport
65
+ * @return Varien_Object
66
+ */
67
+ protected function _prepareSpecificInformation($transport = null)
68
+ {
69
+ // This is adapted from Mage_Payment_Block_Info_Cc
70
+
71
+ if ($this->_paymentSpecificInformation !== null) {
72
+ return $this->_paymentSpecificInformation;
73
+ }
74
+
75
+ /**
76
+ * @var Mage_Payment_Helper_Data
77
+ */
78
+ $p = Mage::helper('payment');
79
+
80
+ $transport = parent::_prepareSpecificInformation($transport);
81
+ $data = array();
82
+
83
+ $method = $this->getPriceWaiterPaymentMethodName();
84
+ if ($method) {
85
+ $data[$p->__('Paid via')] = $method;
86
+ }
87
+
88
+ $ccType = $this->getCcTypeName();
89
+ if ($ccType) {
90
+ $data[$p->__('Credit Card Type')] = $ccType;
91
+ }
92
+
93
+ $ccLast4 = $this->getCcLast4();
94
+
95
+ if ($ccLast4) {
96
+ $data[$p->__('Credit Card Number')] = sprintf('xxxx-%s', $ccLast4);
97
+ }
98
+
99
+ return $transport->setData(array_merge($data, $transport->getData()));
100
+ }
101
+ }
app/code/community/PriceWaiter/NYPWidget/Block/Widget.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Block_Widget extends Mage_Core_Block_Template
21
  {
22
  public function _getHelper()
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Block_Widget extends Mage_Core_Block_Template
4
  {
5
  public function _getHelper()
app/code/community/PriceWaiter/NYPWidget/Exception/Abstract.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Base for implementing exceptions to be thrown by the PriceWaiter extension.
5
+ */
6
+ abstract class PriceWaiter_NYPWidget_Exception_Abstract extends RuntimeException
7
+ {
8
+ /**
9
+ * Unchanging error code to be reported back to clients.
10
+ * This is a string, favored over PHP's built-in int `code` property.
11
+ * @var String
12
+ */
13
+ public $errorCode;
14
+
15
+ /**
16
+ * HTTP status code to be used when reporting this error back to the client.
17
+ * @var integer
18
+ */
19
+ public $httpStatusCode = 400;
20
+
21
+ /**
22
+ * @return Array Representation of this error, ready to be passed to json_encode.
23
+ */
24
+ public function jsonSerialize()
25
+ {
26
+ $json = array(
27
+ 'message' => $this->getMessage(),
28
+ );
29
+
30
+ if ($this->errorCode) {
31
+ $json['code'] = $this->errorCode;
32
+ }
33
+
34
+ return $json;
35
+ }
36
+ }
app/code/community/PriceWaiter/NYPWidget/Exception/ApiKey.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception thrown when an incoming PriceWaiter API key does not match any
5
+ * store in the system.
6
+ */
7
+ class PriceWaiter_NYPWidget_Exception_ApiKey
8
+ extends PriceWaiter_NYPWidget_Exception_Abstract
9
+ {
10
+ public $errorCode = 'invalid_api_key';
11
+
12
+ public function __construct()
13
+ {
14
+ parent::__construct('An invalid PriceWaiter API key was detected.');
15
+ }
16
+ }
app/code/community/PriceWaiter/NYPWidget/Exception/DuplicateOrder.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception thrown when an order already exists for an incoming order callback request.
5
+ */
6
+ class PriceWaiter_NYPWidget_Exception_DuplicateOrder
7
+ extends PriceWaiter_NYPWidget_Exception_Abstract
8
+ {
9
+ public $errorCode = 'duplicate_order';
10
+
11
+ public function __construct(PriceWaiter_NYPWidget_Model_Order $existingOrder)
12
+ {
13
+ $id = $this->data['existing_order_id'] = $existingOrder->getId();
14
+
15
+ parent::__construct(sprintf(
16
+ 'Duplicate order callback detected: Order %s already exists.',
17
+ $id
18
+ ));
19
+ }
20
+
21
+ public function getExistingOrderId()
22
+ {
23
+ return $this->data['existing_order_id'];
24
+ }
25
+ }
app/code/community/PriceWaiter/NYPWidget/Exception/InvalidOrderData.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception thrown when an incoming order callback request cannot be validated.
5
+ */
6
+ class PriceWaiter_NYPWidget_Exception_InvalidOrderData
7
+ extends PriceWaiter_NYPWidget_Exception_Abstract
8
+ {
9
+ public $errorCode = 'invalid_order_data';
10
+
11
+ public function __construct()
12
+ {
13
+ parent::__construct(
14
+ 'An invalid PriceWaiter order notification has been received.'
15
+ );
16
+ }
17
+ }
app/code/community/PriceWaiter/NYPWidget/Exception/InvalidRegion.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception thrown when an order comes in for a geographic region we don't know about.
5
+ */
6
+ class PriceWaiter_NYPWidget_Exception_InvalidRegion
7
+ extends PriceWaiter_NYPWidget_Exception_Abstract
8
+ {
9
+ public $errorCode = 'invalid_region';
10
+
11
+ /**
12
+ * @var String
13
+ */
14
+ public $regionCode = null;
15
+
16
+ /**
17
+ * @var String
18
+ */
19
+ public $countryCode = null;
20
+
21
+ public function __construct($regionCode, $countryCode)
22
+ {
23
+ $this->regionCode = $regionCode;
24
+ $this->countryCode = $countryCode;
25
+
26
+ parent::__construct(
27
+ "Invalid region: '$regionCode, $countryCode'"
28
+ );
29
+ }
30
+ }
app/code/community/PriceWaiter/NYPWidget/Exception/OutOfStock.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception thrown when there's not enough inventory of an item.
5
+ */
6
+ class PriceWaiter_NYPWidget_Exception_OutOfStock
7
+ extends PriceWaiter_NYPWidget_Exception_Abstract
8
+ {
9
+ public $errorCode = 'out_of_stock';
10
+ }
app/code/community/PriceWaiter/NYPWidget/Exception/Product/Abstract.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Base for product data related exceptions.
5
+ */
6
+ abstract class PriceWaiter_NYPWidget_Exception_Product_Abstract
7
+ extends PriceWaiter_NYPWidget_Exception_Abstract
8
+ {
9
+ }
app/code/community/PriceWaiter/NYPWidget/Exception/Product/NotFound.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception thrown when a product cannot be found.
5
+ */
6
+ class PriceWaiter_NYPWidget_Exception_Product_NotFound
7
+ extends PriceWaiter_NYPWidget_Exception_Product_Abstract
8
+ {
9
+ public $errorCode = 'product_not_found';
10
+ }
app/code/community/PriceWaiter/NYPWidget/Exception/Signature.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception thrown when an incoming request's signature does not match what
5
+ * was expected.
6
+ */
7
+ class PriceWaiter_NYPWidget_Exception_Signature
8
+ extends PriceWaiter_NYPWidget_Exception_Abstract
9
+ {
10
+ public $errorCode = 'signature';
11
+ }
app/code/community/PriceWaiter/NYPWidget/Helper/Data.php CHANGED
@@ -1,51 +1,90 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
21
  {
 
 
 
 
 
22
  private $_product = false;
23
- private $_testing = false;
24
  private $_buttonEnabled = null;
25
  private $_conversionToolsEnabled = null;
26
 
27
- private $_apiUrl = 'https://api.pricewaiter.com';
28
- private $_retailerUrl = 'https://retailer.pricewaiter.com';
29
  private $_widgetUrl = 'https://widget.pricewaiter.com';
30
 
31
  public function __construct()
32
  {
33
- if (!!getenv('PRICEWAITER_API_URL')) {
34
- $this->_apiUrl = getenv('PRICEWAITER_API_URL');
35
  }
 
36
 
37
- if (!!getenv('PRICEWAITER_RETAILER_URL')) {
38
- $this->_retailerUrl = getenv('PRICEWAITER_RETAILER_URL');
 
 
 
 
 
 
 
39
  }
40
 
41
- if (!!getenv('PRICEWAITER_WIDGET_URL')) {
42
- $this->_widgetUrl = getenv('PRICEWAITER_WIDGET_URL');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
 
 
 
 
 
 
 
44
  }
45
 
46
- public function isTesting()
 
 
 
47
  {
48
- return $this->_testing;
 
 
 
 
 
 
49
  }
50
 
51
  public function isEnabledForStore()
@@ -161,9 +200,7 @@ class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
161
 
162
  public function getPriceWaiterSettingsUrl()
163
  {
164
- $apiKey = Mage::getStoreConfig('pricewaiter/configuration/api_key');
165
-
166
- return sprintf("%s/", $this->_retailerUrl);
167
  }
168
 
169
  public function getWidgetUrl()
@@ -177,11 +214,6 @@ class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
177
  return $this->_widgetUrl . '/nyp/script/widget.js';
178
  }
179
 
180
- public function getApiUrl()
181
- {
182
- return $this->_apiUrl . '/1/order/verify?api_key='
183
- . Mage::getStoreConfig('pricewaiter/configuration/api_key');
184
- }
185
 
186
  public function getProductPrice($product)
187
  {
@@ -269,19 +301,29 @@ class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
269
  return $javascript;
270
  }
271
 
272
- public function getStoreByApiKey($apiKey)
 
 
 
 
 
 
273
  {
274
  $stores = Mage::app()->getStores();
275
 
276
- // Find the store with the matching API key by checking the key for each store
277
- // in Magento
278
  foreach ($stores as $store) {
279
- if ($apiKey == Mage::getStoreConfig('pricewaiter/configuration/api_key', $store->getId())) {
 
 
 
 
 
 
280
  return $store;
281
  }
282
  }
283
 
284
- return Mage::app()->getStore();
285
  }
286
 
287
  /**
@@ -341,6 +383,7 @@ class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
341
  * @param {String} $sku SKU of the product
342
  * @param {Array} $productOptions An array of options for the product, name => value
343
  * @return {Object} Returns Mage_Catalog_Model_Product of product that matches options.
 
344
  */
345
  public function getProductWithOptions($sku, $productOptions)
346
  {
@@ -375,6 +418,11 @@ class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
375
 
376
  $parentProduct = $product;
377
  $product = $product->getTypeInstance()->getProductByAttributes($productOptions, $product);
 
 
 
 
 
378
  $product->load($product->getId());
379
  }
380
 
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
5
+ const PRICEWAITER_API_URL = 'https://api.pricewaiter.com';
6
+ const PRICEWAITER_RETAILER_URL = 'https://retailer.pricewaiter.com';
7
+
8
+ const XML_PATH_DEFAULT_ORDER_STATUS = 'pricewaiter/orders/default_status';
9
+
10
  private $_product = false;
 
11
  private $_buttonEnabled = null;
12
  private $_conversionToolsEnabled = null;
13
 
 
 
14
  private $_widgetUrl = 'https://widget.pricewaiter.com';
15
 
16
  public function __construct()
17
  {
18
+ if (!!getenv('PRICEWAITER_WIDGET_URL')) {
19
+ $this->_widgetUrl = getenv('PRICEWAITER_WIDGET_URL');
20
  }
21
+ }
22
 
23
+ /**
24
+ * @return String URL of the PriceWaiter API.
25
+ */
26
+ public function getApiUrl()
27
+ {
28
+ $url = getenv('PRICEWAITER_API_URL');
29
+
30
+ if ($url) {
31
+ return $url;
32
  }
33
 
34
+ return self::PRICEWAITER_API_URL;
35
+ }
36
+
37
+ /**
38
+ * @return String The status to assign to new PriceWaiter orders.
39
+ */
40
+ public function getDefaultOrderStatus($store = null)
41
+ {
42
+ return Mage::getStoreConfig(self::XML_PATH_DEFAULT_ORDER_STATUS, $store);
43
+ }
44
+
45
+ /**
46
+ * @param String $id
47
+ * @return String URL to view the given offer on PriceWaiter.
48
+ */
49
+ public function getOfferUrl($id)
50
+ {
51
+ $url = $this->getRetailerUrl();
52
+ $url = rtrim($url, '/');
53
+ $url .= '/offers/' . rawurlencode($id);
54
+
55
+ return $url;
56
+ }
57
+
58
+ /**
59
+ * @return String URL to which to POST order data for verification.
60
+ */
61
+ public function getOrderVerificationUrl()
62
+ {
63
+ $url = getenv('PRICEWAITER_ORDER_VERIFICATION_URL');
64
+ if ($url) {
65
+ return $url;
66
  }
67
+
68
+ // Build verification URL off base API url.
69
+ $url = $this->getApiUrl();
70
+ $url = rtrim($url, '/');
71
+ $url .= '/1/order/verify';
72
+
73
+ return $url;
74
  }
75
 
76
+ /**
77
+ * @return String The URL of the PriceWaiter Retailer area.
78
+ */
79
+ public function getRetailerUrl()
80
  {
81
+ $url = getenv('PRICEWAITER_RETAILER_URL');
82
+
83
+ if ($url) {
84
+ return $url;
85
+ }
86
+
87
+ return self::PRICEWAITER_RETAILER_URL;
88
  }
89
 
90
  public function isEnabledForStore()
200
 
201
  public function getPriceWaiterSettingsUrl()
202
  {
203
+ return $this->getRetailerUrl();
 
 
204
  }
205
 
206
  public function getWidgetUrl()
214
  return $this->_widgetUrl . '/nyp/script/widget.js';
215
  }
216
 
 
 
 
 
 
217
 
218
  public function getProductPrice($product)
219
  {
301
  return $javascript;
302
  }
303
 
304
+ /**
305
+ * Returns the Magento store configured with the given PriceWaiter API key, or false if none is found.
306
+ * @param String $apiKey
307
+ * @return Mage_Core_Model_Store|false
308
+ * @throws PriceWaiter
309
+ */
310
+ public function getStoreByPriceWaiterApiKey($apiKey)
311
  {
312
  $stores = Mage::app()->getStores();
313
 
 
 
314
  foreach ($stores as $store) {
315
+
316
+ $storeApiKey = Mage::getStoreConfig(
317
+ 'pricewaiter/configuration/api_key',
318
+ $store->getId()
319
+ );
320
+
321
+ if (strcasecmp($apiKey, $storeApiKey) === 0) {
322
  return $store;
323
  }
324
  }
325
 
326
+ return false;
327
  }
328
 
329
  /**
383
  * @param {String} $sku SKU of the product
384
  * @param {Array} $productOptions An array of options for the product, name => value
385
  * @return {Object} Returns Mage_Catalog_Model_Product of product that matches options.
386
+ * @throws PriceWaiter_NYPWidget_Exception_Product_NotFound If no product can be found.
387
  */
388
  public function getProductWithOptions($sku, $productOptions)
389
  {
418
 
419
  $parentProduct = $product;
420
  $product = $product->getTypeInstance()->getProductByAttributes($productOptions, $product);
421
+
422
+ if (!$product) {
423
+ throw new PriceWaiter_NYPWidget_Exception_Product_NotFound();
424
+ }
425
+
426
  $product->load($product->getId());
427
  }
428
 
app/code/community/PriceWaiter/NYPWidget/Model/Callback.php CHANGED
@@ -1,322 +1,820 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Model_Callback
21
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- private $_store;
24
- private $_product;
 
 
 
 
 
 
 
25
 
26
- private $_test = false;
 
27
 
28
- public function processRequest($request)
 
 
 
 
 
 
 
 
 
29
  {
30
- if ($request['test'] == 1) {
31
- $this->_test = true;
 
 
 
 
 
 
 
32
  }
33
 
34
- // Build URL to check validity of order notification.
35
- $url = Mage::helper('nypwidget')->getApiUrl();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
- $ch = curl_init($url);
38
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
39
- curl_setopt($ch, CURLOPT_POST, true);
40
- curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
41
-
42
- try {
43
- // If PriceWaiter returns an invalid response
44
- if (curl_exec($ch) == "1") {
45
- $message = "The Name Your Price Widget has received a valid order notification.";
46
- if ($this->_test) {
47
- $message .= ' This is a TEST order that will be created and canceled.';
48
- }
49
- Mage::log($message);
50
- $this->_log($message);
51
- } else {
52
- $message = "An invalid PriceWaiter order notification has been received.";
53
- throw(new Exception($message));
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
- // Verify that we have not already received this callback based on the `pricewaiter_id` field
57
- $pricewaiterOrder = Mage::getModel('nypwidget/order');
58
- $pricewaiterOrder->loadByPriceWaiterId($request['pricewaiter_id']);
59
- if ($pricewaiterOrder->getId()) {
60
- $message = "Received a duplicate order from the PriceWaiter Callback API. Ignoring.";
61
- throw(new Exception($message));
62
- }
63
 
 
64
 
65
- // First, determine the store that this order corresponds to.
66
- // This is a new feature as of 1.2.2, so we need to make sure the API
67
- // is compatible first.
68
- if (array_key_exists('api_key', $request)
69
- && $request['api_key'] != ''
70
- ) {
71
- $store = Mage::helper('nypwidget')->getStoreByApiKey($request['api_key']);
72
- $this->_store = $store;
73
- } else {
74
- // Fallback for when the API key isn't found
75
- $this->_store = Mage::app()->getStore();
76
- }
77
 
78
- // Is this an existing customer?
79
- $customer = Mage::getModel('customer/customer')
80
- ->setWebsiteId($this->_store->getWebsiteId());
81
- $customer->loadByEmail($request['buyer_email']);
82
-
83
- if (!$customer->getId()) {
84
- // Create a new customer with this email
85
- $customer->reset();
86
- $passwordLength = 10;
87
- $passwordCharacters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
88
- $password = '';
89
- for ($p = 0; $p < $passwordLength; $p++) {
90
- $password .= $passwordCharacters[mt_rand(0, strlen($passwordCharacters))];
91
- }
92
-
93
- $customer->setEmail($request['buyer_email']);
94
- $customer->setFirstname($request['buyer_first_name']);
95
- $customer->setLastname($request['buyer_last_name']);
96
- $customer->setPassword($password);
97
- $customer->setConfirmation(null);
98
- $customer->setWebsiteId($this->_store->getWebsiteId());
99
- $customer->save();
100
- if (Mage::getStoreConfig('pricewaiter/customer_interaction/send_welcome_email')) {
101
- $customer->sendNewAccountEmail('registered', '', $this->_store->getId());
102
- }
103
- $customer->load($customer->getId());
104
- }
105
 
106
- $transaction = Mage::getModel('core/resource_transaction');
107
- $reservedOrderId = Mage::getSingleton('eav/config')->getEntityType('order')->fetchNewIncrementId($this->_store->getId());
108
 
109
- // Grab the currency code from the request, if one is set.
110
- // Otherwise, use the store's default currency code.
111
- if ($request['currency']) {
112
- $currencyCode = $request['currency'];
113
- } else {
114
- $currencyCode = $this->_store->getDefaultCurrencyCode();
115
- }
116
 
117
- $order = Mage::getModel('sales/order')
118
- ->setIncrementId($reservedOrderId)
119
- ->setStoreId($this->_store->getId())
120
- ->setQuoteId(0)
121
- ->setGlobal_currency_code($currencyCode)
122
- ->setBase_currency_code($currencyCode)
123
- ->setStore_currency_code($currencyCode)
124
- ->setOrder_currency_code($currencyCode);
125
-
126
- // set Customer data
127
- $order->setCustomer_email($customer->getEmail())
128
- ->setCustomerFirstname($customer->getFirstname())
129
- ->setCustomerLastname($customer->getLastname())
130
- ->setCustomerGroupId($customer->getGroupId())
131
- ->setCustomer_is_guest(0)
132
- ->setCustomer($customer);
133
-
134
- // Find billing Region ID
135
- $regionModel = Mage::getModel('directory/region')->loadByCode($request['buyer_billing_state'], $request['buyer_billing_country']);
136
-
137
- //Get a phone number, or make a dummy one
138
- if ($request['buyer_billing_phone']) {
139
- $telephone = $request['buyer_billing_phone'];
140
- } else {
141
- $telephone = "000-000-0000";
142
- }
143
 
144
- // set Billing Address
145
- $billing = $customer->getDefaultBillingAddress();
146
- $billingAddress = Mage::getModel('sales/order_address')
147
- ->setStoreId($this->_store->getId())
148
- ->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_BILLING)
149
- ->setCustomerId($customer->getId())
150
- ->setPrefix('')
151
- ->setFirstname($request['buyer_billing_first_name'])
152
- ->setMiddlename('')
153
- ->setLastname($request['buyer_billing_last_name'])
154
- ->setSuffix('')
155
- ->setCompany('')
156
- ->setStreet(array($request['buyer_billing_address'], $request['buyer_billing_address2']))
157
- ->setCity($request['buyer_billing_city'])
158
- ->setCountry_id($request['buyer_billing_country'])
159
- ->setRegion($request['buyer_billing_state'])
160
- ->setRegion_id($regionModel->getId())
161
- ->setPostcode($request['buyer_billing_zip'])
162
- ->setTelephone($telephone)
163
- ->setFax('');
164
- $order->setBillingAddress($billingAddress);
165
-
166
- // Find shipping Region ID
167
- $regionModel = Mage::getModel('directory/region')->loadByCode($request['buyer_shipping_state'], $request['buyer_shipping_country']);
168
-
169
- //Get a phone number, or make a dummy one
170
- if ($request['buyer_shipping_phone']) {
171
- $telephone = $request['buyer_shipping_phone'];
172
- } else {
173
- $telephone = "000-000-0000";
174
- }
175
 
176
- // set Shipping Address
177
- $shipping = $customer->getDefaultShippingAddress();
178
- $shippingAddress = Mage::getModel('sales/order_address')
179
- ->setStoreId($this->_store->getId())
180
- ->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_BILLING)
181
- ->setCustomerId($customer->getId())
182
- ->setPrefix('')
183
- ->setFirstname($request['buyer_shipping_first_name'])
184
- ->setMiddlename('')
185
- ->setLastname($request['buyer_shipping_last_name'])
186
- ->setSuffix('')
187
- ->setCompany('')
188
- ->setStreet(array($request['buyer_shipping_address'], $request['buyer_shipping_address2']))
189
- ->setCity($request['buyer_shipping_city'])
190
- ->setCountry_id($request['buyer_shipping_country'])
191
- ->setRegion($request['buyer_shipping_state'])
192
- ->setRegion_id($regionModel->getId())
193
- ->setPostcode($request['buyer_shipping_zip'])
194
- ->setTelephone($telephone)
195
- ->setFax('');
196
-
197
- // Apply shipping address to order, add PriceWaiter shipping method
198
- $order->setShippingAddress($shippingAddress)
199
- ->setShipping_method('nypwidget_nypwidget')
200
- ->setShipping_amount($request['shipping'])
201
- ->setShippingDescription('PriceWaiter');
202
-
203
- // Add PriceWaiter payment method
204
- $orderPayment = Mage::getModel('sales/order_payment')
205
- ->setStoreId($this->_store->getId())
206
- ->setCustomerPaymentId(0)
207
- ->setMethod('nypwidget');
208
- $order->setPayment($orderPayment);
209
-
210
- // Find the Product from the request
211
- $requestOptions = array();
212
-
213
- for ($i = $request['product_option_count']; $i > 0; $i--) {
214
- $requestOptions[$request['product_option_name' . $i]] = $request['product_option_value' . $i];
215
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
 
217
- $this->_product = Mage::helper('nypwidget')->getProductWithOptions($request['product_sku'], $requestOptions);
218
-
219
- // Build the pricing information of the product
220
- $subTotal = 0;
221
- $rowTotal = ($request['unit_price'] * $request['quantity']) + $request['tax'];
222
- $itemDiscount = ($this->_product->getPrice() - $request['unit_price']);
223
-
224
- $orderItem = Mage::getModel('sales/order_item')
225
- ->setStoreId($this->_store->getId())
226
- ->setQuoteItemId(0)
227
- ->setQuoteParentItemId(NULL)
228
- ->setProductId($this->_product->getId())
229
- ->setProductType($this->_product->getTypeId())
230
- ->setQtyBackordered(NULL)
231
- ->setTotalQtyOrdered($request['quantity'])
232
- ->setQtyOrdered($request['quantity'])
233
- ->setName($this->_product->getName())
234
- ->setSku($this->_product->getSku())
235
- ->setPrice($request['unit_price'])
236
- ->setBasePrice($request['unit_price'])
237
- ->setOriginalPrice($this->_product->getPrice())
238
- // ->setDiscountAmount($itemDiscount)
239
- ->setTaxAmount($request['tax'])
240
- ->setRowTotal($rowTotal)
241
- ->setBaseRowTotal($rowTotal);
242
-
243
- // Do we have a simple product with custom options, a bundle product, or a grouped product?
244
- if (($this->_product->getTypeId() == 'simple'
245
- || $this->_product->getTypeId() == 'bundle'
246
- || $this->_product->getTypeId() == 'grouped')
247
- && $request['product_option_count'] > 0
248
- ) {
249
- // Grab the options from the request, build $additionalOptions array
250
- $additionalOptions = array();
251
- for ($i = $request['product_option_count']; $i > 0; $i--) {
252
- $additionalOptions[] = array(
253
- 'label' => $request['product_option_name' . $i],
254
- 'value' => $request['product_option_value' . $i]
255
- );
256
- }
257
-
258
- // Apply the $additionalOptions array to the simple product
259
- $orderItem->setProductOptions(array('additional_options' => $additionalOptions));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  }
261
 
262
- // Build and apply the order totals
263
- $subTotal += $rowTotal;
264
- $order->addItem($orderItem);
265
 
266
- $order->setSubtotal($subTotal)
267
- ->setBaseSubtotal($subTotal)
268
- ->setGrandTotal($subTotal + $request['shipping'])
269
- ->setBaseGrandTotal($subTotal + $request['shipping']);
270
 
271
- $order->addStatusHistoryComment("This order has been programmatically created by the PriceWaiter Name Your Price Widget.");
 
 
272
 
273
  // Ok, done with the order.
274
- $transaction->addObject($order);
275
- $transaction->addCommitCallback(array($order, 'place'));
276
- $transaction->addCommitCallback(array($order, 'save'));
277
- $transaction->save();
278
-
279
- // Add this order to the list of received callback orders
280
- $pricewaiterOrder->setData(array(
281
- 'store_id' => $order->getStoreId(),
282
- 'pricewaiter_id' => $request['pricewaiter_id'],
283
- 'order_id' => $order->getId()
284
- ));
285
- $pricewaiterOrder->save();
286
 
287
- if (Mage::getStoreConfig('pricewaiter/customer_interaction/send_new_order_email')) {
288
- $order->sendNewOrderEmail();
 
 
289
  }
290
 
291
- // Add order Increment ID to response
292
- Mage::app()->getResponse()->setHeader('X-Platform-Order-Id', $order->getIncrementId());
 
 
 
 
 
 
 
 
293
 
294
- // If this is a test order, cancel it to prevent it from any further processing.
295
- if ($this->_test) {
296
- $order->cancel();
297
- $order->save();
298
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
 
301
- // Capture the invoice
302
- $invoiceId = Mage::getModel('sales/order_invoice_api')
303
- ->create($order->getIncrementId(), array());
304
- $invoice = Mage::getModel('sales/order_invoice')
305
- ->loadByIncrementId($invoiceId);
306
- $invoice->capture()->save();
307
-
308
-
309
- Mage::log("The Name Your Price Widget has created order #"
310
- . $order->getIncrementId() . " with order ID " . $order->getId());
311
- $this->_log("The Name Your Price Widget has created order #"
312
- . $order->getIncrementId() . " with order ID " . $order->getId());
313
- } catch (Exception $e) {
314
- Mage::app()->getResponse()->setHeader('HTTP/1.0 500 Internal Server Error', 500, true);
315
- Mage::app()->getResponse()->setHeader('X-Platform-Error', $e->getMessage(), true);
316
- $this->_log("PriceWaiter Name Your Price Widget was unable to create order. Check log for details.");
317
- $this->_log($e->getMessage());
318
  }
319
 
 
320
  }
321
 
322
  private function _log($message)
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Model_Callback
4
  {
5
+ /**
6
+ * Description used for shipping if none specified.
7
+ */
8
+ const DEFAULT_SHIPPING_DESCRIPTION = 'PriceWaiter';
9
+
10
+ const LOGFILE = 'PriceWaiter_Callback.log';
11
+
12
+ const XML_PATH_ORDER_LOGGING = 'pricewaiter/orders/log';
13
+
14
+ /**
15
+ * @var PriceWaiter_NYPWidget_Helper_Data
16
+ */
17
+ private $_helper = null;
18
+
19
+ /**
20
+ * @internal Probably redundant, but don't want to tie our field names to internal Magento constants.
21
+ * @var array
22
+ */
23
+ protected static $magentoAddressTypes = array(
24
+ 'billing' => Mage_Sales_Model_Quote_Address::TYPE_BILLING,
25
+ 'shipping' => Mage_Sales_Model_Quote_Address::TYPE_SHIPPING
26
+ );
27
+
28
+ /**
29
+ * @internal
30
+ * @var string
31
+ */
32
+ protected $passwordCharacters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
33
+
34
+ /**
35
+ * @internal Adds items to the given order and calculates final total.
36
+ * @param Mage_Sales_Model_Order $order [description]
37
+ * @param Array $request [description]
38
+ * @param Mage_Core_Model_Store $store [description]
39
+ * @param Mage_Customer_Model_Customer $customer [description]
40
+ */
41
+ public function addItemsToOrder(
42
+ Mage_Sales_Model_Order $order,
43
+ Array $request,
44
+ Mage_Core_Model_Store $store,
45
+ Mage_Customer_Model_Customer $customer
46
+ )
47
+ {
48
+ $product = $this->findProduct($request);
49
+
50
+ if (!$product) {
51
+ throw new PriceWaiter_NYPWidget_Exception_Product_NotFound();
52
+ }
53
+
54
+ // Build the pricing information of the product
55
+ $orderItem = Mage::getModel('sales/order_item')
56
+ ->setStoreId($store->getId())
57
+ ->setQuoteItemId(0)
58
+ ->setQuoteParentItemId(null)
59
+ ->setProductId($product->getId())
60
+ ->setProductType($product->getTypeId())
61
+ ->setTotalQtyOrdered($request['quantity'])
62
+ ->setQtyOrdered($request['quantity'])
63
+ ->setName($product->getName())
64
+ ->setSku($product->getSku())
65
+ ->setIsNominal(0);
66
+
67
+ // Delegate out to some more unit-testable code to calculate all the
68
+ // various amount fields present on the order item.
69
+ $amounts = $this->calculateOrderItemAmounts(
70
+ $request,
71
+ $product->getPrice(),
72
+ array($store, 'roundPrice')
73
+ );
74
+ foreach($amounts as $key => $value) {
75
+ $orderItem->setData($key, $value);
76
+ $orderItem->setData("base_$key", $value);
77
+ }
78
 
79
+ $additionalOptions = array();
80
+ foreach($this->buildProductOptionsArray($request) as $label => $value) {
81
+ $additionalOptions[] = array(
82
+ 'label' => $label,
83
+ 'value' => $value,
84
+ );
85
+ }
86
+
87
+ $orderItem->setProductOptions(array('additional_options' => $additionalOptions));
88
 
89
+ $order->addItem($orderItem);
90
+ }
91
 
92
+ /**
93
+ * @internal Constructs address models based on request data.
94
+ * @param String $type 'billing' or 'shipping'.
95
+ * @param Array $request
96
+ * @param Mage_Customer_Model_Customer $customer
97
+ * @param Mage_Core_Model_Store $store
98
+ * @return Mage_Sales_Model_Order_Address
99
+ * @throws PriceWaiter_NYPWidget_Exception_InvalidRegion
100
+ */
101
+ public function buildAddress($type, Array $request, Mage_Customer_Model_Customer $customer, Mage_Core_Model_Store $store)
102
  {
103
+ $state = $request["buyer_{$type}_state"];
104
+ $country = $request["buyer_{$type}_country"];
105
+
106
+ // Resolve state + country into a Mage_Directory_Model_Region
107
+ $regionModel = Mage::getModel('directory/region')
108
+ ->loadByCode($state, $country);
109
+
110
+ if (!$regionModel->getId()) {
111
+ throw new PriceWaiter_NYPWidget_Exception_InvalidRegion($state, $country);
112
  }
113
 
114
+ return Mage::getModel('sales/order_address')
115
+ // System data
116
+ ->setStoreId($store->getId())
117
+ ->setAddressType(self::$magentoAddressTypes[$type])
118
+
119
+ // Customer + name
120
+ ->setCustomerId($customer->getId())
121
+ ->setPrefix('')
122
+ ->setFirstname($request["buyer_{$type}_first_name"])
123
+ ->setMiddlename('')
124
+ ->setLastname($request["buyer_{$type}_last_name"])
125
+ ->setSuffix('')
126
+ ->setCompany('')
127
+
128
+ // Actual address
129
+ ->setStreet(array_filter(array(
130
+ $request["buyer_{$type}_address"],
131
+ $request["buyer_{$type}_address2"],
132
+ $request["buyer_{$type}_address3"],
133
+ )))
134
+ ->setCity($request["buyer_{$type}_city"])
135
+ ->setRegionId($regionModel->getId())
136
+ ->setPostcode($request["buyer_{$type}_zip"])
137
+ ->setCountryId($country)
138
+
139
+ // Phone numbers
140
+ ->setTelephone($request["buyer_{$type}_phone"])
141
+ ->setFax('');
142
+ }
143
 
144
+ /**
145
+ * @internal Assembles a Mage_Sales_Model_Order out of all incoming request data.
146
+ * @param Array $request
147
+ * @param Mage_Core_Model_Store $store
148
+ * @param Mage_Customer_Model_Customer $customer
149
+ * @return Mage_Sales_Model_Order
150
+ */
151
+ public function buildMagentoOrder(Array $request, Mage_Core_Model_Store $store, Mage_Customer_Model_Customer $customer)
152
+ {
153
+ $reservedOrderId = Mage::getSingleton('eav/config')
154
+ ->getEntityType('order')
155
+ ->fetchNewIncrementId($store->getId());
156
+
157
+ $currencyCode = $request['currency'];
158
+
159
+ $order = Mage::getModel('sales/order')
160
+ // System fields
161
+ ->setIncrementId($reservedOrderId)
162
+ ->setStoreId($store->getId())
163
+ ->setQuoteId(0)
164
+ ->setGlobalCurrencyCode($currencyCode)
165
+ ->setBaseCurrencyCode($currencyCode)
166
+ ->setStoreCurrencyCode($currencyCode)
167
+ ->setOrderCurrencyCode($currencyCode)
168
+
169
+ // Customer
170
+ ->setCustomerEmail($customer->getEmail())
171
+ ->setCustomerFirstname($customer->getFirstname())
172
+ ->setCustomerLastname($customer->getLastname())
173
+ ->setCustomerGroupId($customer->getGroupId())
174
+ ->setCustomerIsGuest(0)
175
+ ->setCustomer($customer)
176
+
177
+ // Addresses
178
+ ->setBillingAddress($this->buildAddress(
179
+ 'billing',
180
+ $request,
181
+ $customer,
182
+ $store
183
+ ))
184
+ ->setShippingAddress($this->buildAddress(
185
+ 'shipping',
186
+ $request,
187
+ $customer,
188
+ $store
189
+ ));
190
 
191
+ $this->setOrderShippingMethod($order, $request, $store, $customer);
 
 
 
 
 
 
192
 
193
+ $this->setOrderPaymentMethod($order, $request, $store, $customer);
194
 
195
+ $this->addItemsToOrder($order, $request, $store, $customer);
 
 
 
 
 
 
 
 
 
 
 
196
 
197
+ $product = $this->findProduct($request);
198
+ if (!$product) {
199
+ throw new PriceWaiter_NYPWidget_Exception_Product_NotFound();
200
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
 
202
+ $amounts = $this->calculateOrderAmounts($request, $product->getPrice(), array($store, 'roundPrice'));
 
203
 
204
+ foreach($amounts as $key => $value) {
205
+ $order->setData($key, $value);
206
+ $order->setData("base_$key", $value);
207
+ }
 
 
 
208
 
209
+ $order->setDiscountDescription('PriceWaiter');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
 
211
+ $comment = $this->getNewOrderComment($request);
212
+ if ($comment) {
213
+ $order->addStatusHistoryComment($comment);
214
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
+ return $order;
217
+ }
218
+
219
+ /**
220
+ * @internal
221
+ * Assembles an array of product options in the format array("name" => "value", "name" => "value")
222
+ * @param Array $request
223
+ */
224
+ public function buildProductOptionsArray(Array $request)
225
+ {
226
+ $options = array();
227
+
228
+ $count = intval($request['product_option_count']);
229
+
230
+ // Decode product_option_name<N> and product_option_value<N>-style incoming data.
231
+ // Note that we start numbering at 1.
232
+
233
+ for ($i = 1; $i <= $count; $i++) {
234
+ $nameKey = "product_option_name{$i}";
235
+ $name = $request[$nameKey];
236
+
237
+ $valueKey = "product_option_value{$i}";
238
+ $value = $request[$valueKey];
239
+
240
+ $options[$name] = $value;
241
+ }
242
+
243
+ return $options;
244
+ }
245
+
246
+ /**
247
+ * @internal Calculates pricing-related fields to go on the order.
248
+ * @param Array $request
249
+ * @return Array
250
+ */
251
+ public function calculateOrderAmounts(Array $request, $productPrice, Callable $rounder)
252
+ {
253
+ $amountPerItem = $request['unit_price'];
254
+ $qty = $request['quantity'];
255
+ $shipping = $request['shipping'];
256
+ $tax = $request['tax'];
257
+ $subtotal = $amountPerItem * $qty;
258
+
259
+ $regularSubtotal = $productPrice * $qty;
260
+ $discountAmount = $regularSubtotal - $subtotal;
261
+
262
+ $total = $rounder($subtotal + $shipping + $tax);
263
+
264
+ return array(
265
+ 'discount_amount' => $rounder(-$discountAmount),
266
+ 'grand_total' => $total,
267
+ 'shipping_amount' => $shipping,
268
+ 'shipping_discount_amount' => 0,
269
+ 'shipping_incl_tax' => $shipping,
270
+ 'shipping_tax_amount' => 0,
271
+ 'subtotal' => $rounder($regularSubtotal),
272
+ 'subtotal_incl_tax' => $rounder($regularSubtotal + $tax),
273
+ 'tax_amount' => $rounder($tax),
274
+ );
275
+ }
276
+
277
+ /**
278
+ * @internal Calculates pricing-related fields to be set on an order item.
279
+ * @param Array $request
280
+ * @param Mage_Catalog_Model_Product $product
281
+ */
282
+ public function calculateOrderItemAmounts(Array $request, $productPrice, Callable $rounder)
283
+ {
284
+ $amountPerItem = $request['unit_price'];
285
+ $qty = $request['quantity'];
286
+ $subtotal = $amountPerItem * $qty;
287
+ $tax = $request['tax'];
288
+ $taxPercent = $tax / ($amountPerItem * $qty);
289
+
290
+ $regularSubtotal = $productPrice * $qty;
291
+ $taxBeforeDiscount = $regularSubtotal * $taxPercent;
292
+
293
+ $discountAmount = $regularSubtotal - $subtotal;
294
+ $discountPercent = $discountAmount / $regularSubtotal * 100;
295
+
296
+ return array(
297
+ 'discount_amount' => $rounder($discountAmount),
298
+ 'discount_percent' => $rounder($discountPercent),
299
+ 'original_price' => $productPrice,
300
+ 'price' => $productPrice,
301
+ 'price_incl_tax' => $rounder($productPrice + ($tax / $qty)),
302
+ 'row_total' => $rounder($regularSubtotal),
303
+ 'row_total_incl_tax' => $rounder($regularSubtotal + $tax),
304
+ 'tax_amount' => $tax,
305
+ 'tax_before_discount' => $rounder($taxBeforeDiscount),
306
+ 'tax_percent' => $rounder($taxPercent * 100),
307
+ );
308
+ }
309
+
310
+ /**
311
+ * @internal Creates a new customer, saves it, and returns it.
312
+ * @param Array $request
313
+ * @param Mage_Core_Model_Store $store
314
+ * @return Mage_Customer_Model_Customer
315
+ */
316
+ public function createCustomer(Array $request, Mage_Core_Model_Store $store)
317
+ {
318
+ $customer = Mage::getModel('customer/customer')
319
+ // System
320
+ ->setWebsiteId($store->getWebsiteId())
321
+ ->setPassword($this->generatePassword(10))
322
+ ->setConfirmation(null)
323
+
324
+ // Person
325
+ ->setEmail($request['buyer_email'])
326
+ ->setFirstname($request['buyer_first_name'])
327
+ ->setLastname($request['buyer_last_name']);
328
 
329
+ $customer->save();
330
+
331
+ $this->sendWelcomeEmail($customer, $store);
332
+
333
+ return $customer;
334
+ }
335
+
336
+ /**
337
+ * @internal Either returns an existing customer (by email) or creates a new one.
338
+ * @param Array $request
339
+ * @param Mage_Core_Model_Store $store
340
+ * @return Mage_Customer_Model_Customer
341
+ */
342
+ public function findOrCreateCustomer(Array $request, Mage_Core_Model_Store $store)
343
+ {
344
+ $customer = Mage::getModel('customer/customer')
345
+ ->setWebsiteId($store->getWebsiteId())
346
+ ->loadByEmail($request['buyer_email']);
347
+
348
+ if ($customer->getId()) {
349
+ // This an existing customer for this Magento store.
350
+ return $customer;
351
+ }
352
+
353
+ return $this->createCustomer($request, $store);
354
+ }
355
+
356
+ /**
357
+ * @internal Resolves the product for an incoming request.
358
+ * @param Array $request
359
+ * @return Mage_Catalog_Model_Product|false
360
+ */
361
+ public function findProduct(Array $request)
362
+ {
363
+ $productSku = $request['product_sku'];
364
+ $productOptions = $this->buildProductOptionsArray($request);
365
+
366
+ $product = $this->getHelper()->getProductWithOptions($productSku, $productOptions);
367
+
368
+ return $product->getId() ? $product : false;
369
+ }
370
+
371
+ /**
372
+ * Looks for an existing order that matches the given order callback request.
373
+ * @param Array $request
374
+ * @return PriceWaiter_NYPWidget_Model_Order|false
375
+ */
376
+ public function getExistingOrder(Array $request)
377
+ {
378
+ $existingOrder = Mage::getModel('nypwidget/order');
379
+ $existingOrder->loadByPriceWaiterId($request['pricewaiter_id']);
380
+
381
+ if ($existingOrder->getId()) {
382
+ return $existingOrder;
383
+ }
384
+
385
+ return false;
386
+ }
387
+
388
+ /**
389
+ * @param Array $request
390
+ * @return String Comment to be added to the order generated from $request.
391
+ */
392
+ public function getNewOrderComment(Array $request)
393
+ {
394
+ $helper = $this->getHelper();
395
+ $url = $helper->getOfferUrl($request['pricewaiter_id']);
396
+
397
+ $safeUrl = htmlentities($url, ENT_QUOTES);
398
+
399
+ return sprintf(
400
+ 'Ordered via PriceWaiter (<a href="%s" target="_blank">%s</a>).',
401
+ $safeUrl,
402
+ $safeUrl
403
+ );
404
+ }
405
+
406
+ /**
407
+ * @param Array $request
408
+ * @return Mage_Core_Model_Store
409
+ * @throws PriceWaiter_NYPWidget_Exception_ApiKey If no store configured for API key.
410
+ */
411
+ public function getStore(Array $request)
412
+ {
413
+ $apiKey = isset($request['api_key']) ? $request['api_key'] : null;
414
+ $store = false;
415
+
416
+ if ($apiKey) {
417
+ $store = $this->getHelper()->getStoreByPriceWaiterApiKey($apiKey);
418
+ }
419
+
420
+ if (!$store) {
421
+ throw new PriceWaiter_NYPWidget_Exception_ApiKey();
422
+ }
423
+
424
+ return $store;
425
+ }
426
+
427
+ /**
428
+ * @return boolean
429
+ */
430
+ public function isTestOrder(Array $request)
431
+ {
432
+ return !empty($request['test']);
433
+ }
434
+
435
+ /**
436
+ * @param Array $request
437
+ * @return Mage_Sales_Model_Order
438
+ */
439
+ public function processRequest(Array $request)
440
+ {
441
+ $this->logIncomingRequest($request);
442
+
443
+ // Hint to our custom payment method about the incoming request
444
+ PriceWaiter_NYPWidget_Model_PaymentMethod::setCurrentOrderCallbackRequest($request);
445
+
446
+ try
447
+ {
448
+ if (!$this->verifyRequest($request)) {
449
+ throw new PriceWaiter_NYPWidget_Exception_InvalidOrderData();
450
  }
451
 
452
+ $store = $this->getStore($request);
453
+
454
+ $existingOrder = $this->getExistingOrder($request);
455
 
456
+ if ($existingOrder) {
457
+ throw new PriceWaiter_NYPWidget_Exception_DuplicateOrder($existingOrder);
458
+ }
 
459
 
460
+ $customer = $this->findOrCreateCustomer($request, $store);
461
+
462
+ $order = $this->buildMagentoOrder($request, $store, $customer);
463
 
464
  // Ok, done with the order.
465
+ $this->saveAndPlaceOrder($order);
466
+
467
+ $this->logOrderCreated($request, $order);
468
+
469
+ // --- After this point, we have a *live* order in the system. ---
470
+
471
+ $this->recordOrderCreation($request, $order);
 
 
 
 
 
472
 
473
+ $this->sendNewOrderEmail($order, $store);
474
+
475
+ if ($this->isTestOrder($request)) {
476
+ $this->cancelOrder($order);
477
  }
478
 
479
+ PriceWaiter_NYPWidget_Model_PaymentMethod::resetCurrentOrderCallbackRequest();
480
+ return $order;
481
+ }
482
+ catch (Exception $ex)
483
+ {
484
+ $this->logException($request, $ex);
485
+ PriceWaiter_NYPWidget_Model_PaymentMethod::resetCurrentOrderCallbackRequest();
486
+ throw $ex;
487
+ }
488
+ }
489
 
490
+ /**
491
+ * @internal Assigns details around order payment.
492
+ * @param Mage_Sales_Model_Order $order
493
+ * @param Array $request
494
+ * @param Mage_Core_Model_Store $store
495
+ * @param Mage_Customer_Model_Customer $customer
496
+ */
497
+ public function setOrderPaymentMethod(
498
+ Mage_Sales_Model_Order $order,
499
+ Array $request,
500
+ Mage_Core_Model_Store $store,
501
+ Mage_Customer_Model_Customer $customer
502
+ )
503
+ {
504
+ // Add PriceWaiter payment method
505
+ $orderPayment = Mage::getModel('sales/order_payment')
506
+ ->setMethod('nypwidget')
507
+ ->setStoreId($store->getId())
508
+ ->setCustomerPaymentId(0)
509
+ ->setTransactionId($request['transaction_id']);
510
+
511
+ // Extra details for credit card payments
512
+ if (!empty($request['cc_type'])) {
513
+ $ccType = $this->translateCcType($request['cc_type']);
514
+ if ($ccType) {
515
+ $orderPayment->setCcType($ccType);
516
  }
517
+ }
518
+
519
+ if (!empty($request['cc_last4'])) {
520
+ $orderPayment->setCcLast4($request['cc_last4']);
521
+ }
522
+
523
+ if (!empty($request['avs_result'])) {
524
+ $orderPayment->setCcAvsStatus($request['avs_result']);
525
+ }
526
+
527
+ // Stash PW-specific stuff in "additional data"
528
+ $additionalData = array(
529
+ 'pricewaiter_payment_method' => $request['payment_method'],
530
+ );
531
+
532
+ if (!empty($request['payment_method_nice'])) {
533
+ $additionalData['pricewaiter_payment_method_nice'] =
534
+ $request['payment_method_nice'];
535
+ }
536
+
537
+ $orderPayment->setAdditionalData(serialize($additionalData));
538
+
539
+ $order->setPayment($orderPayment);
540
+ }
541
+
542
+ /**
543
+ * @internal Assigns details around shipping method to $order.
544
+ * @param Mage_Sales_Model_Order $order
545
+ * @param Array $request
546
+ * @param Mage_Core_Model_Store $store
547
+ * @param Mage_Customer_Model_Customer $customer
548
+ */
549
+ public function setOrderShippingMethod(
550
+ Mage_Sales_Model_Order $order,
551
+ Array $request,
552
+ Mage_Core_Model_Store $store,
553
+ Mage_Customer_Model_Customer $customer
554
+ )
555
+ {
556
+ $description = $request['shipping_method'];
557
+ if (trim($description) === '') {
558
+ // Leaving description blank results in "No shipping information available" in PW admin
559
+ $description = self::DEFAULT_SHIPPING_DESCRIPTION;
560
+ }
561
+
562
+ // Use PriceWaiter shipping method
563
+ $order->setShippingMethod('nypwidget_nypwidget')
564
+ ->setShippingAmount($request['shipping'])
565
+ ->setShippingDescription($description);
566
+ }
567
+
568
+ /**
569
+ * @internal
570
+ * @return PriceWaiter_NYPWidget_Helper_Data
571
+ */
572
+ public function getHelper()
573
+ {
574
+ if ($this->_helper === null) {
575
+ $this->_helper = Mage::helper('nypwidget');
576
+ }
577
+ return $this->_helper;
578
+ }
579
+
580
+ /**
581
+ * @internal
582
+ * @param PriceWaiter_NYPWidget_Helper_Data $helper
583
+ * @return PriceWaiter_NYPWidget_Model_Callback $this
584
+ */
585
+ public function setHelper(PriceWaiter_NYPWidget_Helper_Data $helper)
586
+ {
587
+ $this->_helper = $helper;
588
+ return $this;
589
+ }
590
+
591
+ /**
592
+ * Attempts to validate incoming PriceWaiter order data by POSTing it back
593
+ * to the PriceWaiter Order Verification endpoint.
594
+ * @param Array $request
595
+ */
596
+ public function verifyRequest(Array $request)
597
+ {
598
+ $verifyUrl = $this->getHelper()->getOrderVerificationUrl();
599
+ $ch = curl_init($verifyUrl);
600
+
601
+ if (!$ch) {
602
+ return false;
603
+ }
604
+
605
+ // NOTE: Building $postFields string manually to avoid multipart/form-data content type
606
+ // assigned by default when using Array.
607
+ $postFields = http_build_query(
608
+ $request,
609
+ '',
610
+ '&',
611
+ // NOTE: PHP_QUERY_RFC1738 added in PHP 5.4
612
+ defined('PHP_QUERY_RFC1738') ? PHP_QUERY_RFC1738 : 0
613
+ );
614
+
615
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
616
+ curl_setopt($ch, CURLOPT_POST, true);
617
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
618
+
619
+ if (defined('CURLOPT_SAFE_UPLOAD')) {
620
+ // Disable curl's dumb '@filename' upload option
621
+ curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
622
+ }
623
+
624
+ $response = curl_exec($ch);
625
+ $valid = ($response === '1');
626
+
627
+ return $valid;
628
+ }
629
+
630
+ /**
631
+ * @internal
632
+ * @param Mage_Sales_Model_Order $order
633
+ */
634
+ protected function cancelOrder(Mage_Sales_Model_Order $order)
635
+ {
636
+ $order->cancel();
637
+ $order->save();
638
+ }
639
+
640
+ /**
641
+ * @internal
642
+ * @param Integer $length
643
+ * @return String
644
+ */
645
+ protected function generatePassword($length)
646
+ {
647
+ $password = [];
648
+
649
+ $numberOfChars = strlen($this->passwordCharacters);
650
+
651
+ for ($i = 0; $i < $length; $i++) {
652
+ $password[] = $this->passwordCharacters[mt_rand(0, $numberOfChars - 1)];
653
+ }
654
+
655
+ return implode('', $password);
656
+ }
657
+
658
+ protected function isLogEnabled($store = null)
659
+ {
660
+ return !!Mage::getStoreConfig(
661
+ self::XML_PATH_ORDER_LOGGING,
662
+ $store
663
+ );
664
+ }
665
+
666
+ /**
667
+ * @internal
668
+ */
669
+ protected function logException(Array $request, Exception $ex)
670
+ {
671
+ $id = isset($request['pricewaiter_id']) ? $request['pricewaiter_id'] : '';
672
+
673
+ $message = $ex->getMessage();
674
+ $code = isset($ex->errorCode) ? $ex->errorCode : null;
675
+
676
+ return $this->log(
677
+ 'Error processing order callback for PriceWaiter offer #%s: %s (%s)',
678
+ $id,
679
+ $message,
680
+ $code
681
+ );
682
+ }
683
+
684
+ /**
685
+ * @internal
686
+ */
687
+ protected function logIncomingRequest(Array $request)
688
+ {
689
+ $id = isset($request['pricewaiter_id']) ? $request['pricewaiter_id'] : '';
690
+ return $this->log('Received order callback for PriceWaiter offer %s', $id);
691
+ }
692
+
693
+ /**
694
+ * @internal
695
+ */
696
+ protected function logOrderCreated(Array $request, Mage_Sales_Model_Order $order)
697
+ {
698
+ $id = isset($request['pricewaiter_id']) ? $request['pricewaiter_id'] : '';
699
+ $orderId = $order->getIncrementId();
700
+ return $this->log('Created order #%s for PriceWaiter offer %s', $orderId, $id);
701
+ }
702
+
703
+
704
+ /**
705
+ * Runs the arguments through sprintf and passes them to the order callback log.
706
+ * @return PriceWaiter_NYPWidget_Model_Callback $this
707
+ */
708
+ protected function log()
709
+ {
710
+ if (!$this->isLogEnabled()) {
711
+ return $this;
712
+ }
713
+
714
+ $args = func_get_args();
715
+ $message = call_user_func_array('sprintf', $args);
716
+
717
+ Mage::log($message, null, self::LOGFILE);
718
+ return $this;
719
+ }
720
+
721
+ /**
722
+ * Stores a record in the db indicating we've processed $request into $order. This is used for
723
+ * duplicate order detection.
724
+ * @param Array $request
725
+ * @param Mage_Sales_Model_Order $order
726
+ */
727
+ protected function recordOrderCreation(Array $request, Mage_Sales_Model_Order $order)
728
+ {
729
+ Mage::getModel('nypwidget/order')
730
+ ->setStoreId($order->getStoreId())
731
+ ->setPricewaiterId($request['pricewaiter_id'])
732
+ ->setOrderId($order->getId())
733
+ ->save();
734
+ }
735
+
736
+ /**
737
+ * @param Mage_Sales_Model_Order $order
738
+ */
739
+ protected function saveAndPlaceOrder(Mage_Sales_Model_Order $order)
740
+ {
741
+ // NOTE: Magento's built-in inventory handling operates during the conversion
742
+ // of quotes -> orders. Since we write orders directly (without a quote),
743
+ // we have to handle inventory ourselves.
744
+ $inventory = Mage::getModel('nypwidget/callback_inventory', $order);
745
+
746
+ $transaction = Mage::getModel('core/resource_transaction');
747
+ $transaction->addObject($order);
748
+ $transaction->addCommitCallback(array($inventory, 'registerPricewaiterSale'));
749
+ $transaction->addCommitCallback(array($order, 'place'));
750
+ $transaction->addCommitCallback(array($order, 'save'));
751
+ $transaction->save();
752
+ }
753
+
754
+ /**
755
+ * @param Mage_Sales_Model_Order $order
756
+ * @param Mage_Core_Model_Store $store
757
+ * @return Boolean Whether email was sent.
758
+ */
759
+ protected function sendNewOrderEmail(Mage_Sales_Model_Order $order, Mage_Core_Model_Store $store)
760
+ {
761
+ if (!$store->getConfig('pricewaiter/customer_interaction/send_new_order_email')) {
762
+ return false;
763
+ }
764
+
765
+ $order->sendNewOrderEmail();
766
+ return true;
767
+ }
768
+
769
+ /**
770
+ * @param Mage_Customer_Model_Customer $customer
771
+ * @return Boolean Whether email was sent.
772
+ */
773
+ protected function sendWelcomeEmail(Mage_Customer_Model_Customer $customer, Mage_Core_Model_Store $store)
774
+ {
775
+ if (!$store->getConfig('pricewaiter/customer_interaction/send_welcome_email')) {
776
+ return false;
777
+ }
778
+
779
+ $customer->sendNewAccountEmail('registered', '', $store->getId());
780
+
781
+ return true;
782
+ }
783
+
784
+ /**
785
+ * @internal Translates an incoming PriceWaiter cc_type into a 2-character Magento credit card type.
786
+ * @param String $type A credit card type, e.g. "Visa".
787
+ * @return String|false A 2-character credit card type code or false if none can be resolved.
788
+ */
789
+ public function translateCcType($type)
790
+ {
791
+ /**
792
+ * @var Mage_Payment_Model_Config
793
+ */
794
+ $config = Mage::getSingleton('payment/config');
795
+
796
+ // $types is an array in the format:
797
+ // array(
798
+ // 'VI' => 'Visa',
799
+ // )
800
+ $types = $config->getCcTypes();
801
+
802
+ $magentoTypeCodes = array();
803
+ $normalizedNames = array();
804
+
805
+ foreach($types as $code => $name) {
806
+ $magentoTypeCodes[] = $code;
807
+ $normalizedNames[] = strtolower(preg_replace('/[^\w\d]/', '', $name));
808
+ }
809
+
810
+ $map = array_combine($normalizedNames, $magentoTypeCodes);
811
+ $normalizedType = strtolower(preg_replace('/[^\w\d]/', '', $type));
812
 
813
+ if (isset($map[$normalizedType])) {
814
+ return $map[$normalizedType];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
815
  }
816
 
817
+ return false;
818
  }
819
 
820
  private function _log($message)
app/code/community/PriceWaiter/NYPWidget/Model/Callback/Inventory.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Manages decrementing inventory for orders written via PriceWaiter order callback.
5
+ */
6
+ class PriceWaiter_NYPWidget_Model_Callback_Inventory
7
+ {
8
+ protected $_order = null;
9
+
10
+ public function __construct(Mage_Sales_Model_Order $order)
11
+ {
12
+ $this->_order = $order;
13
+ }
14
+
15
+ /**
16
+ * @return Array An array in the format [ "product_id" => [ "qty" => quantity_ordered ] ].
17
+ */
18
+ public function getProductsAndQuantities()
19
+ {
20
+ $items = $this->_order->getAllItems();
21
+ $result = array();
22
+
23
+ foreach($items as $item) {
24
+ $productId = $item->getProductId();
25
+ $result[$productId] = array('qty' => $item->getQtyOrdered());
26
+ }
27
+
28
+ return $result;
29
+ }
30
+
31
+ /**
32
+ * Decrements inventory for items sold via PriceWaiter.
33
+ * @throws Mage_Core_Exception If there's not enough inventory to fill the order.
34
+ */
35
+ public function registerPriceWaiterSale()
36
+ {
37
+ // This is adapted from code in Mage_CatalogInventory_Observer.
38
+ // The issue is that Magento's inventory code is quote-based, but we (currently) create orders directly.
39
+
40
+ // 1. Tell Mage_CatalogInventory_Model_Stock to decrement inventory.
41
+ // This will throw if there's not enough inventory to fill the order.
42
+ $stock = Mage::getSingleton('cataloginventory/stock');
43
+ $productQtys = $this->getProductsAndQuantities();
44
+
45
+ try
46
+ {
47
+ $stockItemsNeedingSave = $stock->registerProductsSale($productQtys);
48
+ }
49
+ catch (Mage_Core_Exception $ex)
50
+ {
51
+ // There's not really a great way to be *sure* this is the "not enough inventory" error
52
+ // without examining the (localizable) error message.
53
+ throw new PriceWaiter_NYPWidget_Exception_OutOfStock(
54
+ $ex->getMessage(),
55
+ 0,
56
+ $ex
57
+ );
58
+ }
59
+
60
+ // 2. If that resulted in items going out of stock, they need to be saved + reindexed.
61
+ // Again, this is adapted from Mage_CatalogInventory_Observer
62
+
63
+ $productIdsToIndex = array();
64
+
65
+ foreach ($stockItemsNeedingSave as $stockItem) {
66
+ $stockItem->save();
67
+ $productIds[] = $stockItem->getProductId();
68
+ }
69
+
70
+ if ($productIdsToIndex) {
71
+ Mage::getResourceSingleton('catalog/product_indexer_price')->reindexProductIds($productIdsToIndex);
72
+ }
73
+ }
74
+ }
app/code/community/PriceWaiter/NYPWidget/Model/Carrier/ShippingMethod.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Model_Carrier_ShippingMethod
21
  extends Mage_Shipping_Model_Carrier_Abstract
22
  implements Mage_Shipping_Model_Carrier_Interface
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Model_Carrier_ShippingMethod
4
  extends Mage_Shipping_Model_Carrier_Abstract
5
  implements Mage_Shipping_Model_Carrier_Interface
app/code/community/PriceWaiter/NYPWidget/Model/Category.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Model_Category extends Mage_Core_Model_Abstract
21
  {
22
  public function _construct()
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Model_Category extends Mage_Core_Model_Abstract
4
  {
5
  public function _construct()
app/code/community/PriceWaiter/NYPWidget/Model/Display/Phrase.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Model_Display_Phrase
21
  {
22
  public function toOptionArray()
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Model_Display_Phrase
4
  {
5
  public function toOptionArray()
app/code/community/PriceWaiter/NYPWidget/Model/Display/Size.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Model_Display_Size
21
  {
22
  public function toOptionArray()
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Model_Display_Size
4
  {
5
  public function toOptionArray()
app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Category.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Model_Mysql4_Category extends Mage_Core_Model_Mysql4_Abstract
21
  {
22
  public function _construct()
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Model_Mysql4_Category extends Mage_Core_Model_Mysql4_Abstract
4
  {
5
  public function _construct()
app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Category/Collection.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Model_Mysql4_Category_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
21
  {
22
  public function _construct()
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Model_Mysql4_Category_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
  {
5
  public function _construct()
app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Order.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Model_Mysql4_Order extends Mage_Core_Model_Mysql4_Abstract
21
  {
22
  public function _construct()
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Model_Mysql4_Order extends Mage_Core_Model_Mysql4_Abstract
4
  {
5
  public function _construct()
app/code/community/PriceWaiter/NYPWidget/Model/Mysql4/Order/Collection.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Model_Mysql4_Order_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
21
  {
22
  public function _construct()
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Model_Mysql4_Order_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
  {
5
  public function _construct()
app/code/community/PriceWaiter/NYPWidget/Model/Observer.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Model_Observer
21
  {
22
  // Adds the "PriceWaiter" tab to the "Manage Categories" page
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Model_Observer
4
  {
5
  // Adds the "PriceWaiter" tab to the "Manage Categories" page
app/code/community/PriceWaiter/NYPWidget/Model/Order.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Model_Order extends Mage_Core_Model_Abstract
21
  {
22
  public function _construct()
@@ -24,6 +7,27 @@ class PriceWaiter_NYPWidget_Model_Order extends Mage_Core_Model_Abstract
24
  $this->_init('nypwidget/order', 'entity_id');
25
  }
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  public function loadByPriceWaiterId($pricewaiterId)
28
  {
29
  if (is_null($pricewaiterId)) {
@@ -40,5 +44,4 @@ class PriceWaiter_NYPWidget_Model_Order extends Mage_Core_Model_Abstract
40
 
41
  return $this;
42
  }
43
-
44
  }
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Model_Order extends Mage_Core_Model_Abstract
4
  {
5
  public function _construct()
7
  $this->_init('nypwidget/order', 'entity_id');
8
  }
9
 
10
+ /**
11
+ * @param String $orderId
12
+ * @return PriceWaiter_NYPWidget_Model_Order $this
13
+ */
14
+ public function loadByMagentoOrderId($orderId)
15
+ {
16
+ $collection = Mage::getModel('nypwidget/order')
17
+ ->getCollection()
18
+ ->addFieldToFilter('order_id', $orderId);
19
+
20
+ if (count($collection)) {
21
+ $this->load($collection->getFirstItem()->getEntityId());
22
+ }
23
+
24
+ return $this;
25
+ }
26
+
27
+ /**
28
+ * @param String $pricewaiterId
29
+ * @return PriceWaiter_NYPWidget_Model_Order $this
30
+ */
31
  public function loadByPriceWaiterId($pricewaiterId)
32
  {
33
  if (is_null($pricewaiterId)) {
44
 
45
  return $this;
46
  }
 
47
  }
app/code/community/PriceWaiter/NYPWidget/Model/PaymentMethod.php CHANGED
@@ -1,30 +1,19 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
  */
19
-
20
  class PriceWaiter_NYPWidget_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract
21
  {
22
  protected $_code = 'nypwidget';
23
 
 
 
 
24
  protected $_isGateway = false;
25
  protected $_canOrder = true;
26
- protected $_canAuthorize = false;
27
- protected $_canCapture = false;
28
  protected $_canCapturePartial = false;
29
  protected $_canRefund = false;
30
  protected $_canVoid = true;
@@ -32,8 +21,13 @@ class PriceWaiter_NYPWidget_Model_PaymentMethod extends Mage_Payment_Model_Metho
32
  protected $_canUseCheckout = false;
33
  protected $_canUseForMultishipping = false;
34
 
 
 
35
  public function authorize(Varien_Object $payment, $amount)
36
  {
 
 
 
37
  return $this;
38
  }
39
 
@@ -51,4 +45,83 @@ class PriceWaiter_NYPWidget_Model_PaymentMethod extends Mage_Payment_Model_Metho
51
  {
52
  return false;
53
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
1
  <?php
2
 
3
+ /**
4
+ * PriceWaiter Payment method.
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  */
 
6
  class PriceWaiter_NYPWidget_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract
7
  {
8
  protected $_code = 'nypwidget';
9
 
10
+ // Custom info block to display payment details on order in admin.
11
+ protected $_infoBlockType = 'nypwidget/payment_info_pricewaiter';
12
+
13
  protected $_isGateway = false;
14
  protected $_canOrder = true;
15
+ protected $_canAuthorize = true;
16
+ protected $_canCapture = true;
17
  protected $_canCapturePartial = false;
18
  protected $_canRefund = false;
19
  protected $_canVoid = true;
21
  protected $_canUseCheckout = false;
22
  protected $_canUseForMultishipping = false;
23
 
24
+ private static $_currentOrderCallbackRequest = [];
25
+
26
  public function authorize(Varien_Object $payment, $amount)
27
  {
28
+ // Don't close transactions for auth-only.
29
+ $payment->setIsTransactionClosed(0);
30
+
31
  return $this;
32
  }
33
 
45
  {
46
  return false;
47
  }
48
+
49
+ public function getConfigData($field, $storeId = null)
50
+ {
51
+ if ($field !== 'order_status') {
52
+ return parent::getConfigData($field, $storeId);
53
+ }
54
+
55
+ if ($storeId === null) {
56
+ $storeId = $this->getStore();
57
+ }
58
+
59
+ $status = Mage::helper('nypwidget')->getDefaultOrderStatus($storeId);
60
+ return $status;
61
+ }
62
+
63
+ public function getConfigPaymentAction()
64
+ {
65
+ // For test orders (which will be immediately canceled) we don't
66
+ // want to "capture" payment, since that removes our ability to cancel.
67
+ if ($this->isCurrentRequestTest()) {
68
+ return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
69
+ }
70
+
71
+ // Detect auth-only transactions and, uh, only auth them.
72
+ if ($this->isCurrentRequestAuthorizeOnly()) {
73
+ return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
74
+ }
75
+
76
+ return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE;
77
+ }
78
+
79
+ /**
80
+ * @return boolean Whether the current order callback request being processed is authorize only (no capture).
81
+ */
82
+ protected function isCurrentRequestAuthorizeOnly()
83
+ {
84
+ $request = $this->getCurrentOrderCallbackRequest();
85
+
86
+ return (
87
+ is_array($request) &&
88
+ isset($request['transaction_type']) &&
89
+ strcasecmp($request['transaction_type'], 'auth') === 0
90
+ );
91
+ }
92
+
93
+ /**
94
+ * @return boolean Whether the current order callback request being processed is a test.
95
+ */
96
+ protected function isCurrentRequestTest()
97
+ {
98
+ $request = $this->getCurrentOrderCallbackRequest();
99
+ return is_array($request) && !empty($request['test']);
100
+ }
101
+
102
+ /**
103
+ * @internal
104
+ */
105
+ public static function resetCurrentOrderCallbackRequest()
106
+ {
107
+ self::$_currentOrderCallbackRequest = array();
108
+ }
109
+
110
+ /**
111
+ * @internal Hack to allow payment method access to incoming order data.
112
+ * @param Array $request
113
+ */
114
+ public static function setCurrentOrderCallbackRequest(Array $request)
115
+ {
116
+ self::$_currentOrderCallbackRequest = $request;
117
+ }
118
+
119
+ /**
120
+ * @internal
121
+ * @return Array
122
+ */
123
+ protected function getCurrentOrderCallbackRequest()
124
+ {
125
+ return self::$_currentOrderCallbackRequest;
126
+ }
127
  }
app/code/community/PriceWaiter/NYPWidget/Model/Resource/Eav/Mysql4/Setup.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
21
  {
22
 
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
4
  {
5
 
app/code/community/PriceWaiter/NYPWidget/controllers/Adminhtml/PricewaiterController.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_Adminhtml_PriceWaiterController extends Mage_Adminhtml_Controller_Action
21
  {
22
 
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_Adminhtml_PriceWaiterController extends Mage_Adminhtml_Controller_Action
4
  {
5
 
app/code/community/PriceWaiter/NYPWidget/controllers/CallbackController.php CHANGED
@@ -1,55 +1,69 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_CallbackController extends Mage_Core_Controller_Front_Action
21
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  public function indexAction()
24
  {
25
- if (!$this->getRequest()->isPost()) {
26
- $this->_log("HTTP Request is invalid.");
 
 
 
 
27
  return;
28
  }
29
 
30
- Mage::helper('nypwidget')->setHeaders();
 
 
31
 
32
- try {
33
- $request = $this->getRequest()->getPost();
34
- if (!array_key_exists('pricewaiter_id', $request)) {
35
- $this->_log($request);
36
- $this->_log("PriceWaiter Notification is missing required fields.");
37
- return;
38
- }
39
- $this->_log("Incoming PriceWaiter order notification.");
40
- $this->_log($request);
41
- Mage::getModel('nypwidget/callback')->processRequest($request);
42
- } catch (Exception $e) {
43
- Mage::logException($e);
44
- $this->_log($e);
45
  }
46
- }
 
 
 
 
 
47
 
48
- private function _log($message)
49
- {
50
- if (Mage::getStoreConfig('pricewaiter/configuration/log')) {
51
- Mage::log($message, null, "PriceWaiter_Callback.log");
 
 
 
 
 
 
 
 
 
 
 
52
  }
53
  }
54
-
55
  }
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_CallbackController extends Mage_Core_Controller_Front_Action
4
  {
5
+ /**
6
+ * Header used to pass error messages back to PriceWaiter.
7
+ */
8
+ const ERROR_MESSAGE_HEADER = 'X-Platform-Error';
9
+
10
+ /**
11
+ * Header used to pass error codes back to PriceWaiter.
12
+ */
13
+ const ERROR_CODE_HEADER = 'X-Platform-Error-Code';
14
+
15
+ /**
16
+ * Header used to pass the generated order id back to PriceWaiter.
17
+ */
18
+ const ORDER_ID_HEADER = 'X-Platform-Order-Id';
19
 
20
  public function indexAction()
21
  {
22
+ $httpRequest = $this->getRequest();
23
+ $httpResponse = $this->getResponse();
24
+
25
+ if (!$httpRequest->isPost()) {
26
+ // Pretend like this page isn't even *here*
27
+ $this->norouteAction();
28
  return;
29
  }
30
 
31
+ // Add debugging headers
32
+ Mage::helper('nypwidget')->setHeaders($httpResponse);
33
+ $pricewaiterId = '';
34
 
35
+ try
36
+ {
37
+ $data = $httpRequest->getPost();
38
+
39
+ $order = Mage::getModel('nypwidget/callback')
40
+ ->processRequest($data);
41
+
42
+ // Success!
43
+ $httpResponse->setHeader(self::ORDER_ID_HEADER, $order->getIncrementId(), true);
 
 
 
 
44
  }
45
+ catch (Exception $ex)
46
+ {
47
+ // Augment duplicate order errors with the existing order id.
48
+ if ($ex instanceof PriceWaiter_NYPWidget_Exception_DuplicateOrder) {
49
+ $httpResponse->setHeader(self::ORDER_ID_HEADER, $ex->getExistingOrderId(), true);
50
+ }
51
 
52
+ if ($ex instanceof PriceWaiter_NYPWidget_Exception_Abstract) {
53
+ // These are normal errors indicating problems we've previously thought of
54
+ // occurring during error processing.
55
+ $httpResponse->setHttpResponseCode($ex->httpStatusCode);
56
+
57
+ if (!empty($ex->errorCode)) {
58
+ $httpResponse->setHeader(self::ERROR_CODE_HEADER, $ex->errorCode, true);
59
+ }
60
+
61
+ } else {
62
+ // These are not.
63
+ $httpResponse->setHttpResponseCode(500);
64
+ }
65
+
66
+ $httpResponse->setHeader(self::ERROR_MESSAGE_HEADER, $ex->getMessage(), true);
67
  }
68
  }
 
69
  }
app/code/community/PriceWaiter/NYPWidget/controllers/ProductinfoController.php CHANGED
@@ -1,22 +1,5 @@
1
  <?php
2
 
3
- /*
4
- * Copyright 2013-2015 Price Waiter, LLC
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- */
19
-
20
  class PriceWaiter_NYPWidget_ProductinfoController extends Mage_Core_Controller_Front_Action
21
  {
22
  public function indexAction()
@@ -44,6 +27,12 @@ class PriceWaiter_NYPWidget_ProductinfoController extends Mage_Core_Controller_F
44
  $productConfiguration = array();
45
  parse_str(urldecode($postFields['_magento_product_configuration']), $productConfiguration);
46
 
 
 
 
 
 
 
47
  // Create a cart and add the product to it
48
  // This is necessary to make Magento calculate the cost of the item in the correct context.
49
  try {
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PriceWaiter_NYPWidget_ProductinfoController extends Mage_Core_Controller_Front_Action
4
  {
5
  public function indexAction()
27
  $productConfiguration = array();
28
  parse_str(urldecode($postFields['_magento_product_configuration']), $productConfiguration);
29
 
30
+ // always lookup the product with a low quantity
31
+ // the below code will fail if the product is out of stock
32
+ if ($productConfiguration && isset($productConfiguration['qty'])) {
33
+ $productConfiguration['qty'] = 1;
34
+ }
35
+
36
  // Create a cart and add the product to it
37
  // This is necessary to make Magento calculate the cost of the item in the correct context.
38
  try {
app/code/community/PriceWaiter/NYPWidget/etc/adminhtml.xml CHANGED
@@ -1,19 +1,4 @@
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <!--
3
- Copyright 2013-2015 Price Waiter, LLC
4
-
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
- -->
17
  <config>
18
  <acl>
19
  <resources>
1
  <?xml version="1.0" encoding="utf-8"?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  <config>
3
  <acl>
4
  <resources>
app/code/community/PriceWaiter/NYPWidget/etc/config.xml CHANGED
@@ -1,24 +1,9 @@
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <!--
3
- Copyright 2013-2015 Price Waiter, LLC
4
-
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
- -->
17
  <config>
18
 
19
  <modules>
20
  <PriceWaiter_NYPWidget>
21
- <version>2.2.2</version>
22
  </PriceWaiter_NYPWidget>
23
  </modules>
24
 
@@ -147,8 +132,11 @@
147
  <pricewaiter>
148
  <configuration>
149
  <enabled>0</enabled>
150
- <log>1</log>
151
  </configuration>
 
 
 
 
152
  <customer_groups>
153
  <disable>0</disable>
154
  <group_select>0</group_select>
@@ -177,7 +165,6 @@
177
  <model>nypwidget/paymentMethod</model>
178
  <order_status>pricewaiter_processing</order_status>
179
  <title>PriceWaiter Payment</title>
180
- <payment_action>authorize</payment_action>
181
  <allowspecific>0</allowspecific>
182
  </nypwidget>
183
  </payment>
1
  <?xml version="1.0" encoding="utf-8"?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  <config>
3
 
4
  <modules>
5
  <PriceWaiter_NYPWidget>
6
+ <version>2.5.0</version>
7
  </PriceWaiter_NYPWidget>
8
  </modules>
9
 
132
  <pricewaiter>
133
  <configuration>
134
  <enabled>0</enabled>
 
135
  </configuration>
136
+ <orders>
137
+ <default_status>processing</default_status>
138
+ <log>1</log>
139
+ </orders>
140
  <customer_groups>
141
  <disable>0</disable>
142
  <group_select>0</group_select>
165
  <model>nypwidget/paymentMethod</model>
166
  <order_status>pricewaiter_processing</order_status>
167
  <title>PriceWaiter Payment</title>
 
168
  <allowspecific>0</allowspecific>
169
  </nypwidget>
170
  </payment>
app/code/community/PriceWaiter/NYPWidget/etc/system.xml CHANGED
@@ -1,19 +1,4 @@
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <!--
3
- Copyright 2013-2015 Price Waiter, LLC
4
-
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
- -->
17
  <config>
18
  <sections>
19
  <pricewaiter>
@@ -111,8 +96,31 @@
111
  <show_in_website>1</show_in_website>
112
  <show_in_store>1</show_in_store>
113
  </api_secret>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  <log translate="label comment">
115
- <label>Log Callback Information</label>
116
  <comment>
117
  <![CDATA[Log information about order
118
  notifications from PriceWaiter. For
@@ -128,7 +136,7 @@
128
  <show_in_store>1</show_in_store>
129
  </log>
130
  </fields>
131
- </configuration>
132
  <customer_groups translate="label">
133
  <label>Disable button by Customer Groups</label>
134
  <frontend_type>text</frontend_type>
1
  <?xml version="1.0" encoding="utf-8"?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  <config>
3
  <sections>
4
  <pricewaiter>
96
  <show_in_website>1</show_in_website>
97
  <show_in_store>1</show_in_store>
98
  </api_secret>
99
+ </fields>
100
+ </configuration>
101
+ <orders translate="label">
102
+ <label>Orders</label>
103
+ <frontend_type>text</frontend_type>
104
+ <sort_order>2</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>1</show_in_store>
108
+ <expanded>1</expanded>
109
+ <fields>
110
+ <default_status translate="label comment">
111
+ <label>Status for Incoming Orders</label>
112
+ <comment>
113
+ <![CDATA[Orders from PriceWaiter will be given this status when they first enter the system.]]>
114
+ </comment>
115
+ <frontend_type>select</frontend_type>
116
+ <source_model>adminhtml/system_config_source_order_status</source_model>
117
+ <sort_order>10</sort_order>
118
+ <show_in_default>1</show_in_default>
119
+ <show_in_website>1</show_in_website>
120
+ <show_in_store>1</show_in_store>
121
+ </default_status>
122
  <log translate="label comment">
123
+ <label>Log Incoming Orders</label>
124
  <comment>
125
  <![CDATA[Log information about order
126
  notifications from PriceWaiter. For
136
  <show_in_store>1</show_in_store>
137
  </log>
138
  </fields>
139
+ </orders>
140
  <customer_groups translate="label">
141
  <label>Disable button by Customer Groups</label>
142
  <frontend_type>text</frontend_type>
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-install-1.0.0.php CHANGED
@@ -1,20 +1,4 @@
1
  <?php
2
- /*
3
- * Copyright 2013-2015 Price Waiter, LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- *
17
- */
18
 
19
  // Product types supported by the Name Your Price Widget
20
  // $supportTypeIds = array('simple', 'configurable');
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  // Product types supported by the Name Your Price Widget
4
  // $supportTypeIds = array('simple', 'configurable');
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.1.2-1.1.3.php CHANGED
@@ -1,20 +1,4 @@
1
  <?php
2
- /*
3
- * Copyright 2013-2015 Price Waiter, LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- *
17
- */
18
 
19
  // Product types supported by the Name Your Price Widget
20
  $supportTypeIds = array('simple', 'configurable', 'grouped', 'bundle');
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  // Product types supported by the Name Your Price Widget
4
  $supportTypeIds = array('simple', 'configurable', 'grouped', 'bundle');
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.1.7-1.1.8.php CHANGED
@@ -1,20 +1,4 @@
1
  <?php
2
- /*
3
- * Copyright 2013-2015 Price Waiter, LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- *
17
- */
18
 
19
  // Add table to keep track of order IDs associated with `pricewaiter_id`s
20
  // Will prevent duplicate orders from the order callback API
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  // Add table to keep track of order IDs associated with `pricewaiter_id`s
4
  // Will prevent duplicate orders from the order callback API
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.2.4-1.2.5.php CHANGED
@@ -1,20 +1,4 @@
1
  <?php
2
- /*
3
- * Copyright 2013-2015 Price Waiter, LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- *
17
- */
18
 
19
  $this->startSetup();
20
 
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  $this->startSetup();
4
 
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-1.3.0-1.3.1.php CHANGED
@@ -1,20 +1,4 @@
1
  <?php
2
- /*
3
- * Copyright 2013-2015 Price Waiter, LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- *
17
- */
18
 
19
  // Product types supported by the Name Your Price Widget
20
  $supportTypeIds = array('simple', 'configurable', 'grouped', 'bundle');
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  // Product types supported by the Name Your Price Widget
4
  $supportTypeIds = array('simple', 'configurable', 'grouped', 'bundle');
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-2.1.5-2.2.0.php CHANGED
@@ -1,20 +1,4 @@
1
  <?php
2
- /*
3
- * Copyright 2013-2015 Price Waiter, LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- *
17
- */
18
 
19
  $installer = $this;
20
  $installer->startSetup();
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  $installer = $this;
4
  $installer->startSetup();
app/code/community/PriceWaiter/NYPWidget/sql/nypwidget_setup/mysql4-upgrade-2.2.0-2.5.0.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ // 1. Figure out if any orders used the old "Processing - PriceWaiter" setting
7
+ $processingOrders = Mage::getModel('sales/order')->getCollection()
8
+ ->addFieldToFilter('status', 'pricewaiter_processing')
9
+ ->addAttributeToSelect('created_at');
10
+
11
+ $isPriceWaiterProcessingUsed = $processingOrders->count() > 0;
12
+
13
+ // 2. If not, delete it.
14
+ if (!$isPriceWaiterProcessingUsed) {
15
+
16
+ $status = Mage::getModel('sales/order_status')
17
+ ->getCollection()
18
+ ->addFieldToFilter('status', 'pricewaiter_processing')
19
+ ->getFirstItem();
20
+
21
+ if ($status) {
22
+ $status->delete();
23
+ }
24
+ }
25
+
26
+ // 3. Figure out what the default status should be for new orders
27
+ $defaultOrderStatus = null;
28
+
29
+ if ($isPriceWaiterProcessingUsed) {
30
+ // Keep using "Processing - PriceWaiter" if we have been.
31
+ $defaultOrderStatus = 'pricewaiter_processing';
32
+ } else {
33
+ // Otherwise, just use the default status for the "processing" state
34
+ $status = Mage::getModel('sales/order_status')
35
+ ->loadDefaultByState(Mage_Sales_Model_Order::STATE_PROCESSING);
36
+ $defaultOrderStatus = $status->getStatus();
37
+ }
38
+
39
+ // 4. Assign value for default order status setting for each store
40
+ if ($defaultOrderStatus) {
41
+ $this->setConfigData('pricewaiter/orders/default_status', $defaultOrderStatus);
42
+ }
app/design/adminhtml/default/default/layout/pricewaiter.xml CHANGED
@@ -1,19 +1,4 @@
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <!--
3
- Copyright 2013-2015 Price Waiter, LLC
4
-
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
- -->
17
  <layout>
18
  <adminhtml_system_config_edit>
19
  <reference name="head">
1
  <?xml version="1.0" encoding="utf-8"?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  <layout>
3
  <adminhtml_system_config_edit>
4
  <reference name="head">
app/design/adminhtml/default/default/template/pricewaiter/categorytab.phtml CHANGED
@@ -1,22 +1,4 @@
1
  <?php
2
- /*
3
- * Copyright 2013-2015 Price Waiter, LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- *
17
- */
18
- ?>
19
- <?php
20
  $enabled = $this->getIsEnabled();
21
  $ctEnabled = $this->getIsConversionToolsEnabled();
22
  ?>
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  $enabled = $this->getIsEnabled();
3
  $ctEnabled = $this->getIsConversionToolsEnabled();
4
  ?>
app/design/frontend/base/default/layout/pricewaiter.xml CHANGED
@@ -1,19 +1,4 @@
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <!--
3
- Copyright 2013-2015 Price Waiter, LLC
4
-
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
- -->
17
  <layout>
18
  <catalog_product_view>
19
  <reference name="head">
1
  <?xml version="1.0" encoding="utf-8"?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  <layout>
3
  <catalog_product_view>
4
  <reference name="head">
app/design/frontend/base/default/template/pricewaiter/widget.phtml CHANGED
@@ -1,21 +1,3 @@
1
- <?php
2
- /*
3
- * Copyright 2013-2015 Price Waiter, LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- *
17
- */
18
- ?>
19
  <?php $_product = Mage::registry('current_product'); ?>
20
  <?php if ($_product->isSaleable()): ?>
21
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php $_product = Mage::registry('current_product'); ?>
2
  <?php if ($_product->isSaleable()): ?>
3
  <?php
app/etc/modules/PriceWaiter_NYPWidget.xml CHANGED
@@ -1,19 +1,4 @@
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <!--
3
- Copyright 2013-2015 Price Waiter, LLC
4
-
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
- -->
17
  <config>
18
  <modules>
19
  <PriceWaiter_NYPWidget>
1
  <?xml version="1.0" encoding="utf-8"?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  <config>
3
  <modules>
4
  <PriceWaiter_NYPWidget>
js/pricewaiter/product-pages.js CHANGED
@@ -1,22 +1 @@
1
-
2
- /*
3
- * Copyright 2013-2015 Price Waiter, LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- *
17
- */
18
-
19
- (function() {
20
-
21
-
22
- }).call(this);
1
+ /* Left empty to ensure removal of previous version on upgrade */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/pricewaiter/token.js CHANGED
@@ -1,21 +1,3 @@
1
-
2
- /**
3
- * Copyright 2013-2015 Price Waiter, LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- *
17
- */
18
-
19
  (function() {
20
  document.observe('dom:loaded', function() {
21
  var apiSecret, button, enableButton, fetchSecret, fetchToken, pwSignup, scope, tokenInput;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  (function() {
2
  document.observe('dom:loaded', function() {
3
  var apiSecret, button, enableButton, fetchSecret, fetchToken, pwSignup, scope, tokenInput;
package.xml CHANGED
@@ -1,14 +1,14 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>nypwidget</name>
4
- <version>2.2.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License, Version 2.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>PriceWaiter lets buyers make offers on your products that you can easily accept, counter offer or reject.</summary>
10
  <description>Sell more, immediately, with the PriceWaiter widget. Convert comparison shoppers you might have lost, increase sales and conversions, and stop "minimum advertised price" from preventing sales before they even start.&#xD;&#xD; PriceWaiter lets customers make offers on products you sell-- offers you can accept, reject or counter. The widget embeds a simple Name Your Price button on any product page or category that you choose. Simply install the extension and you'll have full control over PriceWaiter in your Magento admin control panel.</description>
11
- <notes>Bug Fix:&#xD;- Resolves some order writing issues.</notes>
12
  <authors>
13
  <author>
14
  <name>PriceWaiter</name>
@@ -16,15 +16,15 @@
16
  <email>extensions@pricewaiter.com</email>
17
  </author>
18
  </authors>
19
- <date>2016-03-07</date>
20
- <time>19:22:44</time>
21
- <contents><target name="mageweb"><dir name="app"><dir name="etc"><dir name="modules"><file name="PriceWaiter_NYPWidget.xml" hash="72be18d9a8a741abc8926866449619cd"/></dir></dir><dir name="code"><dir name="community"><dir name="PriceWaiter"><dir name="NYPWidget"><dir name="Block"><dir name="Adminhtml"><file name="Link.php" hash="6b860db5d597f3ff697c927e3d08a085"/><file name="Signup.php" hash="35a2739246307b5c7a3b69780a7f31fd"/><file name="Widget.php" hash="b781daf1de34d7856de7faba65afe414"/></dir><file name="Category.php" hash="de6397a45d7deabc803bef83a83d6b9a"/><file name="Widget.php" hash="193d694c4acc2133d8402f1e59d4dc25"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PricewaiterController.php" hash="27e17f05c8e2b2edcc28230185334f35"/></dir><file name="CallbackController.php" hash="4c45b3d73999c3e69a11538b99b3b3fd"/><file name="ProductinfoController.php" hash="62780d33252c907cd48f9ff3326b3e8b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="dff2f6de0dacaf5a933048fa4a347f2f"/><file name="config.xml" hash="220d3ee18d35807d2cd2f63d80a5183e"/><file name="system.xml" hash="5188b4e0994ed8b51a10f4129b3c0d19"/></dir><dir name="Helper"><file name="Data.php" hash="3ac3e13715ee6ece2d53d67213a19939"/></dir><dir name="Model"><file name="Callback.php" hash="441661b9a5a6d812a1d39b1a199da2a0"/><file name="Category.php" hash="884685769be745cb273833ab7d691593"/><file name="Observer.php" hash="2399e210dd82633091570483f144bf12"/><file name="Order.php" hash="080844dcc4cf55d516abe27175a3a62a"/><file name="PaymentMethod.php" hash="386134e1ac803580222263523f0ced31"/><dir name="Carrier"><file name="ShippingMethod.php" hash="43a6ec1ad462797a5359238dcf9a749d"/></dir><dir name="Display"><file name="Phrase.php" hash="5b595a42b487930154c505a8e9a1301c"/><file name="Size.php" hash="8a596164268f48c3c034274550b13b96"/></dir><dir name="Mysql4"><dir name="Category"><file name="Collection.php" hash="45eaa532cd5935b69102b8969da848fa"/></dir><file name="Category.php" hash="f4e761813ec4bb81d919f30895ce3578"/><file name="Order.php" hash="c08b340cec16bf774a7c178726dee0ac"/><dir name="Order"><file name="Collection.php" hash="4dc5b344274c0e5a391a24864fd1c003"/></dir></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="d63678e9cc718ee87e8db3ca5163a8fd"/></dir></dir></dir></dir><dir name="sql"><dir name="nypwidget_setup"><file name="mysql4-install-1.0.0.php" hash="cd1b7892e75e4452ee94afbbefb4de6e"/><file name="mysql4-upgrade-1.1.2-1.1.3.php" hash="5a3771ffa0121abd2a6951832d5d9cff"/><file name="mysql4-upgrade-1.1.7-1.1.8.php" hash="bd342c802f6c91de6f9f51b0a4a25414"/><file name="mysql4-upgrade-1.2.4-1.2.5.php" hash="b1ced0226bef6e950e026402b933872f"/><file name="mysql4-upgrade-1.3.0-1.3.1.php" hash="6679da88507af81c186489afc0c9de11"/><file name="mysql4-upgrade-2.1.5-2.2.0.php" hash="3c07f9cb641d892862d8493535d5d761"/></dir></dir></dir></dir></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="pricewaiter.xml" hash="9e06026a8a820224336de4c9a7dde3fd"/></dir><dir name="template"><dir name="pricewaiter"><file name="categorytab.phtml" hash="d1d2c333cc9b18c909a44d333d8ab077"/><file name="signup.phtml" hash="fc18c669c18c55cccdf2c66c96199dec"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="pricewaiter.xml" hash="ab65e8c99c560997d403a780295a47da"/></dir><dir name="template"><dir name="pricewaiter"><file name="widget.phtml" hash="9b8c7e38ecadb2f84f37b61d973f707e"/></dir></dir></dir></dir></dir></dir></dir><dir name="skin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="pricewaiter_logo.png" hash="becb9713a561131ff69eabb7503d3e74"/><file name="pricewaiter_tab.png" hash="1bab71be6b1a93aee2ae7aeae3807484"/><file name="pricewaiter_logo.png" hash="becb9713a561131ff69eabb7503d3e74"/><file name="pricewaiter_tab.png" hash="1bab71be6b1a93aee2ae7aeae3807484"/></dir><file name="pricewaiter.css" hash="c4061169f3e505c28bd09924108ca0ad"/></dir></dir></dir></dir><dir name="js"><dir name="pricewaiter"><file name="product-pages.js" hash="073eb5cd568a3db8b3ab7f94d5ffba3c"/><file name="token.js" hash="dbaedb04a60982743949e16096ed7f58"/></dir></dir></target></contents>
22
  <compatible/>
23
  <dependencies>
24
  <required>
25
  <php>
26
- <min>5.2.0</min>
27
- <max>6.0.0</max>
28
  </php>
29
  </required>
30
  </dependencies>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>nypwidget</name>
4
+ <version>2.5.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License, Version 2.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>PriceWaiter lets buyers make offers on your products that you can easily accept, counter offer or reject.</summary>
10
  <description>Sell more, immediately, with the PriceWaiter widget. Convert comparison shoppers you might have lost, increase sales and conversions, and stop "minimum advertised price" from preventing sales before they even start.&#xD;&#xD; PriceWaiter lets customers make offers on products you sell-- offers you can accept, reject or counter. The widget embeds a simple Name Your Price button on any product page or category that you choose. Simply install the extension and you'll have full control over PriceWaiter in your Magento admin control panel.</description>
11
+ <notes>Order callback improvements and bugfixes.</notes>
12
  <authors>
13
  <author>
14
  <name>PriceWaiter</name>
16
  <email>extensions@pricewaiter.com</email>
17
  </author>
18
  </authors>
19
+ <date>2016-05-05</date>
20
+ <time>19:05:56</time>
21
+ <contents><target name="mageweb"><dir name="app"><dir name="code"><dir name="community"><dir name="PriceWaiter"><dir name="NYPWidget"><dir name="Block"><dir name="Adminhtml"><file name="Link.php" hash="f17d6461e82c76a3a49266aa6a6b23e4"/><file name="Signup.php" hash="f3464994c972a3f0dcc7747ed011bbff"/><file name="Widget.php" hash="a5a15261dae201aca09a8249fe7e8a81"/></dir><file name="Category.php" hash="1047b4af8b7e438964dff8d82e7d8cf6"/><file name="Widget.php" hash="b6b1d0eab14ccb31a06971d6b824ed45"/><dir name="Payment"><dir name="Info"><file name="Pricewaiter.php" hash="ea9b94211a536552689d95c1664894e7"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="PricewaiterController.php" hash="29d6f14dc97fde5c5d1c5bb969692b9a"/></dir><file name="CallbackController.php" hash="efedef40a3b35220216eeabbd3ae3567"/><file name="ProductinfoController.php" hash="e5a7fcef7d4e4025c9e56268f5fe2dbe"/></dir><dir name="etc"><file name="adminhtml.xml" hash="57af207c7a6966d365ed41ebe6d88ecb"/><file name="config.xml" hash="d930943a7f1ecb3c17af9601b24e5c73"/><file name="system.xml" hash="3d83e0edf292b6e653d30f05382f1d9b"/></dir><dir name="Exception"><file name="Abstract.php" hash="d19b842ccbefffb2132c957b7feaf3e1"/><file name="ApiKey.php" hash="0cb0715d3242092d5e1fbecb8d978f59"/><file name="DuplicateOrder.php" hash="91eb14444c1bb6e01ddf2a78b92419c9"/><file name="InvalidOrderData.php" hash="6bbb8a438f1464acae9077b7d00f197c"/><file name="InvalidRegion.php" hash="02b69fca49a6584999d979816afca19d"/><file name="OutOfStock.php" hash="767b26a3d548ad92d86048f42910af6f"/><file name="Signature.php" hash="5244f5902f9141a189df78f696814a63"/><dir name="Product"><file name="Abstract.php" hash="1cb077cd79f7185657efb09ff285c7e9"/><file name="NotFound.php" hash="8e1507ab1798d85ce722705c913da441"/></dir></dir><dir name="Helper"><file name="Data.php" hash="69ef8411e6f6b3ef2d5424c24b893fb8"/></dir><dir name="Model"><dir name="Callback"><file name="Inventory.php" hash="0be9afd71ec20b87ba29321f9fdc3cb8"/></dir><file name="Callback.php" hash="515f611b2be416ceb4bbd78a63aaefb2"/><file name="Category.php" hash="18826308eba00faaeffea8b473198ca4"/><file name="Observer.php" hash="0acd80de4ceb912ed8e7d48b017644a8"/><file name="Order.php" hash="86206e5678929e57b833f7ea4bc6bf96"/><file name="PaymentMethod.php" hash="369fecbbc3f8c766950cdcf36e93cf2b"/><dir name="Carrier"><file name="ShippingMethod.php" hash="93baf3d128481be22154b103cdf5d627"/></dir><dir name="Display"><file name="Phrase.php" hash="54339c37d5d88f0b2e68dfbe814af2e2"/><file name="Size.php" hash="2a70f37e54202f4a8de5a3f0b376f090"/></dir><dir name="Mysql4"><dir name="Category"><file name="Collection.php" hash="a5113a9db28d82cedcc8eb2c9b609a88"/></dir><file name="Category.php" hash="656c556879e61bbb20733ffc1dbe38d0"/><file name="Order.php" hash="ebecab2ef597171207ae787b0ddb68df"/><dir name="Order"><file name="Collection.php" hash="07773d6ca5bdf74d14e2d3290466b28f"/></dir></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="c23a03f23524957235bb3cbd1363551b"/></dir></dir></dir></dir><dir name="sql"><dir name="nypwidget_setup"><file name="mysql4-install-1.0.0.php" hash="b977c3a62af93441d115650b543ff858"/><file name="mysql4-upgrade-1.1.2-1.1.3.php" hash="df453265b32071329de809aa750dd31f"/><file name="mysql4-upgrade-1.1.7-1.1.8.php" hash="9b18e12698cbdc6896666b26362a7ddb"/><file name="mysql4-upgrade-1.2.4-1.2.5.php" hash="5e501f27bf223c34e19443923e998021"/><file name="mysql4-upgrade-1.3.0-1.3.1.php" hash="4cd7633a027696aa74668c61c58a83e2"/><file name="mysql4-upgrade-2.1.5-2.2.0.php" hash="be3f748105ff6bf61d4329b967c09c94"/><file name="mysql4-upgrade-2.2.0-2.5.0.php" hash="c02dacf91e070d7274daeda881e68f2a"/></dir></dir></dir></dir></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="pricewaiter.xml" hash="646560535c94bf42ed75438ec9cc6b9f"/></dir><dir name="template"><dir name="pricewaiter"><file name="categorytab.phtml" hash="703fcf0daa0fb71bef23987a9896bd29"/><file name="signup.phtml" hash="fc18c669c18c55cccdf2c66c96199dec"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="pricewaiter.xml" hash="d578d936a726cca4837d5f2e58c5ca45"/></dir><dir name="template"><dir name="pricewaiter"><file name="widget.phtml" hash="1035d7df739b2a80a581b13684f95b39"/></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="PriceWaiter_NYPWidget.xml" hash="7649918eb71009656f956a077f0cf6a8"/></dir></dir></dir><dir name="js"><dir name="pricewaiter"><file name="product-pages.js" hash="775a2c04db1f58c50f204ed7e15aef76"/><file name="token.js" hash="79ce2bdf4d9ae33fb4ef38c298f2dffe"/></dir></dir><dir name="skin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="pricewaiter_logo.png" hash="becb9713a561131ff69eabb7503d3e74"/><file name="pricewaiter_tab.png" hash="1bab71be6b1a93aee2ae7aeae3807484"/><file name="pricewaiter_logo.png" hash="becb9713a561131ff69eabb7503d3e74"/><file name="pricewaiter_tab.png" hash="1bab71be6b1a93aee2ae7aeae3807484"/></dir><file name="pricewaiter.css" hash="cbda20d51ec4c1505962c1e79007d7f7"/></dir></dir></dir></dir></target></contents>
22
  <compatible/>
23
  <dependencies>
24
  <required>
25
  <php>
26
+ <min>5.3.0</min>
27
+ <max>8.0.0</max>
28
  </php>
29
  </required>
30
  </dependencies>
skin/adminhtml/default/default/pricewaiter.css CHANGED
@@ -1,19 +1,3 @@
1
- /*
2
- * Copyright 2013-2015 Price Waiter, LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
  h3.pricewaiter-header {
18
  background: url(images/pricewaiter_logo.png) no-repeat 0 0;
19
  height: 0px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  h3.pricewaiter-header {
2
  background: url(images/pricewaiter_logo.png) no-repeat 0 0;
3
  height: 0px;