Version Notes
Fix to run on Magento v1.4.1.0 and above.
Fix to manage stock properly.
Fix to update the Order status properly.
Download this release
Release Info
Developer | Magento Core Team |
Extension | Iridiumcorp_Tpg |
Version | 1.10.0 |
Comparing to | |
See all releases |
Code changes from version 1.9.1 to 1.10.0
- app/code/local/Iridiumcorp/Checkout/Model/Type/Onepage.php +690 -492
- app/code/local/Iridiumcorp/Sales/Model/Order.php +4 -2
- app/code/local/Iridiumcorp/Sales/Model/Order/Payment.php +117 -0
- app/code/local/Iridiumcorp/Sales/Model/Service/Quote.php +87 -0
- app/code/local/Iridiumcorp/Sales/etc/config.xml +23 -0
- app/code/local/Iridiumcorp/Tpg/Block/Threedsecure.php +10 -1
- app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/GlobalErrors.php +1 -1
- app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/ISOCountries.php +0 -0
- app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/ISOCurrencies.php +0 -0
- app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/PaymentFormHelper.php +21 -0
- app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/ThePaymentGateway/PaymentSystem.php +0 -0
- app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/ThePaymentGateway/SOAP.php +0 -0
- app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/ThePaymentGateway/TPG_Common.php +0 -0
- app/code/local/Iridiumcorp/Tpg/Model/Direct.php +19 -10
- app/code/local/Iridiumcorp/Tpg/Model/Source/ResultDeliveryMethod.php +2 -2
- app/code/local/Iridiumcorp/Tpg/controllers/PaymentController.php +212 -45
- app/code/local/Iridiumcorp/Tpg/etc/config.xml +1 -0
- app/code/local/Iridiumcorp/Tpg/etc/system.xml +13 -1
- app/design/adminhtml/default/default/template/Tpg/info.phtml +1 -1
- app/design/frontend/default/default/template/Tpg/info.phtml +1 -1
- package.xml +9 -7
app/code/local/Iridiumcorp/Checkout/Model/Type/Onepage.php
CHANGED
@@ -2,6 +2,20 @@
|
|
2 |
|
3 |
class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
|
4 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
/**
|
6 |
* Create an order
|
7 |
*
|
@@ -9,254 +23,356 @@ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_O
|
|
9 |
*/
|
10 |
public function saveOrder()
|
11 |
{
|
12 |
-
$this->
|
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 |
-
Mage::log(time());
|
59 |
-
break;
|
60 |
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
66 |
{
|
67 |
-
|
68 |
-
$customer->addAddress($customerBilling);
|
69 |
}
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
-
$customer->
|
78 |
$customer->save();
|
79 |
|
80 |
-
$
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
83 |
{
|
84 |
-
$
|
85 |
-
$changed = true;
|
86 |
}
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
{
|
92 |
-
$customer->setDefaultShipping($customerBilling->getId());
|
93 |
-
$changed = true;
|
94 |
}
|
95 |
-
|
96 |
-
isset($customerShipping) &&
|
97 |
-
!$customer->getDefaultShipping())
|
98 |
{
|
99 |
-
$customer->
|
100 |
-
$changed = true;
|
101 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
{
|
105 |
-
|
|
|
|
|
106 |
}
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
if (!$this->getQuote()->isVirtual())
|
124 |
-
{
|
125 |
-
$order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
|
126 |
-
}
|
127 |
-
|
128 |
-
$order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
|
129 |
-
|
130 |
-
foreach ($this->getQuote()->getAllItems() as $item)
|
131 |
-
{
|
132 |
-
$orderItem = $convertQuote->itemToOrderItem($item);
|
133 |
-
if ($item->getParentItem())
|
134 |
-
{
|
135 |
-
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
|
136 |
-
}
|
137 |
-
$order->addItem($orderItem);
|
138 |
-
}
|
139 |
-
|
140 |
-
// We can use configuration data for declare new order status
|
141 |
-
Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
|
142 |
-
// check again, if customer exists
|
143 |
-
if ($this->getQuote()->getCheckoutMethod() == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)
|
144 |
-
{
|
145 |
-
if ($this->_customerEmailExists($customer->getEmail(), Mage::app()->getWebsite()->getId()))
|
146 |
-
{
|
147 |
-
Mage::throwException(Mage::helper('checkout')->__('There is already a customer registered using this email address'));
|
148 |
-
}
|
149 |
-
}
|
150 |
-
|
151 |
-
// clear 3dSecure session variables
|
152 |
-
Mage::getSingleton('checkout/session')->setThreedsecurerequired(null);
|
153 |
-
Mage::getSingleton('checkout/session')->setMd(null);
|
154 |
-
Mage::getSingleton('checkout/session')->setPares(null);
|
155 |
-
Mage::getSingleton('checkout/session')->setAcsurl(null);
|
156 |
-
|
157 |
-
$order->place();
|
158 |
-
|
159 |
-
if ($this->getQuote()->getCheckoutMethod()==Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)
|
160 |
-
{
|
161 |
-
$customer->save();
|
162 |
-
$customerBillingId = $customerBilling->getId();
|
163 |
-
if (!$this->getQuote()->isVirtual())
|
164 |
-
{
|
165 |
-
$customerShippingId = isset($customerShipping) ? $customerShipping->getId() : $customerBillingId;
|
166 |
-
$customer->setDefaultShipping($customerShippingId);
|
167 |
-
}
|
168 |
-
$customer->setDefaultBilling($customerBillingId);
|
169 |
-
$customer->save();
|
170 |
-
|
171 |
-
$this->getQuote()->setCustomerId($customer->getId());
|
172 |
-
|
173 |
-
$order->setCustomerId($customer->getId());
|
174 |
-
Mage::helper('core')->copyFieldset('customer_account', 'to_order', $customer, $order);
|
175 |
-
|
176 |
-
$billing->setCustomerId($customer->getId())->setCustomerAddressId($customerBillingId);
|
177 |
-
if (!$this->getQuote()->isVirtual())
|
178 |
-
{
|
179 |
-
$shipping->setCustomerId($customer->getId())->setCustomerAddressId($customerShippingId);
|
180 |
-
}
|
181 |
-
|
182 |
-
if ($customer->isConfirmationRequired())
|
183 |
-
{
|
184 |
-
$customer->sendNewAccountEmail('confirmation');
|
185 |
-
}
|
186 |
-
else
|
187 |
-
{
|
188 |
-
$customer->sendNewAccountEmail();
|
189 |
-
}
|
190 |
-
}
|
191 |
-
|
192 |
-
/**
|
193 |
-
* a flag to set that there will be redirect to third party after confirmation
|
194 |
-
* eg: paypal standard ipn
|
195 |
-
*/
|
196 |
-
$redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
|
197 |
-
if(!$redirectUrl)
|
198 |
-
{
|
199 |
-
$order->setEmailSent(true);
|
200 |
-
}
|
201 |
-
|
202 |
-
if(!$redirectUrl ||
|
203 |
-
$this->getQuote()->getPayment()->getMethodInstance()->getCode() != 'tpg')
|
204 |
-
{
|
205 |
-
$order->save();
|
206 |
-
}
|
207 |
-
|
208 |
-
Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
|
209 |
-
|
210 |
-
|
211 |
-
/**
|
212 |
-
* need to have somelogic to set order as new status to make sure order is not finished yet
|
213 |
-
* quote will be still active when we send the customer to paypal
|
214 |
-
*/
|
215 |
-
|
216 |
-
$orderId = $order->getIncrementId();
|
217 |
-
$this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
|
218 |
-
$this->getCheckout()->setLastOrderId($order->getId());
|
219 |
-
$this->getCheckout()->setLastRealOrderId($order->getIncrementId());
|
220 |
-
$this->getCheckout()->setRedirectUrl($redirectUrl);
|
221 |
-
|
222 |
-
/**
|
223 |
-
* we only want to send to customer about new order when there is no redirect to third party
|
224 |
-
*/
|
225 |
-
if(!$redirectUrl)
|
226 |
-
{
|
227 |
-
$order->sendNewOrderEmail();
|
228 |
-
}
|
229 |
-
|
230 |
-
if ($this->getQuote()->getCheckoutMethod(true) == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER &&
|
231 |
-
!Mage::getSingleton('customer/session')->isLoggedIn())
|
232 |
-
{
|
233 |
-
/**
|
234 |
-
* we need to save quote here to have it saved with Customer Id.
|
235 |
-
* so when loginById() executes checkout/session method loadCustomerQuote
|
236 |
-
* it would not create new quotes and merge it with old one.
|
237 |
-
*/
|
238 |
-
$this->getQuote()->save();
|
239 |
-
if ($customer->isConfirmationRequired())
|
240 |
-
{
|
241 |
-
Mage::getSingleton('checkout/session')->addSuccess(Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.',
|
242 |
-
Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())
|
243 |
-
));
|
244 |
-
}
|
245 |
-
else
|
246 |
-
{
|
247 |
-
Mage::getSingleton('customer/session')->loginById($customer->getId());
|
248 |
-
}
|
249 |
-
}
|
250 |
-
|
251 |
-
//Setting this one more time like control flag that we haves saved order
|
252 |
-
//Must be checkout on success page to show it or not.
|
253 |
-
$this->getCheckout()->setLastSuccessQuoteId($this->getQuote()->getId());
|
254 |
-
|
255 |
-
/*
|
256 |
-
* Fix for v1.4.1.0 and above - need to comment the below lines
|
257 |
-
*/
|
258 |
-
//$this->getQuote()->setIsActive(false);
|
259 |
-
//$this->getQuote()->save();
|
260 |
|
261 |
return $this;
|
262 |
}
|
@@ -270,143 +386,180 @@ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_O
|
|
270 |
*/
|
271 |
public function saveOrderAfter3dSecure($pares, $md)
|
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 |
-
$customerShipping = $shipping->exportCustomerAddress();
|
302 |
-
$customer->addAddress($customerShipping);
|
303 |
-
}
|
304 |
-
$customer->setSavedFromQuote(true);
|
305 |
-
$customer->save();
|
306 |
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
}
|
322 |
-
elseif (!$this->getQuote()->isVirtual() &&
|
323 |
-
isset($customerShipping) &&
|
324 |
-
!$customer->getDefaultShipping())
|
325 |
-
{
|
326 |
-
$customer->setDefaultShipping($customerShipping->getId());
|
327 |
-
$changed = true;
|
328 |
-
}
|
329 |
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
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 |
return $this;
|
411 |
}
|
412 |
|
@@ -423,143 +576,188 @@ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_O
|
|
423 |
*/
|
424 |
public function saveOrderAfterRedirectedPaymentAction($boIsHostedPaymentAction, $szStatusCode, $szMessage, $szPreviousStatusCode, $szPreviousMessage, $szOrderID)
|
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 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
$customer->addAddress($customerShipping);
|
457 |
-
}
|
458 |
-
$customer->setSavedFromQuote(true);
|
459 |
-
$customer->save();
|
460 |
|
461 |
-
|
462 |
-
if (isset($customerBilling) &&
|
463 |
-
!$customer->getDefaultBilling())
|
464 |
-
{
|
465 |
-
$customer->setDefaultBilling($customerBilling->getId());
|
466 |
-
$changed = true;
|
467 |
-
}
|
468 |
-
if (!$this->getQuote()->isVirtual() &&
|
469 |
-
isset($customerBilling) &&
|
470 |
-
!$customer->getDefaultShipping() &&
|
471 |
-
$shipping->getSameAsBilling())
|
472 |
-
{
|
473 |
-
$customer->setDefaultShipping($customerBilling->getId());
|
474 |
-
$changed = true;
|
475 |
-
}
|
476 |
-
elseif (!$this->getQuote()->isVirtual() &&
|
477 |
-
isset($customerShipping) &&
|
478 |
-
!$customer->getDefaultShipping())
|
479 |
-
{
|
480 |
-
$customer->setDefaultShipping($customerShipping->getId());
|
481 |
-
$changed = true;
|
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 |
return $this;
|
565 |
}
|
2 |
|
3 |
class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
|
4 |
{
|
5 |
+
public function getVersion($magentoVersion)
|
6 |
+
{
|
7 |
+
$pattern = '/[^\d]/';
|
8 |
+
$magentoVersion = preg_replace($pattern, '', $magentoVersion);
|
9 |
+
|
10 |
+
while(strlen($magentoVersion) < 4)
|
11 |
+
{
|
12 |
+
$magentoVersion .= '0';
|
13 |
+
}
|
14 |
+
$magentoVersion = (int)$magentoVersion;
|
15 |
+
|
16 |
+
return $magentoVersion;
|
17 |
+
}
|
18 |
+
|
19 |
/**
|
20 |
* Create an order
|
21 |
*
|
23 |
*/
|
24 |
public function saveOrder()
|
25 |
{
|
26 |
+
$nVersion = $this->getVersion(Mage::getVersion());
|
27 |
+
|
28 |
+
if($nVersion >= 1410)
|
29 |
+
{
|
30 |
+
// logic for version 1.4.1.0 and above
|
31 |
+
$this->validate();
|
32 |
+
$isNewCustomer = false;
|
33 |
+
|
34 |
+
switch ($this->getCheckoutMethod())
|
35 |
+
{
|
36 |
+
case self::METHOD_GUEST:
|
37 |
+
$this->_prepareGuestQuote();
|
38 |
+
break;
|
39 |
+
case self::METHOD_REGISTER:
|
40 |
+
$this->_prepareNewCustomerQuote();
|
41 |
+
$isNewCustomer = true;
|
42 |
+
break;
|
43 |
+
default:
|
44 |
+
$this->_prepareCustomerQuote();
|
45 |
+
break;
|
46 |
+
}
|
47 |
+
|
48 |
+
$service = Mage::getModel('sales/service_quote', $this->getQuote());
|
49 |
+
$redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
|
50 |
+
|
51 |
+
if(!$redirectUrl ||
|
52 |
+
$this->getQuote()->getPayment()->getMethodInstance()->getCode() != 'tpg')
|
53 |
+
{
|
54 |
+
$service->submitAll();
|
55 |
+
}
|
56 |
+
|
57 |
+
if ($isNewCustomer)
|
58 |
+
{
|
59 |
+
try
|
60 |
{
|
61 |
+
$this->_involveNewCustomer();
|
62 |
}
|
63 |
+
catch (Exception $e)
|
64 |
+
{
|
65 |
+
Mage::logException($e);
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
$this->_checkoutSession->setLastQuoteId($this->getQuote()->getId())
|
70 |
+
->setLastSuccessQuoteId($this->getQuote()->getId());
|
71 |
+
#->clearHelperData();
|
72 |
+
|
73 |
+
$order = $service->getOrder();
|
74 |
+
if ($order)
|
75 |
+
{
|
76 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
|
77 |
|
78 |
+
/**
|
79 |
+
* a flag to set that there will be redirect to third party after confirmation
|
80 |
+
* eg: paypal standard ipn
|
81 |
+
*/
|
82 |
+
$redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
|
83 |
+
/**
|
84 |
+
* we only want to send to customer about new order when there is no redirect to third party
|
85 |
+
*/
|
86 |
+
if(!$redirectUrl)
|
87 |
{
|
88 |
+
try
|
89 |
+
{
|
90 |
+
$order->sendNewOrderEmail();
|
91 |
+
}
|
92 |
+
catch (Exception $e)
|
93 |
+
{
|
94 |
+
Mage::logException($e);
|
95 |
+
}
|
96 |
}
|
97 |
+
|
98 |
+
// add order information to the session
|
99 |
+
$this->_checkoutSession->setLastOrderId($order->getId())
|
100 |
+
->setRedirectUrl($redirectUrl)
|
101 |
+
->setLastRealOrderId($order->getIncrementId());
|
102 |
|
103 |
+
// as well a billing agreement can be created
|
104 |
+
$agreement = $order->getPayment()->getBillingAgreement();
|
105 |
+
if ($agreement)
|
106 |
+
{
|
107 |
+
$this->_checkoutSession->setLastBillingAgreementId($agreement->getId());
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
// add recurring profiles information to the session
|
112 |
+
$profiles = $service->getRecurringPaymentProfiles();
|
113 |
+
if ($profiles)
|
114 |
+
{
|
115 |
+
$ids = array();
|
116 |
+
foreach($profiles as $profile)
|
117 |
{
|
118 |
+
$ids[] = $profile->getId();
|
119 |
}
|
120 |
+
$this->_checkoutSession->setLastRecurringProfileIds($ids);
|
121 |
+
// TODO: send recurring profile emails
|
122 |
+
}
|
123 |
+
}
|
124 |
+
else
|
125 |
+
{
|
126 |
+
// logic for version below 1.4.0.1 and below
|
127 |
+
$this->validateOrder();
|
128 |
+
$billing = $this->getQuote()->getBillingAddress();
|
129 |
+
|
130 |
+
if (!$this->getQuote()->isVirtual())
|
131 |
+
{
|
132 |
+
$shipping = $this->getQuote()->getShippingAddress();
|
133 |
+
}
|
134 |
+
|
135 |
+
switch ($this->getQuote()->getCheckoutMethod())
|
136 |
+
{
|
137 |
+
case Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST:
|
138 |
+
if (!$this->getQuote()->isAllowedGuestCheckout())
|
139 |
+
{
|
140 |
+
Mage::throwException(Mage::helper('checkout')->__('Sorry, guest checkout is not enabled. Please try again or contact store owner.'));
|
141 |
+
}
|
142 |
+
$this->getQuote()->setCustomerId(null)
|
143 |
+
->setCustomerEmail($billing->getEmail())
|
144 |
+
->setCustomerIsGuest(true)
|
145 |
+
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
146 |
+
break;
|
147 |
+
|
148 |
+
case Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER:
|
149 |
+
$customer = Mage::getModel('customer/customer');
|
150 |
+
|
151 |
+
$customerBilling = $billing->exportCustomerAddress();
|
152 |
+
$customer->addAddress($customerBilling);
|
153 |
+
|
154 |
+
if (!$this->getQuote()->isVirtual() &&
|
155 |
+
!$shipping->getSameAsBilling())
|
156 |
+
{
|
157 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
158 |
+
$customer->addAddress($customerShipping);
|
159 |
+
}
|
160 |
+
|
161 |
+
if ($this->getQuote()->getCustomerDob() &&
|
162 |
+
!$billing->getCustomerDob())
|
163 |
+
{
|
164 |
+
$billing->setCustomerDob($this->getQuote()->getCustomerDob());
|
165 |
+
}
|
166 |
+
|
167 |
+
Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer);
|
168 |
+
|
169 |
+
$customer->setPassword($customer->decryptPassword($this->getQuote()->getPasswordHash()));
|
170 |
+
$customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
|
171 |
+
|
172 |
+
$this->getQuote()->setCustomer($customer);
|
173 |
+
Mage::log(time());
|
174 |
+
break;
|
175 |
+
|
176 |
+
default:
|
177 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
178 |
+
|
179 |
+
if (!$billing->getCustomerId() ||
|
180 |
+
$billing->getSaveInAddressBook())
|
181 |
+
{
|
182 |
+
$customerBilling = $billing->exportCustomerAddress();
|
183 |
+
$customer->addAddress($customerBilling);
|
184 |
+
}
|
185 |
+
if (!$this->getQuote()->isVirtual() &&
|
186 |
+
((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) ||
|
187 |
+
(!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())))
|
188 |
+
{
|
189 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
190 |
+
$customer->addAddress($customerShipping);
|
191 |
+
}
|
192 |
+
$customer->setSavedFromQuote(true);
|
193 |
+
$customer->save();
|
194 |
+
|
195 |
+
$changed = false;
|
196 |
+
if (isset($customerBilling) &&
|
197 |
+
!$customer->getDefaultBilling())
|
198 |
+
{
|
199 |
+
$customer->setDefaultBilling($customerBilling->getId());
|
200 |
+
$changed = true;
|
201 |
+
}
|
202 |
+
if (!$this->getQuote()->isVirtual() &&
|
203 |
+
isset($customerBilling) &&
|
204 |
+
!$customer->getDefaultShipping() &&
|
205 |
+
$shipping->getSameAsBilling())
|
206 |
+
{
|
207 |
+
$customer->setDefaultShipping($customerBilling->getId());
|
208 |
+
$changed = true;
|
209 |
+
}
|
210 |
+
elseif (!$this->getQuote()->isVirtual() &&
|
211 |
+
isset($customerShipping) &&
|
212 |
+
!$customer->getDefaultShipping())
|
213 |
+
{
|
214 |
+
$customer->setDefaultShipping($customerShipping->getId());
|
215 |
+
$changed = true;
|
216 |
+
}
|
217 |
+
|
218 |
+
if ($changed)
|
219 |
+
{
|
220 |
+
$customer->save();
|
221 |
+
}
|
222 |
+
}
|
223 |
|
224 |
+
$this->getQuote()->reserveOrderId();
|
225 |
+
$convertQuote = Mage::getModel('sales/convert_quote');
|
226 |
+
// @var $convertQuote Mage_Sales_Model_Convert_Quote
|
227 |
+
if ($this->getQuote()->isVirtual())
|
228 |
+
{
|
229 |
+
$order = $convertQuote->addressToOrder($billing);
|
230 |
+
}
|
231 |
+
else
|
232 |
+
{
|
233 |
+
$order = $convertQuote->addressToOrder($shipping);
|
234 |
+
}
|
235 |
+
// @var $order Mage_Sales_Model_Order
|
236 |
+
$order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
|
237 |
|
238 |
+
if (!$this->getQuote()->isVirtual())
|
239 |
+
{
|
240 |
+
$order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
|
241 |
+
}
|
242 |
|
243 |
+
$order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
|
|
|
|
|
244 |
|
245 |
+
foreach ($this->getQuote()->getAllItems() as $item)
|
246 |
+
{
|
247 |
+
$orderItem = $convertQuote->itemToOrderItem($item);
|
248 |
+
if ($item->getParentItem())
|
249 |
+
{
|
250 |
+
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
|
251 |
+
}
|
252 |
+
$order->addItem($orderItem);
|
253 |
+
}
|
254 |
|
255 |
+
// We can use configuration data for declare new order status
|
256 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
|
257 |
+
// check again, if customer exists
|
258 |
+
if ($this->getQuote()->getCheckoutMethod() == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)
|
259 |
+
{
|
260 |
+
if ($this->_customerEmailExists($customer->getEmail(), Mage::app()->getWebsite()->getId()))
|
261 |
{
|
262 |
+
Mage::throwException(Mage::helper('checkout')->__('There is already a customer registered using this email address'));
|
|
|
263 |
}
|
264 |
+
}
|
265 |
+
|
266 |
+
// clear 3dSecure session variables
|
267 |
+
Mage::getSingleton('checkout/session')->setThreedsecurerequired(null)
|
268 |
+
->setMd(null)
|
269 |
+
->setPares(null)
|
270 |
+
->setAcsurl(null);
|
271 |
+
|
272 |
+
$order->place();
|
273 |
+
|
274 |
+
if ($this->getQuote()->getCheckoutMethod()==Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)
|
275 |
+
{
|
276 |
+
$customer->save();
|
277 |
+
$customerBillingId = $customerBilling->getId();
|
278 |
+
if (!$this->getQuote()->isVirtual())
|
279 |
+
{
|
280 |
+
$customerShippingId = isset($customerShipping) ? $customerShipping->getId() : $customerBillingId;
|
281 |
+
$customer->setDefaultShipping($customerShippingId);
|
282 |
}
|
283 |
+
$customer->setDefaultBilling($customerBillingId);
|
284 |
$customer->save();
|
285 |
|
286 |
+
$this->getQuote()->setCustomerId($customer->getId());
|
287 |
+
|
288 |
+
$order->setCustomerId($customer->getId());
|
289 |
+
Mage::helper('core')->copyFieldset('customer_account', 'to_order', $customer, $order);
|
290 |
+
|
291 |
+
$billing->setCustomerId($customer->getId())->setCustomerAddressId($customerBillingId);
|
292 |
+
if (!$this->getQuote()->isVirtual())
|
293 |
{
|
294 |
+
$shipping->setCustomerId($customer->getId())->setCustomerAddressId($customerShippingId);
|
|
|
295 |
}
|
296 |
+
|
297 |
+
if ($customer->isConfirmationRequired())
|
298 |
+
{
|
299 |
+
$customer->sendNewAccountEmail('confirmation');
|
|
|
|
|
|
|
300 |
}
|
301 |
+
else
|
|
|
|
|
302 |
{
|
303 |
+
$customer->sendNewAccountEmail();
|
|
|
304 |
}
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* a flag to set that there will be redirect to third party after confirmation
|
309 |
+
* eg: paypal standard ipn
|
310 |
+
*/
|
311 |
+
$redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
|
312 |
+
if(!$redirectUrl)
|
313 |
+
{
|
314 |
+
$order->setEmailSent(true);
|
315 |
+
}
|
316 |
+
|
317 |
+
if(!$redirectUrl ||
|
318 |
+
$this->getQuote()->getPayment()->getMethodInstance()->getCode() != 'tpg')
|
319 |
+
{
|
320 |
+
$order->save();
|
321 |
+
}
|
322 |
+
|
323 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
|
324 |
+
|
325 |
|
326 |
+
/**
|
327 |
+
* need to have some logic to set order as new status to make sure order is not finished yet
|
328 |
+
* quote will be still active when we send the customer to paypal
|
329 |
+
*/
|
330 |
+
|
331 |
+
$orderId = $order->getIncrementId();
|
332 |
+
$this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
|
333 |
+
$this->getCheckout()->setLastOrderId($order->getId());
|
334 |
+
$this->getCheckout()->setLastRealOrderId($order->getIncrementId());
|
335 |
+
$this->getCheckout()->setRedirectUrl($redirectUrl);
|
336 |
+
|
337 |
+
/**
|
338 |
+
* we only want to send to customer about new order when there is no redirect to third party
|
339 |
+
*/
|
340 |
+
if(!$redirectUrl)
|
341 |
+
{
|
342 |
+
$order->sendNewOrderEmail();
|
343 |
+
}
|
344 |
+
|
345 |
+
if ($this->getQuote()->getCheckoutMethod(true) == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER &&
|
346 |
+
!Mage::getSingleton('customer/session')->isLoggedIn())
|
347 |
+
{
|
348 |
+
/**
|
349 |
+
* we need to save quote here to have it saved with Customer Id.
|
350 |
+
* so when loginById() executes checkout/session method loadCustomerQuote
|
351 |
+
* it would not create new quotes and merge it with old one.
|
352 |
+
*/
|
353 |
+
$this->getQuote()->save();
|
354 |
+
if ($customer->isConfirmationRequired())
|
355 |
{
|
356 |
+
Mage::getSingleton('checkout/session')->addSuccess(Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.',
|
357 |
+
Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())
|
358 |
+
));
|
359 |
}
|
360 |
+
else
|
361 |
+
{
|
362 |
+
Mage::getSingleton('customer/session')->loginById($customer->getId());
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
+
//Setting this one more time like control flag that we haves saved order
|
367 |
+
//Must be checkout on success page to show it or not.
|
368 |
+
$this->getCheckout()->setLastSuccessQuoteId($this->getQuote()->getId());
|
369 |
+
|
370 |
+
/*
|
371 |
+
* Fix for v1.4.1.0 and above - need to comment the below lines
|
372 |
+
*/
|
373 |
+
//$this->getQuote()->setIsActive(false);
|
374 |
+
//$this->getQuote()->save();
|
375 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
|
377 |
return $this;
|
378 |
}
|
386 |
*/
|
387 |
public function saveOrderAfter3dSecure($pares, $md)
|
388 |
{
|
389 |
+
$nVersion = $this->getVersion(Mage::getVersion());
|
390 |
+
|
391 |
+
if($nVersion >= 1410)
|
392 |
+
{
|
393 |
+
$_order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getTpgOrderId());
|
394 |
+
|
395 |
+
if(!$_order->getId())
|
396 |
+
{
|
397 |
+
Mage::throwException('Could not load order.');
|
398 |
+
}
|
399 |
+
|
400 |
+
Mage::getSingleton('checkout/session')->setThreedsecurerequired(true)
|
401 |
+
->setMd($md)
|
402 |
+
->setPares($pares);
|
403 |
+
|
404 |
+
$method = Mage::getSingleton('checkout/session')->getRedirectionmethod();
|
405 |
+
$_order->getPayment()->getMethodInstance()->{$method}($_order->getPayment(), $pares, $md);
|
406 |
+
|
407 |
+
if ($_order->getFailedThreed() !== true &&
|
408 |
+
$_order->getPayment()->getMethodInstance()->getCode() == 'tpg' &&
|
409 |
+
$_order->getStatus() != 'pending')
|
410 |
+
{
|
411 |
+
$order_status = Mage::getStoreConfig('payment/tpg/order_status', Mage::app()->getStore()->getId());
|
412 |
+
$_order->addStatusToHistory($order_status);
|
413 |
+
$_order->setStatus($order_status);
|
414 |
+
}
|
415 |
+
|
416 |
+
$_order->save();
|
|
|
|
|
|
|
|
|
|
|
417 |
|
418 |
+
Mage::getSingleton('checkout/session')->setThreedsecurerequired(null)
|
419 |
+
->setMd(null)
|
420 |
+
->setPareq(null)
|
421 |
+
->setAcsurl(null)
|
422 |
+
->setTpgOrderId(null);
|
423 |
+
}
|
424 |
+
else
|
425 |
+
{
|
426 |
+
$this->validateOrder();
|
427 |
+
$billing = $this->getQuote()->getBillingAddress();
|
428 |
+
if (!$this->getQuote()->isVirtual())
|
429 |
+
{
|
430 |
+
$shipping = $this->getQuote()->getShippingAddress();
|
431 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
|
433 |
+
switch ($this->getQuote()->getCheckoutMethod())
|
434 |
+
{
|
435 |
+
case 'guest':
|
436 |
+
$this->getQuote()->setCustomerEmail($billing->getEmail())
|
437 |
+
->setCustomerIsGuest(true)
|
438 |
+
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
439 |
+
break;
|
440 |
+
|
441 |
+
default:
|
442 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
443 |
+
|
444 |
+
if (!$billing->getCustomerId() ||
|
445 |
+
$billing->getSaveInAddressBook())
|
446 |
+
{
|
447 |
+
$customerBilling = $billing->exportCustomerAddress();
|
448 |
+
$customer->addAddress($customerBilling);
|
449 |
+
}
|
450 |
+
if (!$this->getQuote()->isVirtual() &&
|
451 |
+
((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) ||
|
452 |
+
(!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())))
|
453 |
+
{
|
454 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
455 |
+
$customer->addAddress($customerShipping);
|
456 |
+
}
|
457 |
+
$customer->setSavedFromQuote(true);
|
458 |
+
$customer->save();
|
459 |
+
|
460 |
+
$changed = false;
|
461 |
+
if (isset($customerBilling) &&
|
462 |
+
!$customer->getDefaultBilling())
|
463 |
+
{
|
464 |
+
$customer->setDefaultBilling($customerBilling->getId());
|
465 |
+
$changed = true;
|
466 |
+
}
|
467 |
+
if (!$this->getQuote()->isVirtual() &&
|
468 |
+
isset($customerBilling) &&
|
469 |
+
!$customer->getDefaultShipping() &&
|
470 |
+
$shipping->getSameAsBilling())
|
471 |
+
{
|
472 |
+
$customer->setDefaultShipping($customerBilling->getId());
|
473 |
+
$changed = true;
|
474 |
+
}
|
475 |
+
elseif (!$this->getQuote()->isVirtual() &&
|
476 |
+
isset($customerShipping) &&
|
477 |
+
!$customer->getDefaultShipping())
|
478 |
+
{
|
479 |
+
$customer->setDefaultShipping($customerShipping->getId());
|
480 |
+
$changed = true;
|
481 |
+
}
|
482 |
+
|
483 |
+
if ($changed)
|
484 |
+
{
|
485 |
+
$customer->save();
|
486 |
+
}
|
487 |
+
}
|
488 |
+
|
489 |
+
$this->getQuote()->reserveOrderId();
|
490 |
+
$convertQuote = Mage::getModel('sales/convert_quote');
|
491 |
+
// @var $convertQuote Mage_Sales_Model_Convert_Quote
|
492 |
+
if ($this->getQuote()->isVirtual())
|
493 |
+
{
|
494 |
+
$order = $convertQuote->addressToOrder($billing);
|
495 |
+
}
|
496 |
+
else
|
497 |
+
{
|
498 |
+
$order = $convertQuote->addressToOrder($shipping);
|
499 |
+
}
|
500 |
+
/* @var $order Mage_Sales_Model_Order */
|
501 |
+
$order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
|
502 |
+
|
503 |
+
if (!$this->getQuote()->isVirtual())
|
504 |
+
{
|
505 |
+
$order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
|
506 |
+
}
|
507 |
+
|
508 |
+
$order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
|
509 |
+
|
510 |
+
foreach ($this->getQuote()->getAllItems() as $item)
|
511 |
+
{
|
512 |
+
$order->addItem($convertQuote->itemToOrderItem($item));
|
513 |
+
}
|
514 |
+
|
515 |
+
/**
|
516 |
+
* We can use configuration data for declare new order status
|
517 |
+
*/
|
518 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
|
519 |
+
|
520 |
+
Mage::getSingleton('checkout/session')->setThreedsecurerequired(true)
|
521 |
+
->setMd($md)
|
522 |
+
->setPares($pares);
|
523 |
+
|
524 |
+
$order->place();
|
525 |
+
|
526 |
+
if ( $order->getPayment()->getMethodInstance()->getCode() == 'tpg' &&
|
527 |
+
$order->getStatus() != 'pending' )
|
528 |
+
{
|
529 |
+
$order_status = Mage::getStoreConfig('payment/tpg/order_status', Mage::app()->getStore()->getId());
|
530 |
+
|
531 |
+
$order->addStatusToHistory($order_status);
|
532 |
+
$order->setStatus($order_status);
|
533 |
+
}
|
534 |
+
|
535 |
+
$order->save();
|
536 |
+
|
537 |
+
|
538 |
+
|
539 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
|
540 |
+
|
541 |
+
|
542 |
+
$this->getQuote()->setIsActive(false);
|
543 |
+
$this->getQuote()->save();
|
544 |
+
|
545 |
+
$orderId = $order->getIncrementId();
|
546 |
+
$this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
|
547 |
+
$this->getCheckout()->setLastOrderId($order->getId());
|
548 |
+
$this->getCheckout()->setLastRealOrderId($order->getIncrementId());
|
549 |
+
// $this->getCheckout()->setRedirectUrl($redirectUrl);
|
550 |
+
|
551 |
+
/**
|
552 |
+
* we only want to send to customer about new order when there is no redirect to third party
|
553 |
+
*/
|
554 |
+
/*if(!$redirectUrl){
|
555 |
+
$order->sendNewOrderEmail();
|
556 |
+
}*/
|
557 |
+
|
558 |
+
if ($this->getQuote()->getCheckoutMethod() == 'register')
|
559 |
+
{
|
560 |
+
Mage::getSingleton('customer/session')->loginById($customer->getId());
|
561 |
+
}
|
562 |
+
}
|
563 |
return $this;
|
564 |
}
|
565 |
|
576 |
*/
|
577 |
public function saveOrderAfterRedirectedPaymentAction($boIsHostedPaymentAction, $szStatusCode, $szMessage, $szPreviousStatusCode, $szPreviousMessage, $szOrderID)
|
578 |
{
|
579 |
+
$nVersion = $this->getVersion(Mage::getVersion());
|
580 |
+
|
581 |
+
if($nVersion >= 1410)
|
582 |
+
{
|
583 |
+
$_order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getTpgOrderId());
|
584 |
+
|
585 |
+
if(!$_order->getId())
|
586 |
+
{
|
587 |
+
Mage::throwException('Could not load order.');
|
588 |
+
}
|
589 |
+
|
590 |
+
Mage::getSingleton('checkout/session')->setRedirectedpayment(true)
|
591 |
+
->setIshostedpayment($boIsHostedPaymentAction)
|
592 |
+
->setStatuscode($szStatusCode)
|
593 |
+
->setMessage($szMessage)
|
594 |
+
->setPreviousstatuscode($szPreviousStatusCode)
|
595 |
+
->setPreviousmessage($szPreviousMessage)
|
596 |
+
->setOrderid($szOrderID);
|
597 |
+
|
598 |
+
$method = Mage::getSingleton('checkout/session')->getRedirectionmethod();
|
599 |
+
$_order->getPayment()->getMethodInstance()->{$method}($_order->getPayment(), $boIsHostedPaymentAction, $szStatusCode, $szMessage, $szPreviousStatusCode, $szPreviousMessage, $szOrderID);
|
600 |
+
|
601 |
+
if ($_order->getFailedThreed() !== true &&
|
602 |
+
$_order->getPayment()->getMethodInstance()->getCode() == 'tpg' &&
|
603 |
+
$_order->getStatus() != 'pending')
|
604 |
+
{
|
605 |
+
$order_status = Mage::getStoreConfig('payment/tpg/order_status', Mage::app()->getStore()->getId());
|
606 |
+
$_order->addStatusToHistory($order_status);
|
607 |
+
$_order->setStatus($order_status);
|
608 |
+
}
|
|
|
|
|
|
|
|
|
609 |
|
610 |
+
$_order->save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
611 |
|
612 |
+
Mage::getSingleton('checkout/session')->setRedirectedpayment(null)
|
613 |
+
->setIshostedpayment(null)
|
614 |
+
->setStatuscode(null)
|
615 |
+
->setMessage(null)
|
616 |
+
->setPreviousstatuscode(null)
|
617 |
+
->setPreviousmessage(null)
|
618 |
+
->setOrderid(null)
|
619 |
+
->setTpgOrderId(null);
|
620 |
+
}
|
621 |
+
else
|
622 |
+
{
|
623 |
+
$this->validateOrder();
|
624 |
+
$billing = $this->getQuote()->getBillingAddress();
|
625 |
+
|
626 |
+
if (!$this->getQuote()->isVirtual())
|
627 |
+
{
|
628 |
+
$shipping = $this->getQuote()->getShippingAddress();
|
629 |
+
}
|
630 |
+
|
631 |
+
switch ($this->getQuote()->getCheckoutMethod())
|
632 |
+
{
|
633 |
+
case 'guest':
|
634 |
+
$this->getQuote()->setCustomerEmail($billing->getEmail())
|
635 |
+
->setCustomerIsGuest(true)
|
636 |
+
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
637 |
+
break;
|
638 |
+
|
639 |
+
default:
|
640 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
641 |
+
|
642 |
+
if (!$billing->getCustomerId() ||
|
643 |
+
$billing->getSaveInAddressBook())
|
644 |
+
{
|
645 |
+
$customerBilling = $billing->exportCustomerAddress();
|
646 |
+
$customer->addAddress($customerBilling);
|
647 |
+
}
|
648 |
+
if (!$this->getQuote()->isVirtual() &&
|
649 |
+
((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) ||
|
650 |
+
(!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())))
|
651 |
+
{
|
652 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
653 |
+
$customer->addAddress($customerShipping);
|
654 |
+
}
|
655 |
+
$customer->setSavedFromQuote(true);
|
656 |
+
$customer->save();
|
657 |
+
|
658 |
+
$changed = false;
|
659 |
+
if (isset($customerBilling) &&
|
660 |
+
!$customer->getDefaultBilling())
|
661 |
+
{
|
662 |
+
$customer->setDefaultBilling($customerBilling->getId());
|
663 |
+
$changed = true;
|
664 |
+
}
|
665 |
+
if (!$this->getQuote()->isVirtual() &&
|
666 |
+
isset($customerBilling) &&
|
667 |
+
!$customer->getDefaultShipping() &&
|
668 |
+
$shipping->getSameAsBilling())
|
669 |
+
{
|
670 |
+
$customer->setDefaultShipping($customerBilling->getId());
|
671 |
+
$changed = true;
|
672 |
+
}
|
673 |
+
elseif (!$this->getQuote()->isVirtual() &&
|
674 |
+
isset($customerShipping) &&
|
675 |
+
!$customer->getDefaultShipping())
|
676 |
+
{
|
677 |
+
$customer->setDefaultShipping($customerShipping->getId());
|
678 |
+
$changed = true;
|
679 |
+
}
|
680 |
+
|
681 |
+
if ($changed)
|
682 |
+
{
|
683 |
+
$customer->save();
|
684 |
+
}
|
685 |
+
}
|
686 |
+
|
687 |
+
$this->getQuote()->reserveOrderId();
|
688 |
+
$convertQuote = Mage::getModel('sales/convert_quote');
|
689 |
+
// @var $convertQuote Mage_Sales_Model_Convert_Quote
|
690 |
+
if ($this->getQuote()->isVirtual())
|
691 |
+
{
|
692 |
+
$order = $convertQuote->addressToOrder($billing);
|
693 |
+
}
|
694 |
+
else
|
695 |
+
{
|
696 |
+
$order = $convertQuote->addressToOrder($shipping);
|
697 |
+
}
|
698 |
+
/* @var $order Mage_Sales_Model_Order */
|
699 |
+
$order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
|
700 |
+
|
701 |
+
if (!$this->getQuote()->isVirtual())
|
702 |
+
{
|
703 |
+
$order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
|
704 |
+
}
|
705 |
+
|
706 |
+
$order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
|
707 |
+
|
708 |
+
foreach ($this->getQuote()->getAllItems() as $item)
|
709 |
+
{
|
710 |
+
$order->addItem($convertQuote->itemToOrderItem($item));
|
711 |
+
}
|
712 |
+
|
713 |
+
/**
|
714 |
+
* We can use configuration data for declare new order status
|
715 |
+
*/
|
716 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
|
717 |
+
|
718 |
+
Mage::getSingleton('checkout/session')->setRedirectedpayment(true)
|
719 |
+
->setIshostedpayment($boIsHostedPaymentAction)
|
720 |
+
->setStatuscode($szStatusCode)
|
721 |
+
->setMessage($szMessage)
|
722 |
+
->setPreviousstatuscode($szPreviousStatusCode)
|
723 |
+
->setPreviousmessage($szPreviousMessage)
|
724 |
+
->setOrderid($szOrderID);
|
725 |
+
|
726 |
+
$order->place();
|
727 |
+
|
728 |
+
if ( $order->getPayment()->getMethodInstance()->getCode() == 'tpg' &&
|
729 |
+
$order->getStatus() != 'pending' )
|
730 |
+
{
|
731 |
+
$order_status = Mage::getStoreConfig('payment/tpg/order_status', Mage::app()->getStore()->getId());
|
732 |
+
|
733 |
+
$order->addStatusToHistory($order_status);
|
734 |
+
$order->setStatus($order_status);
|
735 |
+
}
|
736 |
+
|
737 |
+
$order->save();
|
738 |
+
|
739 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
|
740 |
+
|
741 |
+
$this->getQuote()->setIsActive(false);
|
742 |
+
$this->getQuote()->save();
|
743 |
+
|
744 |
+
$orderId = $order->getIncrementId();
|
745 |
+
$this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
|
746 |
+
$this->getCheckout()->setLastOrderId($order->getId());
|
747 |
+
$this->getCheckout()->setLastRealOrderId($order->getIncrementId());
|
748 |
+
|
749 |
+
/**
|
750 |
+
* we only want to send to customer about new order when there is no redirect to third party
|
751 |
+
*/
|
752 |
+
/*if(!$redirectUrl){
|
753 |
+
$order->sendNewOrderEmail();
|
754 |
+
}*/
|
755 |
+
|
756 |
+
if ($this->getQuote()->getCheckoutMethod()=='register')
|
757 |
+
{
|
758 |
+
Mage::getSingleton('customer/session')->loginById($customer->getId());
|
759 |
+
}
|
760 |
+
}
|
761 |
|
762 |
return $this;
|
763 |
}
|
app/code/local/Iridiumcorp/Sales/Model/Order.php
CHANGED
@@ -5,8 +5,10 @@ class Iridiumcorp_Sales_Model_Order extends Mage_Sales_Model_Order
|
|
5 |
protected function _setState($state, $status = false, $comment = '', $isCustomerNotified = null, $shouldProtectState = false)
|
6 |
{
|
7 |
// attempt to set the specified state
|
8 |
-
if ($shouldProtectState)
|
9 |
-
|
|
|
|
|
10 |
Mage::throwException(Mage::helper('sales')->__('The Order State "%s" must not be set manually.', $state));
|
11 |
}
|
12 |
}
|
5 |
protected function _setState($state, $status = false, $comment = '', $isCustomerNotified = null, $shouldProtectState = false)
|
6 |
{
|
7 |
// attempt to set the specified state
|
8 |
+
if ($shouldProtectState)
|
9 |
+
{
|
10 |
+
if ($this->isStateProtected($state))
|
11 |
+
{
|
12 |
Mage::throwException(Mage::helper('sales')->__('The Order State "%s" must not be set manually.', $state));
|
13 |
}
|
14 |
}
|
app/code/local/Iridiumcorp/Sales/Model/Order/Payment.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Iridiumcorp_Sales_Model_Order_Payment extends Mage_Sales_Model_Order_Payment
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Authorize or authorize and capture payment on gateway, if applicable
|
7 |
+
* This method is supposed to be called only when order is placed
|
8 |
+
*
|
9 |
+
* @return Mage_Sales_Model_Order_Payment
|
10 |
+
*/
|
11 |
+
public function place()
|
12 |
+
{
|
13 |
+
Mage::dispatchEvent('sales_order_payment_place_start', array('payment' => $this));
|
14 |
+
$order = $this->getOrder();
|
15 |
+
|
16 |
+
$this->setAmountOrdered($order->getTotalDue());
|
17 |
+
$this->setBaseAmountOrdered($order->getBaseTotalDue());
|
18 |
+
$this->setShippingAmount($order->getShippingAmount());
|
19 |
+
$this->setBaseShippingAmount($order->getBaseShippingAmount());
|
20 |
+
|
21 |
+
$methodInstance = $this->getMethodInstance();
|
22 |
+
$methodInstance->setStore($order->getStoreId());
|
23 |
+
|
24 |
+
$orderState = Mage_Sales_Model_Order::STATE_NEW;
|
25 |
+
$orderStatus= false;
|
26 |
+
|
27 |
+
$stateObject = new Varien_Object();
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Do order payment validation on payment method level
|
31 |
+
*/
|
32 |
+
$methodInstance->validate();
|
33 |
+
$action = $methodInstance->getConfigPaymentAction();
|
34 |
+
if ($action) {
|
35 |
+
if ($methodInstance->isInitializeNeeded()) {
|
36 |
+
/**
|
37 |
+
* For method initialization we have to use original config value for payment action
|
38 |
+
*/
|
39 |
+
$methodInstance->initialize($methodInstance->getConfigData('payment_action'), $stateObject);
|
40 |
+
} else {
|
41 |
+
$orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
|
42 |
+
switch ($action) {
|
43 |
+
case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
|
44 |
+
$this->_authorize(true, $order->getBaseTotalDue()); // base amount will be set inside
|
45 |
+
$this->setAmountAuthorized($order->getTotalDue());
|
46 |
+
break;
|
47 |
+
case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
|
48 |
+
$this->setAmountAuthorized($order->getTotalDue());
|
49 |
+
$this->setBaseAmountAuthorized($order->getBaseTotalDue());
|
50 |
+
$this->capture(null);
|
51 |
+
break;
|
52 |
+
default:
|
53 |
+
break;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
$this->_createBillingAgreement();
|
59 |
+
|
60 |
+
$orderIsNotified = null;
|
61 |
+
if ($stateObject->getState() && $stateObject->getStatus())
|
62 |
+
{
|
63 |
+
$orderState = $stateObject->getState();
|
64 |
+
$orderStatus = $stateObject->getStatus();
|
65 |
+
$orderIsNotified = $stateObject->getIsNotified();
|
66 |
+
}
|
67 |
+
else if($order->getIsThreeDSecurePending())
|
68 |
+
{
|
69 |
+
$orderState = 'pending_payment';
|
70 |
+
$orderStatus = 'iridiumcorp_pending_threed_secure';
|
71 |
+
$orderIsNotified = false;
|
72 |
+
$order->setCustomerNote(Mage::helper('tpg')->__('Pending 3D Secure Authentication.'));
|
73 |
+
}
|
74 |
+
else if($order->getIsHostedPaymentPending())
|
75 |
+
{
|
76 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
|
77 |
+
$orderState = 'pending_payment';
|
78 |
+
$orderStatus = 'iridiumcorp_pending_hosted_payment';
|
79 |
+
$orderIsNotified = false;
|
80 |
+
$order->setCustomerNote(Mage::helper('tpg')->__('Pending Hosted Payment.'));
|
81 |
+
}
|
82 |
+
else
|
83 |
+
{
|
84 |
+
$orderStatus = $methodInstance->getConfigData('order_status');
|
85 |
+
if (!$orderStatus || $order->getIsVirtual())
|
86 |
+
{
|
87 |
+
$orderStatus = $order->getConfig()->getStateDefaultStatus($orderState);
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
$isCustomerNotified = (null !== $orderIsNotified) ? $orderIsNotified : $order->getCustomerNoteNotify();
|
92 |
+
$message = $order->getCustomerNote();
|
93 |
+
|
94 |
+
// add message if order was put into review during authorization or capture
|
95 |
+
if ($order->getState() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW)
|
96 |
+
{
|
97 |
+
if ($message)
|
98 |
+
{
|
99 |
+
$order->addStatusToHistory($order->getStatus(), $message, $isCustomerNotified);
|
100 |
+
}
|
101 |
+
}
|
102 |
+
// add message to history if order state already declared
|
103 |
+
elseif ($order->getState() && ($orderStatus !== $order->getStatus() || $message))
|
104 |
+
{
|
105 |
+
$order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
|
106 |
+
}
|
107 |
+
// set order state
|
108 |
+
elseif (($order->getState() != $orderState) || ($order->getStatus() != $orderStatus) || $message)
|
109 |
+
{
|
110 |
+
$order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
|
111 |
+
}
|
112 |
+
|
113 |
+
Mage::dispatchEvent('sales_order_payment_place_end', array('payment' => $this));
|
114 |
+
|
115 |
+
return $this;
|
116 |
+
}
|
117 |
+
}
|
app/code/local/Iridiumcorp/Sales/Model/Service/Quote.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Iridiumcorp_Sales_Model_Service_Quote extends Mage_Sales_Model_Service_Quote
|
4 |
+
{
|
5 |
+
public function submitOrder()
|
6 |
+
{
|
7 |
+
if ($this->_quote->getPayment()->getMethodInstance()->getCode() != 'tpg')
|
8 |
+
{
|
9 |
+
return parent::submitOrder();
|
10 |
+
}
|
11 |
+
|
12 |
+
$this->_deleteNominalItems();
|
13 |
+
$this->_validate();
|
14 |
+
$quote = $this->_quote;
|
15 |
+
$isVirtual = $quote->isVirtual();
|
16 |
+
|
17 |
+
$transaction = Mage::getModel('core/resource_transaction');
|
18 |
+
if ($quote->getCustomerId())
|
19 |
+
{
|
20 |
+
$transaction->addObject($quote->getCustomer());
|
21 |
+
}
|
22 |
+
$transaction->addObject($quote);
|
23 |
+
|
24 |
+
$quote->reserveOrderId();
|
25 |
+
if ($isVirtual)
|
26 |
+
{
|
27 |
+
$order = $this->_convertor->addressToOrder($quote->getBillingAddress());
|
28 |
+
}
|
29 |
+
else
|
30 |
+
{
|
31 |
+
$order = $this->_convertor->addressToOrder($quote->getShippingAddress());
|
32 |
+
}
|
33 |
+
$order->setBillingAddress($this->_convertor->addressToOrderAddress($quote->getBillingAddress()));
|
34 |
+
|
35 |
+
if (!$isVirtual)
|
36 |
+
{
|
37 |
+
$order->setShippingAddress($this->_convertor->addressToOrderAddress($quote->getShippingAddress()));
|
38 |
+
}
|
39 |
+
$order->setPayment($this->_convertor->paymentToOrderPayment($quote->getPayment()));
|
40 |
+
|
41 |
+
foreach ($this->_orderData as $key => $value)
|
42 |
+
{
|
43 |
+
$order->setData($key, $value);
|
44 |
+
}
|
45 |
+
|
46 |
+
foreach ($quote->getAllItems() as $item)
|
47 |
+
{
|
48 |
+
$orderItem = $this->_convertor->itemToOrderItem($item);
|
49 |
+
if ($item->getParentItem())
|
50 |
+
{
|
51 |
+
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
|
52 |
+
}
|
53 |
+
$order->addItem($orderItem);
|
54 |
+
}
|
55 |
+
$quote->setIsActive(false);
|
56 |
+
|
57 |
+
$transaction->addObject($order);
|
58 |
+
$transaction->addCommitCallback(array($order, 'place'));
|
59 |
+
$transaction->addCommitCallback(array($order, 'save'));
|
60 |
+
|
61 |
+
/**
|
62 |
+
* We can use configuration data for declare new order status
|
63 |
+
*/
|
64 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$quote));
|
65 |
+
Mage::dispatchEvent('sales_model_service_quote_submit_before', array('order'=>$order, 'quote'=>$quote));
|
66 |
+
try
|
67 |
+
{
|
68 |
+
$transaction->save();
|
69 |
+
Mage::dispatchEvent('sales_model_service_quote_submit_success', array('order'=>$order, 'quote'=>$quote));
|
70 |
+
|
71 |
+
// need to store the orderID in the session for the callback from an external page
|
72 |
+
Mage::getSingleton('checkout/session')->setTpgOrderId($order->getId());
|
73 |
+
|
74 |
+
}
|
75 |
+
catch (Exception $e)
|
76 |
+
{
|
77 |
+
Mage::logException($e);
|
78 |
+
Mage::dispatchEvent('sales_model_service_quote_submit_failure', array('order'=>$order, 'quote'=>$quote));
|
79 |
+
throw $e;
|
80 |
+
}
|
81 |
+
Mage::dispatchEvent('sales_model_service_quote_submit_after', array('order'=>$order, 'quote'=>$quote));
|
82 |
+
$this->_order = $order;
|
83 |
+
|
84 |
+
return $order;
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
app/code/local/Iridiumcorp/Sales/etc/config.xml
CHANGED
@@ -11,8 +11,31 @@
|
|
11 |
<rewrite>
|
12 |
<order>Iridiumcorp_Sales_Model_Order</order>
|
13 |
<order_invoice>Iridiumcorp_Sales_Model_Order_Invoice</order_invoice>
|
|
|
|
|
14 |
</rewrite>
|
15 |
</sales>
|
16 |
</models>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
</global>
|
18 |
</config>
|
11 |
<rewrite>
|
12 |
<order>Iridiumcorp_Sales_Model_Order</order>
|
13 |
<order_invoice>Iridiumcorp_Sales_Model_Order_Invoice</order_invoice>
|
14 |
+
<order_payment>Iridiumcorp_Sales_Model_Order_Payment</order_payment>
|
15 |
+
<service_quote>Iridiumcorp_Sales_Model_Service_Quote</service_quote>
|
16 |
</rewrite>
|
17 |
</sales>
|
18 |
</models>
|
19 |
+
<sales>
|
20 |
+
<order>
|
21 |
+
<statuses>
|
22 |
+
<iridiumcorp_pending_threed_secure translate="label">
|
23 |
+
<label>Iridiumcorp - Pending 3D Secure</label>
|
24 |
+
</iridiumcorp_pending_threed_secure>
|
25 |
+
<iridiumcorp_failed_threed_secure translate="label">
|
26 |
+
<label>Iridiumcorp - Failed 3D Secure</label>
|
27 |
+
</iridiumcorp_failed_threed_secure>
|
28 |
+
<iridiumcorp_pending translate="label">
|
29 |
+
<label>Iridiumcorp - Pending Hosted Payment</label>
|
30 |
+
</iridiumcorp_pending>
|
31 |
+
<iridiumcorp_pending_hosted_payment translate="label">
|
32 |
+
<label>Iridiumcorp - Pending Hosted Payment</label>
|
33 |
+
</iridiumcorp_pending_hosted_payment>
|
34 |
+
<iridiumcorp_failed_hosted_payment translate="label">
|
35 |
+
<label>Iridiumcorp - Failed Hosted Payment</label>
|
36 |
+
</iridiumcorp_failed_hosted_payment>
|
37 |
+
</statuses>
|
38 |
+
</order>
|
39 |
+
</sales>
|
40 |
</global>
|
41 |
</config>
|
app/code/local/Iridiumcorp/Tpg/Block/Threedsecure.php
CHANGED
@@ -8,7 +8,16 @@ class Iridiumcorp_Tpg_Block_Threedsecure extends Mage_Core_Block_Abstract
|
|
8 |
*/
|
9 |
protected function _toHtml()
|
10 |
{
|
11 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
$form = new Varien_Data_Form();
|
14 |
$form->setAction(Mage::getSingleton('checkout/session')->getAcsurl())
|
8 |
*/
|
9 |
protected function _toHtml()
|
10 |
{
|
11 |
+
$mode = Mage::getModel('tpg/direct')->getConfigData('mode');
|
12 |
+
|
13 |
+
if($mode == Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_TRANSPARENT_REDIRECT)
|
14 |
+
{
|
15 |
+
$szTermURL = 'tpg/payment/callbacktransparentredirect';
|
16 |
+
}
|
17 |
+
else
|
18 |
+
{
|
19 |
+
$szTermURL = 'tpg/payment/callback3d';
|
20 |
+
}
|
21 |
|
22 |
$form = new Varien_Data_Form();
|
23 |
$form->setAction(Mage::getSingleton('checkout/session')->getAcsurl())
|
app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/GlobalErrors.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class
|
4 |
{
|
5 |
/*
|
6 |
* failure - probably a wrong card details entered in
|
1 |
<?php
|
2 |
|
3 |
+
class Iridiumcorp_Tpg_Model_Common_GlobalErrors
|
4 |
{
|
5 |
/*
|
6 |
* failure - probably a wrong card details entered in
|
app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/ISOCountries.php
RENAMED
File without changes
|
app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/ISOCurrencies.php
RENAMED
File without changes
|
app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/PaymentFormHelper.php
RENAMED
@@ -506,5 +506,26 @@
|
|
506 |
|
507 |
return $boMatch;
|
508 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
509 |
}
|
510 |
?>
|
506 |
|
507 |
return $boMatch;
|
508 |
}
|
509 |
+
|
510 |
+
/**
|
511 |
+
* Transform the string Magento version number into an integer ready for comparison
|
512 |
+
*
|
513 |
+
* @param unknown_type $nVersion
|
514 |
+
* @return unknown
|
515 |
+
*/
|
516 |
+
public static function getVersion($magentoVersion)
|
517 |
+
{
|
518 |
+
//$nVersion = Mage::getVersion();
|
519 |
+
$pattern = '/[^\d]/';
|
520 |
+
$magentoVersion = preg_replace($pattern, '', $magentoVersion);
|
521 |
+
|
522 |
+
while(strlen($magentoVersion) < 4)
|
523 |
+
{
|
524 |
+
$magentoVersion .= '0';
|
525 |
+
}
|
526 |
+
$magentoVersion = (int)$magentoVersion;
|
527 |
+
|
528 |
+
return $magentoVersion;
|
529 |
+
}
|
530 |
}
|
531 |
?>
|
app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/ThePaymentGateway/PaymentSystem.php
RENAMED
File without changes
|
app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/ThePaymentGateway/SOAP.php
RENAMED
File without changes
|
app/code/local/Iridiumcorp/Tpg/Model/{Tpg → Common}/ThePaymentGateway/TPG_Common.php
RENAMED
File without changes
|
app/code/local/Iridiumcorp/Tpg/Model/Direct.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
include ("
|
4 |
-
include_once ("
|
5 |
-
include ("
|
6 |
-
include ("
|
7 |
|
8 |
class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
|
9 |
{
|
@@ -301,7 +301,7 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
|
|
301 |
if ($boTransactionProcessed == false)
|
302 |
{
|
303 |
// could not communicate with the payment gateway
|
304 |
-
$error =
|
305 |
|
306 |
$szLogMessage = "Couldn't complete transaction. Details: ".print_r($cdtrCardDetailsTransactionResult, 1)." ".print_r($todTransactionOutputData, 1); //"Couldn't communicate with payment gateway.";
|
307 |
Mage::log($szLogMessage);
|
@@ -329,7 +329,10 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
|
|
329 |
|
330 |
Mage::getSingleton('checkout/session')->setMd($szCrossReference)
|
331 |
->setAcsurl($szACSURL)
|
332 |
-
->setPareq($szPaReq)
|
|
|
|
|
|
|
333 |
break;
|
334 |
case 5:
|
335 |
// status code of 5 - means transaction declined
|
@@ -546,7 +549,10 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
|
|
546 |
->setPaymentformdisplaysresult($boPaymentFormDisplaysResult)
|
547 |
->setServerresulturlcookievariables($szServerResultURLCookieVariables)
|
548 |
->setServerresulturlformvariables($szServerResultURLFormVariables)
|
549 |
-
->setServerresulturlquerystringvariables($szServerResultURLQueryStringVariables)
|
|
|
|
|
|
|
550 |
}
|
551 |
|
552 |
/**
|
@@ -643,7 +649,10 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
|
|
643 |
->setStartdatemonth($szStartDateMonth)
|
644 |
->setStartdateyear($szStartDateYear)
|
645 |
->setIssuenumber($szIssueNumber)
|
646 |
-
->setCv2($szCV2)
|
|
|
|
|
|
|
647 |
}
|
648 |
|
649 |
/**
|
@@ -681,8 +690,8 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
|
|
681 |
if ($boTransactionProcessed == false)
|
682 |
{
|
683 |
// could not communicate with the payment gateway
|
684 |
-
$szLogMessage =
|
685 |
-
$message =
|
686 |
Mage::log($szLogMessage);
|
687 |
}
|
688 |
else
|
1 |
<?php
|
2 |
|
3 |
+
include ("Common/ThePaymentGateway/PaymentSystem.php");
|
4 |
+
include_once ("Common/PaymentFormHelper.php");
|
5 |
+
include ("Common/ISOCurrencies.php");
|
6 |
+
include ("Common/ISOCountries.php");
|
7 |
|
8 |
class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
|
9 |
{
|
301 |
if ($boTransactionProcessed == false)
|
302 |
{
|
303 |
// could not communicate with the payment gateway
|
304 |
+
$error = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_261;
|
305 |
|
306 |
$szLogMessage = "Couldn't complete transaction. Details: ".print_r($cdtrCardDetailsTransactionResult, 1)." ".print_r($todTransactionOutputData, 1); //"Couldn't communicate with payment gateway.";
|
307 |
Mage::log($szLogMessage);
|
329 |
|
330 |
Mage::getSingleton('checkout/session')->setMd($szCrossReference)
|
331 |
->setAcsurl($szACSURL)
|
332 |
+
->setPareq($szPaReq)
|
333 |
+
->setRedirectionmethod('_run3DSecureTransaction');
|
334 |
+
|
335 |
+
$order->setIsThreeDSecurePending(true);
|
336 |
break;
|
337 |
case 5:
|
338 |
// status code of 5 - means transaction declined
|
549 |
->setPaymentformdisplaysresult($boPaymentFormDisplaysResult)
|
550 |
->setServerresulturlcookievariables($szServerResultURLCookieVariables)
|
551 |
->setServerresulturlformvariables($szServerResultURLFormVariables)
|
552 |
+
->setServerresulturlquerystringvariables($szServerResultURLQueryStringVariables)
|
553 |
+
->setRedirectionmethod('_runRedirectedPaymentComplete');
|
554 |
+
|
555 |
+
$payment->getOrder()->setIsHostedPaymentPending(true);
|
556 |
}
|
557 |
|
558 |
/**
|
649 |
->setStartdatemonth($szStartDateMonth)
|
650 |
->setStartdateyear($szStartDateYear)
|
651 |
->setIssuenumber($szIssueNumber)
|
652 |
+
->setCv2($szCV2)
|
653 |
+
->setRedirectionmethod('_runRedirectedPaymentComplete');
|
654 |
+
|
655 |
+
$payment->getOrder()->setIsHostedPaymentPending(true);
|
656 |
}
|
657 |
|
658 |
/**
|
690 |
if ($boTransactionProcessed == false)
|
691 |
{
|
692 |
// could not communicate with the payment gateway
|
693 |
+
$szLogMessage = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_431;
|
694 |
+
$message = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_431;
|
695 |
Mage::log($szLogMessage);
|
696 |
}
|
697 |
else
|
app/code/local/Iridiumcorp/Tpg/Model/Source/ResultDeliveryMethod.php
CHANGED
@@ -15,10 +15,10 @@ class Iridiumcorp_Tpg_Model_Source_ResultDeliveryMethod
|
|
15 |
'value' => self::RESULT_DELIVERY_METHOD_POST,
|
16 |
'label' => Mage::helper('tpg')->__('Post')
|
17 |
),
|
18 |
-
array(
|
19 |
'value' => self::RESULT_DELIVERY_METHOD_SERVER,
|
20 |
'label' => Mage::helper('tpg')->__('Server')
|
21 |
-
)
|
22 |
array(
|
23 |
'value' => self::RESULT_DELIVERY_METHOD_SERVER_PULL,
|
24 |
'label' => Mage::helper('tpg')->__('Server Pull')
|
15 |
'value' => self::RESULT_DELIVERY_METHOD_POST,
|
16 |
'label' => Mage::helper('tpg')->__('Post')
|
17 |
),
|
18 |
+
/*array(
|
19 |
'value' => self::RESULT_DELIVERY_METHOD_SERVER,
|
20 |
'label' => Mage::helper('tpg')->__('Server')
|
21 |
+
),*/
|
22 |
array(
|
23 |
'value' => self::RESULT_DELIVERY_METHOD_SERVER_PULL,
|
24 |
'label' => Mage::helper('tpg')->__('Server Pull')
|
app/code/local/Iridiumcorp/Tpg/controllers/PaymentController.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
require_once "app/code/local/Iridiumcorp/Tpg/Model/
|
4 |
|
5 |
/**
|
6 |
* Standard Checkout Controller
|
@@ -42,6 +42,12 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
42 |
*/
|
43 |
public function redirectAction()
|
44 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
$this->getResponse()->setBody($this->getLayout()->createBlock('tpg/redirect')->toHtml());
|
46 |
}
|
47 |
|
@@ -51,6 +57,15 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
51 |
*/
|
52 |
public function threedsecureAction()
|
53 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
$this->getResponse()->setBody($this->getLayout()->createBlock('tpg/threedsecure')->toHtml());
|
55 |
}
|
56 |
|
@@ -78,7 +93,8 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
78 |
catch (Exception $exc)
|
79 |
{
|
80 |
$boError = true;
|
81 |
-
|
|
|
82 |
if( isset($_SESSION['tpg_message']) )
|
83 |
{
|
84 |
$szMessage = $_SESSION['tpg_message'];
|
@@ -86,12 +102,14 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
86 |
}
|
87 |
else
|
88 |
{
|
89 |
-
$szMessage =
|
90 |
}
|
91 |
}
|
92 |
|
93 |
$szPaymentProcessorResponse = $session->getPaymentprocessorresponse();
|
94 |
-
|
|
|
|
|
95 |
if ($boError)
|
96 |
{
|
97 |
if($szPaymentProcessorResponse != null &&
|
@@ -99,6 +117,17 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
99 |
{
|
100 |
$szMessage = $szMessage.'<br/>'.$szPaymentProcessorResponse;
|
101 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
// report out an fatal error
|
103 |
Mage::getSingleton('core/session')->addError($szMessage);
|
104 |
$this->_redirect('checkout/onepage/failure');
|
@@ -109,13 +138,13 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
109 |
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
110 |
|
111 |
// send confirmation email to customer
|
112 |
-
$order = Mage::getModel('sales/order');
|
113 |
-
|
114 |
-
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
115 |
if($order->getId())
|
116 |
{
|
117 |
$order->sendNewOrderEmail();
|
118 |
}
|
|
|
|
|
|
|
119 |
|
120 |
if($szPaymentProcessorResponse != '')
|
121 |
{
|
@@ -138,7 +167,9 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
138 |
$checkout = Mage::getSingleton('checkout/type_onepage');
|
139 |
$session = Mage::getSingleton('checkout/session');
|
140 |
$szPaymentProcessorResponse = '';
|
141 |
-
|
|
|
|
|
142 |
try
|
143 |
{
|
144 |
$hmHashMethod = $model->getConfigData('hashmethod');
|
@@ -176,7 +207,6 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
176 |
}
|
177 |
else
|
178 |
{
|
179 |
-
// need to finish off the transaction
|
180 |
$checkout->saveOrderAfterRedirectedPaymentAction(true,
|
181 |
$this->getRequest()->getPost('StatusCode'),
|
182 |
$this->getRequest()->getPost('Message'),
|
@@ -188,7 +218,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
188 |
catch (Exception $exc)
|
189 |
{
|
190 |
$boError = true;
|
191 |
-
$szNotificationMessage =
|
192 |
Mage::logException($exc);
|
193 |
}
|
194 |
|
@@ -200,25 +230,34 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
200 |
{
|
201 |
$szNotificationMessage = $szNotificationMessage.'<br/>'.$szPaymentProcessorResponse;
|
202 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
|
|
|
204 |
Mage::getSingleton('core/session')->addError($szNotificationMessage);
|
205 |
$this->_redirect('checkout/onepage/failure');
|
206 |
}
|
207 |
else
|
208 |
{
|
209 |
-
$order = Mage::getModel('sales/order');
|
210 |
-
|
211 |
// set the quote as inactive after back from paypal
|
212 |
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
213 |
|
214 |
// send confirmation email to customer
|
215 |
-
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
216 |
-
|
217 |
if($order->getId())
|
218 |
{
|
219 |
$order->sendNewOrderEmail();
|
220 |
}
|
221 |
|
|
|
|
|
|
|
222 |
if($szPaymentProcessorResponse != '')
|
223 |
{
|
224 |
Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
|
@@ -240,7 +279,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
240 |
|
241 |
try
|
242 |
{
|
243 |
-
//
|
244 |
$checkout->saveOrderAfterRedirectedPaymentAction(true,
|
245 |
$this->getRequest()->getPost('StatusCode'),
|
246 |
$this->getRequest()->getPost('Message'),
|
@@ -252,7 +291,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
252 |
{
|
253 |
$boError = true;
|
254 |
$szErrorMessage = $exc->getMessage();
|
255 |
-
$szNotificationMessage =
|
256 |
Mage::logException($exc);
|
257 |
}
|
258 |
|
@@ -263,13 +302,11 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
263 |
else
|
264 |
{
|
265 |
$order = Mage::getModel('sales/order');
|
266 |
-
|
267 |
// set the quote as inactive after back from paypal
|
268 |
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
269 |
|
270 |
// send confirmation email to customer
|
271 |
-
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
272 |
-
|
273 |
if($order->getId())
|
274 |
{
|
275 |
$order->sendNewOrderEmail();
|
@@ -280,6 +317,8 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
280 |
if($this->getRequest()->getPost('StatusCode') == '0')
|
281 |
{
|
282 |
Mage::getSingleton('checkout/session')->clear();
|
|
|
|
|
283 |
}
|
284 |
|
285 |
$this->getResponse()->setBody('StatusCode=0');
|
@@ -293,7 +332,6 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
293 |
{
|
294 |
$boError = false;
|
295 |
$nStartIndex = false;
|
296 |
-
//
|
297 |
$szHashDigest = false;
|
298 |
$szMerchantID = false;// password, presharedkey, hashmethod
|
299 |
$szCrossReference = false;
|
@@ -310,11 +348,13 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
310 |
$szPreSharedKey = $model->getConfigData('presharedkey');
|
311 |
$szURLVariableString = $this->getRequest()->getRequestUri();
|
312 |
$nStartIndex = strpos($szURLVariableString, "?");
|
313 |
-
|
|
|
|
|
314 |
if(!is_int($nStartIndex))
|
315 |
{
|
316 |
-
$szErrorMessage =
|
317 |
-
Mage::log(
|
318 |
}
|
319 |
else
|
320 |
{
|
@@ -324,7 +364,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
324 |
if(!IRC_PaymentFormHelper::compareServerHashDigest($arFormVariables, $szPassword, $hmHashMethod, $szPreSharedKey))
|
325 |
{
|
326 |
// report an error message
|
327 |
-
$szErrorMessage =
|
328 |
}
|
329 |
else
|
330 |
{
|
@@ -351,7 +391,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
351 |
{
|
352 |
Mage::log("Error happened while trying to retrieve the transaction result details for a SERVER_PULL method for CrossReference: ".$szCrossReference.". Error code: ".$nErrorNumber.", message: ".$szErrorMessage);
|
353 |
// suppress the message and use customer friendly instead
|
354 |
-
$szErrorMessage =
|
355 |
}
|
356 |
else
|
357 |
{
|
@@ -367,7 +407,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
367 |
|
368 |
if($szStatusCode !== '0')
|
369 |
{
|
370 |
-
$szErrorMessage =
|
371 |
$szErrorMessage .= " Message: ".$szMessage;
|
372 |
}
|
373 |
else
|
@@ -380,7 +420,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
380 |
$szMessage = isset($transactionResult["Message"]) ? $transactionResult["Message"] : false;
|
381 |
$szPreviousStatusCode = $szStatusCode;
|
382 |
$szPreviousMessage = $szMessage;
|
383 |
-
|
384 |
$checkout->saveOrderAfterRedirectedPaymentAction(true,
|
385 |
$szStatusCode,
|
386 |
$szMessage,
|
@@ -401,24 +441,32 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
401 |
|
402 |
if($szErrorMessage)
|
403 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
Mage::getSingleton('core/session')->addError($szErrorMessage);
|
405 |
$this->_redirect('checkout/onepage/failure');
|
406 |
}
|
407 |
else
|
408 |
{
|
409 |
-
$order = Mage::getModel('sales/order');
|
410 |
-
|
411 |
// set the quote as inactive after back from paypal
|
412 |
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
413 |
|
414 |
// send confirmation email to customer
|
415 |
-
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
416 |
-
|
417 |
if($order->getId())
|
418 |
{
|
419 |
$order->sendNewOrderEmail();
|
420 |
}
|
421 |
-
|
|
|
|
|
422 |
Mage::getSingleton('core/session')->addSuccess('Payment Processor Response: '.$szMessage);
|
423 |
$this->_redirect('checkout/onepage/success', array('_secure' => true));
|
424 |
}
|
@@ -431,7 +479,9 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
431 |
public function callbacktransparentredirectAction()
|
432 |
{
|
433 |
$model = Mage::getModel('tpg/direct');
|
434 |
-
|
|
|
|
|
435 |
try
|
436 |
{
|
437 |
$hmHashMethod = $model->getConfigData('hashmethod');
|
@@ -461,9 +511,19 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
461 |
}
|
462 |
catch (Exception $exc)
|
463 |
{
|
464 |
-
$error =
|
465 |
Mage::logException($exc);
|
466 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
467 |
Mage::getSingleton('core/session')->addError($error);
|
468 |
$this->_redirect('checkout/onepage/failure');
|
469 |
}
|
@@ -492,8 +552,10 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
492 |
|
493 |
if($error)
|
494 |
{
|
495 |
-
|
496 |
-
|
|
|
|
|
497 |
}
|
498 |
else
|
499 |
{
|
@@ -521,7 +583,6 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
521 |
$szCallbackURL = Mage::getUrl('tpg/payment/callbacktransparentredirect');
|
522 |
$szHashDigest = IRC_PaymentFormHelper::calculatePostThreeDSecureAuthenticationHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $szPaRES, $szCrossReference, $szTransactionDateTime, $szCallbackURL);
|
523 |
|
524 |
-
|
525 |
Mage::getSingleton('checkout/session')->setHashdigest($szHashDigest)
|
526 |
->setMerchantid($szMerchantID)
|
527 |
->setCrossreference($szCrossReference)
|
@@ -542,7 +603,9 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
542 |
$checkout = Mage::getSingleton('checkout/type_onepage');
|
543 |
$session = Mage::getSingleton('checkout/session');
|
544 |
$szPaymentProcessorResponse = '';
|
545 |
-
|
|
|
|
|
546 |
try
|
547 |
{
|
548 |
$formVariables['HashDigest'] = $this->getRequest()->getPost('HashDigest');
|
@@ -575,7 +638,6 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
575 |
}
|
576 |
else
|
577 |
{
|
578 |
-
// need to finish off the transaction
|
579 |
$checkout->saveOrderAfterRedirectedPaymentAction(false,
|
580 |
$this->getRequest()->getPost('StatusCode'),
|
581 |
$this->getRequest()->getPost('Message'),
|
@@ -587,7 +649,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
587 |
catch(Exception $exc)
|
588 |
{
|
589 |
$boError = true;
|
590 |
-
$szNotificationMessage =
|
591 |
Mage::logException($exc);
|
592 |
}
|
593 |
|
@@ -599,23 +661,32 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
599 |
{
|
600 |
$szNotificationMessage = $szNotificationMessage.'<br/>'.$szPaymentProcessorResponse;
|
601 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
602 |
Mage::getSingleton('core/session')->addError($szNotificationMessage);
|
603 |
$this->_redirect('checkout/onepage/failure');
|
604 |
}
|
605 |
else
|
606 |
{
|
607 |
-
$order = Mage::getModel('sales/order');
|
608 |
-
|
609 |
// set the quote as inactive after back from paypal
|
610 |
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
611 |
-
|
612 |
// send confirmation email to customer
|
613 |
-
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
614 |
-
|
615 |
if($order->getId())
|
616 |
{
|
617 |
$order->sendNewOrderEmail();
|
618 |
}
|
|
|
|
|
|
|
619 |
|
620 |
if($szPaymentProcessorResponse != '')
|
621 |
{
|
@@ -624,4 +695,100 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
|
|
624 |
$this->_redirect('checkout/onepage/success', array('_secure' => true));
|
625 |
}
|
626 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
627 |
}
|
1 |
<?php
|
2 |
|
3 |
+
require_once "app/code/local/Iridiumcorp/Tpg/Model/Common/PaymentFormHelper.php";
|
4 |
|
5 |
/**
|
6 |
* Standard Checkout Controller
|
42 |
*/
|
43 |
public function redirectAction()
|
44 |
{
|
45 |
+
// need to re-add the ordered item quantity to stock as per not completed 3DS transaction
|
46 |
+
if(!Mage::getSingleton('checkout/session')->getPares())
|
47 |
+
{
|
48 |
+
$order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
49 |
+
$this->_addOrderedItemsToStock($order);
|
50 |
+
}
|
51 |
$this->getResponse()->setBody($this->getLayout()->createBlock('tpg/redirect')->toHtml());
|
52 |
}
|
53 |
|
57 |
*/
|
58 |
public function threedsecureAction()
|
59 |
{
|
60 |
+
$mode = Mage::getModel('tpg/direct')->getConfigData('mode');
|
61 |
+
|
62 |
+
// need to re-add the ordered item quantity to stock as per not completed 3DS transaction
|
63 |
+
if($mode != Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_TRANSPARENT_REDIRECT)
|
64 |
+
{
|
65 |
+
$order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
66 |
+
$this->_addOrderedItemsToStock($order);
|
67 |
+
}
|
68 |
+
|
69 |
$this->getResponse()->setBody($this->getLayout()->createBlock('tpg/threedsecure')->toHtml());
|
70 |
}
|
71 |
|
93 |
catch (Exception $exc)
|
94 |
{
|
95 |
$boError = true;
|
96 |
+
Mage::logException($exc);
|
97 |
+
|
98 |
if( isset($_SESSION['tpg_message']) )
|
99 |
{
|
100 |
$szMessage = $_SESSION['tpg_message'];
|
102 |
}
|
103 |
else
|
104 |
{
|
105 |
+
$szMessage = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_7655;
|
106 |
}
|
107 |
}
|
108 |
|
109 |
$szPaymentProcessorResponse = $session->getPaymentprocessorresponse();
|
110 |
+
$order = Mage::getModel('sales/order');
|
111 |
+
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
112 |
+
|
113 |
if ($boError)
|
114 |
{
|
115 |
if($szPaymentProcessorResponse != null &&
|
117 |
{
|
118 |
$szMessage = $szMessage.'<br/>'.$szPaymentProcessorResponse;
|
119 |
}
|
120 |
+
|
121 |
+
if($order)
|
122 |
+
{
|
123 |
+
$orderState = 'pending_payment';
|
124 |
+
$orderStatus = 'iridiumcorp_failed_threed_secure';
|
125 |
+
$order->setCustomerNote(Mage::helper('tpg')->__('3D Secure Authentication Failed'));
|
126 |
+
$order->setState($orderState, $orderStatus, $szPaymentProcessorResponse, false);
|
127 |
+
$order->save();
|
128 |
+
}
|
129 |
+
$this->_clearSessionVariables();
|
130 |
+
|
131 |
// report out an fatal error
|
132 |
Mage::getSingleton('core/session')->addError($szMessage);
|
133 |
$this->_redirect('checkout/onepage/failure');
|
138 |
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
139 |
|
140 |
// send confirmation email to customer
|
|
|
|
|
|
|
141 |
if($order->getId())
|
142 |
{
|
143 |
$order->sendNewOrderEmail();
|
144 |
}
|
145 |
+
|
146 |
+
// need to decrease the stock only after a succecssful payment
|
147 |
+
$this->_subtractOrderedItemsFromStock($order);
|
148 |
|
149 |
if($szPaymentProcessorResponse != '')
|
150 |
{
|
167 |
$checkout = Mage::getSingleton('checkout/type_onepage');
|
168 |
$session = Mage::getSingleton('checkout/session');
|
169 |
$szPaymentProcessorResponse = '';
|
170 |
+
$order = Mage::getModel('sales/order');
|
171 |
+
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
172 |
+
|
173 |
try
|
174 |
{
|
175 |
$hmHashMethod = $model->getConfigData('hashmethod');
|
207 |
}
|
208 |
else
|
209 |
{
|
|
|
210 |
$checkout->saveOrderAfterRedirectedPaymentAction(true,
|
211 |
$this->getRequest()->getPost('StatusCode'),
|
212 |
$this->getRequest()->getPost('Message'),
|
218 |
catch (Exception $exc)
|
219 |
{
|
220 |
$boError = true;
|
221 |
+
$szNotificationMessage = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_183;
|
222 |
Mage::logException($exc);
|
223 |
}
|
224 |
|
230 |
{
|
231 |
$szNotificationMessage = $szNotificationMessage.'<br/>'.$szPaymentProcessorResponse;
|
232 |
}
|
233 |
+
|
234 |
+
if($order)
|
235 |
+
{
|
236 |
+
$orderState = 'pending_payment';
|
237 |
+
$orderStatus = 'iridiumcorp_failed_hosted_payment';
|
238 |
+
$order->setCustomerNote(Mage::helper('tpg')->__('Hosted Payment Failed'));
|
239 |
+
$order->setState($orderState, $orderStatus, $szPaymentProcessorResponse, false);
|
240 |
+
$order->save();
|
241 |
+
}
|
242 |
|
243 |
+
$this->_clearSessionVariables();
|
244 |
Mage::getSingleton('core/session')->addError($szNotificationMessage);
|
245 |
$this->_redirect('checkout/onepage/failure');
|
246 |
}
|
247 |
else
|
248 |
{
|
|
|
|
|
249 |
// set the quote as inactive after back from paypal
|
250 |
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
251 |
|
252 |
// send confirmation email to customer
|
|
|
|
|
253 |
if($order->getId())
|
254 |
{
|
255 |
$order->sendNewOrderEmail();
|
256 |
}
|
257 |
|
258 |
+
// need to decrease the stock only after a succecssful payment
|
259 |
+
$this->_subtractOrderedItemsFromStock($order);
|
260 |
+
|
261 |
if($szPaymentProcessorResponse != '')
|
262 |
{
|
263 |
Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
|
279 |
|
280 |
try
|
281 |
{
|
282 |
+
// finish off the transaction: if StatusCode = 0 create an order otherwise do nothing
|
283 |
$checkout->saveOrderAfterRedirectedPaymentAction(true,
|
284 |
$this->getRequest()->getPost('StatusCode'),
|
285 |
$this->getRequest()->getPost('Message'),
|
291 |
{
|
292 |
$boError = true;
|
293 |
$szErrorMessage = $exc->getMessage();
|
294 |
+
$szNotificationMessage = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_183;
|
295 |
Mage::logException($exc);
|
296 |
}
|
297 |
|
302 |
else
|
303 |
{
|
304 |
$order = Mage::getModel('sales/order');
|
305 |
+
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
306 |
// set the quote as inactive after back from paypal
|
307 |
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
308 |
|
309 |
// send confirmation email to customer
|
|
|
|
|
310 |
if($order->getId())
|
311 |
{
|
312 |
$order->sendNewOrderEmail();
|
317 |
if($this->getRequest()->getPost('StatusCode') == '0')
|
318 |
{
|
319 |
Mage::getSingleton('checkout/session')->clear();
|
320 |
+
// need to decrease the stock only after a succecssful payment
|
321 |
+
$this->_subtractOrderedItemsFromStock($order);
|
322 |
}
|
323 |
|
324 |
$this->getResponse()->setBody('StatusCode=0');
|
332 |
{
|
333 |
$boError = false;
|
334 |
$nStartIndex = false;
|
|
|
335 |
$szHashDigest = false;
|
336 |
$szMerchantID = false;// password, presharedkey, hashmethod
|
337 |
$szCrossReference = false;
|
348 |
$szPreSharedKey = $model->getConfigData('presharedkey');
|
349 |
$szURLVariableString = $this->getRequest()->getRequestUri();
|
350 |
$nStartIndex = strpos($szURLVariableString, "?");
|
351 |
+
$order = Mage::getModel('sales/order');
|
352 |
+
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
353 |
+
|
354 |
if(!is_int($nStartIndex))
|
355 |
{
|
356 |
+
$szErrorMessage = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_309;
|
357 |
+
Mage::log(Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_309." Request URI: ".$szURLVariableString);
|
358 |
}
|
359 |
else
|
360 |
{
|
364 |
if(!IRC_PaymentFormHelper::compareServerHashDigest($arFormVariables, $szPassword, $hmHashMethod, $szPreSharedKey))
|
365 |
{
|
366 |
// report an error message
|
367 |
+
$szErrorMessage = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_304;
|
368 |
}
|
369 |
else
|
370 |
{
|
391 |
{
|
392 |
Mage::log("Error happened while trying to retrieve the transaction result details for a SERVER_PULL method for CrossReference: ".$szCrossReference.". Error code: ".$nErrorNumber.", message: ".$szErrorMessage);
|
393 |
// suppress the message and use customer friendly instead
|
394 |
+
$szErrorMessage = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_329." Message: ".$szErrorMessage;
|
395 |
}
|
396 |
else
|
397 |
{
|
407 |
|
408 |
if($szStatusCode !== '0')
|
409 |
{
|
410 |
+
$szErrorMessage = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_381;
|
411 |
$szErrorMessage .= " Message: ".$szMessage;
|
412 |
}
|
413 |
else
|
420 |
$szMessage = isset($transactionResult["Message"]) ? $transactionResult["Message"] : false;
|
421 |
$szPreviousStatusCode = $szStatusCode;
|
422 |
$szPreviousMessage = $szMessage;
|
423 |
+
|
424 |
$checkout->saveOrderAfterRedirectedPaymentAction(true,
|
425 |
$szStatusCode,
|
426 |
$szMessage,
|
441 |
|
442 |
if($szErrorMessage)
|
443 |
{
|
444 |
+
if($order)
|
445 |
+
{
|
446 |
+
$orderState = 'pending_payment';
|
447 |
+
$orderStatus = 'cardsave_failed_hosted_payment';
|
448 |
+
$order->setCustomerNote(Mage::helper('cardsaveonlinepayments')->__('Hosted Payment Failed'));
|
449 |
+
$order->setState($orderState, $orderStatus, $szErrorMessage, false);
|
450 |
+
$order->save();
|
451 |
+
}
|
452 |
+
|
453 |
+
$this->_clearSessionVariables();
|
454 |
Mage::getSingleton('core/session')->addError($szErrorMessage);
|
455 |
$this->_redirect('checkout/onepage/failure');
|
456 |
}
|
457 |
else
|
458 |
{
|
|
|
|
|
459 |
// set the quote as inactive after back from paypal
|
460 |
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
461 |
|
462 |
// send confirmation email to customer
|
|
|
|
|
463 |
if($order->getId())
|
464 |
{
|
465 |
$order->sendNewOrderEmail();
|
466 |
}
|
467 |
+
|
468 |
+
// need to decrease the stock only after a succecssful payment
|
469 |
+
$this->_subtractOrderedItemsFromStock($order);
|
470 |
Mage::getSingleton('core/session')->addSuccess('Payment Processor Response: '.$szMessage);
|
471 |
$this->_redirect('checkout/onepage/success', array('_secure' => true));
|
472 |
}
|
479 |
public function callbacktransparentredirectAction()
|
480 |
{
|
481 |
$model = Mage::getModel('tpg/direct');
|
482 |
+
$order = Mage::getModel('sales/order');
|
483 |
+
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
484 |
+
|
485 |
try
|
486 |
{
|
487 |
$hmHashMethod = $model->getConfigData('hashmethod');
|
511 |
}
|
512 |
catch (Exception $exc)
|
513 |
{
|
514 |
+
$error = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_260;
|
515 |
Mage::logException($exc);
|
516 |
|
517 |
+
if($order)
|
518 |
+
{
|
519 |
+
$orderState = 'pending_payment';
|
520 |
+
$orderStatus = 'iridiumcorp_failed_hosted_payment';
|
521 |
+
$order->setCustomerNote(Mage::helper('tpg')->__('Transparent Redirect Payment Failed'));
|
522 |
+
$order->setState($orderState, $orderStatus, $exc->getMessage(), false);
|
523 |
+
$order->save();
|
524 |
+
}
|
525 |
+
|
526 |
+
$this->_clearSessionVariables();
|
527 |
Mage::getSingleton('core/session')->addError($error);
|
528 |
$this->_redirect('checkout/onepage/failure');
|
529 |
}
|
552 |
|
553 |
if($error)
|
554 |
{
|
555 |
+
$this->_clearSessionVariables();
|
556 |
+
//Mage::getSingleton('core/session')->addError($error);
|
557 |
+
//$this->_redirect('checkout/onepage/failure');
|
558 |
+
Mage::throwException($error);
|
559 |
}
|
560 |
else
|
561 |
{
|
583 |
$szCallbackURL = Mage::getUrl('tpg/payment/callbacktransparentredirect');
|
584 |
$szHashDigest = IRC_PaymentFormHelper::calculatePostThreeDSecureAuthenticationHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $szPaRES, $szCrossReference, $szTransactionDateTime, $szCallbackURL);
|
585 |
|
|
|
586 |
Mage::getSingleton('checkout/session')->setHashdigest($szHashDigest)
|
587 |
->setMerchantid($szMerchantID)
|
588 |
->setCrossreference($szCrossReference)
|
603 |
$checkout = Mage::getSingleton('checkout/type_onepage');
|
604 |
$session = Mage::getSingleton('checkout/session');
|
605 |
$szPaymentProcessorResponse = '';
|
606 |
+
$order = Mage::getModel('sales/order');
|
607 |
+
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
|
608 |
+
|
609 |
try
|
610 |
{
|
611 |
$formVariables['HashDigest'] = $this->getRequest()->getPost('HashDigest');
|
638 |
}
|
639 |
else
|
640 |
{
|
|
|
641 |
$checkout->saveOrderAfterRedirectedPaymentAction(false,
|
642 |
$this->getRequest()->getPost('StatusCode'),
|
643 |
$this->getRequest()->getPost('Message'),
|
649 |
catch(Exception $exc)
|
650 |
{
|
651 |
$boError = true;
|
652 |
+
$szNotificationMessage = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_183;
|
653 |
Mage::logException($exc);
|
654 |
}
|
655 |
|
661 |
{
|
662 |
$szNotificationMessage = $szNotificationMessage.'<br/>'.$szPaymentProcessorResponse;
|
663 |
}
|
664 |
+
|
665 |
+
if($order)
|
666 |
+
{
|
667 |
+
$orderState = 'pending_payment';
|
668 |
+
$orderStatus = 'iridiumcorp_failed_hosted_payment';
|
669 |
+
$order->setCustomerNote(Mage::helper('tpg')->__('Transparent Redirect Payment Failed'));
|
670 |
+
$order->setState($orderState, $orderStatus, $szPaymentProcessorResponse, false);
|
671 |
+
$order->save();
|
672 |
+
}
|
673 |
+
|
674 |
+
$this->_clearSessionVariables();
|
675 |
Mage::getSingleton('core/session')->addError($szNotificationMessage);
|
676 |
$this->_redirect('checkout/onepage/failure');
|
677 |
}
|
678 |
else
|
679 |
{
|
|
|
|
|
680 |
// set the quote as inactive after back from paypal
|
681 |
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
|
|
682 |
// send confirmation email to customer
|
|
|
|
|
683 |
if($order->getId())
|
684 |
{
|
685 |
$order->sendNewOrderEmail();
|
686 |
}
|
687 |
+
|
688 |
+
// need to decrease the stock only after a succecssful payment
|
689 |
+
$this->_subtractOrderedItemsFromStock($order);
|
690 |
|
691 |
if($szPaymentProcessorResponse != '')
|
692 |
{
|
695 |
$this->_redirect('checkout/onepage/success', array('_secure' => true));
|
696 |
}
|
697 |
}
|
698 |
+
|
699 |
+
/**
|
700 |
+
* Deduct the order items from the stock
|
701 |
+
*
|
702 |
+
* @param unknown_type $order
|
703 |
+
*/
|
704 |
+
private function _subtractOrderedItemsFromStock($order)
|
705 |
+
{
|
706 |
+
/*$items = $order->getAllItems();
|
707 |
+
foreach ($items as $itemId => $item)
|
708 |
+
{
|
709 |
+
Mage::log('paymentcontroller.php - _subtractOrderedItemsFromStock called');
|
710 |
+
// subtract ordered quantity of the item from stock
|
711 |
+
Mage::getSingleton('cataloginventory/stock')->registerItemSale($item);
|
712 |
+
}*/
|
713 |
+
$nVersion = IRC_PaymentFormHelper::getVersion(Mage::getVersion());
|
714 |
+
$isCustomStockManagementEnabled = Mage::getModel('tpg/direct')->getConfigData('customstockmanagementenabled');
|
715 |
+
|
716 |
+
if($nVersion >= 1410 &&
|
717 |
+
$isCustomStockManagementEnabled)
|
718 |
+
{
|
719 |
+
$items = $order->getAllItems();
|
720 |
+
foreach ($items as $itemId => $item)
|
721 |
+
{
|
722 |
+
// ordered quantity of the item from stock
|
723 |
+
$quantity = $item->getQtyOrdered();
|
724 |
+
$productId = $item->getProductId();
|
725 |
+
|
726 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
|
727 |
+
$stockManagement = $stock->getManageStock();
|
728 |
+
|
729 |
+
if($stockManagement)
|
730 |
+
{
|
731 |
+
$stock->setQty($stock->getQty() - $quantity);
|
732 |
+
$stock->save();
|
733 |
+
}
|
734 |
+
}
|
735 |
+
}
|
736 |
+
}
|
737 |
+
|
738 |
+
/**
|
739 |
+
* Re-add the order items to the stock to balance the incorrect stock management before a payment is completed
|
740 |
+
*
|
741 |
+
* @param unknown_type $order
|
742 |
+
*/
|
743 |
+
private function _addOrderedItemsToStock($order)
|
744 |
+
{
|
745 |
+
$nVersion = IRC_PaymentFormHelper::getVersion(Mage::getVersion());
|
746 |
+
$isCustomStockManagementEnabled = Mage::getModel('tpg/direct')->getConfigData('customstockmanagementenabled');
|
747 |
+
|
748 |
+
if($nVersion >= 1410 &&
|
749 |
+
$isCustomStockManagementEnabled)
|
750 |
+
{
|
751 |
+
$items = $order->getAllItems();
|
752 |
+
foreach ($items as $itemId => $item)
|
753 |
+
{
|
754 |
+
// ordered quantity of the item from stock
|
755 |
+
$quantity = $item->getQtyOrdered();
|
756 |
+
$productId = $item->getProductId();
|
757 |
+
|
758 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
|
759 |
+
$stockManagement = $stock->getManageStock();
|
760 |
+
|
761 |
+
if($stockManagement)
|
762 |
+
{
|
763 |
+
$stock->setQty($stock->getQty() + $quantity);
|
764 |
+
$stock->save();
|
765 |
+
}
|
766 |
+
}
|
767 |
+
}
|
768 |
+
}
|
769 |
+
|
770 |
+
|
771 |
+
private function _clearSessionVariables()
|
772 |
+
{
|
773 |
+
// clear all the custom session variables used in the payment module in case of a failed payment
|
774 |
+
Mage::getSingleton('checkout/session')->setHashdigest(null)
|
775 |
+
->setMerchantid(null)
|
776 |
+
->setCrossreference(null)
|
777 |
+
->setTransactiondatetime(null)
|
778 |
+
->setCallbackurl(null)
|
779 |
+
->setPareq(null)
|
780 |
+
->setPares(null)
|
781 |
+
->setMd(null)
|
782 |
+
->setAcsurl(null)
|
783 |
+
->setTermurl(null)
|
784 |
+
->setThreedsecurerequired(null)
|
785 |
+
->setIshostedpayment(null)
|
786 |
+
->setStatuscode(null)
|
787 |
+
->setMessage(null)
|
788 |
+
->setPreviousstatuscode(null)
|
789 |
+
->setPreviousmessage(null)
|
790 |
+
->setOrderid(null)
|
791 |
+
->setRedirectedpayment(null)
|
792 |
+
->setTpgOrderId(null);
|
793 |
+
}
|
794 |
}
|
app/code/local/Iridiumcorp/Tpg/etc/config.xml
CHANGED
@@ -97,6 +97,7 @@
|
|
97 |
<countrymandatory>1</countrymandatory>
|
98 |
<resultdeliverymethod>POST</resultdeliverymethod>
|
99 |
<allowspecific>0</allowspecific>
|
|
|
100 |
</tpg>
|
101 |
</payment>
|
102 |
</default>
|
97 |
<countrymandatory>1</countrymandatory>
|
98 |
<resultdeliverymethod>POST</resultdeliverymethod>
|
99 |
<allowspecific>0</allowspecific>
|
100 |
+
<customstockmanagementenabled>1</customstockmanagementenabled>
|
101 |
</tpg>
|
102 |
</payment>
|
103 |
</default>
|
app/code/local/Iridiumcorp/Tpg/etc/system.xml
CHANGED
@@ -226,9 +226,21 @@
|
|
226 |
<![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
|
227 |
</comment>
|
228 |
</resultdeliverymethod>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
</fields>
|
230 |
</tpg>
|
231 |
</groups>
|
232 |
</payment>
|
233 |
</sections>
|
234 |
-
</config>
|
226 |
<![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
|
227 |
</comment>
|
228 |
</resultdeliverymethod>
|
229 |
+
<customstockmanagementenabled>
|
230 |
+
<label>Custom Stock Management Enabled</label>
|
231 |
+
<sort_order>210</sort_order>
|
232 |
+
<frontend_type>select</frontend_type>
|
233 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
234 |
+
<show_in_default>1</show_in_default>
|
235 |
+
<show_in_website>1</show_in_website>
|
236 |
+
<show_in_store>0</show_in_store>
|
237 |
+
<comment>
|
238 |
+
<![CDATA[<strong>Please note</strong>: The above setting is only applicable to Magento version 1.4.1.0 and above]]>
|
239 |
+
</comment>
|
240 |
+
</customstockmanagementenabled>
|
241 |
</fields>
|
242 |
</tpg>
|
243 |
</groups>
|
244 |
</payment>
|
245 |
</sections>
|
246 |
+
</config>
|
app/design/adminhtml/default/default/template/Tpg/info.phtml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php $direct = Mage::getModel('tpg/direct'); ?>
|
2 |
<?php if ($direct->getConfigData('mode') != Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API) {?>
|
3 |
<?php if ($direct->getConfigData('mode') == Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
|
4 |
-
<?php echo $this->__('
|
5 |
<?php } else {?>
|
6 |
<?php echo $this->__('No card information is available'); ?>
|
7 |
<?php }?>
|
1 |
<?php $direct = Mage::getModel('tpg/direct'); ?>
|
2 |
<?php if ($direct->getConfigData('mode') != Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API) {?>
|
3 |
<?php if ($direct->getConfigData('mode') == Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
|
4 |
+
<?php echo $this->__('You will be redirected to a secure payment page'); ?>
|
5 |
<?php } else {?>
|
6 |
<?php echo $this->__('No card information is available'); ?>
|
7 |
<?php }?>
|
app/design/frontend/default/default/template/Tpg/info.phtml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php $direct = Mage::getModel('tpg/direct'); ?>
|
2 |
<?php if ($direct->getConfigData('mode') != Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API) {?>
|
3 |
<?php if ($direct->getConfigData('mode') == Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
|
4 |
-
<?php echo $this->__('
|
5 |
<?php } else {?>
|
6 |
<?php echo $this->__('No card information is available'); ?>
|
7 |
<?php }?>
|
1 |
<?php $direct = Mage::getModel('tpg/direct'); ?>
|
2 |
<?php if ($direct->getConfigData('mode') != Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API) {?>
|
3 |
<?php if ($direct->getConfigData('mode') == Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
|
4 |
+
<?php echo $this->__('You will be redirected to a secure payment page'); ?>
|
5 |
<?php } else {?>
|
6 |
<?php echo $this->__('No card information is available'); ?>
|
7 |
<?php }?>
|
package.xml
CHANGED
@@ -1,18 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Iridiumcorp_Tpg</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
<description>Fully supports 3D secure transactions. Also supports all of the integration methods provided by Iridium.</description>
|
11 |
-
<notes>Fix
|
12 |
-
|
13 |
-
|
14 |
-
<
|
15 |
-
<
|
|
|
|
|
16 |
<compatible/>
|
17 |
<dependencies/>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Iridiumcorp_Tpg</name>
|
4 |
+
<version>1.10.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Iridiumcorp Payment Extension for Magento v1.4.1.0 and above</summary>
|
10 |
<description>Fully supports 3D secure transactions. Also supports all of the integration methods provided by Iridium.</description>
|
11 |
+
<notes>Fix to run on Magento v1.4.1.0 and above.
|
12 |
+
Fix to manage stock properly.
|
13 |
+
Fix to update the Order status properly.</notes>
|
14 |
+
<authors><author><name>iridiumcorp</name><user>auto-converted</user><email>support@iridiumcorp.co.uk</email></author></authors>
|
15 |
+
<date>2010-10-18</date>
|
16 |
+
<time>09:48:35</time>
|
17 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="Tpg"><file name="form.phtml" hash="9b2afd627d6e9e4f9ad43b0a7153962b"/><file name="info.phtml" hash="3164afadd87c4811b5f7d0879537f10e"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="Tpg"><file name="form.phtml" hash="231e39bb2821718eeaec4c1d0ee3233d"/><file name="info.phtml" hash="7d72d07f3afa018d0402219e50573439"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="images"><file name="iridium_corporation.jpg" hash="589faaa1b7e80b32a425175ecfc3b455"/></dir></dir></dir></dir></target><target name="magelocal"><dir name="Iridiumcorp"><dir name="Checkout"><dir name="Block"><dir name="Onepage"><dir name="Payment"><file name="Methods.php" hash="a10e1c19ad7bb8718dcb3adf9d3e4de0"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="aaa95b6e1d6e145940bf9ba9bbe1dc0f"/></dir><dir name="Model"><dir name="Type"><file name="Onepage.php" hash="f57d3807294d61ee997cbdfd6acce34c"/></dir></dir></dir><dir name="Sales"><dir name="etc"><file name="config.xml" hash="a68c91eef35d347a95232c198ccf31fe"/></dir><dir name="Model"><file name="Order.php" hash="a57c4bd661dbc322d5bd18aa2f51dd67"/><dir name="Order"><file name="Invoice.php" hash="0da517143d8c83606fb51721043e7be1"/><file name="Payment.php" hash="bd5ed39ecef936e9f2225989668851be"/></dir><dir name="Service"><file name="Quote.php" hash="bf113cd154e23dd9c8df0946adf9b94f"/></dir></dir></dir><dir name="Tpg"><dir name="Block"><file name="Error.php" hash="905367210beb53a0bc68dc6033e24127"/><file name="Form.php" hash="4b1d51aa84982486f3139510c41a221a"/><file name="Info.php" hash="f88445c4880bfe14914252bc76b6fc28"/><file name="Redirect.php" hash="a91a8a8f8b5ad887ed2cdd8d52732b8b"/><file name="Threedsecure.php" hash="9cbcf7d598fe4fdb5144aa6496436176"/></dir><dir name="controllers"><file name="PaymentController.php" hash="5ccbff29e1fb37b7ca0b85b0566f4da8"/></dir><dir name="etc"><file name="config.xml" hash="3395b3323803ea1c1fdea27f919c08da"/><file name="system.xml" hash="13531b8280be72392ae8abbd47f00adf"/></dir><dir name="Helper"><file name="Data.php" hash="a72fba87e718c94d993a57199e20ca96"/></dir><dir name="Model"><file name="Direct.php" hash="5581007f591f1a6dc9b16716fc12d223"/><file name="Request.php" hash="a96e462ed3c1882048ea45f2c3a6662c"/><dir name="Common"><file name="GlobalErrors.php" hash="a9c7bab60ebfe87967c794194e1e7208"/><file name="ISOCountries.php" hash="fc63d76fbe25458ba351f114782074cb"/><file name="ISOCurrencies.php" hash="89ac1e124e89c0713ef43a0cf6dd0e2b"/><file name="PaymentFormHelper.php" hash="85721dd87049dbd6c4aef2e48453815f"/><dir name="ThePaymentGateway"><file name="PaymentSystem.php" hash="4ad38bdb85f865e967153d9f253390cd"/><file name="SOAP.php" hash="504dcb0cb7c60c134b25652881349cc3"/><file name="TPG_Common.php" hash="df1033ef855c7e0e715076a105acb84a"/></dir></dir><dir name="Source"><file name="HashMethod.php" hash="36d7fb4fc762feae459f0e67d51006f4"/><file name="OrderStatus.php" hash="95eb926db39d4afeb26784a9396f7b18"/><file name="PaymentAction.php" hash="bd8dc40852b9ff8c80c08fc01f35a988"/><file name="PaymentMode.php" hash="6849defade8a7da4cfaeff3227ae5b83"/><file name="ResultDeliveryMethod.php" hash="05f3806f2ff4bd5b1568bfb1681b2242"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Iridiumcorp_All.xml" hash="f1a85eaa7631af1906f461b662519732"/></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies/>
|
20 |
</package>
|