Version Notes
Upgraded with commit and refund functionality
Download this release
Release Info
Developer | ZooZ Payments |
Extension | ZooZ_payment |
Version | 2.0.8 |
Comparing to | |
See all releases |
Code changes from version 2.0.3 to 2.0.8
- app/code/community/ZooZ/ZoozPayment/Helper/Data.php +25 -2
- app/code/community/ZooZ/ZoozPayment/Model/Estimate.php +238 -238
- app/code/community/ZooZ/ZoozPayment/Model/Observer.php +247 -0
- app/code/community/ZooZ/ZoozPayment/Model/Order.php +191 -316
- app/code/community/ZooZ/ZoozPayment/Model/Source/Action.php +18 -0
- app/code/community/ZooZ/ZoozPayment/Model/Source/Status.php +18 -0
- app/code/community/ZooZ/ZoozPayment/Model/Standard.php +739 -588
- app/code/community/ZooZ/ZoozPayment/controllers/EstimateController.php +85 -26
- app/code/community/ZooZ/ZoozPayment/controllers/IndexController.php +65 -3
- app/code/community/ZooZ/ZoozPayment/controllers/StandardController.php +123 -90
- app/code/community/ZooZ/ZoozPayment/etc/config.xml +6 -0
- app/code/community/ZooZ/ZoozPayment/etc/system.xml +9 -1
- app/design/frontend/default/default/template/zoozpayment/index.phtml +0 -1
- app/design/frontend/default/default/template/zoozpayment/result.phtml +9 -8
- app/design/frontend/default/default/template/zoozpayment/shortcut-checkout.phtml +1 -1
- app/etc/modules/ZooZ_ZoozPayment.xml +1 -1
- lib/zooz/zooz.extended.server.api.php +6 -6
- package.xml +5 -5
app/code/community/ZooZ/ZoozPayment/Helper/Data.php
CHANGED
@@ -1,5 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
}
|
5 |
|
1 |
<?php
|
2 |
+
|
3 |
+
class ZooZ_ZoozPayment_Helper_Data extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
public function getTax() {
|
6 |
+
$totals = Mage::getSingleton("checkout/session")->getQuote()->getTotals(); //Total object
|
7 |
+
if (isset($totals['tax']) && $totals['tax']->getValue()) {
|
8 |
+
return $totals['tax']->getValue();
|
9 |
+
} else {
|
10 |
+
return 0;
|
11 |
+
}
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getshipping() {
|
15 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
16 |
+
return $shipping = $quote->getShippingAddress()->getShippingAmount();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getdiscount() {
|
20 |
+
$quote = Mage::getSingleton("checkout/session")->getQuote(); //Total object
|
21 |
+
Mage::log('Data.php -- Get discount - getSubtotalWithDiscount: ' . $quote->getSubtotalWithDiscount() . ' subtotal:' . $quote->getSubtotal());
|
22 |
+
|
23 |
+
return (float) $quote->getSubtotal() - $quote->getSubtotalWithDiscount();
|
24 |
+
|
25 |
+
}
|
26 |
+
|
27 |
}
|
28 |
|
app/code/community/ZooZ/ZoozPayment/Model/Estimate.php
CHANGED
@@ -1,238 +1,238 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Magento
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is bundled with this package in the file LICENSE.txt.
|
10 |
-
* It is also available through the world-wide-web at this URL:
|
11 |
-
* http://opensource.org/licenses/osl-3.0.php
|
12 |
-
*
|
13 |
-
* @category EcomDev
|
14 |
-
* @package Lotus_Getshipping
|
15 |
-
* @copyright Copyright (c) 2010 Ecommerce Developer Blog (http://www.ecomdev.org)
|
16 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
-
*/
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Estimate model
|
21 |
-
*
|
22 |
-
*/
|
23 |
-
class ZooZ_ZoozPayment_Model_Estimate {
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Customer object,
|
27 |
-
* if customer isn't logged in it quals to false
|
28 |
-
*
|
29 |
-
* @var Mage_Customer_Model_Customer|boolean
|
30 |
-
*/
|
31 |
-
protected $_customer = null;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Sales quote object to add products for shipping estimation
|
35 |
-
*
|
36 |
-
* @var Mage_Sales_Model_Quote
|
37 |
-
*/
|
38 |
-
protected $_quote = null;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Product model
|
42 |
-
*
|
43 |
-
* @var Mage_Catalog_Model_Product
|
44 |
-
*/
|
45 |
-
protected $_product = array();
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Estimation result
|
49 |
-
*
|
50 |
-
* @var array
|
51 |
-
*/
|
52 |
-
protected $_result = array();
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Delivery address information
|
56 |
-
*
|
57 |
-
* @var array
|
58 |
-
*/
|
59 |
-
protected $_addressInfo = null;
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Set address info for estimation
|
63 |
-
*
|
64 |
-
* @param array $info
|
65 |
-
* @return Lotus_Getshipping_Model_Estimate
|
66 |
-
*/
|
67 |
-
public function setAddressInfo($info) {
|
68 |
-
$this->_addressInfo = $info;
|
69 |
-
return $this;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Retrieve address information
|
74 |
-
*
|
75 |
-
* @return boolean
|
76 |
-
*/
|
77 |
-
public function getAddressInfo() {
|
78 |
-
return $this->_addressInfo;
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Set a product for the estimation
|
83 |
-
*
|
84 |
-
* @param Mage_Catalog_Model_Product $product
|
85 |
-
* @return Lotus_Getshipping_Model_Estimate
|
86 |
-
*/
|
87 |
-
public function setProduct($product) {
|
88 |
-
$this->_product[] = $product;
|
89 |
-
return $this;
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Retrieve product for the estimation
|
94 |
-
*/
|
95 |
-
public function getProduct() {
|
96 |
-
return $this->_product;
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* Retrieve shipping rate result
|
101 |
-
*
|
102 |
-
* @return array|null
|
103 |
-
*/
|
104 |
-
public function getResult() {
|
105 |
-
|
106 |
-
return $this->_result;
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Retrieve list of shipping rates
|
111 |
-
*
|
112 |
-
* @param Mage_Catalog_Model_Product $product
|
113 |
-
* @param array $info
|
114 |
-
* @param array $address
|
115 |
-
* @return Lotus_Getshipping_Model_Estimate
|
116 |
-
*/
|
117 |
-
public function estimate() {
|
118 |
-
$products = $this->getProduct();
|
119 |
-
foreach ($products as $product) {
|
120 |
-
$addToCartInfo = (array) $product->getAddToCartInfo();
|
121 |
-
$addressInfo = (array) $this->getAddressInfo();
|
122 |
-
if (!($product instanceof Mage_Catalog_Model_Product) || !$product->getId()) {
|
123 |
-
Mage::throwException(
|
124 |
-
Mage::helper('zoozpayment')->__('Please specify a valid product')
|
125 |
-
);
|
126 |
-
}
|
127 |
-
|
128 |
-
if (!isset($addressInfo['country_id'])) {
|
129 |
-
Mage::throwException(
|
130 |
-
Mage::helper('zoozpayment')->__('Please specify a country')
|
131 |
-
);
|
132 |
-
}
|
133 |
-
|
134 |
-
if (empty($addressInfo['cart'])) {
|
135 |
-
$this->resetQuote();
|
136 |
-
}
|
137 |
-
$shippingAddress = $this->getQuote()->getShippingAddress();
|
138 |
-
|
139 |
-
$shippingAddress->setCountryId($addressInfo['country_id']);
|
140 |
-
|
141 |
-
if (isset($addressInfo['region_id'])) {
|
142 |
-
$shippingAddress->setRegionId($addressInfo['region_id']);
|
143 |
-
}
|
144 |
-
|
145 |
-
if (isset($addressInfo['postcode'])) {
|
146 |
-
$shippingAddress->setPostcode($addressInfo['postcode']);
|
147 |
-
}
|
148 |
-
|
149 |
-
if (isset($addressInfo['region'])) {
|
150 |
-
$shippingAddress->setRegion($addressInfo['region']);
|
151 |
-
}
|
152 |
-
|
153 |
-
if (isset($addressInfo['city'])) {
|
154 |
-
$shippingAddress->setCity($addressInfo['city']);
|
155 |
-
}
|
156 |
-
|
157 |
-
$shippingAddress->setCollectShippingRates(true);
|
158 |
-
|
159 |
-
if (isset($addressInfo['coupon_code'])) {
|
160 |
-
$this->getQuote()->setCouponCode($addressInfo['coupon_code']);
|
161 |
-
}
|
162 |
-
|
163 |
-
$request = new Varien_Object($addToCartInfo);
|
164 |
-
|
165 |
-
if ($product->getStockItem()) {
|
166 |
-
$minimumQty = $product->getStockItem()->getMinSaleQty();
|
167 |
-
if ($minimumQty > 0 && $request->getQty() < $minimumQty) {
|
168 |
-
$request->setQty($minimumQty);
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
$result = $this->getQuote()->addProduct($product, $request);
|
173 |
-
}
|
174 |
-
if (is_string($result)) {
|
175 |
-
Mage::throwException($result);
|
176 |
-
}
|
177 |
-
|
178 |
-
Mage::dispatchEvent('checkout_cart_product_add_after', array('quote_item' => $result, 'product' => $product));
|
179 |
-
|
180 |
-
$this->getQuote()->collectTotals();
|
181 |
-
$this->_result = $shippingAddress->getGroupedAllShippingRates();
|
182 |
-
return $this;
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Retrieve sales quote object
|
187 |
-
*
|
188 |
-
* @return Mage_Sales_Model_Quote
|
189 |
-
*/
|
190 |
-
public function getQuote() {
|
191 |
-
if ($this->_quote === null) {
|
192 |
-
$addressInfo = $this->getAddressInfo();
|
193 |
-
if (!empty($addressInfo['cart'])) {
|
194 |
-
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
195 |
-
} else {
|
196 |
-
$quote = Mage::getModel('sales/quote');
|
197 |
-
}
|
198 |
-
|
199 |
-
$this->_quote = $quote;
|
200 |
-
}
|
201 |
-
|
202 |
-
return $this->_quote;
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Reset quote object
|
207 |
-
*
|
208 |
-
* @return Lotus_Getshipping_Model_Estimate
|
209 |
-
*/
|
210 |
-
public function resetQuote() {
|
211 |
-
$this->getQuote()->removeAllAddresses();
|
212 |
-
|
213 |
-
if ($this->getCustomer()) {
|
214 |
-
$this->getQuote()->setCustomer($this->getCustomer());
|
215 |
-
}
|
216 |
-
|
217 |
-
return $this;
|
218 |
-
}
|
219 |
-
|
220 |
-
/**
|
221 |
-
* Retrieve currently logged in customer,
|
222 |
-
* if customer isn't logged it returns false
|
223 |
-
*
|
224 |
-
* @return Mage_Customer_Model_Customer|boolean
|
225 |
-
*/
|
226 |
-
public function getCustomer() {
|
227 |
-
if ($this->_customer === null) {
|
228 |
-
$customerSession = Mage::getSingleton('customer/session');
|
229 |
-
if ($customerSession->isLoggedIn()) {
|
230 |
-
$this->_customer = $customerSession->getCustomer();
|
231 |
-
} else {
|
232 |
-
$this->_customer = false;
|
233 |
-
}
|
234 |
-
}
|
235 |
-
return $this->_customer;
|
236 |
-
}
|
237 |
-
|
238 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
*
|
13 |
+
* @category EcomDev
|
14 |
+
* @package Lotus_Getshipping
|
15 |
+
* @copyright Copyright (c) 2010 Ecommerce Developer Blog (http://www.ecomdev.org)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Estimate model
|
21 |
+
*
|
22 |
+
*/
|
23 |
+
class ZooZ_ZoozPayment_Model_Estimate {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Customer object,
|
27 |
+
* if customer isn't logged in it quals to false
|
28 |
+
*
|
29 |
+
* @var Mage_Customer_Model_Customer|boolean
|
30 |
+
*/
|
31 |
+
protected $_customer = null;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Sales quote object to add products for shipping estimation
|
35 |
+
*
|
36 |
+
* @var Mage_Sales_Model_Quote
|
37 |
+
*/
|
38 |
+
protected $_quote = null;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Product model
|
42 |
+
*
|
43 |
+
* @var Mage_Catalog_Model_Product
|
44 |
+
*/
|
45 |
+
protected $_product = array();
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Estimation result
|
49 |
+
*
|
50 |
+
* @var array
|
51 |
+
*/
|
52 |
+
protected $_result = array();
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Delivery address information
|
56 |
+
*
|
57 |
+
* @var array
|
58 |
+
*/
|
59 |
+
protected $_addressInfo = null;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Set address info for estimation
|
63 |
+
*
|
64 |
+
* @param array $info
|
65 |
+
* @return Lotus_Getshipping_Model_Estimate
|
66 |
+
*/
|
67 |
+
public function setAddressInfo($info) {
|
68 |
+
$this->_addressInfo = $info;
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Retrieve address information
|
74 |
+
*
|
75 |
+
* @return boolean
|
76 |
+
*/
|
77 |
+
public function getAddressInfo() {
|
78 |
+
return $this->_addressInfo;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Set a product for the estimation
|
83 |
+
*
|
84 |
+
* @param Mage_Catalog_Model_Product $product
|
85 |
+
* @return Lotus_Getshipping_Model_Estimate
|
86 |
+
*/
|
87 |
+
public function setProduct($product) {
|
88 |
+
$this->_product[] = $product;
|
89 |
+
return $this;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Retrieve product for the estimation
|
94 |
+
*/
|
95 |
+
public function getProduct() {
|
96 |
+
return $this->_product;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Retrieve shipping rate result
|
101 |
+
*
|
102 |
+
* @return array|null
|
103 |
+
*/
|
104 |
+
public function getResult() {
|
105 |
+
|
106 |
+
return $this->_result;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Retrieve list of shipping rates
|
111 |
+
*
|
112 |
+
* @param Mage_Catalog_Model_Product $product
|
113 |
+
* @param array $info
|
114 |
+
* @param array $address
|
115 |
+
* @return Lotus_Getshipping_Model_Estimate
|
116 |
+
*/
|
117 |
+
public function estimate() {
|
118 |
+
$products = $this->getProduct();
|
119 |
+
foreach ($products as $product) {
|
120 |
+
$addToCartInfo = (array) $product->getAddToCartInfo();
|
121 |
+
$addressInfo = (array) $this->getAddressInfo();
|
122 |
+
if (!($product instanceof Mage_Catalog_Model_Product) || !$product->getId()) {
|
123 |
+
Mage::throwException(
|
124 |
+
Mage::helper('zoozpayment')->__('Please specify a valid product')
|
125 |
+
);
|
126 |
+
}
|
127 |
+
|
128 |
+
if (!isset($addressInfo['country_id'])) {
|
129 |
+
Mage::throwException(
|
130 |
+
Mage::helper('zoozpayment')->__('Please specify a country')
|
131 |
+
);
|
132 |
+
}
|
133 |
+
|
134 |
+
if (empty($addressInfo['cart'])) {
|
135 |
+
$this->resetQuote();
|
136 |
+
}
|
137 |
+
$shippingAddress = $this->getQuote()->getShippingAddress();
|
138 |
+
|
139 |
+
$shippingAddress->setCountryId($addressInfo['country_id']);
|
140 |
+
|
141 |
+
if (isset($addressInfo['region_id'])) {
|
142 |
+
$shippingAddress->setRegionId($addressInfo['region_id']);
|
143 |
+
}
|
144 |
+
|
145 |
+
if (isset($addressInfo['postcode'])) {
|
146 |
+
$shippingAddress->setPostcode($addressInfo['postcode']);
|
147 |
+
}
|
148 |
+
|
149 |
+
if (isset($addressInfo['region'])) {
|
150 |
+
$shippingAddress->setRegion($addressInfo['region']);
|
151 |
+
}
|
152 |
+
|
153 |
+
if (isset($addressInfo['city'])) {
|
154 |
+
$shippingAddress->setCity($addressInfo['city']);
|
155 |
+
}
|
156 |
+
|
157 |
+
$shippingAddress->setCollectShippingRates(true);
|
158 |
+
|
159 |
+
if (isset($addressInfo['coupon_code'])) {
|
160 |
+
$this->getQuote()->setCouponCode($addressInfo['coupon_code']);
|
161 |
+
}
|
162 |
+
|
163 |
+
$request = new Varien_Object($addToCartInfo);
|
164 |
+
|
165 |
+
if ($product->getStockItem()) {
|
166 |
+
$minimumQty = $product->getStockItem()->getMinSaleQty();
|
167 |
+
if ($minimumQty > 0 && $request->getQty() < $minimumQty) {
|
168 |
+
$request->setQty($minimumQty);
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
$result = $this->getQuote()->addProduct($product, $request);
|
173 |
+
}
|
174 |
+
if (is_string($result)) {
|
175 |
+
Mage::throwException($result);
|
176 |
+
}
|
177 |
+
|
178 |
+
Mage::dispatchEvent('checkout_cart_product_add_after', array('quote_item' => $result, 'product' => $product));
|
179 |
+
|
180 |
+
$this->getQuote()->collectTotals();
|
181 |
+
$this->_result = $shippingAddress->getGroupedAllShippingRates();
|
182 |
+
return $this;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Retrieve sales quote object
|
187 |
+
*
|
188 |
+
* @return Mage_Sales_Model_Quote
|
189 |
+
*/
|
190 |
+
public function getQuote() {
|
191 |
+
if ($this->_quote === null) {
|
192 |
+
$addressInfo = $this->getAddressInfo();
|
193 |
+
if (!empty($addressInfo['cart'])) {
|
194 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
195 |
+
} else {
|
196 |
+
$quote = Mage::getModel('sales/quote');
|
197 |
+
}
|
198 |
+
|
199 |
+
$this->_quote = $quote;
|
200 |
+
}
|
201 |
+
|
202 |
+
return $this->_quote;
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Reset quote object
|
207 |
+
*
|
208 |
+
* @return Lotus_Getshipping_Model_Estimate
|
209 |
+
*/
|
210 |
+
public function resetQuote() {
|
211 |
+
$this->getQuote()->removeAllAddresses();
|
212 |
+
|
213 |
+
if ($this->getCustomer()) {
|
214 |
+
$this->getQuote()->setCustomer($this->getCustomer());
|
215 |
+
}
|
216 |
+
|
217 |
+
return $this;
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Retrieve currently logged in customer,
|
222 |
+
* if customer isn't logged it returns false
|
223 |
+
*
|
224 |
+
* @return Mage_Customer_Model_Customer|boolean
|
225 |
+
*/
|
226 |
+
public function getCustomer() {
|
227 |
+
if ($this->_customer === null) {
|
228 |
+
$customerSession = Mage::getSingleton('customer/session');
|
229 |
+
if ($customerSession->isLoggedIn()) {
|
230 |
+
$this->_customer = $customerSession->getCustomer();
|
231 |
+
} else {
|
232 |
+
$this->_customer = false;
|
233 |
+
}
|
234 |
+
}
|
235 |
+
return $this->_customer;
|
236 |
+
}
|
237 |
+
|
238 |
+
}
|
app/code/community/ZooZ/ZoozPayment/Model/Observer.php
ADDED
@@ -0,0 +1,247 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento Enterprise Edition
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Magento Enterprise Edition License
|
9 |
+
* that is bundled with this package in the file LICENSE_EE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.magentocommerce.com/license/enterprise-edition
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Mage
|
23 |
+
* @package Mage_Tax
|
24 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
25 |
+
* @license http://www.magentocommerce.com/license/enterprise-edition
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Tax Event Observer
|
30 |
+
*
|
31 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
32 |
+
*/
|
33 |
+
class ZooZ_ZoozPayment_Model_Observer {
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Put quote address tax information into order
|
37 |
+
*
|
38 |
+
* @param Varien_Event_Observer $observer
|
39 |
+
*/
|
40 |
+
public function salesEventConvertQuoteAddressToOrder(Varien_Event_Observer $observer) {
|
41 |
+
$address = $observer->getEvent()->getAddress();
|
42 |
+
$order = $observer->getEvent()->getOrder();
|
43 |
+
|
44 |
+
$taxes = $address->getAppliedTaxes();
|
45 |
+
if (is_array($taxes)) {
|
46 |
+
if (is_array($order->getAppliedTaxes())) {
|
47 |
+
$taxes = array_merge($order->getAppliedTaxes(), $taxes);
|
48 |
+
}
|
49 |
+
$order->setAppliedTaxes($taxes);
|
50 |
+
$order->setConvertingFromQuote(true);
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Save order tax information
|
56 |
+
*
|
57 |
+
* @param Varien_Event_Observer $observer
|
58 |
+
*/
|
59 |
+
public function salesEventOrderAfterSave(Varien_Event_Observer $observer) {
|
60 |
+
$order = $observer->getEvent()->getOrder();
|
61 |
+
|
62 |
+
if (!$order->getConvertingFromQuote() || $order->getAppliedTaxIsSaved()) {
|
63 |
+
return;
|
64 |
+
}
|
65 |
+
|
66 |
+
$getTaxesForItems = $order->getQuote()->getTaxesForItems();
|
67 |
+
$taxes = $order->getAppliedTaxes();
|
68 |
+
|
69 |
+
$ratesIdQuoteItemId = array();
|
70 |
+
if (!is_array($getTaxesForItems)) {
|
71 |
+
$getTaxesForItems = array();
|
72 |
+
}
|
73 |
+
foreach ($getTaxesForItems as $quoteItemId => $taxesArray) {
|
74 |
+
foreach ($taxesArray as $rates) {
|
75 |
+
if (count($rates['rates']) == 1) {
|
76 |
+
$ratesIdQuoteItemId[$rates['id']][] = array(
|
77 |
+
'id' => $quoteItemId,
|
78 |
+
'percent' => $rates['percent'],
|
79 |
+
'code' => $rates['rates'][0]['code']
|
80 |
+
);
|
81 |
+
} else {
|
82 |
+
$percentDelta = $rates['percent'];
|
83 |
+
$percentSum = 0;
|
84 |
+
foreach ($rates['rates'] as $rate) {
|
85 |
+
$ratesIdQuoteItemId[$rates['id']][] = array(
|
86 |
+
'id' => $quoteItemId,
|
87 |
+
'percent' => $rate['percent'],
|
88 |
+
'code' => $rate['code']
|
89 |
+
);
|
90 |
+
$percentSum += $rate['percent'];
|
91 |
+
}
|
92 |
+
|
93 |
+
if ($percentDelta != $percentSum) {
|
94 |
+
$delta = $percentDelta - $percentSum;
|
95 |
+
foreach ($ratesIdQuoteItemId[$rates['id']] as &$rateTax) {
|
96 |
+
if ($rateTax['id'] == $quoteItemId) {
|
97 |
+
$rateTax['percent'] = (($rateTax['percent'] / $percentSum) * $delta) + $rateTax['percent'];
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
foreach ($taxes as $id => $row) {
|
106 |
+
foreach ($row['rates'] as $tax) {
|
107 |
+
if (is_null($row['percent'])) {
|
108 |
+
$baseRealAmount = $row['base_amount'];
|
109 |
+
} else {
|
110 |
+
if ($row['percent'] == 0 || $tax['percent'] == 0) {
|
111 |
+
continue;
|
112 |
+
}
|
113 |
+
$baseRealAmount = $row['base_amount'] / $row['percent'] * $tax['percent'];
|
114 |
+
}
|
115 |
+
$hidden = (isset($row['hidden']) ? $row['hidden'] : 0);
|
116 |
+
$data = array(
|
117 |
+
'order_id' => $order->getId(),
|
118 |
+
'code' => $tax['code'],
|
119 |
+
'title' => $tax['title'],
|
120 |
+
'hidden' => $hidden,
|
121 |
+
'percent' => $tax['percent'],
|
122 |
+
'priority' => $tax['priority'],
|
123 |
+
'position' => $tax['position'],
|
124 |
+
'amount' => $row['amount'],
|
125 |
+
'base_amount' => $row['base_amount'],
|
126 |
+
'process' => $row['process'],
|
127 |
+
'base_real_amount' => $baseRealAmount,
|
128 |
+
);
|
129 |
+
|
130 |
+
$result = Mage::getModel('tax/sales_order_tax')->setData($data)->save();
|
131 |
+
|
132 |
+
if (isset($ratesIdQuoteItemId[$id])) {
|
133 |
+
foreach ($ratesIdQuoteItemId[$id] as $quoteItemId) {
|
134 |
+
if ($quoteItemId['code'] == $tax['code']) {
|
135 |
+
$item = $order->getItemByQuoteItemId($quoteItemId['id']);
|
136 |
+
if ($item) {
|
137 |
+
$define = 'FIX_' . $item->getId() . '_' . $result->getTaxId();
|
138 |
+
if (!defined($define) || constant($define) != true) {
|
139 |
+
$data = array(
|
140 |
+
'item_id' => $item->getId(),
|
141 |
+
'tax_id' => $result->getTaxId(),
|
142 |
+
'tax_percent' => $quoteItemId['percent']
|
143 |
+
);
|
144 |
+
Mage::getModel('tax/sales_order_tax_item')->setData($data)->save();
|
145 |
+
define($define, true);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
$order->setAppliedTaxIsSaved(true);
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Prepare select which is using to select index data for layered navigation
|
159 |
+
*
|
160 |
+
* @param Varien_Event_Observer $observer
|
161 |
+
* @return Mage_Tax_Model_Observer
|
162 |
+
*/
|
163 |
+
public function prepareCatalogIndexPriceSelect(Varien_Event_Observer $observer) {
|
164 |
+
$table = $observer->getEvent()->getTable();
|
165 |
+
$response = $observer->getEvent()->getResponseObject();
|
166 |
+
$select = $observer->getEvent()->getSelect();
|
167 |
+
$storeId = $observer->getEvent()->getStoreId();
|
168 |
+
|
169 |
+
$additionalCalculations = $response->getAdditionalCalculations();
|
170 |
+
$calculation = Mage::helper('tax')->getPriceTaxSql(
|
171 |
+
$table . '.min_price', $table . '.tax_class_id'
|
172 |
+
);
|
173 |
+
|
174 |
+
if (!empty($calculation)) {
|
175 |
+
$additionalCalculations[] = $calculation;
|
176 |
+
$response->setAdditionalCalculations($additionalCalculations);
|
177 |
+
/**
|
178 |
+
* Tax class presented in price index table
|
179 |
+
*/
|
180 |
+
//Mage::helper('tax')->joinTaxClass($select, $storeId, $table);
|
181 |
+
}
|
182 |
+
|
183 |
+
return $this;
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Add tax percent values to product collection items
|
188 |
+
*
|
189 |
+
* @param Varien_Event_Observer $observer
|
190 |
+
* @return Mage_Tax_Model_Observer
|
191 |
+
*/
|
192 |
+
public function addTaxPercentToProductCollection($observer) {
|
193 |
+
$helper = Mage::helper('tax');
|
194 |
+
$collection = $observer->getEvent()->getCollection();
|
195 |
+
$store = $collection->getStoreId();
|
196 |
+
if (!$helper->needPriceConversion($store)) {
|
197 |
+
return $this;
|
198 |
+
}
|
199 |
+
|
200 |
+
if ($collection->requireTaxPercent()) {
|
201 |
+
$request = Mage::getSingleton('tax/calculation')->getRateRequest();
|
202 |
+
foreach ($collection as $item) {
|
203 |
+
if (null === $item->getTaxClassId()) {
|
204 |
+
$item->setTaxClassId($item->getMinimalTaxClassId());
|
205 |
+
}
|
206 |
+
if (!isset($classToRate[$item->getTaxClassId()])) {
|
207 |
+
$request->setProductClassId($item->getTaxClassId());
|
208 |
+
$classToRate[$item->getTaxClassId()] = Mage::getSingleton('tax/calculation')->getRate($request);
|
209 |
+
}
|
210 |
+
$item->setTaxPercent($classToRate[$item->getTaxClassId()]);
|
211 |
+
}
|
212 |
+
}
|
213 |
+
return $this;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Refresh sales tax report statistics for last day
|
218 |
+
*
|
219 |
+
* @param Mage_Cron_Model_Schedule $schedule
|
220 |
+
* @return Mage_Tax_Model_Observer
|
221 |
+
*/
|
222 |
+
public function aggregateSalesReportTaxData($schedule) {
|
223 |
+
Mage::app()->getLocale()->emulate(0);
|
224 |
+
$currentDate = Mage::app()->getLocale()->date();
|
225 |
+
$date = $currentDate->subHour(25);
|
226 |
+
Mage::getResourceModel('tax/report_tax')->aggregate($date);
|
227 |
+
Mage::app()->getLocale()->revert();
|
228 |
+
return $this;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Reset extra tax amounts on quote addresses before recollecting totals
|
233 |
+
*
|
234 |
+
* @param Varien_Event_Observer $observer
|
235 |
+
* @return Mage_Tax_Model_Observer
|
236 |
+
*/
|
237 |
+
public function quoteCollectTotalsBefore(Varien_Event_Observer $observer) {
|
238 |
+
/* @var $quote Mage_Sales_Model_Quote */
|
239 |
+
$quote = $observer->getEvent()->getQuote();
|
240 |
+
foreach ($quote->getAllAddresses() as $address) {
|
241 |
+
$address->setExtraTaxAmount(0);
|
242 |
+
$address->setBaseExtraTaxAmount(0);
|
243 |
+
}
|
244 |
+
return $this;
|
245 |
+
}
|
246 |
+
|
247 |
+
}
|
app/code/community/ZooZ/ZoozPayment/Model/Order.php
CHANGED
@@ -1,316 +1,191 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class ZooZ_ZoozPayment_Model_Order extends Mage_Core_Model_Abstract {
|
4 |
-
|
5 |
-
public function saveOrder($info = null, $giftInfo = null) {
|
6 |
-
try {
|
7 |
-
|
8 |
-
$
|
9 |
-
$
|
10 |
-
$
|
11 |
-
|
12 |
-
$
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
$
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
$
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
$
|
55 |
-
$
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
->
|
72 |
-
->
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
->
|
89 |
-
->
|
90 |
-
->
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
$shippingAddress = clone $billingAddress;
|
193 |
-
$shippingAddress->setSameAsBilling(false);
|
194 |
-
|
195 |
-
$order->setShippingAddress($shippingAddress);
|
196 |
-
}
|
197 |
-
}
|
198 |
-
} else {
|
199 |
-
|
200 |
-
$billingAddress = $this->cloneAddress();
|
201 |
-
$order->setBillingAddress($billingAddress);
|
202 |
-
|
203 |
-
$shippingAddress = clone $billingAddress;
|
204 |
-
$shippingAddress->setSameAsBilling(true);
|
205 |
-
|
206 |
-
$order->setShippingAddress($shippingAddress);
|
207 |
-
}
|
208 |
-
|
209 |
-
$orderPayment = Mage::getModel('sales/order_payment')
|
210 |
-
->setStoreId($storeId)
|
211 |
-
->setCustomerPaymentId(0)
|
212 |
-
->setMethod('zoozpayment')
|
213 |
-
->setPo_number(' - ');
|
214 |
-
$order->setPayment($orderPayment);
|
215 |
-
|
216 |
-
$convertQuoteObj = Mage::getSingleton('sales/convert_quote');
|
217 |
-
|
218 |
-
$cart = Mage::helper('checkout/cart')->getCart();
|
219 |
-
$items = $cart->getQuote()->getAllVisibleItems();
|
220 |
-
$subTotal = 0;
|
221 |
-
$baseSubTotal = 0;
|
222 |
-
|
223 |
-
foreach ($items as $item) {
|
224 |
-
$itemdata = $item->getData();
|
225 |
-
|
226 |
-
$orderItem = $convertQuoteObj->itemToOrderItem($item);
|
227 |
-
|
228 |
-
$options = array();
|
229 |
-
if ($productOptions = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct())) {
|
230 |
-
$options = $productOptions;
|
231 |
-
}
|
232 |
-
if ($addOptions = $item->getOptionByCode('additional_options')) {
|
233 |
-
$options['additional_options'] = unserialize($addOptions->getValue());
|
234 |
-
}
|
235 |
-
if ($options) {
|
236 |
-
$orderItem->setProductOptions($options);
|
237 |
-
}
|
238 |
-
if ($item->getParentItem()) {
|
239 |
-
$orderItem->setParentItem($orderObj->getItemByQuoteItemId($item->getParentItem()->getId()));
|
240 |
-
}
|
241 |
-
|
242 |
-
$subTotal += $itemdata['row_total'];
|
243 |
-
$baseSubTotal += $itemdata['base_row_total'];
|
244 |
-
$order->addItem($orderItem);
|
245 |
-
}
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
$shipping_price = $info->shippingAmount;
|
250 |
-
$shipping_name = $info->shippingMethod;
|
251 |
-
$shipping_carrier_name = $info->shippingCarrierName;
|
252 |
-
$shipping_carrier_code = $info->shippingCarrierCode;
|
253 |
-
$order->setSubtotal($subTotal)
|
254 |
-
->setShippingMethod($shipping_carrier_code)
|
255 |
-
->setShippingDescription($shipping_name . " (" . $shipping_carrier_name .")")
|
256 |
-
->setBaseShippingAmount($shipping_price)
|
257 |
-
->setShippingAmount($shipping_price)
|
258 |
-
->setBaseSubtotal($baseSubTotal + $shipping_price)
|
259 |
-
->setBaseTotalDue($subTotal + $shipping_price)
|
260 |
-
->setGrandTotal($subTotal + $shipping_price)
|
261 |
-
->setBaseGrandTotal($baseSubTotal);
|
262 |
-
|
263 |
-
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true);
|
264 |
-
$order->setGiftMessageId($gift_id);
|
265 |
-
$transaction->addObject($order);
|
266 |
-
$transaction->addCommitCallback(array($order, 'place'));
|
267 |
-
$transaction->addCommitCallback(array($order, 'save'));
|
268 |
-
$transaction->save();
|
269 |
-
|
270 |
-
//print_r($quote->getId()); die;
|
271 |
-
|
272 |
-
$session = Mage::getSingleton('checkout/session');
|
273 |
-
$session->setLastRealOrderId($order->getIncrementId());
|
274 |
-
$session->setLastSuccessQuoteId($session->getQuote()->getId());
|
275 |
-
$session->setLastQuoteId($session->getQuote()->getId());
|
276 |
-
$session->setLastOrderId($order->getId());
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
$cart2 = Mage::getSingleton('checkout/cart');
|
281 |
-
$cart2->init();
|
282 |
-
$cart2->truncate();
|
283 |
-
$cart2->save();
|
284 |
-
$cart2->getItems()->clear()->save();
|
285 |
-
//
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
Mage::log('zooz payment success');
|
291 |
-
} catch (Exception $ex) {
|
292 |
-
Mage::log($ex->getMessage());
|
293 |
-
}
|
294 |
-
}
|
295 |
-
|
296 |
-
public function cloneAddress() {
|
297 |
-
// set Billing Address
|
298 |
-
$addressData = array(
|
299 |
-
'firstname' => 'Test',
|
300 |
-
'lastname' => 'Test',
|
301 |
-
'street' => 'Sample Street 10',
|
302 |
-
'city' => 'Somewhere',
|
303 |
-
'postcode' => '123456',
|
304 |
-
'telephone' => '123456',
|
305 |
-
'country_id' => 'US',
|
306 |
-
'region_id' => 12, // id from directory_country_region table
|
307 |
-
);
|
308 |
-
|
309 |
-
$tempAddress = Mage::getModel('sales/order_address')
|
310 |
-
->setData($addressData)
|
311 |
-
->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_BILLING);
|
312 |
-
|
313 |
-
return $tempAddress;
|
314 |
-
}
|
315 |
-
|
316 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ZooZ_ZoozPayment_Model_Order extends Mage_Core_Model_Abstract {
|
4 |
+
|
5 |
+
public function saveOrder($info = null, $giftInfo = null) {
|
6 |
+
try {
|
7 |
+
|
8 |
+
$shipping_price = $info->shippingAmount;
|
9 |
+
$shipping_name = $info->shippingMethod;
|
10 |
+
$shipping_carrier_name = $info->shippingCarrierName;
|
11 |
+
|
12 |
+
$shipping_carrier_code = $info->shippingCarrierCode;
|
13 |
+
Mage::log($shipping_name);
|
14 |
+
Mage::log($shipping_carrier_name);
|
15 |
+
Mage::log($shipping_carrier_code);
|
16 |
+
Mage::log($shipping_price);
|
17 |
+
$session = Mage::getSingleton("customer/session");
|
18 |
+
$customer_session = $session->getCustomer();
|
19 |
+
$customer = Mage::getModel('customer/customer')->load($customer_session->getId());
|
20 |
+
$notLogin = false;
|
21 |
+
$storeId = Mage::app()->getStore()->getId();
|
22 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
23 |
+
$quote->save();
|
24 |
+
|
25 |
+
Mage::log("quote sub:" . $quote->getSubtotalWithDiscount());
|
26 |
+
if (Mage::getSingleton('customer/session')->IsLoggedIn()) {
|
27 |
+
$customer = Mage::getModel('customer/customer')->load($customer->getId());
|
28 |
+
$storeId = $customer->getStoreId();
|
29 |
+
$notLogin = true;
|
30 |
+
}
|
31 |
+
if ($info != null) {
|
32 |
+
/* Have Return Info Shipping Address */
|
33 |
+
Mage::log("Have Return Info Shipping Address");
|
34 |
+
$user = $info->user;
|
35 |
+
|
36 |
+
$shippingAddress = $quote->getShippingAddress();
|
37 |
+
$shipp_address = $info->shippingAddress;
|
38 |
+
Mage::log($shipp_address);
|
39 |
+
$phone_number = $user->phoneNumber;
|
40 |
+
if ($phone_number == '') {
|
41 |
+
$phone_number = "0987654321";
|
42 |
+
}
|
43 |
+
$shippingAddress->setStoreId($storeId)
|
44 |
+
->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_SHIPPING)
|
45 |
+
->setCustomerId($customer->getId())
|
46 |
+
->setFirstname($shipp_address->firstName)
|
47 |
+
->setLastname($shipp_address->lastName)
|
48 |
+
->setStreet($shipp_address->street)
|
49 |
+
->setCity($shipp_address->city)
|
50 |
+
->setCountryId($shipp_address->countryCode)
|
51 |
+
->setRegion($shipp_address->state)
|
52 |
+
->setPostcode($shipp_address->zipCode)
|
53 |
+
->setTelephone($phone_number);
|
54 |
+
$shippingAddress->setShippingMethod($shipping_name);
|
55 |
+
$shippingAddress->setShippingDescription($shipping_name . " (" . $shipping_carrier_name . ")");
|
56 |
+
$shippingAddress->setCollectShippingRates(true)->collectShippingRates();
|
57 |
+
|
58 |
+
if ($notLogin) {
|
59 |
+
/* Is Customer Login */
|
60 |
+
Mage::log("Is Customer Login");
|
61 |
+
$billing = $customer->getDefaultBillingAddress();
|
62 |
+
if ($billing) {
|
63 |
+
$billingAddress = $quote->getBillingAddress();
|
64 |
+
$billingAddress
|
65 |
+
->setFirstname($billing->getFirstname())
|
66 |
+
->setLastname($billing->getLastname())
|
67 |
+
->setStreet($billing->getStreet())
|
68 |
+
->setCity($billing->getCity())
|
69 |
+
->setCountryId($billing->getCountryId())
|
70 |
+
->setPostcode($billing->getPostcode());
|
71 |
+
$billingAddress->setRegionId($billing->getRegionId());// != "" ? $billing->getRegion() : $shipp_address->state);
|
72 |
+
$billingAddress->setTelephone($billing->getTelephone() != "" ? $billing->getTelephone() : $phone_number);
|
73 |
+
|
74 |
+
$quote->setBillingAddress($billingAddress);
|
75 |
+
$quote->setShippingAddress($shippingAddress);
|
76 |
+
} else {
|
77 |
+
$billingAddress = $quote->getBillingAddress();
|
78 |
+
$billingAddress
|
79 |
+
->setFirstname($shipp_address->firstName)
|
80 |
+
->setLastname($shipp_address->lastName)
|
81 |
+
->setStreet($shipp_address->street)
|
82 |
+
->setCity($shipp_address->city)
|
83 |
+
->setCountryId($shipp_address->countryCode)
|
84 |
+
->setRegion($shipp_address->state)
|
85 |
+
->setPostcode($shipp_address->zipCode)
|
86 |
+
->setTelephone($phone_number);
|
87 |
+
|
88 |
+
// $shippingAddress->setSameAsBilling(true);
|
89 |
+
$quote->setShippingAddress($shippingAddress);
|
90 |
+
$quote->setBillingAddress($billingAddress);
|
91 |
+
}
|
92 |
+
} else {
|
93 |
+
/* Customer Is Not Login */
|
94 |
+
Mage::log(" Customer Is Not Login");
|
95 |
+
$billingAddress = $quote->getBillingAddress();
|
96 |
+
$billingAddress->setFirstname($shipp_address->firstName)
|
97 |
+
->setLastname($shipp_address->lastName)
|
98 |
+
->setStreet($shipp_address->street)
|
99 |
+
->setCity($shipp_address->city)
|
100 |
+
->setCountryId($shipp_address->countryCode)
|
101 |
+
->setRegion($shipp_address->state)
|
102 |
+
->setPostcode($shipp_address->zipCode)
|
103 |
+
->setTelephone($phone_number);
|
104 |
+
$shippingAddress->setSameAsBilling(true);
|
105 |
+
$quote->setCustomerIsGuest(1)
|
106 |
+
->setCustomerEmail($user->email)
|
107 |
+
->setCustomerFirstname($shipp_address->firstName)
|
108 |
+
->setCustomerLastname($shipp_address->lastName)
|
109 |
+
->setCustomerGroupId(0)
|
110 |
+
->setCustomerIsGuest(1);
|
111 |
+
$quote->setBillingAddress($billingAddress);
|
112 |
+
$quote->setShippingAddress($shippingAddress);
|
113 |
+
}
|
114 |
+
}
|
115 |
+
$quote->save();
|
116 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
117 |
+
$session = Mage::getSingleton('checkout/session');
|
118 |
+
$giftcartcheck = false;
|
119 |
+
|
120 |
+
$payment = $quote->getPayment();
|
121 |
+
$payment->setMethod('zoozpayment');
|
122 |
+
Mage::log("quote sub1:" . $quote->getSubtotalWithDiscount());
|
123 |
+
$quote->collectTotals();
|
124 |
+
Mage::log("quote sub2:" . $quote->getSubtotalWithDiscount());
|
125 |
+
$service = Mage::getModel('sales/service_quote', $quote);
|
126 |
+
$service->submitAll();
|
127 |
+
$order = $service->getOrder();
|
128 |
+
if (!$order) {
|
129 |
+
return;
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
if ($giftInfo != null && $giftInfo != "") {
|
134 |
+
$gift_customer = 0;
|
135 |
+
if ($customer->getId()) {
|
136 |
+
$gift_customer = $customer->getId();
|
137 |
+
}
|
138 |
+
//$Mage::log($info);
|
139 |
+
//$Mage::log($info['gift']['message']);
|
140 |
+
|
141 |
+
$model = Mage::getModel('giftmessage/message');
|
142 |
+
$model->setCustomerId(0);
|
143 |
+
$model->setSender($giftInfo['from']);
|
144 |
+
$model->setRecipient($giftInfo['to']);
|
145 |
+
$model->setMessage($giftInfo['message']);
|
146 |
+
$model->save();
|
147 |
+
$gift_id = $model->getId();
|
148 |
+
$order->setGiftMessageId($gift_id);
|
149 |
+
}
|
150 |
+
$session = Mage::getSingleton('checkout/session');
|
151 |
+
$session->setLastRealOrderId($order->getIncrementId());
|
152 |
+
$session->setLastSuccessQuoteId($session->getQuote()->getId());
|
153 |
+
$session->setLastQuoteId($session->getQuote()->getId());
|
154 |
+
$session->setLastOrderId($order->getId());
|
155 |
+
|
156 |
+
|
157 |
+
|
158 |
+
$cart2 = Mage::getSingleton('checkout/cart');
|
159 |
+
$cart2->init();
|
160 |
+
$cart2->truncate();
|
161 |
+
$cart2->save();
|
162 |
+
$cart2->getItems()->clear()->save();
|
163 |
+
//
|
164 |
+
$order->save();
|
165 |
+
Mage::log('zooz payment success');
|
166 |
+
} catch (Exception $ex) {
|
167 |
+
Mage::log($ex->getMessage());
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
public function cloneAddress() {
|
172 |
+
// set Billing Address
|
173 |
+
$addressData = array(
|
174 |
+
'firstname' => 'Test',
|
175 |
+
'lastname' => 'Test',
|
176 |
+
'street' => 'Sample Street 10',
|
177 |
+
'city' => 'Somewhere',
|
178 |
+
'postcode' => '123456',
|
179 |
+
'telephone' => '123456',
|
180 |
+
'country_id' => 'US',
|
181 |
+
'region_id' => 12, // id from directory_country_region table
|
182 |
+
);
|
183 |
+
|
184 |
+
$tempAddress = Mage::getModel('sales/order_address')
|
185 |
+
->setData($addressData)
|
186 |
+
->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_BILLING);
|
187 |
+
|
188 |
+
return $tempAddress;
|
189 |
+
}
|
190 |
+
|
191 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/ZooZ/ZoozPayment/Model/Source/Action.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ZooZ_ZoozPayment_Model_Source_Action {
|
4 |
+
|
5 |
+
public function toOptionArray() {
|
6 |
+
return array(
|
7 |
+
array(
|
8 |
+
'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE,
|
9 |
+
'label' => Mage::helper('core')->__('Authorize')
|
10 |
+
),
|
11 |
+
array(
|
12 |
+
'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE,
|
13 |
+
'label' => Mage::helper('core')->__('Authorize & Capture')
|
14 |
+
)
|
15 |
+
);
|
16 |
+
}
|
17 |
+
|
18 |
+
}
|
app/code/community/ZooZ/ZoozPayment/Model/Source/Status.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class ZooZ_ZoozPayment_Model_Source_Status
|
3 |
+
{
|
4 |
+
public function toOptionArray()
|
5 |
+
{
|
6 |
+
return array(
|
7 |
+
array(
|
8 |
+
'value' => Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
9 |
+
'label' => Mage::helper('core')->__('Pending')
|
10 |
+
),
|
11 |
+
array(
|
12 |
+
'value' => Mage_Sales_Model_Order::STATE_PROCESSING,
|
13 |
+
'label' => Mage::helper('core')->__('Processing')
|
14 |
+
)
|
15 |
+
|
16 |
+
);
|
17 |
+
}
|
18 |
+
}
|
app/code/community/ZooZ/ZoozPayment/Model/Standard.php
CHANGED
@@ -1,588 +1,739 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once(Mage::getBaseDir('lib') . '/zooz/zooz.extended.server.api.php');
|
4 |
-
|
5 |
-
class ZooZ_ZoozPayment_Model_Standard extends Mage_Payment_Model_Method_Abstract {
|
6 |
-
|
7 |
-
protected $_code = 'zoozpayment';
|
8 |
-
protected $_isInitializeNeeded = true;
|
9 |
-
protected $_canUseInternal = false;
|
10 |
-
protected $_canUseForMultishipping =
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
}
|
33 |
-
|
34 |
-
public function
|
35 |
-
|
36 |
-
}
|
37 |
-
|
38 |
-
public function
|
39 |
-
|
40 |
-
}
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
$
|
49 |
-
|
50 |
-
$
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
$
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
$
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
$
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
$
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
$
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
}
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
//
|
294 |
-
$
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
$
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
if (
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
$
|
432 |
-
|
433 |
-
|
434 |
-
$
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
$
|
443 |
-
|
444 |
-
$
|
445 |
-
|
446 |
-
$
|
447 |
-
|
448 |
-
$
|
449 |
-
$
|
450 |
-
|
451 |
-
|
452 |
-
$postFields .= "&
|
453 |
-
$postFields .= "&
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
}
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
$
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
$
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
$
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once(Mage::getBaseDir('lib') . '/zooz/zooz.extended.server.api.php');
|
4 |
+
|
5 |
+
class ZooZ_ZoozPayment_Model_Standard extends Mage_Payment_Model_Method_Abstract {
|
6 |
+
|
7 |
+
protected $_code = 'zoozpayment';
|
8 |
+
protected $_isInitializeNeeded = true;
|
9 |
+
protected $_canUseInternal = false;
|
10 |
+
protected $_canUseForMultishipping = true;
|
11 |
+
protected $_canAuthorize = true;
|
12 |
+
protected $_canCapture = true;
|
13 |
+
protected $_canRefund = true;
|
14 |
+
protected $_canRefundInvoicePartial = true;
|
15 |
+
protected $_canCapturePartial = true;
|
16 |
+
|
17 |
+
# protected $_canVoid = true;
|
18 |
+
|
19 |
+
public function canCapture() {
|
20 |
+
return $this->_canCapture;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function canCapturePartial() {
|
24 |
+
return $this->_canCapturePartial;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function initialize($paymentAction, $stateObject) {
|
28 |
+
$state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
|
29 |
+
$stateObject->setState($state);
|
30 |
+
$stateObject->setStatus('pending_payment');
|
31 |
+
$stateObject->setIsNotified(false);
|
32 |
+
}
|
33 |
+
|
34 |
+
public function canRefund() {
|
35 |
+
return $this->_canRefund;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function canRefundInvoicePartial() {
|
39 |
+
return $this->_canRefundInvoicePartial;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function refund(Varien_Object $payment, $amount) {
|
43 |
+
$isSandbox = false;
|
44 |
+
if ($this->getIsSandBox()) {
|
45 |
+
$isSandbox = true;
|
46 |
+
}
|
47 |
+
$zooz_useremail = Mage::getStoreConfig('payment/zoozpayment/zooz_useremail');
|
48 |
+
$zooz_serverkey = Mage::getStoreConfig('payment/zoozpayment/zooz_serverkey');
|
49 |
+
|
50 |
+
if ($isSandbox) {
|
51 |
+
$zooz = new ZooZExtendedServerAPI($zooz_useremail, $zooz_serverkey, true);
|
52 |
+
} else {
|
53 |
+
$zooz = new ZooZExtendedServerAPI($zooz_useremail, $zooz_serverkey, false);
|
54 |
+
}
|
55 |
+
|
56 |
+
// $info = $zooz->getTransactionDetailsByTransactionID($payment->getLastTransId());
|
57 |
+
|
58 |
+
if ($zooz->refundTransaction($payment->getLastTransId(), $amount)) {
|
59 |
+
$payment->setTransactionId($payment->getLastTransId());
|
60 |
+
$payment->setIsTransactionClosed(false);
|
61 |
+
$payment->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_APPROVED);
|
62 |
+
} else {
|
63 |
+
$this->showException('Error in you refund request');
|
64 |
+
}
|
65 |
+
return $this;
|
66 |
+
}
|
67 |
+
|
68 |
+
public function capture(Varien_Object $payment, $amount) {
|
69 |
+
//code execute to getway
|
70 |
+
//commitTransaction($transactionID, $amount=NULL, $invoice=NULL)
|
71 |
+
$isSandbox = false;
|
72 |
+
if ($this->getIsSandBox()) {
|
73 |
+
$isSandbox = true;
|
74 |
+
}
|
75 |
+
$zooz_useremail = Mage::getStoreConfig('payment/zoozpayment/zooz_useremail');
|
76 |
+
$zooz_serverkey = Mage::getStoreConfig('payment/zoozpayment/zooz_serverkey');
|
77 |
+
|
78 |
+
if ($isSandbox) {
|
79 |
+
$zooz = new ZooZExtendedServerAPI($zooz_useremail, $zooz_serverkey, true);
|
80 |
+
} else {
|
81 |
+
$zooz = new ZooZExtendedServerAPI($zooz_useremail, $zooz_serverkey, false);
|
82 |
+
}
|
83 |
+
|
84 |
+
if($amount == 0){
|
85 |
+
$payment->setTransactionId($payment->getLastTransId());
|
86 |
+
$payment->setIsTransactionClosed(false);
|
87 |
+
$payment->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_APPROVED);
|
88 |
+
|
89 |
+
}else if ($zooz->commitTransaction($payment->getLastTransId(), $amount)) {
|
90 |
+
$payment->setTransactionId($payment->getLastTransId());
|
91 |
+
$payment->setIsTransactionClosed(false);
|
92 |
+
$payment->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_APPROVED);
|
93 |
+
}
|
94 |
+
return $this;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Return Order place redirect url
|
99 |
+
*
|
100 |
+
* @return string
|
101 |
+
*/
|
102 |
+
public function getOrderPlaceRedirectUrl() {
|
103 |
+
//when you click on place order you will be redirected on this url, if you don't want this action remove this method
|
104 |
+
return Mage::getUrl('zoozpayment/standard/redirect', array('_secure' => true));
|
105 |
+
}
|
106 |
+
|
107 |
+
public function getAppUniqueId() {
|
108 |
+
return $config = Mage::getStoreConfig('payment/zoozpayment/app_unique_id');
|
109 |
+
}
|
110 |
+
|
111 |
+
public function getAppKey() {
|
112 |
+
return $config = Mage::getStoreConfig('payment/zoozpayment/app_key');
|
113 |
+
}
|
114 |
+
|
115 |
+
public function getIsSandBox() {
|
116 |
+
return $config = Mage::getStoreConfig('payment/zoozpayment/sandbox_flag');
|
117 |
+
}
|
118 |
+
|
119 |
+
public function getSandboxUrl() {
|
120 |
+
return $config = Mage::getStoreConfig('payment/zoozpayment/zooz_sandbox_url');
|
121 |
+
}
|
122 |
+
|
123 |
+
public function getProductionUrl() {
|
124 |
+
return $config = Mage::getStoreConfig('payment/zoozpayment/zooz_production_url');
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Instantiate state and set it to state object
|
129 |
+
* @param string $paymentAction
|
130 |
+
* @param Varien_Object
|
131 |
+
*/
|
132 |
+
public function processing($start = false) {
|
133 |
+
if ($start == true) {
|
134 |
+
|
135 |
+
$postFields = $this->getPostFieldFromCart();
|
136 |
+
} else {
|
137 |
+
$postFields = $this->getPostField();
|
138 |
+
}
|
139 |
+
if ($postFields != '') {
|
140 |
+
// Flag to indicate whether sandbox environment should be used
|
141 |
+
$isSandbox = false;
|
142 |
+
if ($this->getIsSandBox()) {
|
143 |
+
$isSandbox = true;
|
144 |
+
}
|
145 |
+
|
146 |
+
$url;
|
147 |
+
$zoozServer;
|
148 |
+
|
149 |
+
if ($isSandbox == true) {
|
150 |
+
|
151 |
+
$zoozServer = $this->getSandboxUrl();
|
152 |
+
$url = $zoozServer . "/mobile/SecuredWebServlet";
|
153 |
+
} else {
|
154 |
+
|
155 |
+
$zoozServer = $this->getProductionUrl();
|
156 |
+
$url = $zoozServer . "/mobile/SecuredWebServlet";
|
157 |
+
}
|
158 |
+
|
159 |
+
if (!function_exists('curl_init')) {
|
160 |
+
Mage::getSingleton('checkout/session')->addError('Sorry cURL is not installed!');
|
161 |
+
return Mage::getUrl('checkout/cart');
|
162 |
+
}
|
163 |
+
|
164 |
+
// OK cool - then let's create a new cURL resource handle
|
165 |
+
$ch = curl_init();
|
166 |
+
|
167 |
+
// Now set some options
|
168 |
+
// Set URL
|
169 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
170 |
+
|
171 |
+
//Header fields: ZooZUniqueID, ZooZAppKey, ZooZResponseType
|
172 |
+
$header = array('ZooZUniqueID: ' . $this->getAppUniqueId(), 'ZooZAppKey: ' . $this->getAppKey(), 'ZooZResponseType: NVP');
|
173 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
174 |
+
|
175 |
+
// If it is a post request
|
176 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
177 |
+
|
178 |
+
// Timeout in seconds
|
179 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
180 |
+
|
181 |
+
// If you are experiencing issues recieving the token on the sandbox environment, please set this option
|
182 |
+
if ($isSandbox) {
|
183 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
184 |
+
}
|
185 |
+
|
186 |
+
//Mandatory POST fields: cmd, amount, currencyCode
|
187 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
|
188 |
+
|
189 |
+
ob_start();
|
190 |
+
|
191 |
+
curl_exec($ch);
|
192 |
+
|
193 |
+
$result = ob_get_contents();
|
194 |
+
|
195 |
+
ob_end_clean();
|
196 |
+
|
197 |
+
curl_close($ch);
|
198 |
+
|
199 |
+
parse_str($result);
|
200 |
+
|
201 |
+
|
202 |
+
if ($statusCode == 0) {
|
203 |
+
|
204 |
+
// Get token from ZooZ server
|
205 |
+
$trimmedSessionToken = rtrim($sessionToken, "\n");
|
206 |
+
|
207 |
+
// Send token back to page
|
208 |
+
if ($start == true) {
|
209 |
+
$success = Mage::getUrl('zoozpayment/standard/successexpress');
|
210 |
+
} else {
|
211 |
+
$success = Mage::getUrl('zoozpayment/standard/success');
|
212 |
+
}
|
213 |
+
|
214 |
+
$cancel = Mage::getUrl('zoozpayment/standard/cancel');
|
215 |
+
|
216 |
+
$redirect = $zoozServer . "/mobile/mobileweb/zooz-checkout.jsp?";
|
217 |
+
$redirect .= "token=" . $trimmedSessionToken;
|
218 |
+
$redirect .= "&uniqueID=" . $this->getAppUniqueId();
|
219 |
+
$redirect .= "&largeViewport=true";
|
220 |
+
$redirect .= "&returnUrl=" . $success;
|
221 |
+
$redirect .= "&cancelUrl=" . $cancel;
|
222 |
+
$redirect .= "&isShippingRequired=false";
|
223 |
+
|
224 |
+
// process order
|
225 |
+
$session = Mage::getSingleton('checkout/session');
|
226 |
+
$session->setZoozQuoteId($session->getQuoteId());
|
227 |
+
|
228 |
+
//Mage::log($redirect);
|
229 |
+
return $redirect;
|
230 |
+
|
231 |
+
$session->unsQuoteId();
|
232 |
+
$session->unsRedirectUrl();
|
233 |
+
} else if (isset($errorMessage)) {
|
234 |
+
Mage::getSingleton('checkout/session')->addError("Error to open transaction to ZooZ server. " . $errorMessage);
|
235 |
+
return Mage::getUrl('checkout/cart');
|
236 |
+
}
|
237 |
+
//Close the cURL resource, and free system resources
|
238 |
+
} else {
|
239 |
+
return Mage::getUrl('checkout/cart');
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
public function ajaxprocessing($start = false) {
|
244 |
+
if ($start == true) {
|
245 |
+
|
246 |
+
$postFields = $this->getPostFieldFromCart();
|
247 |
+
} else {
|
248 |
+
$postFields = $this->getPostField();
|
249 |
+
}
|
250 |
+
if (Mage::getSingleton('customer/session')->IsLoggedIn()) {
|
251 |
+
$session = Mage::getSingleton("customer/session");
|
252 |
+
$customer = $session->getCustomer();
|
253 |
+
$customerLoginID = $customer->getId();
|
254 |
+
$postFields.="&customerLoginID=$customerLoginID";
|
255 |
+
}
|
256 |
+
|
257 |
+
if ($postFields != '') {
|
258 |
+
|
259 |
+
$postFields.="&dynamicShippingUrl=" . Mage::getUrl('zoozpayment/estimate/index');
|
260 |
+
if (Mage::getStoreConfig('sales/gift_options/allow_order', null)) {
|
261 |
+
$postFields.="&providerSupportedFeatures=[100,104]";
|
262 |
+
} else {
|
263 |
+
$postFields.="&providerSupportedFeatures=[104]";
|
264 |
+
}
|
265 |
+
//Mage::log($postFields);
|
266 |
+
//die($postFields);
|
267 |
+
// Flag to indicate whether sandbox environment should be used
|
268 |
+
$isSandbox = false;
|
269 |
+
if ($this->getIsSandBox()) {
|
270 |
+
$isSandbox = true;
|
271 |
+
}
|
272 |
+
|
273 |
+
$url;
|
274 |
+
$zoozServer;
|
275 |
+
|
276 |
+
if ($isSandbox == true) {
|
277 |
+
|
278 |
+
$zoozServer = $this->getSandboxUrl();
|
279 |
+
$url = $zoozServer . "/mobile/SecuredWebServlet";
|
280 |
+
} else {
|
281 |
+
|
282 |
+
$zoozServer = $this->getProductionUrl();
|
283 |
+
$url = $zoozServer . "/mobile/SecuredWebServlet";
|
284 |
+
}
|
285 |
+
|
286 |
+
// is cURL installed yet?
|
287 |
+
|
288 |
+
if (!function_exists('curl_init')) {
|
289 |
+
Mage::getSingleton('checkout/session')->addError('Sorry cURL is not installed!');
|
290 |
+
return Mage::getUrl('checkout/cart');
|
291 |
+
}
|
292 |
+
|
293 |
+
// OK cool - then let's create a new cURL resource handle
|
294 |
+
$ch = curl_init();
|
295 |
+
|
296 |
+
// Now set some options
|
297 |
+
// Set URL
|
298 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
299 |
+
|
300 |
+
//Header fields: ZooZUniqueID, ZooZAppKey, ZooZResponseType
|
301 |
+
$header = array('ZooZUniqueID: ' . $this->getAppUniqueId(), 'ZooZAppKey: ' . $this->getAppKey(), 'ZooZResponseType: NVP');
|
302 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
303 |
+
|
304 |
+
// If it is a post request
|
305 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
306 |
+
|
307 |
+
// Timeout in seconds
|
308 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
309 |
+
|
310 |
+
// If you are experiencing issues recieving the token on the sandbox environment, please set this option
|
311 |
+
if ($isSandbox) {
|
312 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
313 |
+
}
|
314 |
+
|
315 |
+
//Mandatory POST fields: cmd, amount, currencyCode
|
316 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
|
317 |
+
|
318 |
+
ob_start();
|
319 |
+
|
320 |
+
curl_exec($ch);
|
321 |
+
|
322 |
+
$result = ob_get_contents();
|
323 |
+
|
324 |
+
ob_end_clean();
|
325 |
+
|
326 |
+
curl_close($ch);
|
327 |
+
|
328 |
+
parse_str($result);
|
329 |
+
|
330 |
+
// Mage::log($result);
|
331 |
+
|
332 |
+
if ($statusCode == 0) {
|
333 |
+
// Get token from ZooZ server
|
334 |
+
$trimmedSessionToken = rtrim($sessionToken, "\n");
|
335 |
+
|
336 |
+
$session = Mage::getSingleton('checkout/session');
|
337 |
+
$session->setZoozQuoteId($session->getQuoteId());
|
338 |
+
if ($start == true)
|
339 |
+
$typecheckout = 1;
|
340 |
+
else
|
341 |
+
$typecheckout = 0;
|
342 |
+
Mage::getSingleton('core/session')->setZooztype($typecheckout);
|
343 |
+
return $trimmedSessionToken;
|
344 |
+
//return $trimmedSessionToken;
|
345 |
+
// Send token back to page
|
346 |
+
} else if (isset($errorMessage)) {
|
347 |
+
Mage::getSingleton('checkout/session')->addError("Error to open transaction to ZooZ server. " . $errorMessage);
|
348 |
+
return Mage::getUrl('checkout/cart');
|
349 |
+
}
|
350 |
+
// Close the cURL resource, and free system resources
|
351 |
+
} else {
|
352 |
+
|
353 |
+
return Mage::getUrl('checkout/cart');
|
354 |
+
}
|
355 |
+
}
|
356 |
+
|
357 |
+
protected function _getCart() {
|
358 |
+
return Mage::getSingleton('checkout/cart');
|
359 |
+
}
|
360 |
+
|
361 |
+
public function getPostFieldFromCart() {
|
362 |
+
|
363 |
+
//Mage::log("getPostFieldFromCart");
|
364 |
+
$postFields = "";
|
365 |
+
// $cart = Mage::helper('checkout/cart')->getCart();
|
366 |
+
$cart = $this->_getCart();
|
367 |
+
$cart->save();
|
368 |
+
|
369 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
370 |
+
|
371 |
+
$session = Mage::getSingleton('checkout/session');
|
372 |
+
|
373 |
+
|
374 |
+
|
375 |
+
$itemsCount = $cart->getItemsCount();
|
376 |
+
|
377 |
+
if ($itemsCount > 0) {
|
378 |
+
$data = $cart->getQuote()->getData();
|
379 |
+
|
380 |
+
//Mage::log($data);
|
381 |
+
// cmd
|
382 |
+
$amount = $data['grand_total'] - Mage::helper('zoozpayment')->getshipping();
|
383 |
+
$postFields .= "cmd=openTrx";
|
384 |
+
$postFields .= "&amount=" . $amount;
|
385 |
+
$postFields .= "¤cyCode=" . $data['quote_currency_code'];
|
386 |
+
//$postFields .= "&taxAmount=".$data['tax_amount'];
|
387 |
+
//shipping
|
388 |
+
$carrier = Mage::helper('zoozpayment/carrier');
|
389 |
+
$carrier->setCarrier('freeshipping');
|
390 |
+
$carrier_temp = '';
|
391 |
+
$carrier_temp_0 = '';
|
392 |
+
if ($carrier->check()) {
|
393 |
+
$carrier_temp_0 = "{name:'" . $carrier->getAllowedMethods() . "', price: " . (float) $carrier->getAllowedPrice() . "}";
|
394 |
+
$carrier_temp.=$carrier_temp_0;
|
395 |
+
}
|
396 |
+
$carrier->setCarrier('flatrate');
|
397 |
+
$carrier_temp_1 = '';
|
398 |
+
if ($carrier->check()) {
|
399 |
+
$cart = Mage::helper('checkout/cart')->getCart();
|
400 |
+
$items = $cart->getQuote()->getAllVisibleItems();
|
401 |
+
$total = 0;
|
402 |
+
$price_total = 0;
|
403 |
+
foreach ($items as $item) {
|
404 |
+
$total+=$item->getQty();
|
405 |
+
// $price_total+= $item->getPrice()*$item->getQty();
|
406 |
+
}
|
407 |
+
if ($carrier->getAllowedType() == "I") {
|
408 |
+
$price = $total * (float) $carrier->getAllowedPrice();
|
409 |
+
} elseif ($carrier->getAllowedType() == "O") {
|
410 |
+
$price = (float) $carrier->getAllowedPrice();
|
411 |
+
} else {
|
412 |
+
$price = 0;
|
413 |
+
}
|
414 |
+
if ($carrier->getAllowedHandlingType() == 'F') {
|
415 |
+
$price_handing = (float) $carrier->getAllowedHandlingFee();
|
416 |
+
$price_handing = number_format($price_handing, 2);
|
417 |
+
}
|
418 |
+
if ($carrier->getAllowedHandlingType() == 'P') {
|
419 |
+
|
420 |
+
$price_handing = ((float) $carrier->getAllowedHandlingFee() * $price) / 100;
|
421 |
+
$price_handing = number_format($price_handing, 2);
|
422 |
+
}
|
423 |
+
$price = $price + $price_handing;
|
424 |
+
$carrier_temp_1 = "{name:'" . $carrier->getAllowedMethods() . "', price: " . $price . "}";
|
425 |
+
if ($carrier_temp != '')
|
426 |
+
$carrier_temp.="," . $carrier_temp_1;
|
427 |
+
else
|
428 |
+
$carrier_temp = $carrier_temp_1;
|
429 |
+
}
|
430 |
+
$postFields.="&isShippingRequired=true";
|
431 |
+
if ($carrier_temp != '') {
|
432 |
+
$postFields.= "&shippingMethods=[" . $carrier_temp . "]";
|
433 |
+
} else {
|
434 |
+
$postFields.="&isShippingRequired=false";
|
435 |
+
}
|
436 |
+
//shipping
|
437 |
+
//
|
438 |
+
// customer
|
439 |
+
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
|
440 |
+
|
441 |
+
/* Get the customer data */
|
442 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
443 |
+
/* Get the customer's first name */
|
444 |
+
$firstname = $customer->getFirstname();
|
445 |
+
/* Get the customer's last name */
|
446 |
+
$lastname = $customer->getLastname();
|
447 |
+
/* Get the customer's email address */
|
448 |
+
$email = $customer->getEmail();
|
449 |
+
$_billingData = $customer->getDefaultBillingAddress();
|
450 |
+
$_shippingData = $customer->getDefaultShippingAddress();
|
451 |
+
|
452 |
+
$postFields .= "&user.idNumber=" . $customer->getId();
|
453 |
+
$postFields .= "&user.email=" . $email;
|
454 |
+
$postFields .= "&user.firstName=" . $firstname;
|
455 |
+
$postFields .= "&user.lastName=" . $lastname;
|
456 |
+
if (is_object($_billingData)) {
|
457 |
+
$postFields .= "&user.phone.phoneNumber=" . $_billingData->getTelephone();
|
458 |
+
}
|
459 |
+
|
460 |
+
|
461 |
+
//$postFields .= "&user.additionalDetails=Payment for ".$data['entity_id'];
|
462 |
+
//Billing and Shipping
|
463 |
+
if (is_object($_billingData)) {
|
464 |
+
$postFields .= "&billingAddress.firstName=" . $_billingData['firstname'];
|
465 |
+
$postFields .= "&billingAddress.lastName=" . $_billingData['lastname'];
|
466 |
+
//$postFields .= "&billingAddress.phone.countryCode=USA";
|
467 |
+
//$postFields .= "&billingAddress.phone.number=1222323".$_billingData['telephone'];
|
468 |
+
$postFields .= "&billingAddress.street=" . $_billingData['street'];
|
469 |
+
$postFields .= "&billingAddress.city=" . $_billingData['city'];
|
470 |
+
//$postFields .= "&billingAddress.state=22";
|
471 |
+
$postFields .= "&billingAddress.state=" . $_billingData['region'];
|
472 |
+
$postFields .= "&billingAddress.country=" . $_billingData['country_id'];
|
473 |
+
$postFields .= "&billingAddress.zipCode=" . $_billingData['postcode'];
|
474 |
+
}
|
475 |
+
|
476 |
+
// shipping address
|
477 |
+
if (is_object($_shippingData)) {
|
478 |
+
$postFields .= "&shippingAddress.firstName=" . $_shippingData['firstname'];
|
479 |
+
$postFields .= "&shippingAddress.lastName=" . $_shippingData['lastname'];
|
480 |
+
//$postFields .= "&shippingAddress.phone.countryCode=2323";
|
481 |
+
//$postFields .= "&shippingAddress.phone.number=232323".$_shippingData['telephone'];
|
482 |
+
$postFields .= "&shippingAddress.street=" . $_shippingData['street'];
|
483 |
+
$postFields .= "&shippingAddress.city=" . $_shippingData['city'];
|
484 |
+
//$postFields .= "&shippingAddress.state=22";
|
485 |
+
$postFields .= "&shippingAddress.state=" . $_shippingData['region'];
|
486 |
+
$postFields .= "&shippingAddress.country=" . $_shippingData['country_id'];
|
487 |
+
$postFields .= "&shippingAddress.zipCode=" . $_shippingData['postcode'];
|
488 |
+
}
|
489 |
+
} else {
|
490 |
+
|
491 |
+
}
|
492 |
+
// invoice
|
493 |
+
$postFields .= "&invoice.number=" . $data['entity_id'];
|
494 |
+
$postFields .= "&invoice.additionalDetails=" . $data['entity_id'] . ': $' . $data['base_grand_total'];
|
495 |
+
|
496 |
+
// items
|
497 |
+
$cartItems = $cart->getQuote()->getAllVisibleItems();
|
498 |
+
$i = 1;
|
499 |
+
// $tax = 0;
|
500 |
+
foreach ($cartItems as $item) {
|
501 |
+
$itemdata = $item->getData();
|
502 |
+
|
503 |
+
$postFields .= "&invoice.items(" . $i . ").id=" . $itemdata['product_id'];
|
504 |
+
$postFields .= "&invoice.items(" . $i . ").name=" . $itemdata['name'];
|
505 |
+
$postFields .= "&invoice.items(" . $i . ").quantity=" . $itemdata['qty'];
|
506 |
+
$postFields .= "&invoice.items(" . $i . ").price=" . $itemdata['price'];
|
507 |
+
// $tax += ($item->getData('tax_percent') * $itemdata['price'] * $itemdata['qty']) / 100;
|
508 |
+
$i++;
|
509 |
+
}
|
510 |
+
|
511 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
512 |
+
|
513 |
+
$coupon_code = $quote->getCouponCode();
|
514 |
+
$discount = Mage::helper('zoozpayment')->getdiscount();
|
515 |
+
|
516 |
+
// $discount = $quote->getSubtotal() - $quote->getSubtotalWithDiscount();
|
517 |
+
/*
|
518 |
+
$postFields .= "&invoice.items(" . $i . ").id=-i";
|
519 |
+
$postFields .= "&invoice.items(" . $i . ").name=Discount";
|
520 |
+
$postFields .= "&invoice.items(" . $i . ").quantity=" . 1;
|
521 |
+
$postFields .= "&invoice.items(" . $i . ").price=-" . $data['subtotal'];
|
522 |
+
$i += 1;
|
523 |
+
*/
|
524 |
+
|
525 |
+
if ($discount != '' && $discount > 0) {
|
526 |
+
$postFields .= "&invoice.items(" . $i . ").id=-i";
|
527 |
+
$postFields .= "&invoice.items(" . $i . ").name=Discount";
|
528 |
+
$postFields .= "&invoice.items(" . $i . ").quantity=" . 1;
|
529 |
+
$postFields .= "&invoice.items(" . $i . ").price=-" . $discount;
|
530 |
+
$i += 1;
|
531 |
+
}
|
532 |
+
|
533 |
+
if (isset($code) && $code != '') {
|
534 |
+
|
535 |
+
$postFields .= "&invoice.items(" . $i . ").id=-i";
|
536 |
+
$postFields .= "&invoice.items(" . $i . ").quantity=" . 1;
|
537 |
+
$postFields .= "&invoice.items(" . $i . ").price=-" . $amount;
|
538 |
+
}
|
539 |
+
}
|
540 |
+
$tax = $discount = Mage::helper('zoozpayment')->getTax();
|
541 |
+
$postFields .= "&taxAmount=" . $tax;
|
542 |
+
|
543 |
+
// if (isset($code) && $code != '') {
|
544 |
+
$postFields.="&featureProvider=102";
|
545 |
+
// }
|
546 |
+
|
547 |
+
|
548 |
+
|
549 |
+
return $postFields;
|
550 |
+
}
|
551 |
+
|
552 |
+
public function getPostField() {
|
553 |
+
|
554 |
+
$postFields = "";
|
555 |
+
$session = Mage::getSingleton('checkout/session');
|
556 |
+
$session->setQuoteId($session->getZoozQuoteId(true));
|
557 |
+
if ($session->getLastRealOrderId()) {
|
558 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
|
559 |
+
if ($order->getId()) {
|
560 |
+
$_orderData = $order->getData();
|
561 |
+
$_shippingData = $order->getShippingAddress()->getData();
|
562 |
+
$_billingData = $order->getBillingAddress()->getData();
|
563 |
+
|
564 |
+
// cmd
|
565 |
+
$postFields .= "cmd=openTrx";
|
566 |
+
$postFields .= "&amount=" . $_orderData['grand_total'];
|
567 |
+
$postFields .= "¤cyCode=" . $_orderData['order_currency_code'];
|
568 |
+
$postFields .= "&taxAmount=" . $_orderData['tax_amount'];
|
569 |
+
$postFields.="&isShippingRequired=false";
|
570 |
+
// customer
|
571 |
+
$postFields .= "&user.idNumber=" . $_orderData['customer_id'];
|
572 |
+
$postFields .= "&user.email=" . $_orderData['customer_email'];
|
573 |
+
$postFields .= "&user.firstName=" . $_orderData['customer_firstname'];
|
574 |
+
$postFields .= "&user.lastName=" . $_orderData['customer_lastname'];
|
575 |
+
$postFields .= "&user.phone.phoneNumber=" . $_shippingData['telephone'];
|
576 |
+
$postFields .= "&user.additionalDetails=Payment for Invoice #" . $_orderData['increment_id'];
|
577 |
+
|
578 |
+
// invoice
|
579 |
+
$postFields .= "&invoice.number=" . $_orderData['increment_id'];
|
580 |
+
$postFields .= "&invoice.additionalDetails=" . $_orderData['shipping_description'] . ': $' . $_orderData['shipping_amount'];
|
581 |
+
|
582 |
+
// items
|
583 |
+
$items = $order->getAllItems();
|
584 |
+
$i = 1;
|
585 |
+
foreach ($items as $itemId => $item) {
|
586 |
+
$postFields .= "&invoice.items(" . $i . ").id=" . $item->getProductId();
|
587 |
+
$postFields .= "&invoice.items(" . $i . ").name=" . $item->getName();
|
588 |
+
$postFields .= "&invoice.items(" . $i . ").quantity=" . $item->getQtyToInvoice();
|
589 |
+
$postFields .= "&invoice.items(" . $i . ").price=" . $item->getPrice();
|
590 |
+
$i++;
|
591 |
+
}
|
592 |
+
|
593 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
594 |
+
$coupon_code = $quote->getCouponCode();
|
595 |
+
$discount = $quote->getSubtotal() - $quote->getSubtotalWithDiscount();
|
596 |
+
|
597 |
+
if ($coupon_code != '') {
|
598 |
+
$postFields .= "&invoice.items(" . $i . ").id=" . $i;
|
599 |
+
$postFields .= "&invoice.items(" . $i . ").name=Discount";
|
600 |
+
$postFields .= "&invoice.items(" . $i . ").quantity=" . 1;
|
601 |
+
$postFields .= "&invoice.items(" . $i . ").price=" . $discount;
|
602 |
+
}
|
603 |
+
|
604 |
+
|
605 |
+
if ($code != '') {
|
606 |
+
|
607 |
+
$postFields .= "&invoice.items(" . $i . ").id=" . $i;
|
608 |
+
$postFields .= "&invoice.items(" . $i . ").quantity=" . 1;
|
609 |
+
$postFields .= "&invoice.items(" . $i . ").price=-" . $amount;
|
610 |
+
}
|
611 |
+
|
612 |
+
// billing address
|
613 |
+
$postFields .= "&billingAddress.firstName=" . $_billingData['firstname'];
|
614 |
+
$postFields .= "&billingAddress.lastName=" . $_billingData['lastname'];
|
615 |
+
$postFields .= "&billingAddress.phone.countryCode=USA";
|
616 |
+
$postFields .= "&billingAddress.phone.number=1222323" . $_billingData['telephone'];
|
617 |
+
$postFields .= "&billingAddress.street=" . $_billingData['street'];
|
618 |
+
$postFields .= "&billingAddress.city=" . $_billingData['city'];
|
619 |
+
//$postFields .= "&billingAddress.state=22";
|
620 |
+
$postFields .= "&billingAddress.state=" . $_billingData['region'];
|
621 |
+
$postFields .= "&billingAddress.country=" . $_billingData['country_id'];
|
622 |
+
$postFields .= "&billingAddress.zipCode=" . $_billingData['postcode'];
|
623 |
+
|
624 |
+
// shipping address
|
625 |
+
$postFields .= "&shippingAddress.firstName=" . $_shippingData['firstname'];
|
626 |
+
$postFields .= "&shippingAddress.lastName=" . $_shippingData['lastname'];
|
627 |
+
$postFields .= "&shippingAddress.phone.countryCode=2323";
|
628 |
+
$postFields .= "&shippingAddress.phone.number=232323" . $_shippingData['telephone'];
|
629 |
+
$postFields .= "&shippingAddress.street=" . $_shippingData['street'];
|
630 |
+
$postFields .= "&shippingAddress.city=" . $_shippingData['city'];
|
631 |
+
//$postFields .= "&shippingAddress.state=22";
|
632 |
+
$postFields .= "&shippingAddress.state=" . $_shippingData['region'];
|
633 |
+
$postFields .= "&shippingAddress.country=" . $_shippingData['country_id'];
|
634 |
+
$postFields .= "&shippingAddress.zipCode=" . $_shippingData['postcode'];
|
635 |
+
}
|
636 |
+
}
|
637 |
+
|
638 |
+
|
639 |
+
return $postFields;
|
640 |
+
}
|
641 |
+
|
642 |
+
public function successprocessing() {
|
643 |
+
// Flag to indicate whether sandbox environment should be used
|
644 |
+
$isSandbox = false;
|
645 |
+
|
646 |
+
if ($this->getIsSandBox()) {
|
647 |
+
$isSandbox = true;
|
648 |
+
}
|
649 |
+
|
650 |
+
$url;
|
651 |
+
|
652 |
+
if ($isSandbox == true) {
|
653 |
+
|
654 |
+
$zoozServer = $this->getSandboxUrl();
|
655 |
+
$url = $zoozServer . "/mobile/SecuredWebServlet";
|
656 |
+
} else {
|
657 |
+
|
658 |
+
$zoozServer = $this->getProductionUrl();
|
659 |
+
$url = $zoozServer . "/mobile/SecuredWebServlet";
|
660 |
+
}
|
661 |
+
// is cURL installed yet?
|
662 |
+
|
663 |
+
if (!function_exists('curl_init')) {
|
664 |
+
Mage::getSingleton('checkout/session')->addError('Sorry cURL is not installed!');
|
665 |
+
return Mage::getUrl('checkout/cart');
|
666 |
+
}
|
667 |
+
|
668 |
+
// OK cool - then let's create a new cURL resource handle
|
669 |
+
$ch = curl_init();
|
670 |
+
|
671 |
+
// Now set some options
|
672 |
+
// Set URL
|
673 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
674 |
+
|
675 |
+
//Header fields: ZooZUniqueID, ZooZAppKey, ZooZResponseType
|
676 |
+
$header = array('ZooZUniqueID: ' . $this->getAppUniqueId(), 'ZooZAppKey: ' . $this->getAppKey(), 'ZooZResponseType: NVP');
|
677 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
678 |
+
|
679 |
+
// If it is a post request
|
680 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
681 |
+
|
682 |
+
// Timeout in seconds
|
683 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
684 |
+
|
685 |
+
// If you are experiencing issues recieving the token on the sandbox environment, please set this option
|
686 |
+
if ($isSandbox) {
|
687 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
688 |
+
}
|
689 |
+
|
690 |
+
$params = Mage::app()->getRequest()->getParams();
|
691 |
+
|
692 |
+
$transactionID = $params['transactionID'];
|
693 |
+
|
694 |
+
$sessionToken = $params['sessionToken'];
|
695 |
+
|
696 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=verifyTrx&transactionID=" . $transactionID);
|
697 |
+
|
698 |
+
ob_start();
|
699 |
+
|
700 |
+
curl_exec($ch);
|
701 |
+
|
702 |
+
$result = ob_get_contents();
|
703 |
+
|
704 |
+
ob_end_clean();
|
705 |
+
|
706 |
+
parse_str($result);
|
707 |
+
|
708 |
+
curl_close($ch);
|
709 |
+
|
710 |
+
// create order with billding return
|
711 |
+
$zooz_useremail = Mage::getStoreConfig('payment/zoozpayment/zooz_useremail');
|
712 |
+
$zooz_serverkey = Mage::getStoreConfig('payment/zoozpayment/zooz_serverkey');
|
713 |
+
|
714 |
+
if ($isSandbox) {
|
715 |
+
$zooz = new ZooZExtendedServerAPI($zooz_useremail, $zooz_serverkey, true);
|
716 |
+
} else {
|
717 |
+
$zooz = new ZooZExtendedServerAPI($zooz_useremail, $zooz_serverkey, false);
|
718 |
+
}
|
719 |
+
//
|
720 |
+
//$info = $zooz->getTransactionDetailsByTransactionID('4QQ6RIRDNNKI7GN37JLHI7BSAI');
|
721 |
+
|
722 |
+
$info = $zooz->getTransactionDetailsByTransactionID($transactionID);
|
723 |
+
|
724 |
+
//Get Gift information from Params
|
725 |
+
|
726 |
+
if (isset($params['gift']) && $params['gift'] != '')
|
727 |
+
$giftInfo = $params['gift'];
|
728 |
+
else
|
729 |
+
$giftInfo = null;
|
730 |
+
//
|
731 |
+
Mage::getModel('zoozpayment/order')->saveOrder($info, $giftInfo);
|
732 |
+
// create order with billding return
|
733 |
+
//Mage::log($result);
|
734 |
+
Mage::getSingleton('core/session')->setZoozInfo($info);
|
735 |
+
|
736 |
+
return $statusCode;
|
737 |
+
}
|
738 |
+
|
739 |
+
}
|
app/code/community/ZooZ/ZoozPayment/controllers/EstimateController.php
CHANGED
@@ -29,54 +29,113 @@ class ZooZ_ZoozPayment_EstimateController extends Mage_Catalog_ProductController
|
|
29 |
*
|
30 |
* Initializes the product and passes data to estimate model in block
|
31 |
*/
|
32 |
-
|
33 |
-
return $this->_initProduct('');
|
34 |
-
}
|
35 |
|
36 |
-
protected function _initProduct(
|
37 |
$params = new Varien_Object();
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
|
41 |
public function indexAction() {
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
49 |
$arr_addressinfo = get_object_vars($variable_post->estimate);
|
50 |
$arr_cart = $variable_post->cart;
|
51 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
|
|
52 |
$this->loadLayout(false);
|
53 |
$block = $this->getLayout()->getBlock('shipping.estimate.result');
|
54 |
-
|
55 |
if ($block) {
|
56 |
-
|
57 |
$estimate = $block->getEstimate();
|
58 |
foreach ($arr_cart as $pro) {
|
59 |
-
|
60 |
-
if ($pro->
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
$params = get_object_vars($pro->options);
|
63 |
$pro_cart = array('product' => $pro->invoiceItemId, 'qty' => $pro->qty, 'options' => $params);
|
64 |
-
|
65 |
} else {
|
66 |
-
|
67 |
$pro_cart = array('product' => $pro->invoiceItemId, 'qty' => $pro->qty);
|
68 |
-
|
69 |
}
|
70 |
-
|
71 |
$product->setAddToCartInfo($pro_cart);
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
}
|
77 |
///$addressInfo = $arr_addressinfo;
|
78 |
-
$addressConvert = array("city"=> $arr_addressinfo["city"],"region_id"
|
79 |
-
|
80 |
$estimate->setAddressInfo((array) $addressConvert);
|
81 |
$block->getSession()->setFormValues($addressConvert);
|
82 |
try {
|
29 |
*
|
30 |
* Initializes the product and passes data to estimate model in block
|
31 |
*/
|
32 |
+
protected $productId;
|
|
|
|
|
33 |
|
34 |
+
protected function _initProduct() {
|
35 |
$params = new Varien_Object();
|
36 |
+
$productId = $this->productId;
|
37 |
+
//return Mage::helper('catalog/product')->initProduct($productId, $this, $params);
|
38 |
+
return Mage::getModel('catalog/product')->load($productId);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function quoteAction() {
|
42 |
+
echo $discount = Mage::helper('zoozpayment')->getdiscount();
|
43 |
+
die();
|
44 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
45 |
+
$payment = $quote->getPayment();
|
46 |
+
|
47 |
+
$payment->setMethod('zoozpayment');
|
48 |
+
//
|
49 |
+
$quote->collectTotals();
|
50 |
+
$service = Mage::getModel('sales/service_quote', $quote);
|
51 |
+
$service->submitAll();
|
52 |
+
//
|
53 |
+
$cart = Mage::helper('checkout/cart')->getCart();
|
54 |
+
$data = $cart->getQuote()->getData();
|
55 |
+
|
56 |
+
//$quote = Mage::getSingleton('checkout/session')->getQuote();
|
57 |
+
// print_r($quote->getData());
|
58 |
+
// $rewardsQuote = Mage::getSingleton('rewards/session')->getQuote();
|
59 |
+
// print_r($rewardsQuote);
|
60 |
+
// $cart = Mage::getSingleton('checkout/cart');
|
61 |
+
// $rewardsQuote = Mage::getModel('rewards/sales_quote');
|
62 |
+
//
|
63 |
+
// $rewardsQuote->updateItemCatalogPoints( $cart->getQuote() );
|
64 |
+
//
|
65 |
+
// $cart->getQuote ()->collectTotals ();
|
66 |
+
// $cart->getQuote ()->getShippingAddress ()->setCollectShippingRates ( true );
|
67 |
+
// $cart->getQuote ()->getShippingAddress ()->collectShippingRates();
|
68 |
+
//
|
69 |
+
// $rewardsQuote->updateDisabledEarnings( $cart->getQuote() );
|
70 |
+
// $cart = Mage::getSingleton('checkout/cart');
|
71 |
+
// $rewardsQuote->updateItemCatalogPoints($cart->getQuote());
|
72 |
+
// $rewardsQuote->setPointsSpending('500');
|
73 |
+
// $cart = Mage::getSingleton('checkout/cart');
|
74 |
+
// $rewardsQuote = Mage::getModel('rewards/sales_quote');
|
75 |
+
//
|
76 |
+
// $rewardsQuote->updateItemCatalogPoints($cart->getQuote());
|
77 |
+
//
|
78 |
+
// $cart->getQuote()->collectTotals();
|
79 |
+
// $cart->getQuote()->getShippingAddress()->setCollectShippingRates(true);
|
80 |
+
// $cart->getQuote()->getShippingAddress()->collectShippingRates();
|
81 |
+
//
|
82 |
+
// $rewardsQuote->updateDisabledEarnings($cart->getQuote());
|
83 |
+
// echo $rewardsQuote->getTotalPointsSpendingAsStringList()."kkkk";
|
84 |
+
// print_r($rewardsQuote->updateShoppingCartPoints($cart));
|
85 |
+
//magento.zooz.com/magentoe/index.php/zoozpayment/index/test/
|
86 |
}
|
87 |
|
88 |
public function indexAction() {
|
89 |
+
Mage::log("Received Estimate controller index action");
|
90 |
+
$data_json = $this->getRequest()->getPost('data');
|
91 |
+
if ($data_json == '') {
|
92 |
+
$data_json = file_get_contents('php://input');
|
93 |
+
}
|
94 |
+
Mage::log("Json received" . $data_json);
|
95 |
|
96 |
+
|
97 |
+
if ($data_json == '') {
|
98 |
+
Mage::log("Could not receive data.");
|
99 |
+
return;
|
100 |
+
}
|
101 |
+
$variable_post = json_decode($data_json);
|
102 |
$arr_addressinfo = get_object_vars($variable_post->estimate);
|
103 |
$arr_cart = $variable_post->cart;
|
104 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
105 |
+
Mage::log("Loading layout");
|
106 |
$this->loadLayout(false);
|
107 |
$block = $this->getLayout()->getBlock('shipping.estimate.result');
|
108 |
+
Mage::log("Block receieved");
|
109 |
if ($block) {
|
110 |
+
|
111 |
$estimate = $block->getEstimate();
|
112 |
foreach ($arr_cart as $pro) {
|
113 |
+
Mage::log("Itterating product ID: " . $pro->invoiceItemId);
|
114 |
+
if ($pro->invoiceItemId == '-i') {
|
115 |
+
continue;
|
116 |
+
}
|
117 |
+
|
118 |
+
$this->productId = $pro->invoiceItemId;
|
119 |
+
|
120 |
+
$product = $this->_initProduct($pro->invoiceItemId);
|
121 |
+
if (isset($pro->options) && $pro->options != '') {
|
122 |
+
|
123 |
$params = get_object_vars($pro->options);
|
124 |
$pro_cart = array('product' => $pro->invoiceItemId, 'qty' => $pro->qty, 'options' => $params);
|
|
|
125 |
} else {
|
126 |
+
|
127 |
$pro_cart = array('product' => $pro->invoiceItemId, 'qty' => $pro->qty);
|
|
|
128 |
}
|
129 |
+
|
130 |
$product->setAddToCartInfo($pro_cart);
|
131 |
+
$estimate->setProduct($product);
|
132 |
+
Mage::unregister('current_category');
|
133 |
+
Mage::unregister('current_product');
|
134 |
+
Mage::unregister('product');
|
135 |
}
|
136 |
///$addressInfo = $arr_addressinfo;
|
137 |
+
$addressConvert = array("city" => isset($arr_addressinfo["city"]) ? $arr_addressinfo["city"] : "", "region_id" => isset($arr_addressinfo["stateName"]) ? $arr_addressinfo["stateName"] : "", "postcode" => isset($arr_addressinfo["zipCode"]) ? $arr_addressinfo["zipCode"] : "", "country_id" => isset($arr_addressinfo["countryCode"]) ? $arr_addressinfo["countryCode"] : "");
|
138 |
+
Mage::log("Address converted");
|
139 |
$estimate->setAddressInfo((array) $addressConvert);
|
140 |
$block->getSession()->setFormValues($addressConvert);
|
141 |
try {
|
app/code/community/ZooZ/ZoozPayment/controllers/IndexController.php
CHANGED
@@ -1,8 +1,70 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
3 |
//public function IndexAction() {
|
4 |
//$this->getResponse()->setRedirect(Mage::getUrl('', array('_secure' => true)));
|
5 |
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
public function IndexAction() {
|
8 |
$this->loadLayout();
|
@@ -21,6 +83,6 @@ class ZooZ_ZoozPayment_IndexController extends Mage_Core_Controller_Front_Action
|
|
21 |
));
|
22 |
|
23 |
$this->renderLayout();
|
|
|
24 |
|
25 |
-
|
26 |
-
}
|
1 |
<?php
|
2 |
+
|
3 |
+
class ZooZ_ZoozPayment_IndexController extends Mage_Core_Controller_Front_Action {
|
4 |
+
|
5 |
//public function IndexAction() {
|
6 |
//$this->getResponse()->setRedirect(Mage::getUrl('', array('_secure' => true)));
|
7 |
//}
|
8 |
+
public function testAction() {
|
9 |
+
// $tempAddress = Mage::getModel('sales/quote_address')->load(596 );
|
10 |
+
// $quote = Mage::getSingleton('checkout/session')->getQuote();
|
11 |
+
// echo $giftcardAmount = $quote->getGiftCardsAmountUsed();
|
12 |
+
// die();
|
13 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
14 |
+
print_r($quote->getData());
|
15 |
+
die();
|
16 |
+
$coupon_code = $quote->getCouponCode();
|
17 |
+
$oCoupon = Mage::getModel('salesrule/coupon')->load($coupon_code, 'code');
|
18 |
+
$oRule = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());
|
19 |
+
$oRule->getName();
|
20 |
+
die();
|
21 |
+
$date = new DateTime('now');
|
22 |
+
echo $date->format('Y-m-d H:i:s');
|
23 |
+
die();
|
24 |
+
$card_history = Mage::getModel('enterprise_giftcardaccount/history');
|
25 |
+
$card_history->setGiftcardaccountId();
|
26 |
+
$card_history->setUpdatedAt();
|
27 |
+
$card_history->setAction(1);
|
28 |
+
$card_history->setBalanceAmount();
|
29 |
+
$card_history->setAdditionalInfo();
|
30 |
+
$card_history->setBalanceDelta();
|
31 |
+
|
32 |
+
print_r($card_history->getData());
|
33 |
+
|
34 |
+
die();
|
35 |
+
$_card = Mage::getModel('enterprise_giftcardaccount/giftcardaccount')->load(1);
|
36 |
+
$_card->setBalance(80);
|
37 |
+
$_card->save();
|
38 |
+
print_r($_card->getData());
|
39 |
+
//
|
40 |
+
die();
|
41 |
+
$giftcart_s = 'a:1:{i:0;a:4:{s:1:"i";s:1:"2";s:1:"c";s:12:"02DQ9T1K0Y0V";s:1:"a";d:17;s:2:"ba";s:7:"17.0000";}}';
|
42 |
+
$giftcart = unserialize($giftcart_s);
|
43 |
+
$temp_1 = $giftcart[0];
|
44 |
+
$temp_1['authorized'] = $temp_1['a'];
|
45 |
+
$temp_2[] = $temp_1;
|
46 |
+
$giftcart_auth = serialize($temp_2);
|
47 |
+
|
48 |
+
die();
|
49 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
50 |
+
$shippingAddress = $quote->getShippingAddress();
|
51 |
+
// $shippingAddress->setShippingMethod(freeshipping_freeshipping);
|
52 |
+
// $shippingAddress->save();
|
53 |
+
print_r($shippingAddress->getData());
|
54 |
+
echo "Dev";
|
55 |
+
// $quote = Mage::getSingleton('checkout/session')->getQuote();
|
56 |
+
//
|
57 |
+
// $cart = unserialize($quote->getGiftCards());
|
58 |
+
//
|
59 |
+
// echo $quote->getGiftCardsAmount();
|
60 |
+
// echo $quote->getBaseGiftCardsAmount();
|
61 |
+
// echo $quote->getGiftCardsAmountUsed();
|
62 |
+
// echo $quote->getBaseGiftCardsAmountUsed();
|
63 |
+
// print_r($quote->getData());
|
64 |
+
// a:1:{i:0;a:5:{s:1:"i";s:1:"2";s:1:"c";s:12:"02DQ9T1K0Y0V";s:1:"a";d:252;s:2:"ba";d:252;s:10:"authorized";d:252;}}
|
65 |
+
// echo $giftcardAmount = $quote->getGiftCardsAmountUsed();
|
66 |
+
// die();
|
67 |
+
}
|
68 |
|
69 |
public function IndexAction() {
|
70 |
$this->loadLayout();
|
83 |
));
|
84 |
|
85 |
$this->renderLayout();
|
86 |
+
}
|
87 |
|
88 |
+
}
|
|
app/code/community/ZooZ/ZoozPayment/controllers/StandardController.php
CHANGED
@@ -1,83 +1,115 @@
|
|
1 |
<?php
|
|
|
2 |
class ZooZ_ZoozPayment_StandardController extends Mage_Core_Controller_Front_Action {
|
3 |
-
|
4 |
-
|
|
|
5 |
}
|
6 |
|
7 |
-
public function redirectAction() {
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
}
|
15 |
|
16 |
public function successexpressAction() {
|
17 |
-
|
18 |
$statusCode = Mage::getModel('zoozpayment/standard')->successprocessing();
|
19 |
-
|
20 |
-
if ($statusCode == 0) {
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
47 |
-
|
48 |
public function successAction() {
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
}
|
79 |
-
|
80 |
-
|
81 |
function cancelAction() {
|
82 |
$session = Mage::getSingleton('checkout/session');
|
83 |
$session->setQuoteId($session->getZoozQuoteId(true));
|
@@ -87,32 +119,33 @@ class ZooZ_ZoozPayment_StandardController extends Mage_Core_Controller_Front_Act
|
|
87 |
$order->cancel()->save();
|
88 |
}
|
89 |
}
|
90 |
-
|
91 |
$params = Mage::app()->getRequest()->getParams();
|
92 |
Mage::log($params);
|
93 |
-
|
94 |
-
|
95 |
}
|
96 |
-
|
97 |
function ajaxstartAction() {
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
105 |
}
|
106 |
-
|
107 |
function startAction() {
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
}
|
118 |
-
|
|
1 |
<?php
|
2 |
+
|
3 |
class ZooZ_ZoozPayment_StandardController extends Mage_Core_Controller_Front_Action {
|
4 |
+
|
5 |
+
public function indexAction() {
|
6 |
+
$this->getResponse()->setRedirect(Mage::getUrl('', array('_secure' => true)));
|
7 |
}
|
8 |
|
9 |
+
public function redirectAction() {
|
10 |
+
|
11 |
+
$trimmedSessionToken = Mage::getModel('zoozpayment/standard')->ajaxprocessing();
|
12 |
+
if ($trimmedSessionToken != '') {
|
13 |
+
|
14 |
+
$this->getResponse()->setRedirect(Mage::getUrl('zoozpayment') . '?token=' . $trimmedSessionToken);
|
15 |
+
}
|
16 |
}
|
17 |
|
18 |
public function successexpressAction() {
|
19 |
+
|
20 |
$statusCode = Mage::getModel('zoozpayment/standard')->successprocessing();
|
21 |
+
if ($statusCode == 0) {
|
|
|
22 |
|
23 |
+
$session = Mage::getSingleton('checkout/session');
|
24 |
+
$session->setQuoteId($session->getZoozQuoteId(true));
|
25 |
+
if ($session->getLastRealOrderId()) {
|
26 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
|
27 |
+
if ($order->getId()) {
|
28 |
+
// $status = Mage::getStoreConfig('payment/zoozpayment/order_status');
|
29 |
+
$grandtotal = Mage::getSingleton('core/session')->getZoozGrandTotal();
|
30 |
+
$info = Mage::getSingleton('core/session')->getZoozInfo();
|
31 |
+
$payment = $order->getPayment();
|
32 |
+
$payment->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_APPROVED)
|
33 |
+
->setTransactionId($info->transactionID)
|
34 |
+
->setStatusDescription('Payment was successful.')
|
35 |
+
->setAdditionalData(serialize(''))
|
36 |
+
->setIsTransactionClosed('')
|
37 |
+
->authorize(true, $grandtotal)
|
38 |
+
->save();
|
39 |
+
$order->setPayment($payment);
|
40 |
+
$order->save(); //Save details in order
|
41 |
+
if (Mage::getStoreConfig('payment/zoozpayment/payment_action') == "authorize_capture") {
|
42 |
+
try {
|
43 |
+
if (!$order->canInvoice()) {
|
44 |
+
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
|
45 |
+
}
|
46 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
47 |
+
if (!$invoice->getTotalQty()) {
|
48 |
+
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
|
49 |
+
}
|
50 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
51 |
+
$invoice->register();
|
52 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
53 |
+
->addObject($invoice)
|
54 |
+
->addObject($invoice->getOrder());
|
55 |
+
$transactionSave->save();
|
56 |
+
} catch (Mage_Core_Exception $e) {
|
57 |
+
|
58 |
+
}
|
59 |
+
}
|
60 |
+
Mage::getSingleton('core/session')->unsZoozGrandTotal();
|
61 |
+
Mage::getSingleton('core/session')->unsZoozInfo();
|
62 |
+
// $order->setState($status, true)->save();
|
63 |
+
}
|
64 |
+
}
|
65 |
+
$this->getResponse()->setRedirect(Mage::getUrl('checkout/onepage/success'));
|
66 |
+
} else {
|
67 |
+
$session = Mage::getSingleton('checkout/session');
|
68 |
+
$session->setQuoteId($session->getZoozQuoteId(true));
|
69 |
+
if ($session->getLastRealOrderId()) {
|
70 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
|
71 |
+
if ($order->getId()) {
|
72 |
+
$order->cancel()->save();
|
73 |
+
}
|
74 |
+
}
|
75 |
+
$params = Mage::app()->getRequest()->getParams();
|
76 |
+
|
77 |
+
Mage::getSingleton('checkout/session')->addError($params['errorMessage']);
|
78 |
+
$this->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
|
79 |
+
}
|
80 |
}
|
81 |
+
|
82 |
public function successAction() {
|
83 |
+
|
84 |
+
$statusCode = Mage::getModel('zoozpayment/standard')->successprocessing();
|
85 |
+
|
86 |
+
if ($statusCode == 0) {
|
87 |
+
$session = Mage::getSingleton('checkout/session');
|
88 |
+
$session->setQuoteId($session->getZoozQuoteId(true));
|
89 |
+
if ($session->getLastRealOrderId()) {
|
90 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
|
91 |
+
if ($order->getId()) {
|
92 |
+
$order->setState(Mage_Sales_Model_Order::STATE_NEW, true)->save();
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
$this->getResponse()->setRedirect(Mage::getUrl('checkout/onepage/success'));
|
97 |
+
} else {
|
98 |
+
$session = Mage::getSingleton('checkout/session');
|
99 |
+
$session->setQuoteId($session->getZoozQuoteId(true));
|
100 |
+
if ($session->getLastRealOrderId()) {
|
101 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
|
102 |
+
if ($order->getId()) {
|
103 |
+
$order->cancel()->save();
|
104 |
+
}
|
105 |
+
}
|
106 |
+
$params = Mage::app()->getRequest()->getParams();
|
107 |
+
|
108 |
+
Mage::getSingleton('checkout/session')->addError($params['errorMessage']);
|
109 |
+
$this->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
|
110 |
+
}
|
|
|
111 |
}
|
112 |
+
|
|
|
113 |
function cancelAction() {
|
114 |
$session = Mage::getSingleton('checkout/session');
|
115 |
$session->setQuoteId($session->getZoozQuoteId(true));
|
119 |
$order->cancel()->save();
|
120 |
}
|
121 |
}
|
122 |
+
|
123 |
$params = Mage::app()->getRequest()->getParams();
|
124 |
Mage::log($params);
|
125 |
+
Mage::getSingleton('checkout/session')->addError($params['errorMessage']);
|
126 |
+
$this->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
|
127 |
}
|
128 |
+
|
129 |
function ajaxstartAction() {
|
130 |
+
|
131 |
+
$trimmedSessionToken = Mage::getModel('zoozpayment/standard')->ajaxprocessing(true);
|
132 |
+
if ($trimmedSessionToken != '') {
|
133 |
+
|
134 |
+
echo "var data = {'token' : '" . $trimmedSessionToken . "'}";
|
135 |
+
|
136 |
+
return;
|
137 |
+
}
|
138 |
}
|
139 |
+
|
140 |
function startAction() {
|
141 |
+
|
142 |
+
$url = Mage::getModel('zoozpayment/standard')->processing(true);
|
143 |
+
if ($url) {
|
144 |
+
Mage::getModel('zoozpayment/order')->saveOrder();
|
145 |
+
$this->getResponse()->setRedirect($url);
|
146 |
+
} else {
|
147 |
+
$this->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
|
148 |
+
}
|
|
|
149 |
}
|
150 |
+
|
151 |
+
}
|
app/code/community/ZooZ/ZoozPayment/etc/config.xml
CHANGED
@@ -16,6 +16,12 @@
|
|
16 |
<zoozpayment>
|
17 |
<class>ZooZ_ZoozPayment_Model</class>
|
18 |
</zoozpayment>
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
</models>
|
20 |
<helpers>
|
21 |
<zoozpayment>
|
16 |
<zoozpayment>
|
17 |
<class>ZooZ_ZoozPayment_Model</class>
|
18 |
</zoozpayment>
|
19 |
+
<tax>
|
20 |
+
<rewrite>
|
21 |
+
<!-- Model -->
|
22 |
+
<observer>ZooZ_ZoozPayment_Model_Observer</observer>
|
23 |
+
</rewrite>
|
24 |
+
</tax>
|
25 |
</models>
|
26 |
<helpers>
|
27 |
<zoozpayment>
|
app/code/community/ZooZ/ZoozPayment/etc/system.xml
CHANGED
@@ -28,10 +28,18 @@
|
|
28 |
<show_in_website>1</show_in_website>
|
29 |
<show_in_store>1</show_in_store>
|
30 |
</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
<order_status translate="label">
|
32 |
<label>New Order Status</label>
|
33 |
<frontend_type>select</frontend_type>
|
34 |
-
|
35 |
<sort_order>30</sort_order>
|
36 |
<show_in_default>1</show_in_default>
|
37 |
<show_in_website>1</show_in_website>
|
28 |
<show_in_website>1</show_in_website>
|
29 |
<show_in_store>1</show_in_store>
|
30 |
</title>
|
31 |
+
<payment_action translate="label">
|
32 |
+
<label>Payment Action</label>
|
33 |
+
<frontend_type>select</frontend_type>
|
34 |
+
<source_model>zoozpayment/source_action</source_model>
|
35 |
+
<sort_order>21</sort_order>
|
36 |
+
<show_in_default>1</show_in_default>
|
37 |
+
<show_in_website>1</show_in_website>
|
38 |
+
</payment_action>
|
39 |
<order_status translate="label">
|
40 |
<label>New Order Status</label>
|
41 |
<frontend_type>select</frontend_type>
|
42 |
+
<source_model>zoozpayment/source_status</source_model>
|
43 |
<sort_order>30</sort_order>
|
44 |
<show_in_default>1</show_in_default>
|
45 |
<show_in_website>1</show_in_website>
|
app/design/frontend/default/default/template/zoozpayment/index.phtml
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<?php
|
2 |
-
die('dev');
|
3 |
$token = Mage::app()->getRequest()->getParam('token');
|
4 |
if($token != ''):
|
5 |
?>
|
1 |
<?php
|
|
|
2 |
$token = Mage::app()->getRequest()->getParam('token');
|
3 |
if($token != ''):
|
4 |
?>
|
app/design/frontend/default/default/template/zoozpayment/result.phtml
CHANGED
@@ -8,17 +8,18 @@ if ($this->getResult()) {
|
|
8 |
foreach ($_rates as $_rate) {
|
9 |
if (!$_rate->getErrorMessage()) {
|
10 |
$rate_name = $_rate->getMethodTitle();
|
|
|
|
|
11 |
$arr[] = array('name' => $rate_name, 'price' => $_rate->getPrice());
|
12 |
}
|
13 |
}
|
14 |
-
$response[] = array('carrierName' => $this->getCarrierName($code),'carrierCode' => $code, 'rates' => $arr);
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
-
if(count($arr) == 0)
|
17 |
-
{
|
18 |
-
$result[] = array('error'=>true,'message'=>'There is no shipping method available for this address.');
|
19 |
-
echo json_encode($result);
|
20 |
-
}
|
21 |
-
else { echo json_encode($response); }
|
22 |
-
|
23 |
}
|
24 |
?>
|
8 |
foreach ($_rates as $_rate) {
|
9 |
if (!$_rate->getErrorMessage()) {
|
10 |
$rate_name = $_rate->getMethodTitle();
|
11 |
+
//
|
12 |
+
$rate_name = $_rate->getCode();
|
13 |
$arr[] = array('name' => $rate_name, 'price' => $_rate->getPrice());
|
14 |
}
|
15 |
}
|
16 |
+
$response[] = array('carrierName' => $this->getCarrierName($code), 'carrierCode' => $code, 'rates' => $arr);
|
17 |
+
}
|
18 |
+
if (count($arr) == 0) {
|
19 |
+
$result[] = array('error' => true, 'message' => 'There is no shipping method available for this address.');
|
20 |
+
echo json_encode($result);
|
21 |
+
} else {
|
22 |
+
echo json_encode($response);
|
23 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
?>
|
app/design/frontend/default/default/template/zoozpayment/shortcut-checkout.phtml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<a id="zooz-payment-link" style="background-color: #679100; padding: 10px; color: white; font-size: small;" href="<?php echo $this->getUrl('zoozpayment/standard/ajaxstart');?>" onclick='return localDoZooz(this);' >Checkout
|
2 |
</a>
|
3 |
-
<img id="zooz-payment-loading" class=
|
4 |
<style>
|
5 |
.cart .title-buttons .checkout-types li { float: none; }
|
6 |
</style>
|
1 |
<a id="zooz-payment-link" style="background-color: #679100; padding: 10px; color: white; font-size: small;" href="<?php echo $this->getUrl('zoozpayment/standard/ajaxstart');?>" onclick='return localDoZooz(this);' >Checkout
|
2 |
</a>
|
3 |
+
<img id="zooz-payment-loading" class='zooz-payment-loading' style="display: none; margin-left: 10px;z-index:1000" src="<?php echo $this->getSkinUrl('zooz/images/loading.gif');?>" alt="loading" title="loading" />
|
4 |
<style>
|
5 |
.cart .title-buttons .checkout-types li { float: none; }
|
6 |
</style>
|
app/etc/modules/ZooZ_ZoozPayment.xml
CHANGED
@@ -7,4 +7,4 @@
|
|
7 |
<version>0.1.0</version>
|
8 |
</ZooZ_ZoozPayment>
|
9 |
</modules>
|
10 |
-
</config>
|
7 |
<version>0.1.0</version>
|
8 |
</ZooZ_ZoozPayment>
|
9 |
</modules>
|
10 |
+
</config>
|
lib/zooz/zooz.extended.server.api.php
CHANGED
@@ -152,11 +152,11 @@
|
|
152 |
$nvps->add("transactionID", $transactionID);
|
153 |
|
154 |
|
155 |
-
|
156 |
-
if (!empty($amount)) {
|
157 |
$nvps->add("amount", $amount);
|
158 |
}
|
159 |
|
|
|
160 |
if (!empty($invoice)) {
|
161 |
$nvps->add("invoice", json_encode($invoice));
|
162 |
}
|
@@ -218,14 +218,14 @@
|
|
218 |
$decoded = json_decode(trim($chResult), TRUE);
|
219 |
//Mage::log($decoded);
|
220 |
if ($decoded['ResponseStatus'] != 0) {
|
221 |
-
if (!empty($decoded[ResponseObject]) && !empty($decoded[ResponseObject][errorMessage])) {
|
222 |
-
$errorMsg = $decoded[ResponseObject][errorMessage];
|
223 |
-
$errorCode = $decoded[ResponseStatus];
|
224 |
}
|
225 |
throw new ZooZException($errorMsg, $errorCode);
|
226 |
}
|
227 |
|
228 |
-
return $decoded[ResponseObject];
|
229 |
|
230 |
}
|
231 |
|
152 |
$nvps->add("transactionID", $transactionID);
|
153 |
|
154 |
|
155 |
+
if ($amount != null) {
|
|
|
156 |
$nvps->add("amount", $amount);
|
157 |
}
|
158 |
|
159 |
+
|
160 |
if (!empty($invoice)) {
|
161 |
$nvps->add("invoice", json_encode($invoice));
|
162 |
}
|
218 |
$decoded = json_decode(trim($chResult), TRUE);
|
219 |
//Mage::log($decoded);
|
220 |
if ($decoded['ResponseStatus'] != 0) {
|
221 |
+
if (!empty($decoded['ResponseObject']) && !empty($decoded['ResponseObject']['errorMessage'])) {
|
222 |
+
$errorMsg = $decoded['ResponseObject']['errorMessage'];
|
223 |
+
$errorCode = $decoded['ResponseStatus'];
|
224 |
}
|
225 |
throw new ZooZException($errorMsg, $errorCode);
|
226 |
}
|
227 |
|
228 |
+
return $decoded['ResponseObject'];
|
229 |
|
230 |
}
|
231 |
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>ZooZ_payment</name>
|
4 |
-
<version>2.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">GNU General Public License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Checkout module for higher conversions</summary>
|
10 |
<description>Zooz is a complete checkout plugin replaces completely the standard UI and handle payment processing and shipping address.</description>
|
11 |
-
<notes>
|
12 |
<authors><author><name>ZooZ Payments</name><user>Zooz_Payments</user><email>info@zooz.com</email></author></authors>
|
13 |
-
<date>2014-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="ZooZ"><dir name="ZoozPayment"><dir name="Block"><file name="Abstract.php" hash="0ac3cf5751fad5f6fd8d2240adedb197"/><dir name="Estimate"><file name="Abstract.php" hash="822638b4ec0a3d0f1f39b4d9f673de5e"/><file name="Result.php" hash="e26d7b8acaeb5424a608e43127844140"/></dir><file name="Estimate.php" hash="e16de59381c39d89633b7e3e53ee6028"/><file name="Index.php" hash="bea9161ac24756a7cf0c841ad8411da9"/></dir><dir name="Helper"><file name="Carrier.php" hash="a6482b94fcb7e419a3759171d0267df6"/><file name="Data.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>ZooZ_payment</name>
|
4 |
+
<version>2.0.8</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">GNU General Public License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Checkout module for higher conversions</summary>
|
10 |
<description>Zooz is a complete checkout plugin replaces completely the standard UI and handle payment processing and shipping address.</description>
|
11 |
+
<notes>Upgraded with commit and refund functionality</notes>
|
12 |
<authors><author><name>ZooZ Payments</name><user>Zooz_Payments</user><email>info@zooz.com</email></author></authors>
|
13 |
+
<date>2014-04-23</date>
|
14 |
+
<time>16:26:20</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="ZooZ"><dir name="ZoozPayment"><dir name="Block"><file name="Abstract.php" hash="0ac3cf5751fad5f6fd8d2240adedb197"/><dir name="Estimate"><file name="Abstract.php" hash="822638b4ec0a3d0f1f39b4d9f673de5e"/><file name="Result.php" hash="e26d7b8acaeb5424a608e43127844140"/></dir><file name="Estimate.php" hash="e16de59381c39d89633b7e3e53ee6028"/><file name="Index.php" hash="bea9161ac24756a7cf0c841ad8411da9"/></dir><dir name="Helper"><file name="Carrier.php" hash="a6482b94fcb7e419a3759171d0267df6"/><file name="Data.php" hash="7ffe139c5d5b130a9939f0a03604576c"/><file name="Sanbox.php" hash="9521c1d925d462d8e7d78a3318ee3ee0"/></dir><dir name="Model"><file name="Estimate.php" hash="0fc4bfdec840ff3ed9a43c97202e4314"/><file name="Observer.php" hash="e7583aab0d5594c832a86524a8d24be5"/><file name="Order.php" hash="940864d6b424a88f77d96eab97864200"/><file name="Session.php" hash="f2ae892657034ca2d55205f0703eedde"/><dir name="Source"><file name="Action.php" hash="a63cbdc25709c8a73b83001f19da9bdf"/><file name="Status.php" hash="449c28b272bf8c663b8c29e7ff5d5789"/></dir><file name="Standard.php" hash="cfce615a9de0d56f6e6aa373931fec18"/></dir><dir name="controllers"><file name="CartController.php" hash="6c1c69df795bece32f6565acfef22f6d"/><file name="EstimateController.php" hash="4e8b5fcefe3b179d28675971a4f2e746"/><file name="IndexController.php" hash="00854f4a4d1fcc78e02ade0ae244f668"/><file name="StandardController.php" hash="aa40a54c84535d434e3c6c17230f1bb1"/></dir><dir name="etc"><file name="config.xml" hash="d5dc49c2a0bfbc60d062632352928289"/><file name="system.xml" hash="900402e07be9b23378cc3f9207965445"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ZooZ_ZoozPayment.xml" hash="9b5ce2a8c325f210479527a1c0ebd8a9"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="zoozpayment.xml" hash="a3eaf1bf8eb27c4e20d0b30814f20d4f"/></dir><dir name="template"><dir name="zoozpayment"><file name="index.phtml" hash="c5aaccadf9379fb66c2591c060f7abb5"/><file name="result.phtml" hash="924e788ed0c118910ac098488c76324f"/><file name="review.phtml" hash="162e8a7f5548d80bfd987bd6ee0877e4"/><file name="shortcut-checkout.phtml" hash="d86c127a22f05d826997dd122efeeed6"/><file name="shortcut.phtml" hash="11eb2973b1ce3b7c948d8ed233c33bae"/><file name="sidebar.phtml" hash="2a96c03b4100bb88ba3e9e3fcaa8aa8b"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="zooz"><dir name="images"><file name="fastcheckout.png" hash="8f53be05b8c4a3903aec32745e9bf263"/><file name="loading.gif" hash="9a8269421303631316be4ab5e34870e1"/></dir><dir name="js"><file name="jquery-1.9.0.min.js" hash="6c4a706b2e324656fb77c0585c1cff55"/><file name="zooz-magento.js" hash="70e716b6bb6c50091d2bdd7bf1fa26b3"/></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="zooz"><file name="address.php" hash="40af42bf39330383e05c57bd6ba71759"/><file name="invoice.item.php" hash="37803cf953ca2dab2583cc34f80f7844"/><file name="invoice.php" hash="2e75b69bf1592243c70fd90ebaeba41a"/><file name="nvps.php" hash="cffaa4eb22d14af1ea3e69a522e21ad0"/><file name="transaction.details.php" hash="9e7fea0feb69e7468922e6fb8323a489"/><file name="user.details.php" hash="1e571f792f5e87187e1c85172a19c99d"/><file name="zooz.exception.php" hash="dc5a70ef56e64b1bc76f0407c2187f79"/><file name="zooz.extended.server.api.php" hash="f02d08bda2d088c36f34615788111dfd"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|