Iridiumcorp_Tpg - Version 1.11.0

Version Notes

Secure URL fix for 3D Secure payments
Updated Magento v1.3.2.4 and v1.3.3.0 compatible payment extension.
base/default theme path applied for v1.4 compatibility

Download this release

Release Info

Developer Magento Core Team
Extension Iridiumcorp_Tpg
Version 1.11.0
Comparing to
See all releases


Code changes from version 1.10.4 to 1.11.0

app/code/local/Iridiumcorp/Checkout/Block/Onepage/Payment/Methods.php CHANGED
@@ -17,20 +17,21 @@ class Iridiumcorp_Checkout_Block_Onepage_Payment_Methods extends Mage_Checkout_B
17
  */
18
  public function getSelectedMethodCode()
19
  {
 
20
  $model = Mage::getModel('tpg/direct');
21
 
22
  if ($this->getQuote()->getPayment()->getMethod())
23
  {
24
  $method = $this->getQuote()->getPayment()->getMethod();
25
  }
26
- else
27
  {
28
  // force the current payment to be selected
29
  if($model)
30
  {
31
  $method = 'tpg';
32
  }
33
- }
34
 
35
  return $method;
36
  }
17
  */
18
  public function getSelectedMethodCode()
19
  {
20
+ $method = false;
21
  $model = Mage::getModel('tpg/direct');
22
 
23
  if ($this->getQuote()->getPayment()->getMethod())
24
  {
25
  $method = $this->getQuote()->getPayment()->getMethod();
26
  }
27
+ /*else
28
  {
29
  // force the current payment to be selected
30
  if($model)
31
  {
32
  $method = 'tpg';
33
  }
34
+ }*/
35
 
36
  return $method;
37
  }
app/code/local/Iridiumcorp/Checkout/Model/Type/Onepage.php CHANGED
@@ -2,7 +2,8 @@
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);
@@ -14,7 +15,7 @@ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_O
14
  $magentoVersion = (int)$magentoVersion;
15
 
16
  return $magentoVersion;
17
- }
18
 
19
  /**
20
  * Create an order
@@ -23,7 +24,7 @@ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_O
23
  */
24
  public function saveOrder()
25
  {
26
- $nVersion = $this->getVersion(Mage::getVersion());
27
 
28
  if($nVersion >= 1410)
29
  {
@@ -121,7 +122,7 @@ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_O
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();
@@ -373,6 +374,259 @@ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_O
373
  //$this->getQuote()->setIsActive(false);
374
  //$this->getQuote()->save();
375
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
 
377
  return $this;
378
  }
@@ -386,7 +640,7 @@ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_O
386
  */
387
  public function saveOrderAfter3dSecure($pares, $md)
388
  {
389
- $nVersion = $this->getVersion(Mage::getVersion());
390
 
391
  if($nVersion >= 1410)
392
  {
@@ -421,7 +675,7 @@ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_O
421
  ->setAcsurl(null)
422
  ->setTpgOrderId(null);
423
  }
424
- else
425
  {
426
  $this->validateOrder();
427
  $billing = $this->getQuote()->getBillingAddress();
@@ -534,8 +788,6 @@ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_O
534
 
535
  $order->save();
536
 
537
-
538
-
539
  Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
540
 
541
 
@@ -576,7 +828,7 @@ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_O
576
  */
577
  public function saveOrderAfterRedirectedPaymentAction($boIsHostedPaymentAction, $szStatusCode, $szMessage, $szPreviousStatusCode, $szPreviousMessage, $szOrderID)
578
  {
579
- $nVersion = $this->getVersion(Mage::getVersion());
580
 
581
  if($nVersion >= 1410)
582
  {
@@ -618,7 +870,7 @@ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_O
618
  ->setOrderid(null)
619
  ->setTpgOrderId(null);
620
  }
621
- else
622
  {
623
  $this->validateOrder();
624
  $billing = $this->getQuote()->getBillingAddress();
@@ -749,9 +1001,9 @@ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_O
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
  {
2
 
3
  class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
4
  {
5
+ // TODO : REMOVE - old representation
6
+ /*public function getVersion($magentoVersion)
7
  {
8
  $pattern = '/[^\d]/';
9
  $magentoVersion = preg_replace($pattern, '', $magentoVersion);
15
  $magentoVersion = (int)$magentoVersion;
16
 
17
  return $magentoVersion;
18
+ }*/
19
 
20
  /**
21
  * Create an order
24
  */
25
  public function saveOrder()
26
  {
27
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
28
 
29
  if($nVersion >= 1410)
30
  {
122
  // TODO: send recurring profile emails
123
  }
124
  }
125
+ else if($nVersion == 1400 || $nVersion == 1401)
126
  {
127
  // logic for version below 1.4.0.1 and below
128
  $this->validateOrder();
374
  //$this->getQuote()->setIsActive(false);
375
  //$this->getQuote()->save();
376
  }
377
+ else if($nVersion == 1324 || $nVersion == 1330)
378
+ {
379
+ $this->validateOrder();
380
+ $billing = $this->getQuote()->getBillingAddress();
381
+
382
+ if (!$this->getQuote()->isVirtual())
383
+ {
384
+ $shipping = $this->getQuote()->getShippingAddress();
385
+ }
386
+
387
+ switch ($this->getQuote()->getCheckoutMethod())
388
+ {
389
+ case Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST:
390
+ if (!$this->getQuote()->isAllowedGuestCheckout())
391
+ {
392
+ Mage::throwException(Mage::helper('checkout')->__('Sorry, guest checkout is not enabled. Please try again or contact store owner.'));
393
+ }
394
+ $this->getQuote()->setCustomerId(null)
395
+ ->setCustomerEmail($billing->getEmail())
396
+ ->setCustomerIsGuest(true)
397
+ ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
398
+ break;
399
+
400
+ case Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER:
401
+ $customer = Mage::getModel('customer/customer');
402
+
403
+ $customerBilling = $billing->exportCustomerAddress();
404
+ $customer->addAddress($customerBilling);
405
+
406
+ if (!$this->getQuote()->isVirtual() &&
407
+ !$shipping->getSameAsBilling())
408
+ {
409
+ $customerShipping = $shipping->exportCustomerAddress();
410
+ $customer->addAddress($customerShipping);
411
+ }
412
+
413
+ if ($this->getQuote()->getCustomerDob() &&
414
+ !$billing->getCustomerDob())
415
+ {
416
+ $billing->setCustomerDob($this->getQuote()->getCustomerDob());
417
+ }
418
+
419
+ if ($this->getQuote()->getCustomerTaxvat() && !$billing->getCustomerTaxvat())
420
+ {
421
+ $billing->setCustomerTaxvat($this->getQuote()->getCustomerTaxvat());
422
+ }
423
+
424
+ Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer);
425
+
426
+ $customer->setPassword($customer->decryptPassword($this->getQuote()->getPasswordHash()));
427
+ $customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
428
+
429
+ $this->getQuote()->setCustomer($customer);
430
+ Mage::log(time());
431
+ break;
432
+
433
+ default:
434
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
435
+
436
+ if (!$billing->getCustomerId() ||
437
+ $billing->getSaveInAddressBook())
438
+ {
439
+ $customerBilling = $billing->exportCustomerAddress();
440
+ $customer->addAddress($customerBilling);
441
+ }
442
+ if (!$this->getQuote()->isVirtual() &&
443
+ ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) ||
444
+ (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())))
445
+ {
446
+ $customerShipping = $shipping->exportCustomerAddress();
447
+ $customer->addAddress($customerShipping);
448
+ }
449
+ $customer->setSavedFromQuote(true);
450
+ $customer->save();
451
+
452
+ $changed = false;
453
+ if (isset($customerBilling) &&
454
+ !$customer->getDefaultBilling())
455
+ {
456
+ $customer->setDefaultBilling($customerBilling->getId());
457
+ $changed = true;
458
+ }
459
+ if (!$this->getQuote()->isVirtual() &&
460
+ isset($customerBilling) &&
461
+ !$customer->getDefaultShipping() &&
462
+ $shipping->getSameAsBilling())
463
+ {
464
+ $customer->setDefaultShipping($customerBilling->getId());
465
+ $changed = true;
466
+ }
467
+ elseif (!$this->getQuote()->isVirtual() &&
468
+ isset($customerShipping) &&
469
+ !$customer->getDefaultShipping())
470
+ {
471
+ $customer->setDefaultShipping($customerShipping->getId());
472
+ $changed = true;
473
+ }
474
+
475
+ if ($changed)
476
+ {
477
+ $customer->save();
478
+ }
479
+ }
480
+
481
+ $this->getQuote()->reserveOrderId();
482
+ $convertQuote = Mage::getModel('sales/convert_quote');
483
+ // @var $convertQuote Mage_Sales_Model_Convert_Quote
484
+ if ($this->getQuote()->isVirtual())
485
+ {
486
+ $order = $convertQuote->addressToOrder($billing);
487
+ }
488
+ else
489
+ {
490
+ $order = $convertQuote->addressToOrder($shipping);
491
+ }
492
+ // @var $order Mage_Sales_Model_Order
493
+ $order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
494
+
495
+ if (!$this->getQuote()->isVirtual())
496
+ {
497
+ $order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
498
+ }
499
+
500
+ $order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
501
+
502
+ foreach ($this->getQuote()->getAllItems() as $item)
503
+ {
504
+ $orderItem = $convertQuote->itemToOrderItem($item);
505
+ if ($item->getParentItem())
506
+ {
507
+ $orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
508
+ }
509
+ $order->addItem($orderItem);
510
+ }
511
+
512
+ // We can use configuration data for declare new order status
513
+ Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
514
+ // check again, if customer exists
515
+ if ($this->getQuote()->getCheckoutMethod() == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)
516
+ {
517
+ if ($this->_customerEmailExists($customer->getEmail(), Mage::app()->getWebsite()->getId()))
518
+ {
519
+ Mage::throwException(Mage::helper('checkout')->__('There is already a customer registered using this email address'));
520
+ }
521
+ }
522
+
523
+ // clear 3dSecure session variables
524
+ Mage::getSingleton('checkout/session')->setThreedsecurerequired(null);
525
+ Mage::getSingleton('checkout/session')->setMd(null);
526
+ Mage::getSingleton('checkout/session')->setPares(null);
527
+ Mage::getSingleton('checkout/session')->setAcsurl(null);
528
+
529
+ $order->place();
530
+
531
+ if ($this->getQuote()->getCheckoutMethod()==Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)
532
+ {
533
+ $customer->save();
534
+ $customerBillingId = $customerBilling->getId();
535
+ if (!$this->getQuote()->isVirtual())
536
+ {
537
+ $customerShippingId = isset($customerShipping) ? $customerShipping->getId() : $customerBillingId;
538
+ $customer->setDefaultShipping($customerShippingId);
539
+ }
540
+ $customer->setDefaultBilling($customerBillingId);
541
+ $customer->save();
542
+
543
+ $this->getQuote()->setCustomerId($customer->getId());
544
+
545
+ $order->setCustomerId($customer->getId());
546
+ Mage::helper('core')->copyFieldset('customer_account', 'to_order', $customer, $order);
547
+
548
+ $billing->setCustomerId($customer->getId())->setCustomerAddressId($customerBillingId);
549
+ if (!$this->getQuote()->isVirtual())
550
+ {
551
+ $shipping->setCustomerId($customer->getId())->setCustomerAddressId($customerShippingId);
552
+ }
553
+
554
+ if ($customer->isConfirmationRequired())
555
+ {
556
+ $customer->sendNewAccountEmail('confirmation');
557
+ }
558
+ else
559
+ {
560
+ $customer->sendNewAccountEmail();
561
+ }
562
+ }
563
+
564
+ /**
565
+ * a flag to set that there will be redirect to third party after confirmation
566
+ * eg: paypal standard ipn
567
+ */
568
+ $redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
569
+ if(!$redirectUrl)
570
+ {
571
+ $order->setEmailSent(true);
572
+ }
573
+
574
+ if(!$redirectUrl ||
575
+ $this->getQuote()->getPayment()->getMethodInstance()->getCode() != 'tpg')
576
+ {
577
+ $order->save();
578
+ }
579
+
580
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
581
+
582
+
583
+ /**
584
+ * need to have somelogic to set order as new status to make sure order is not finished yet
585
+ * quote will be still active when we send the customer to paypal
586
+ */
587
+
588
+ $orderId = $order->getIncrementId();
589
+ $this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
590
+ $this->getCheckout()->setLastOrderId($order->getId());
591
+ $this->getCheckout()->setLastRealOrderId($order->getIncrementId());
592
+ $this->getCheckout()->setRedirectUrl($redirectUrl);
593
+
594
+ /**
595
+ * we only want to send to customer about new order when there is no redirect to third party
596
+ */
597
+ if(!$redirectUrl)
598
+ {
599
+ $order->sendNewOrderEmail();
600
+ }
601
+
602
+ if ($this->getQuote()->getCheckoutMethod(true) == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER &&
603
+ !Mage::getSingleton('customer/session')->isLoggedIn())
604
+ {
605
+ /**
606
+ * we need to save quote here to have it saved with Customer Id.
607
+ * so when loginById() executes checkout/session method loadCustomerQuote
608
+ * it would not create new quotes and merge it with old one.
609
+ */
610
+ $this->getQuote()->save();
611
+ if ($customer->isConfirmationRequired())
612
+ {
613
+ 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>.',
614
+ Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())
615
+ ));
616
+ }
617
+ else
618
+ {
619
+ Mage::getSingleton('customer/session')->loginById($customer->getId());
620
+ }
621
+ }
622
+
623
+ //Setting this one more time like control flag that we haves saved order
624
+ //Must be checkout on success page to show it or not.
625
+ $this->getCheckout()->setLastSuccessQuoteId($this->getQuote()->getId());
626
+
627
+ $this->getQuote()->setIsActive(false);
628
+ $this->getQuote()->save();
629
+ }
630
 
631
  return $this;
632
  }
640
  */
641
  public function saveOrderAfter3dSecure($pares, $md)
642
  {
643
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
644
 
645
  if($nVersion >= 1410)
646
  {
675
  ->setAcsurl(null)
676
  ->setTpgOrderId(null);
677
  }
678
+ else if($nVersion == 1400 || $nVersion == 1401 || $nVersion == 1324 || $nVersion == 1330)
679
  {
680
  $this->validateOrder();
681
  $billing = $this->getQuote()->getBillingAddress();
788
 
789
  $order->save();
790
 
 
 
791
  Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
792
 
793
 
828
  */
829
  public function saveOrderAfterRedirectedPaymentAction($boIsHostedPaymentAction, $szStatusCode, $szMessage, $szPreviousStatusCode, $szPreviousMessage, $szOrderID)
830
  {
831
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
832
 
833
  if($nVersion >= 1410)
834
  {
870
  ->setOrderid(null)
871
  ->setTpgOrderId(null);
872
  }
873
+ else if($nVersion == 1400 || $nVersion == 1401 || $nVersion == 1324 || $nVersion == 1330)
874
  {
875
  $this->validateOrder();
876
  $billing = $this->getQuote()->getBillingAddress();
1001
  /**
1002
  * we only want to send to customer about new order when there is no redirect to third party
1003
  */
1004
+ //if(!$redirectUrl){
1005
  $order->sendNewOrderEmail();
1006
+ //}
1007
 
1008
  if ($this->getQuote()->getCheckoutMethod()=='register')
1009
  {
app/code/local/Iridiumcorp/Sales/Model/Order/Invoice.php CHANGED
@@ -20,22 +20,45 @@ class Iridiumcorp_Sales_Model_Order_Invoice extends Mage_Sales_Model_Order_Invoi
20
 
21
  public function pay()
22
  {
23
- if ($this->_wasPayCalled)
24
- {
25
- return $this;
26
- }
27
-
28
- if(!$this->getOrder()->getIsThreeDSecurePending() &&
29
- !$this->getOrder()->getIsHostedPaymentPending())
30
- {
31
- $this->_wasPayCalled = true;
32
-
33
- $invoiceState = self::STATE_PAID;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  if ($this->getOrder()->getPayment()->hasForcedState())
35
  {
36
  $invoiceState = $this->getOrder()->getPayment()->getForcedState();
37
  }
38
-
39
  $this->setState($invoiceState);
40
 
41
  $this->getOrder()->getPayment()->pay($this);
@@ -46,8 +69,7 @@ class Iridiumcorp_Sales_Model_Order_Invoice extends Mage_Sales_Model_Order_Invoi
46
  $this->getOrder()->getBaseTotalPaid()+$this->getBaseGrandTotal()
47
  );
48
  Mage::dispatchEvent('sales_order_invoice_pay', array($this->_eventObject=>$this));
49
- }
50
-
51
  return $this;
52
  }
53
  }
20
 
21
  public function pay()
22
  {
23
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
24
+
25
+ if($nVersion >= 1400)
26
+ {
27
+ if ($this->_wasPayCalled)
28
+ {
29
+ return $this;
30
+ }
31
+
32
+ if(!$this->getOrder()->getIsThreeDSecurePending() &&
33
+ !$this->getOrder()->getIsHostedPaymentPending())
34
+ {
35
+ $this->_wasPayCalled = true;
36
+
37
+ $invoiceState = self::STATE_PAID;
38
+ if ($this->getOrder()->getPayment()->hasForcedState())
39
+ {
40
+ $invoiceState = $this->getOrder()->getPayment()->getForcedState();
41
+ }
42
+
43
+ $this->setState($invoiceState);
44
+
45
+ $this->getOrder()->getPayment()->pay($this);
46
+ $this->getOrder()->setTotalPaid(
47
+ $this->getOrder()->getTotalPaid()+$this->getGrandTotal()
48
+ );
49
+ $this->getOrder()->setBaseTotalPaid(
50
+ $this->getOrder()->getBaseTotalPaid()+$this->getBaseGrandTotal()
51
+ );
52
+ Mage::dispatchEvent('sales_order_invoice_pay', array($this->_eventObject=>$this));
53
+ }
54
+ }
55
+ else if($nVersion == 1324 || $nVersion == 1330)
56
+ {
57
+ $invoiceState = self::STATE_PAID;
58
  if ($this->getOrder()->getPayment()->hasForcedState())
59
  {
60
  $invoiceState = $this->getOrder()->getPayment()->getForcedState();
61
  }
 
62
  $this->setState($invoiceState);
63
 
64
  $this->getOrder()->getPayment()->pay($this);
69
  $this->getOrder()->getBaseTotalPaid()+$this->getBaseGrandTotal()
70
  );
71
  Mage::dispatchEvent('sales_order_invoice_pay', array($this->_eventObject=>$this));
72
+ }
 
73
  return $this;
74
  }
75
  }
app/code/local/Iridiumcorp/Sales/Model/Order/Payment.php CHANGED
@@ -2,6 +2,170 @@
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
@@ -10,114 +174,229 @@ class Iridiumcorp_Sales_Model_Order_Payment extends Mage_Sales_Model_Order_Payme
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
- $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
70
- $orderState = 'pending_payment';
71
- $orderStatus = 'irc_pending_threed_secure';
72
- $message = '3D Secure authentication need to be completed';
73
- $orderIsNotified = false;
74
- }
75
- else if($order->getIsHostedPaymentPending())
76
- {
77
- $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
78
- $orderState = 'pending_payment';
79
- $orderStatus = 'irc_pending_hosted_payment';
80
- $orderIsNotified = false;
81
- $message = 'Hosted Payment need to be completed';
82
- }
83
- else
84
- {
85
- $orderStatus = $methodInstance->getConfigData('order_status');
86
- if (!$orderStatus || $order->getIsVirtual())
87
  {
88
- $orderStatus = $order->getConfig()->getStateDefaultStatus($orderState);
89
- }
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
- $isCustomerNotified = (null !== $orderIsNotified) ? $orderIsNotified : $order->getCustomerNoteNotify();
93
- //$message = $order->getCustomerNote();
94
- if(!$order->getIsThreeDSecurePending() &&
95
- !$order->getIsHostedPaymentPending())
96
- {
97
- $message = $order->getCustomerNote();
98
- }
99
 
100
- // add message if order was put into review during authorization or capture
101
- if ($order->getState() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW)
102
- {
103
- if ($message)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  {
105
- $order->addStatusToHistory($order->getStatus(), $message, $isCustomerNotified);
106
- }
107
- }
108
- // add message to history if order state already declared
109
- elseif ($order->getState() && ($orderStatus !== $order->getStatus() || $message))
110
- {
111
- $order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
112
- }
113
- // set order state
114
- elseif (($order->getState() != $orderState) || ($order->getStatus() != $orderStatus) || $message)
115
- {
116
- $order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
117
- }
118
 
119
- Mage::dispatchEvent('sales_order_payment_place_end', array('payment' => $this));
 
 
 
 
 
 
120
 
121
- return $this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  }
123
  }
2
 
3
  class Iridiumcorp_Sales_Model_Order_Payment extends Mage_Sales_Model_Order_Payment
4
  {
5
+ /**
6
+ * Capture payment
7
+ *
8
+ * @return Mage_Sales_Model_Order_Payment
9
+ */
10
+ public function capture($invoice)
11
+ {
12
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
13
+
14
+ if($nVersion == 1411 || $nVersion == 1410)
15
+ {
16
+ if (is_null($invoice))
17
+ {
18
+ $invoice = $this->_invoice();
19
+ $this->setCreatedInvoice($invoice);
20
+ return $this; // @see Mage_Sales_Model_Order_Invoice::capture()
21
+ }
22
+ $amountToCapture = $this->_formatAmount($invoice->getBaseGrandTotal());
23
+ $order = $this->getOrder();
24
+
25
+ // prepare parent transaction and its amount
26
+ $paidWorkaround = 0;
27
+ if (!$invoice->wasPayCalled())
28
+ {
29
+ $paidWorkaround = (float)$amountToCapture;
30
+ }
31
+ $this->_isCaptureFinal($paidWorkaround);
32
+
33
+ $this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $this->getAuthorizationTransaction());
34
+
35
+ Mage::dispatchEvent('sales_order_payment_capture', array('payment' => $this, 'invoice' => $invoice));
36
+
37
+ /**
38
+ * Fetch an update about existing transaction. It can determine whether the transaction can be paid
39
+ * Capture attempt will happen only when invoice is not yet paid and the transaction can be paid
40
+ */
41
+ if ($invoice->getTransactionId())
42
+ {
43
+ $this->getMethodInstance()->setStore($order->getStoreId())->fetchTransactionInfo($this, $invoice->getTransactionId());
44
+ }
45
+ $status = true;
46
+ if (!$invoice->getIsPaid() && !$this->getIsTransactionPending())
47
+ {
48
+ // attempt to capture: this can trigger "is_transaction_pending"
49
+ $this->getMethodInstance()->setStore($order->getStoreId())->capture($this, $amountToCapture);
50
+
51
+ $transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $invoice, true);
52
+
53
+ if ($this->getIsTransactionPending())
54
+ {
55
+ $message = Mage::helper('sales')->__('Capturing amount of %s is pending approval on gateway.', $this->_formatPrice($amountToCapture));
56
+ $state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
57
+ if ($this->getIsFraudDetected())
58
+ {
59
+ $status = 'fraud';
60
+ }
61
+ $invoice->setIsPaid(false);
62
+ }
63
+ else
64
+ { // normal online capture: invoice is marked as "paid"
65
+ $message = Mage::helper('sales')->__('Captured amount of %s online.', $this->_formatPrice($amountToCapture));
66
+ $state = Mage_Sales_Model_Order::STATE_PROCESSING;
67
+ $invoice->setIsPaid(true);
68
+ $this->_updateTotals(array('base_amount_paid_online' => $amountToCapture));
69
+ }
70
+ if ($order->isNominal())
71
+ {
72
+ $message = $this->_prependMessage(Mage::helper('sales')->__('Nominal order registered.'));
73
+ }
74
+ else
75
+ {
76
+ $message = $this->_prependMessage($message);
77
+ $message = $this->_appendTransactionToMessage($transaction, $message);
78
+ }
79
+ $order->setState($state, $status, $message);
80
+ $this->getMethodInstance()->processInvoice($invoice, $this); // should be deprecated
81
+ return $this;
82
+ }
83
+ Mage::throwException(Mage::helper('sales')->__('The transaction "%s" cannot be captured yet.', $invoice->getTransactionId()));
84
+ }
85
+ if($nVersion == 1400 || $nVersion == 1401)
86
+ {
87
+ if (is_null($invoice))
88
+ {
89
+ $invoice = $this->_invoice();
90
+ $this->setCreatedInvoice($invoice);
91
+ return $this; // @see Mage_Sales_Model_Order_Invoice::capture()
92
+ }
93
+ $amountToCapture = $this->_formatAmount($invoice->getBaseGrandTotal());
94
+
95
+ $paidWorkaround = 0;
96
+ if (!$invoice->wasPayCalled())
97
+ {
98
+ $paidWorkaround = (float)$amountToCapture;
99
+ }
100
+ $this->_isCaptureFinal($paidWorkaround);
101
+ $baseTransaction = false;
102
+ if ($invoice->getTransactionId())
103
+ {
104
+ $baseTransaction = $this->_lookupTransaction($invoice->getTransactionId());
105
+ }
106
+ else
107
+ {
108
+ $baseTransaction = $this->getAuthorizationTransaction();
109
+ }
110
+ $this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $baseTransaction);
111
+
112
+ Mage::dispatchEvent('sales_order_payment_capture', array('payment' => $this, 'invoice' => $invoice));
113
+
114
+ $this->getMethodInstance()
115
+ ->setStore($this->getOrder()->getStoreId())
116
+ ->capture($this, $amountToCapture);
117
+
118
+ // update transactions, set order state (order will close itself if required)
119
+ $transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $invoice, true);
120
+ /**
121
+ * Check if payment transaction is under pending state.
122
+ * Gateway can accept peyment transaction but mark it as pending.
123
+ * We need hold such kind of orders
124
+ */
125
+ if ($this->getIsTransactionPending())
126
+ {
127
+ $message = Mage::helper('sales')->__('Amount of %s pending approval on gateway.', $this->_formatPrice($amountToCapture));
128
+ $message = $this->_prependMessage($message);
129
+ $message = $this->_appendTransactionToMessage($transaction, $message);
130
+ $status = $this->getTransactionPendingStatus() ? $this->getTransactionPendingStatus() : true;
131
+ $this->getOrder()->setState(Mage_Sales_Model_Order::STATE_HOLDED, $status, $message);
132
+ $invoice->setIsPaid(false);
133
+ }
134
+ else
135
+ {
136
+ $this->_updateTotals(array('base_amount_paid_online' => $amountToCapture));
137
+ $message = Mage::helper('sales')->__('Captured amount of %s online.', $this->_formatPrice($amountToCapture));
138
+ $message = $this->_prependMessage($message);
139
+ $message = $this->_appendTransactionToMessage($transaction, $message);
140
+ $this->getOrder()->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
141
+ $invoice->setIsPaid(true);
142
+ }
143
+
144
+ $this->getMethodInstance()->processInvoice($invoice, $this); // should be deprecated
145
+ return $this;
146
+ }
147
+ if($nVersion == 1324 || $nVersion == 1330)
148
+ {
149
+ if (is_null($invoice))
150
+ {
151
+ $invoice = $this->_invoice();
152
+ }
153
+
154
+ Mage::dispatchEvent('sales_order_payment_capture', array('payment' => $this, 'invoice' => $invoice));
155
+
156
+ $this->getMethodInstance()
157
+ ->setStore($this->getOrder()->getStoreId())
158
+ ->capture($this, sprintf('%.2f', $invoice->getBaseGrandTotal()));
159
+ if($this->getIsInvoicePaid())
160
+ {
161
+ $invoice->setIsPaid(true);
162
+ }
163
+ $this->getMethodInstance()->processInvoice($invoice, $this);
164
+
165
+ return $this;
166
+ }
167
+ }
168
+
169
  /**
170
  * Authorize or authorize and capture payment on gateway, if applicable
171
  * This method is supposed to be called only when order is placed
174
  */
175
  public function place()
176
  {
177
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
178
+
179
+ if($nVersion == 1411 || $nVersion == 1410 || $nVersion == 1401 || $nVersion == 1400)
180
+ {
181
+ Mage::dispatchEvent('sales_order_payment_place_start', array('payment' => $this));
182
+ $order = $this->getOrder();
183
+
184
+ $this->setAmountOrdered($order->getTotalDue());
185
+ $this->setBaseAmountOrdered($order->getBaseTotalDue());
186
+ $this->setShippingAmount($order->getShippingAmount());
187
+ $this->setBaseShippingAmount($order->getBaseShippingAmount());
188
+
189
+ $methodInstance = $this->getMethodInstance();
190
+ $methodInstance->setStore($order->getStoreId());
191
+
192
+ $orderState = Mage_Sales_Model_Order::STATE_NEW;
193
+ $orderStatus= false;
194
+
195
+ $stateObject = new Varien_Object();
196
+
197
+ /**
198
+ * Do order payment validation on payment method level
199
+ */
200
+ $methodInstance->validate();
201
+ $action = $methodInstance->getConfigPaymentAction();
202
+ if ($action)
203
+ {
204
+ if ($methodInstance->isInitializeNeeded())
205
+ {
206
+ /**
207
+ * For method initialization we have to use original config value for payment action
208
+ */
209
+ $methodInstance->initialize($methodInstance->getConfigData('payment_action'), $stateObject);
210
+ }
211
+ else
212
+ {
213
+ $orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
214
+ switch ($action)
215
+ {
216
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
217
+ $this->_authorize(true, $order->getBaseTotalDue()); // base amount will be set inside
218
+ $this->setAmountAuthorized($order->getTotalDue());
219
+ break;
220
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
221
+ $this->setAmountAuthorized($order->getTotalDue());
222
+ $this->setBaseAmountAuthorized($order->getBaseTotalDue());
223
+ $this->capture(null);
224
+ break;
225
+ default:
226
+ break;
227
+ }
228
+ }
229
+ }
230
 
231
+ if($nVersion == 1411 || $nVersion == 1410)
232
+ {
233
+ $this->_createBillingAgreement();
234
+ $orderStateHelper = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
235
+ }
236
+ else
237
+ {
238
+ $orderStateHelper = Mage_Sales_Model_Order::STATE_HOLDED;
239
+ }
240
 
241
+ $orderIsNotified = null;
242
+ if ($stateObject->getState() && $stateObject->getStatus())
243
+ {
244
+ $orderState = $stateObject->getState();
245
+ $orderStatus = $stateObject->getStatus();
246
+ $orderIsNotified = $stateObject->getIsNotified();
247
+ }
248
+ else if($order->getIsThreeDSecurePending())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  {
250
+ $orderState = 'pending_payment';
251
+ $orderStatus = 'irc_pending_threed_secure';
252
+ $message = '3D Secure authentication need to be completed';
253
+ $orderIsNotified = false;
254
+ }
255
+ else if($order->getIsHostedPaymentPending())
256
+ {
257
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
258
+ $orderState = 'pending_payment';
259
+ $orderStatus = 'irc_pending_hosted_payment';
260
+ $message = 'Hosted Payment need to be completed';
261
+ $orderIsNotified = false;
262
+ }
263
+ else
264
+ {
265
+ $orderStatus = $methodInstance->getConfigData('order_status');
266
+ if (!$orderStatus || $order->getIsVirtual())
267
+ {
268
+ $orderStatus = $order->getConfig()->getStateDefaultStatus($orderState);
269
+ }
270
+ }
271
 
272
+ $isCustomerNotified = (null !== $orderIsNotified) ? $orderIsNotified : $order->getCustomerNoteNotify();
273
+ //$message = $order->getCustomerNote();
274
+ if(!$order->getIsThreeDSecurePending() &&
275
+ !$order->getIsHostedPaymentPending())
276
+ {
277
+ $message = $order->getCustomerNote();
278
+ }
279
 
280
+ // add message if order was put into review during authorization or capture
281
+ //if ($order->getState() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW)$orderState
282
+ if ($order->getState() == $orderStateHelper)
283
+ {
284
+ if ($message)
285
+ {
286
+ $order->addStatusToHistory($order->getStatus(), $message, $isCustomerNotified);
287
+ }
288
+
289
+ if($nVersion == 1400 || $nVersion == 1401)
290
+ {
291
+ $order->setHoldBeforeState($orderState);
292
+ $order->setHoldBeforeStatus($orderStatus);
293
+ }
294
+ }
295
+ // add message to history if order state already declared
296
+ elseif ($order->getState() && ($orderStatus !== $order->getStatus() || $message))
297
+ {
298
+ $order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
299
+ }
300
+ // set order state
301
+ elseif (($order->getState() != $orderState) || ($order->getStatus() != $orderStatus) || $message)
302
  {
303
+ $order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
304
+ }
 
 
 
 
 
 
 
 
 
 
 
305
 
306
+ Mage::dispatchEvent('sales_order_payment_place_end', array('payment' => $this));
307
+
308
+ return $this;
309
+ }
310
+ if($nVersion == 1324 || $nVersion == 1330)
311
+ {
312
+ Mage::dispatchEvent('sales_order_payment_place_start', array('payment' => $this));
313
 
314
+ $this->setAmountOrdered($this->getOrder()->getTotalDue());
315
+ $this->setBaseAmountOrdered($this->getOrder()->getBaseTotalDue());
316
+
317
+ $this->setShippingAmount($this->getOrder()->getShippingAmount());
318
+ $this->setBaseShippingAmount($this->getOrder()->getBaseShippingAmount());
319
+
320
+ $methodInstance = $this->getMethodInstance()->setStore($this->getOrder()->getStoreId());
321
+
322
+ $orderState = Mage_Sales_Model_Order::STATE_NEW;
323
+ $orderStatus= false;
324
+
325
+ $stateObject = new Varien_Object();
326
+
327
+ /**
328
+ * validating payment method again
329
+ */
330
+ $methodInstance->validate();
331
+ if ($action = $methodInstance->getConfigData('payment_action')) {
332
+ /**
333
+ * Run action declared for payment method in configuration
334
+ */
335
+
336
+ if ($methodInstance->isInitializeNeeded()) {
337
+ $methodInstance->initialize($action, $stateObject);
338
+ } else {
339
+ switch ($action) {
340
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
341
+ case Mage_Paypal_Model_Api_Abstract::PAYMENT_TYPE_AUTH:
342
+ $methodInstance->authorize($this, $this->getOrder()->getBaseTotalDue());
343
+
344
+ $this->setAmountAuthorized($this->getOrder()->getTotalDue());
345
+ $this->setBaseAmountAuthorized($this->getOrder()->getBaseTotalDue());
346
+
347
+ $orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
348
+ break;
349
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
350
+ case Mage_Paypal_Model_Api_Abstract::PAYMENT_TYPE_SALE:
351
+ $invoice = $this->_invoice();
352
+
353
+ $this->setAmountAuthorized($this->getOrder()->getTotalDue());
354
+ $this->setBaseAmountAuthorized($this->getOrder()->getBaseTotalDue());
355
+
356
+ $orderState = $this->getOrder()->getIsVirtual()
357
+ ? Mage_Sales_Model_Order::STATE_COMPLETE
358
+ : Mage_Sales_Model_Order::STATE_PROCESSING;
359
+ break;
360
+ default:
361
+ break;
362
+ }
363
+ }
364
+ }
365
+
366
+ $orderIsNotified = null;
367
+ if ($stateObject->getState() && $stateObject->getStatus()) {
368
+ $orderState = $stateObject->getState();
369
+ $orderStatus = $stateObject->getStatus();
370
+ $orderIsNotified = $stateObject->getIsNotified();
371
+ } else {
372
+ /*
373
+ * this flag will set if the order went to as authorization under fraud service for payflowpro
374
+ */
375
+ if ($this->getFraudFlag()) {
376
+ $orderStatus = $methodInstance->getConfigData('fraud_order_status');
377
+ $orderState = Mage_Sales_Model_Order::STATE_HOLDED;
378
+ } else {
379
+ /**
380
+ * Change order status if it specified
381
+ */
382
+ $orderStatus = $methodInstance->getConfigData('order_status');
383
+ }
384
+
385
+ if (!$orderStatus || $this->getOrder()->getIsVirtual()) {
386
+ $orderStatus = $this->getOrder()->getConfig()->getStateDefaultStatus($orderState);
387
+ }
388
+ }
389
+
390
+ $this->getOrder()->setState($orderState);
391
+ $this->getOrder()->addStatusToHistory(
392
+ $orderStatus,
393
+ $this->getOrder()->getCustomerNote(),
394
+ (null !== $orderIsNotified ? $orderIsNotified : $this->getOrder()->getCustomerNoteNotify())
395
+ );
396
+
397
+ Mage::dispatchEvent('sales_order_payment_place_end', array('payment' => $this));
398
+
399
+ return $this;
400
+ }
401
  }
402
  }
app/code/local/Iridiumcorp/Sales/Model/Service/Quote.php CHANGED
@@ -4,84 +4,88 @@ class Iridiumcorp_Sales_Model_Service_Quote extends Mage_Sales_Model_Service_Quo
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
  }
4
  {
5
  public function submitOrder()
6
  {
7
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
8
+
9
+ if($nVersion >= 1410)
10
+ {
11
+ if ($this->_quote->getPayment()->getMethodInstance()->getCode() != 'tpg')
12
+ {
13
+ return parent::submitOrder();
14
+ }
15
+
16
+ $this->_deleteNominalItems();
17
+ $this->_validate();
18
+ $quote = $this->_quote;
19
+ $isVirtual = $quote->isVirtual();
20
+
21
+ $transaction = Mage::getModel('core/resource_transaction');
22
+ if ($quote->getCustomerId())
23
+ {
24
+ $transaction->addObject($quote->getCustomer());
25
+ }
26
+ $transaction->addObject($quote);
27
+
28
+ $quote->reserveOrderId();
29
+ if ($isVirtual)
30
+ {
31
+ $order = $this->_convertor->addressToOrder($quote->getBillingAddress());
32
+ }
33
+ else
34
+ {
35
+ $order = $this->_convertor->addressToOrder($quote->getShippingAddress());
36
+ }
37
+ $order->setBillingAddress($this->_convertor->addressToOrderAddress($quote->getBillingAddress()));
38
+
39
+ if (!$isVirtual)
40
+ {
41
+ $order->setShippingAddress($this->_convertor->addressToOrderAddress($quote->getShippingAddress()));
42
+ }
43
+ $order->setPayment($this->_convertor->paymentToOrderPayment($quote->getPayment()));
44
+
45
+ foreach ($this->_orderData as $key => $value)
46
+ {
47
+ $order->setData($key, $value);
48
+ }
49
+
50
+ foreach ($quote->getAllItems() as $item)
51
+ {
52
+ $orderItem = $this->_convertor->itemToOrderItem($item);
53
+ if ($item->getParentItem())
54
+ {
55
+ $orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
56
+ }
57
+ $order->addItem($orderItem);
58
+ }
59
+ $quote->setIsActive(false);
60
+
61
+ $transaction->addObject($order);
62
+ $transaction->addCommitCallback(array($order, 'place'));
63
+ $transaction->addCommitCallback(array($order, 'save'));
64
+
65
+ /**
66
+ * We can use configuration data for declare new order status
67
+ */
68
+ Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$quote));
69
+ Mage::dispatchEvent('sales_model_service_quote_submit_before', array('order'=>$order, 'quote'=>$quote));
70
+ try
71
+ {
72
+ $transaction->save();
73
+ Mage::dispatchEvent('sales_model_service_quote_submit_success', array('order'=>$order, 'quote'=>$quote));
74
+
75
+ // need to store the orderID in the session for the callback from an external page
76
+ Mage::getSingleton('checkout/session')->setTpgOrderId($order->getId());
77
+
78
+ }
79
+ catch (Exception $e)
80
+ {
81
+ Mage::logException($e);
82
+ Mage::dispatchEvent('sales_model_service_quote_submit_failure', array('order'=>$order, 'quote'=>$quote));
83
+ throw $e;
84
+ }
85
+ Mage::dispatchEvent('sales_model_service_quote_submit_after', array('order'=>$order, 'quote'=>$quote));
86
+ $this->_order = $order;
87
+
88
+ return $order;
89
+ }
90
  }
 
91
  }
app/code/local/Iridiumcorp/Tpg/Block/Threedsecure.php CHANGED
@@ -28,7 +28,7 @@ class Iridiumcorp_Tpg_Block_Threedsecure extends Mage_Core_Block_Abstract
28
 
29
  $form->addField("PaReq", 'hidden', array('name'=>"PaReq", 'value'=>Mage::getSingleton('checkout/session')->getPareq()));
30
  $form->addField("MD", 'hidden', array('name'=>"MD", 'value'=>Mage::getSingleton('checkout/session')->getMd()));
31
- $form->addField("TermUrl", 'hidden', array('name'=>"TermUrl", 'value'=>Mage::getUrl($szTermURL)));
32
 
33
  $html = '<html><body>';
34
  $html.= $this->__('You will be redirected to a 3D secure form in a few seconds.');
28
 
29
  $form->addField("PaReq", 'hidden', array('name'=>"PaReq", 'value'=>Mage::getSingleton('checkout/session')->getPareq()));
30
  $form->addField("MD", 'hidden', array('name'=>"MD", 'value'=>Mage::getSingleton('checkout/session')->getMd()));
31
+ $form->addField("TermUrl", 'hidden', array('name'=>"TermUrl", 'value'=>Mage::getUrl($szTermURL, array('_secure' => true))));
32
 
33
  $html = '<html><body>';
34
  $html.= $this->__('You will be redirected to a 3D secure form in a few seconds.');
app/code/local/Iridiumcorp/Tpg/Model/Common/PaymentFormHelper.php CHANGED
@@ -507,13 +507,14 @@
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]/';
@@ -526,6 +527,6 @@
526
  $magentoVersion = (int)$magentoVersion;
527
 
528
  return $magentoVersion;
529
- }
530
  }
531
  ?>
507
  return $boMatch;
508
  }
509
 
510
+ // TODO : REMOVE
511
  /**
512
  * Transform the string Magento version number into an integer ready for comparison
513
  *
514
  * @param unknown_type $nVersion
515
  * @return unknown
516
  */
517
+ /*public static function getVersion($magentoVersion)
518
  {
519
  //$nVersion = Mage::getVersion();
520
  $pattern = '/[^\d]/';
527
  $magentoVersion = (int)$magentoVersion;
528
 
529
  return $magentoVersion;
530
+ }*/
531
  }
532
  ?>
app/code/local/Iridiumcorp/Tpg/Model/Direct.php CHANGED
@@ -94,6 +94,7 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
94
  $error = false;
95
  $session = Mage::getSingleton('checkout/session');
96
  $mode = $this->getConfigData('mode');
 
97
 
98
  if($amount <= 0)
99
  {
@@ -161,6 +162,13 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
161
  {
162
  Mage::throwException($error);
163
  }
 
 
 
 
 
 
 
164
 
165
  return $this;
166
  }
@@ -176,6 +184,7 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
176
  {
177
  $error = '';
178
  $session = Mage::getSingleton('checkout/session');
 
179
 
180
  $MerchantID = $this->getConfigData('merchantid');
181
  $Password = $this->getConfigData('password');
@@ -329,10 +338,13 @@ 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
- ->setRedirectionmethod('_run3DSecureTransaction');
334
-
335
- $order->setIsThreeDSecurePending(true);
 
 
 
336
  break;
337
  case 5:
338
  // status code of 5 - means transaction declined
@@ -385,6 +397,13 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
385
  ->setCcApproval('FAIL')
386
  ->setAdditionalData($cdtrCardDetailsTransactionResult->getMessage());
387
  }
 
 
 
 
 
 
 
388
 
389
  return $error;
390
  }
@@ -398,6 +417,7 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
398
  public function _runHostedPaymentTransaction(Varien_Object $payment, $amount)
399
  {
400
  $session = Mage::getSingleton('checkout/session');
 
401
 
402
  $szMerchantID = $this->getConfigData('merchantid');
403
  $szPassword = $this->getConfigData('password');
@@ -411,20 +431,21 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
411
  $boCountryMandatory = 'false';
412
  $rdmResultdeliveryMethod = $this->getConfigData('resultdeliverymethod');
413
  $szServerResultURL = '';
 
414
  $boPaymentFormDisplaysResult = '';
415
 
416
  switch($rdmResultdeliveryMethod)
417
  {
418
  case Iridiumcorp_Tpg_Model_Source_ResultDeliveryMethod::RESULT_DELIVERY_METHOD_POST:
419
- $szCallbackURL = Mage::getUrl('tpg/payment/callbackhostedpayment');
420
  break;
421
  case Iridiumcorp_Tpg_Model_Source_ResultDeliveryMethod::RESULT_DELIVERY_METHOD_SERVER:
422
- $szCallbackURL = Mage::getUrl('tpg/payment/callbackhostedpayment');
423
- $szServerResultURL = Mage::getUrl('tpg/payment/serverresult');
424
  $boPaymentFormDisplaysResult = 'true';
425
  break;
426
  case Iridiumcorp_Tpg_Model_Source_ResultDeliveryMethod::RESULT_DELIVERY_METHOD_SERVER_PULL:
427
- $szCallbackURL = Mage::getUrl('tpg/payment/serverpullresult');
428
  break;
429
  }
430
 
@@ -549,10 +570,13 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
549
  ->setPaymentformdisplaysresult($boPaymentFormDisplaysResult)
550
  ->setServerresulturlcookievariables($szServerResultURLCookieVariables)
551
  ->setServerresulturlformvariables($szServerResultURLFormVariables)
552
- ->setServerresulturlquerystringvariables($szServerResultURLQueryStringVariables)
553
- ->setRedirectionmethod('_runRedirectedPaymentComplete');
554
 
555
- $payment->getOrder()->setIsHostedPaymentPending(true);
 
 
 
 
556
  }
557
 
558
  /**
@@ -565,12 +589,13 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
565
  {
566
  $GLOBALS['m_boPayInvoice'] = false;
567
  $payment->setIsTransactionPending(true);
 
568
 
569
  $szMerchantID = $this->getConfigData('merchantid');
570
  $szPassword = $this->getConfigData('password');
571
  $szPreSharedKey = $this->getConfigData('presharedkey');
572
  $hmHashMethod = $this->getConfigData('hashmethod');
573
- $szCallbackURL = Mage::getUrl('tpg/payment/callbacktransparentredirect');
574
  $order = $payment->getOrder();
575
  $billingAddress = $order->getBillingAddress();
576
  $iclISOCurrencyList = IRC_ISOCurrencies::getISOCurrencyList();
@@ -649,10 +674,13 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
649
  ->setStartdatemonth($szStartDateMonth)
650
  ->setStartdateyear($szStartDateYear)
651
  ->setIssuenumber($szIssueNumber)
652
- ->setCv2($szCV2)
653
- ->setRedirectionmethod('_runRedirectedPaymentComplete');
654
 
655
- $payment->getOrder()->setIsHostedPaymentPending(true);
 
 
 
 
656
  }
657
 
658
  /**
@@ -670,6 +698,7 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
670
  $order = $payment->getOrder();
671
  $szOrderID = $payment->getOrder()->increment_id;
672
  $session = Mage::getSingleton('checkout/session');
 
673
 
674
  $MerchantID = $this->getConfigData('merchantid');
675
  $Password = $this->getConfigData('password');
@@ -762,6 +791,12 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
762
  {
763
  $payment->setStatus(self::STATUS_APPROVED)
764
  ->setAdditionalData($message);
 
 
 
 
 
 
765
  }
766
 
767
  return $this;
@@ -772,6 +807,7 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
772
  $error = false;
773
  $message;
774
  $session = Mage::getSingleton('checkout/session');
 
775
 
776
  if($boIsHostedPaymentAction == true)
777
  {
@@ -814,6 +850,12 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
814
  {
815
  $payment->setStatus(self::STATUS_APPROVED)
816
  ->setAdditionalData($message);
 
 
 
 
 
 
817
  }
818
 
819
  return $this;
@@ -834,12 +876,12 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
834
  $session->getPareq())
835
  {
836
  // Direct (API) for 3D Secure payments
837
- $result = Mage::getUrl('tpg/payment/threedsecure');
838
  }
839
  if($session->getHashdigest())
840
  {
841
  // Hosted Payment Form and Transparent Redirect payments
842
- $result = Mage::getUrl('tpg/payment/redirect');
843
  }
844
 
845
  return $result;
@@ -900,4 +942,25 @@ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
900
 
901
  return $szISO3Code;
902
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
903
  }
94
  $error = false;
95
  $session = Mage::getSingleton('checkout/session');
96
  $mode = $this->getConfigData('mode');
97
+ $nVersion = $this->getVersion();
98
 
99
  if($amount <= 0)
100
  {
162
  {
163
  Mage::throwException($error);
164
  }
165
+ else
166
+ {
167
+ if($nVersion == 1324 || $nVersion == 1330)
168
+ {
169
+ $payment->setIsInvoicePaid(true);
170
+ }
171
+ }
172
 
173
  return $this;
174
  }
184
  {
185
  $error = '';
186
  $session = Mage::getSingleton('checkout/session');
187
+ $nVersion = $this->getVersion();
188
 
189
  $MerchantID = $this->getConfigData('merchantid');
190
  $Password = $this->getConfigData('password');
338
 
339
  Mage::getSingleton('checkout/session')->setMd($szCrossReference)
340
  ->setAcsurl($szACSURL)
341
+ ->setPareq($szPaReq);
342
+
343
+ if($nVersion >= 1410)
344
+ {
345
+ Mage::getSingleton('checkout/session')->setRedirectionmethod('_run3DSecureTransaction');
346
+ $order->setIsThreeDSecurePending(true);
347
+ }
348
  break;
349
  case 5:
350
  // status code of 5 - means transaction declined
397
  ->setCcApproval('FAIL')
398
  ->setAdditionalData($cdtrCardDetailsTransactionResult->getMessage());
399
  }
400
+ else
401
+ {
402
+ if($nVersion == 1324 || $nVersion == 1330)
403
+ {
404
+ $payment->setIsInvoicePaid(true);
405
+ }
406
+ }
407
 
408
  return $error;
409
  }
417
  public function _runHostedPaymentTransaction(Varien_Object $payment, $amount)
418
  {
419
  $session = Mage::getSingleton('checkout/session');
420
+ $nVersion = $this->getVersion();
421
 
422
  $szMerchantID = $this->getConfigData('merchantid');
423
  $szPassword = $this->getConfigData('password');
431
  $boCountryMandatory = 'false';
432
  $rdmResultdeliveryMethod = $this->getConfigData('resultdeliverymethod');
433
  $szServerResultURL = '';
434
+ // set to always true to display the result on the Hosted Payment Form
435
  $boPaymentFormDisplaysResult = '';
436
 
437
  switch($rdmResultdeliveryMethod)
438
  {
439
  case Iridiumcorp_Tpg_Model_Source_ResultDeliveryMethod::RESULT_DELIVERY_METHOD_POST:
440
+ $szCallbackURL = Mage::getUrl('tpg/payment/callbackhostedpayment', array('_secure' => true));
441
  break;
442
  case Iridiumcorp_Tpg_Model_Source_ResultDeliveryMethod::RESULT_DELIVERY_METHOD_SERVER:
443
+ $szCallbackURL = Mage::getUrl('tpg/payment/callbackhostedpayment', array('_secure' => true));
444
+ $szServerResultURL = Mage::getUrl('tpg/payment/serverresult', array('_secure' => true));
445
  $boPaymentFormDisplaysResult = 'true';
446
  break;
447
  case Iridiumcorp_Tpg_Model_Source_ResultDeliveryMethod::RESULT_DELIVERY_METHOD_SERVER_PULL:
448
+ $szCallbackURL = Mage::getUrl('tpg/payment/serverpullresult', array('_secure' => true));
449
  break;
450
  }
451
 
570
  ->setPaymentformdisplaysresult($boPaymentFormDisplaysResult)
571
  ->setServerresulturlcookievariables($szServerResultURLCookieVariables)
572
  ->setServerresulturlformvariables($szServerResultURLFormVariables)
573
+ ->setServerresulturlquerystringvariables($szServerResultURLQueryStringVariables);
 
574
 
575
+ if($nVersion >= 1410)
576
+ {
577
+ $session->setRedirectionmethod('_runRedirectedPaymentComplete');
578
+ $payment->getOrder()->setIsHostedPaymentPending(true);
579
+ }
580
  }
581
 
582
  /**
589
  {
590
  $GLOBALS['m_boPayInvoice'] = false;
591
  $payment->setIsTransactionPending(true);
592
+ $nVersion = $this->getVersion();
593
 
594
  $szMerchantID = $this->getConfigData('merchantid');
595
  $szPassword = $this->getConfigData('password');
596
  $szPreSharedKey = $this->getConfigData('presharedkey');
597
  $hmHashMethod = $this->getConfigData('hashmethod');
598
+ $szCallbackURL = Mage::getUrl('tpg/payment/callbacktransparentredirect', array('_secure' => true));
599
  $order = $payment->getOrder();
600
  $billingAddress = $order->getBillingAddress();
601
  $iclISOCurrencyList = IRC_ISOCurrencies::getISOCurrencyList();
674
  ->setStartdatemonth($szStartDateMonth)
675
  ->setStartdateyear($szStartDateYear)
676
  ->setIssuenumber($szIssueNumber)
677
+ ->setCv2($szCV2);
 
678
 
679
+ if($nVersion >= 1410)
680
+ {
681
+ Mage::getSingleton('checkout/session')->setRedirectionmethod('_runRedirectedPaymentComplete');
682
+ $payment->getOrder()->setIsHostedPaymentPending(true);
683
+ }
684
  }
685
 
686
  /**
698
  $order = $payment->getOrder();
699
  $szOrderID = $payment->getOrder()->increment_id;
700
  $session = Mage::getSingleton('checkout/session');
701
+ $nVersion = $this->getVersion();
702
 
703
  $MerchantID = $this->getConfigData('merchantid');
704
  $Password = $this->getConfigData('password');
791
  {
792
  $payment->setStatus(self::STATUS_APPROVED)
793
  ->setAdditionalData($message);
794
+
795
+ if($nVersion == 1324 || $nVersion == 1330)
796
+ {
797
+ $payment->setIsInvoicePaid(true);
798
+ Mage::getSingleton('core/session')->addSuccess($message);
799
+ }
800
  }
801
 
802
  return $this;
807
  $error = false;
808
  $message;
809
  $session = Mage::getSingleton('checkout/session');
810
+ $nVersion = $this->getVersion();
811
 
812
  if($boIsHostedPaymentAction == true)
813
  {
850
  {
851
  $payment->setStatus(self::STATUS_APPROVED)
852
  ->setAdditionalData($message);
853
+
854
+ if($nVersion == 1324 || $nVersion ==1330)
855
+ {
856
+ $payment->setIsInvoicePaid(true);
857
+ Mage::getSingleton('core/session')->addSuccess($message);
858
+ }
859
  }
860
 
861
  return $this;
876
  $session->getPareq())
877
  {
878
  // Direct (API) for 3D Secure payments
879
+ $result = Mage::getUrl('tpg/payment/threedsecure', array('_secure' => true));
880
  }
881
  if($session->getHashdigest())
882
  {
883
  // Hosted Payment Form and Transparent Redirect payments
884
+ $result = Mage::getUrl('tpg/payment/redirect', array('_secure' => true));
885
  }
886
 
887
  return $result;
942
 
943
  return $szISO3Code;
944
  }
945
+
946
+ /**
947
+ * Transform the string Magento version number into an integer ready for comparison
948
+ *
949
+ * @param unknown_type $magentoVersion
950
+ * @return unknown
951
+ */
952
+ public function getVersion()
953
+ {
954
+ $magentoVersion = Mage::getVersion();
955
+ $pattern = '/[^\d]/';
956
+ $magentoVersion = preg_replace($pattern, '', $magentoVersion);
957
+
958
+ while(strlen($magentoVersion) < 4)
959
+ {
960
+ $magentoVersion .= '0';
961
+ }
962
+ $magentoVersion = (int)$magentoVersion;
963
+
964
+ return $magentoVersion;
965
+ }
966
  }
app/code/local/Iridiumcorp/Tpg/controllers/PaymentController.php CHANGED
@@ -42,11 +42,16 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
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
  }
@@ -57,13 +62,18 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
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());
@@ -81,6 +91,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
81
  $checkout = Mage::getSingleton('checkout/type_onepage');
82
  $session = Mage::getSingleton('checkout/session');
83
  $szPaymentProcessorResponse = '';
 
84
 
85
  try
86
  {
@@ -94,7 +105,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
94
  {
95
  $boError = true;
96
  Mage::logException($exc);
97
-
98
  if( isset($_SESSION['tpg_message']) )
99
  {
100
  $szMessage = $_SESSION['tpg_message'];
@@ -110,26 +121,36 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
110
  $order = Mage::getModel('sales/order');
111
  $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
112
 
113
- if ($boError)
114
  {
115
  if($szPaymentProcessorResponse != null &&
116
  $szPaymentProcessorResponse != '')
117
  {
118
- $szMessage = $szMessage.'<br/>'.$szPaymentProcessorResponse;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  }
120
 
121
- if($order)
122
- {
123
- $orderState = 'pending_payment';
124
- $orderStatus = 'irc_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');
134
  }
135
  else
@@ -142,14 +163,21 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
142
  {
143
  $order->sendNewOrderEmail();
144
  }
145
-
146
- $this->_subtractOrderedItemsFromStock($order);
147
- $this->_updateInvoices($order, $szPaymentProcessorResponse);
148
 
149
- if($szPaymentProcessorResponse != '')
150
  {
151
- Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
 
 
 
 
 
 
 
 
 
152
  }
 
153
  $this->_redirect('checkout/onepage/success', array('_secure' => true));
154
  }
155
  }
@@ -169,6 +197,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
169
  $szPaymentProcessorResponse = '';
170
  $order = Mage::getModel('sales/order');
171
  $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
 
172
 
173
  try
174
  {
@@ -231,17 +260,27 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
231
  $szNotificationMessage = $szNotificationMessage.'<br/>'.$szPaymentProcessorResponse;
232
  }
233
 
234
- if($order)
235
- {
236
- $orderState = 'pending_payment';
237
- $orderStatus = 'irc_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
@@ -255,12 +294,18 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
255
  $order->sendNewOrderEmail();
256
  }
257
 
258
- $this->_subtractOrderedItemsFromStock($order);
259
- $this->_updateInvoices($order, $szPaymentProcessorResponse);
 
 
 
260
 
261
- if($szPaymentProcessorResponse != '')
262
  {
263
- Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
 
 
 
264
  }
265
  $this->_redirect('checkout/onepage/success', array('_secure' => true));
266
  }
@@ -277,6 +322,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
277
  $checkout = Mage::getSingleton('checkout/type_onepage');
278
  $szOrderID = $this->getRequest()->getPost('OrderID');
279
  $szMessage = $this->getRequest()->getPost('Message');
 
280
 
281
  try
282
  {
@@ -318,8 +364,12 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
318
  if($this->getRequest()->getPost('StatusCode') == '0')
319
  {
320
  Mage::getSingleton('checkout/session')->clear();
321
- $this->_subtractOrderedItemsFromStock($order);
322
- $this->_updateInvoices($order, $szMessage);
 
 
 
 
323
  }
324
 
325
  $this->getResponse()->setBody('StatusCode=0');
@@ -352,6 +402,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
352
  $nStartIndex = strpos($szURLVariableString, "?");
353
  $order = Mage::getModel('sales/order');
354
  $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
 
355
 
356
  if(!is_int($nStartIndex))
357
  {
@@ -443,17 +494,27 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
443
 
444
  if($szErrorMessage)
445
  {
446
- if($order)
447
  {
448
- $orderState = 'pending_payment';
449
- $orderStatus = 'cardsave_failed_hosted_payment';
450
- $order->setCustomerNote(Mage::helper('cardsaveonlinepayments')->__('Hosted Payment Failed'));
451
- $order->setState($orderState, $orderStatus, $szErrorMessage, false);
452
- $order->save();
 
 
 
 
 
 
 
 
 
 
 
453
  }
454
 
455
  $this->_clearSessionVariables();
456
- Mage::getSingleton('core/session')->addError($szErrorMessage);
457
  $this->_redirect('checkout/onepage/failure');
458
  }
459
  else
@@ -467,10 +528,16 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
467
  $order->sendNewOrderEmail();
468
  }
469
 
470
- $this->_subtractOrderedItemsFromStock($order);
471
- $this->_updateInvoices($order, $szMessage);
 
 
 
472
 
473
- Mage::getSingleton('core/session')->addSuccess('Payment Processor Response: '.$szMessage);
 
 
 
474
  $this->_redirect('checkout/onepage/success', array('_secure' => true));
475
  }
476
  }
@@ -484,6 +551,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
484
  $model = Mage::getModel('tpg/direct');
485
  $order = Mage::getModel('sales/order');
486
  $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
 
487
 
488
  try
489
  {
@@ -517,17 +585,27 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
517
  $error = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_260;
518
  Mage::logException($exc);
519
 
520
- if($order)
521
- {
522
- $orderState = 'pending_payment';
523
- $orderStatus = 'irc_failed_hosted_payment';
524
- $order->setCustomerNote(Mage::helper('tpg')->__('Transparent Redirect Payment Failed'));
525
- $order->setState($orderState, $orderStatus, $exc->getMessage(), false);
526
- $order->save();
527
- }
 
 
 
 
 
 
 
 
 
 
 
528
 
529
  $this->_clearSessionVariables();
530
- Mage::getSingleton('core/session')->addError($error);
531
  $this->_redirect('checkout/onepage/failure');
532
  }
533
  }
@@ -583,7 +661,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
583
  $szCrossReference = $this->getRequest()->getPost('MD');
584
  $szMerchantID = $model->getConfigData('merchantid');
585
  $szTransactionDateTime = date('Y-m-d H:i:s P');
586
- $szCallbackURL = Mage::getUrl('tpg/payment/callbacktransparentredirect');
587
  $szHashDigest = IRC_PaymentFormHelper::calculatePostThreeDSecureAuthenticationHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $szPaRES, $szCrossReference, $szTransactionDateTime, $szCallbackURL);
588
 
589
  Mage::getSingleton('checkout/session')->setHashdigest($szHashDigest)
@@ -608,6 +686,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
608
  $szPaymentProcessorResponse = '';
609
  $order = Mage::getModel('sales/order');
610
  $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
 
611
 
612
  try
613
  {
@@ -665,17 +744,27 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
665
  $szNotificationMessage = $szNotificationMessage.'<br/>'.$szPaymentProcessorResponse;
666
  }
667
 
668
- if($order)
669
- {
670
- $orderState = 'pending_payment';
671
- $orderStatus = 'irc_failed_hosted_payment';
672
- $order->setCustomerNote(Mage::helper('tpg')->__('Transparent Redirect Payment Failed'));
673
- $order->setState($orderState, $orderStatus, $szPaymentProcessorResponse, false);
674
- $order->save();
675
- }
 
 
 
 
 
 
 
 
 
 
 
676
 
677
  $this->_clearSessionVariables();
678
- Mage::getSingleton('core/session')->addError($szNotificationMessage);
679
  $this->_redirect('checkout/onepage/failure');
680
  }
681
  else
@@ -688,12 +777,18 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
688
  $order->sendNewOrderEmail();
689
  }
690
 
691
- $this->_subtractOrderedItemsFromStock($order);
692
- $this->_updateInvoices($order, $szPaymentProcessorResponse);
 
 
 
693
 
694
- if($szPaymentProcessorResponse != '')
695
  {
696
- Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
 
 
 
697
  }
698
  $this->_redirect('checkout/onepage/success', array('_secure' => true));
699
  }
@@ -706,14 +801,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
706
  */
707
  private function _subtractOrderedItemsFromStock($order)
708
  {
709
- /*$items = $order->getAllItems();
710
- foreach ($items as $itemId => $item)
711
- {
712
- Mage::log('paymentcontroller.php - _subtractOrderedItemsFromStock called');
713
- // subtract ordered quantity of the item from stock
714
- Mage::getSingleton('cataloginventory/stock')->registerItemSale($item);
715
- }*/
716
- $nVersion = IRC_PaymentFormHelper::getVersion(Mage::getVersion());
717
  $isCustomStockManagementEnabled = Mage::getModel('tpg/direct')->getConfigData('customstockmanagementenabled');
718
 
719
  if($nVersion >= 1410 &&
@@ -745,7 +833,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
745
  */
746
  private function _addOrderedItemsToStock($order)
747
  {
748
- $nVersion = IRC_PaymentFormHelper::getVersion(Mage::getVersion());
749
  $isCustomStockManagementEnabled = Mage::getModel('tpg/direct')->getConfigData('customstockmanagementenabled');
750
 
751
  if($nVersion >= 1410 &&
@@ -770,10 +858,7 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
770
  }
771
  }
772
 
773
- /**
774
- * Clear the custom session variables after a payment attempt
775
- *
776
- */
777
  private function _clearSessionVariables()
778
  {
779
  // clear all the custom session variables used in the payment module in case of a failed payment
@@ -810,9 +895,9 @@ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Actio
810
 
811
  foreach ($invoices as $invoice)
812
  {
 
813
  $invoice->pay()->save();
814
  }
815
-
816
  // add a comment to the order comments
817
  //$order->addStatusToHistory($status, $message, false);
818
  $order->setState($orderState, 'irc_paid', $message, false);
42
  */
43
  public function redirectAction()
44
  {
45
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
46
+
47
+ if($nVersion >= 1410)
48
  {
49
+ // need to re-add the ordered item quantity to stock as per not completed 3DS transaction
50
+ if(!Mage::getSingleton('checkout/session')->getPares())
51
+ {
52
+ $order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
53
+ $this->_addOrderedItemsToStock($order);
54
+ }
55
  }
56
  $this->getResponse()->setBody($this->getLayout()->createBlock('tpg/redirect')->toHtml());
57
  }
62
  */
63
  public function threedsecureAction()
64
  {
65
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
66
 
67
+ if($nVersion >= 1410)
 
68
  {
69
+ $mode = Mage::getModel('tpg/direct')->getConfigData('mode');
70
+
71
+ // need to re-add the ordered item quantity to stock as per not completed 3DS transaction
72
+ if($mode != Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_TRANSPARENT_REDIRECT)
73
+ {
74
+ $order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
75
+ $this->_addOrderedItemsToStock($order);
76
+ }
77
  }
78
 
79
  $this->getResponse()->setBody($this->getLayout()->createBlock('tpg/threedsecure')->toHtml());
91
  $checkout = Mage::getSingleton('checkout/type_onepage');
92
  $session = Mage::getSingleton('checkout/session');
93
  $szPaymentProcessorResponse = '';
94
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
95
 
96
  try
97
  {
105
  {
106
  $boError = true;
107
  Mage::logException($exc);
108
+
109
  if( isset($_SESSION['tpg_message']) )
110
  {
111
  $szMessage = $_SESSION['tpg_message'];
121
  $order = Mage::getModel('sales/order');
122
  $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
123
 
124
+ if ($boError)
125
  {
126
  if($szPaymentProcessorResponse != null &&
127
  $szPaymentProcessorResponse != '')
128
  {
129
+ $szMessage .= '<br/>'.$szPaymentProcessorResponse;
130
+ }
131
+
132
+ if($nVersion >= 1410)
133
+ {
134
+ if($order)
135
+ {
136
+ $orderState = 'pending_payment';
137
+ $orderStatus = 'irc_failed_threed_secure';
138
+ $order->setCustomerNote(Mage::helper('tpg')->__('3D Secure Authentication Failed'));
139
+ $order->setState($orderState, $orderStatus, $szPaymentProcessorResponse, false);
140
+ $order->save();
141
+ }
142
+ }
143
+ if($nVersion == 1324 || $nVersion == 1330)
144
+ {
145
+ Mage::getSingleton('checkout/session')->addError($szMessage);
146
+ }
147
+ else
148
+ {
149
+ Mage::getSingleton('core/session')->addError($szMessage);
150
  }
151
 
 
 
 
 
 
 
 
 
152
  $this->_clearSessionVariables();
153
+ // report out an fatal error
 
 
154
  $this->_redirect('checkout/onepage/failure');
155
  }
156
  else
163
  {
164
  $order->sendNewOrderEmail();
165
  }
 
 
 
166
 
167
+ if($nVersion >= 1410)
168
  {
169
+ $this->_subtractOrderedItemsFromStock($order);
170
+ $this->_updateInvoices($order, $szPaymentProcessorResponse);
171
+ }
172
+
173
+ if($nVersion != 1324 && $nVersion != 1330)
174
+ {
175
+ if($szPaymentProcessorResponse != '')
176
+ {
177
+ Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
178
+ }
179
  }
180
+
181
  $this->_redirect('checkout/onepage/success', array('_secure' => true));
182
  }
183
  }
197
  $szPaymentProcessorResponse = '';
198
  $order = Mage::getModel('sales/order');
199
  $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
200
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
201
 
202
  try
203
  {
260
  $szNotificationMessage = $szNotificationMessage.'<br/>'.$szPaymentProcessorResponse;
261
  }
262
 
263
+ if($nVersion >= 1410)
264
+ {
265
+ if($order)
266
+ {
267
+ $orderState = 'pending_payment';
268
+ $orderStatus = 'irc_failed_hosted_payment';
269
+ $order->setCustomerNote(Mage::helper('tpg')->__('Hosted Payment Failed'));
270
+ $order->setState($orderState, $orderStatus, $szPaymentProcessorResponse, false);
271
+ $order->save();
272
+ }
273
+ }
274
+ if($nVersion == 1324 || $nVersion == 1330)
275
+ {
276
+ Mage::getSingleton('checkout/session')->addError($szNotificationMessage);
277
+ }
278
+ else
279
+ {
280
+ Mage::getSingleton('core/session')->addError($szNotificationMessage);
281
+ }
282
 
283
  $this->_clearSessionVariables();
 
284
  $this->_redirect('checkout/onepage/failure');
285
  }
286
  else
294
  $order->sendNewOrderEmail();
295
  }
296
 
297
+ if($nVersion >= 1410)
298
+ {
299
+ $this->_subtractOrderedItemsFromStock($order);
300
+ $this->_updateInvoices($order, $szPaymentProcessorResponse);
301
+ }
302
 
303
+ if($nVersion != 1324 && $nVersion != 1330)
304
  {
305
+ if($szPaymentProcessorResponse != '')
306
+ {
307
+ Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
308
+ }
309
  }
310
  $this->_redirect('checkout/onepage/success', array('_secure' => true));
311
  }
322
  $checkout = Mage::getSingleton('checkout/type_onepage');
323
  $szOrderID = $this->getRequest()->getPost('OrderID');
324
  $szMessage = $this->getRequest()->getPost('Message');
325
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
326
 
327
  try
328
  {
364
  if($this->getRequest()->getPost('StatusCode') == '0')
365
  {
366
  Mage::getSingleton('checkout/session')->clear();
367
+
368
+ if($nVersion >= 1410)
369
+ {
370
+ $this->_subtractOrderedItemsFromStock($order);
371
+ $this->_updateInvoices($order, $szMessage);
372
+ }
373
  }
374
 
375
  $this->getResponse()->setBody('StatusCode=0');
402
  $nStartIndex = strpos($szURLVariableString, "?");
403
  $order = Mage::getModel('sales/order');
404
  $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
405
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
406
 
407
  if(!is_int($nStartIndex))
408
  {
494
 
495
  if($szErrorMessage)
496
  {
497
+ if($nVersion >= 1410)
498
  {
499
+ if($order)
500
+ {
501
+ $orderState = 'pending_payment';
502
+ $orderStatus = 'irc_failed_hosted_payment';
503
+ $order->setCustomerNote(Mage::helper('tpg')->__('Hosted Payment Failed'));
504
+ $order->setState($orderState, $orderStatus, $szErrorMessage, false);
505
+ $order->save();
506
+ }
507
+ }
508
+ if($nVersion == 1324 || $nVersion == 1330)
509
+ {
510
+ Mage::getSingleton('checkout/session')->addError($szErrorMessage);
511
+ }
512
+ else
513
+ {
514
+ Mage::getSingleton('core/session')->addError($szErrorMessage);
515
  }
516
 
517
  $this->_clearSessionVariables();
 
518
  $this->_redirect('checkout/onepage/failure');
519
  }
520
  else
528
  $order->sendNewOrderEmail();
529
  }
530
 
531
+ if($nVersion >= 1410)
532
+ {
533
+ $this->_subtractOrderedItemsFromStock($order);
534
+ $this->_updateInvoices($order, $szMessage);
535
+ }
536
 
537
+ if($nVersion != 1324 && $nVersion != 1330)
538
+ {
539
+ Mage::getSingleton('core/session')->addSuccess('Payment Processor Response: '.$szMessage);
540
+ }
541
  $this->_redirect('checkout/onepage/success', array('_secure' => true));
542
  }
543
  }
551
  $model = Mage::getModel('tpg/direct');
552
  $order = Mage::getModel('sales/order');
553
  $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
554
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
555
 
556
  try
557
  {
585
  $error = Iridiumcorp_Tpg_Model_Common_GlobalErrors::ERROR_260;
586
  Mage::logException($exc);
587
 
588
+ if($nVersion >= 1410)
589
+ {
590
+ if($order)
591
+ {
592
+ $orderState = 'pending_payment';
593
+ $orderStatus = 'irc_failed_hosted_payment';
594
+ $order->setCustomerNote(Mage::helper('tpg')->__('Transparent Redirect Payment Failed'));
595
+ $order->setState($orderState, $orderStatus, $exc->getMessage(), false);
596
+ $order->save();
597
+ }
598
+ }
599
+ if($nVersion == 1324 || $nVersion == 1330)
600
+ {
601
+ Mage::getSingleton('checkout/session')->addError($error);
602
+ }
603
+ else
604
+ {
605
+ Mage::getSingleton('core/session')->addError($error);
606
+ }
607
 
608
  $this->_clearSessionVariables();
 
609
  $this->_redirect('checkout/onepage/failure');
610
  }
611
  }
661
  $szCrossReference = $this->getRequest()->getPost('MD');
662
  $szMerchantID = $model->getConfigData('merchantid');
663
  $szTransactionDateTime = date('Y-m-d H:i:s P');
664
+ $szCallbackURL = Mage::getUrl('tpg/payment/callbacktransparentredirect', array('_secure' => true));
665
  $szHashDigest = IRC_PaymentFormHelper::calculatePostThreeDSecureAuthenticationHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $szPaRES, $szCrossReference, $szTransactionDateTime, $szCallbackURL);
666
 
667
  Mage::getSingleton('checkout/session')->setHashdigest($szHashDigest)
686
  $szPaymentProcessorResponse = '';
687
  $order = Mage::getModel('sales/order');
688
  $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
689
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
690
 
691
  try
692
  {
744
  $szNotificationMessage = $szNotificationMessage.'<br/>'.$szPaymentProcessorResponse;
745
  }
746
 
747
+ if($nVersion >= 1410)
748
+ {
749
+ if($order)
750
+ {
751
+ $orderState = 'pending_payment';
752
+ $orderStatus = 'irc_failed_hosted_payment';
753
+ $order->setCustomerNote(Mage::helper('tpg')->__('Transparent Redirect Payment Failed'));
754
+ $order->setState($orderState, $orderStatus, $szPaymentProcessorResponse, false);
755
+ $order->save();
756
+ }
757
+ }
758
+ if($nVersion == 1324 || $nVersion == 1330)
759
+ {
760
+ Mage::getSingleton('checkout/session')->addError($szNotificationMessage);
761
+ }
762
+ else
763
+ {
764
+ Mage::getSingleton('core/session')->addError($szNotificationMessage);
765
+ }
766
 
767
  $this->_clearSessionVariables();
 
768
  $this->_redirect('checkout/onepage/failure');
769
  }
770
  else
777
  $order->sendNewOrderEmail();
778
  }
779
 
780
+ if($nVersion >= 1410)
781
+ {
782
+ $this->_subtractOrderedItemsFromStock($order);
783
+ $this->_updateInvoices($order, $szPaymentProcessorResponse);
784
+ }
785
 
786
+ if($nVersion != 1324 && $nVersion != 1330)
787
  {
788
+ if($szPaymentProcessorResponse != '')
789
+ {
790
+ Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
791
+ }
792
  }
793
  $this->_redirect('checkout/onepage/success', array('_secure' => true));
794
  }
801
  */
802
  private function _subtractOrderedItemsFromStock($order)
803
  {
804
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
 
 
 
 
 
 
 
805
  $isCustomStockManagementEnabled = Mage::getModel('tpg/direct')->getConfigData('customstockmanagementenabled');
806
 
807
  if($nVersion >= 1410 &&
833
  */
834
  private function _addOrderedItemsToStock($order)
835
  {
836
+ $nVersion = Mage::getModel('tpg/direct')->getVersion();
837
  $isCustomStockManagementEnabled = Mage::getModel('tpg/direct')->getConfigData('customstockmanagementenabled');
838
 
839
  if($nVersion >= 1410 &&
858
  }
859
  }
860
 
861
+
 
 
 
862
  private function _clearSessionVariables()
863
  {
864
  // clear all the custom session variables used in the payment module in case of a failed payment
895
 
896
  foreach ($invoices as $invoice)
897
  {
898
+ // set the invoice state to be "Paid"
899
  $invoice->pay()->save();
900
  }
 
901
  // add a comment to the order comments
902
  //$order->addStatusToHistory($status, $message, false);
903
  $order->setState($orderState, 'irc_paid', $message, false);
package.xml CHANGED
@@ -1,18 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Iridiumcorp_Tpg</name>
4
- <version>1.10.4</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Iridiumcorp payment extension for compatible with Magento v 1.4.1 and 1.4.1.1</summary>
10
  <description>Fully supports 3D secure transactions. Also supports all of the integration methods provided by Iridiumcorp.</description>
11
- <notes>Fixed /base template path for frontend files</notes>
 
 
12
  <authors><author><name>benjib98</name><user>auto-converted</user><email>support@iridiumcorp.co.uk</email></author></authors>
13
- <date>2011-01-31</date>
14
- <time>12:33:24</time>
15
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="base"><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 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="base"><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 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="base"><dir name="default"><dir name="images"><file name="iridium_corporation.jpg" hash="589faaa1b7e80b32a425175ecfc3b455"/></dir></dir></dir><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="6e5a6db08b9bbaf959ec31a20ec5ffc2"/></dir><dir name="Model"><dir name="Order"><file name="Invoice.php" hash="14bd6c6a2e0b632fa669b937d0b23f78"/><file name="Payment.php" hash="c6eac0f4c3e0d7bbdd51833773d3cc15"/></dir><dir name="Service"><file name="Quote.php" hash="bf113cd154e23dd9c8df0946adf9b94f"/></dir><file name="Order.php" hash="a57c4bd661dbc322d5bd18aa2f51dd67"/></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="2bcd1917dabbcd88700472451585a49e"/></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"><dir name="Common"><dir name="ThePaymentGateway"><file name="PaymentSystem.php" hash="4ad38bdb85f865e967153d9f253390cd"/><file name="SOAP.php" hash="504dcb0cb7c60c134b25652881349cc3"/><file name="TPG_Common.php" hash="df1033ef855c7e0e715076a105acb84a"/></dir><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><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><file name="Direct.php" hash="5581007f591f1a6dc9b16716fc12d223"/><file name="Request.php" hash="a96e462ed3c1882048ea45f2c3a6662c"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Iridiumcorp_All.xml" hash="f1a85eaa7631af1906f461b662519732"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Iridiumcorp_Tpg</name>
4
+ <version>1.11.0</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Iridiumcorp payment extension compatible with Magento v1.3 and v1.4</summary>
10
  <description>Fully supports 3D secure transactions. Also supports all of the integration methods provided by Iridiumcorp.</description>
11
+ <notes>Secure URL fix for 3D Secure payments
12
+ Updated Magento v1.3.2.4 and v1.3.3.0 compatible payment extension.
13
+ base/default theme path applied for v1.4 compatibility</notes>
14
  <authors><author><name>benjib98</name><user>auto-converted</user><email>support@iridiumcorp.co.uk</email></author></authors>
15
+ <date>2011-02-07</date>
16
+ <time>17:26:46</time>
17
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="base"><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 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="base"><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 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="base"><dir name="default"><dir name="images"><file name="iridium_corporation.jpg" hash="589faaa1b7e80b32a425175ecfc3b455"/></dir></dir></dir><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="47de7ef027476c184a01f6c249a56065"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="aaa95b6e1d6e145940bf9ba9bbe1dc0f"/></dir><dir name="Model"><dir name="Type"><file name="Onepage.php" hash="9effa492d1d9a769a170ae34f36ccea6"/></dir></dir></dir><dir name="Sales"><dir name="etc"><file name="config.xml" hash="6e5a6db08b9bbaf959ec31a20ec5ffc2"/></dir><dir name="Model"><dir name="Order"><file name="Invoice.php" hash="1d4318c7b307f40b4a208dcb116fa14b"/><file name="Payment.php" hash="135a0077bc390878552897c39aa2e431"/></dir><dir name="Service"><file name="Quote.php" hash="d1b341b13a74ea6db2b87f098b4caf9a"/></dir><file name="Order.php" hash="a57c4bd661dbc322d5bd18aa2f51dd67"/></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="5e753e1e1bbf0ada18f7292d4031da97"/></dir><dir name="controllers"><file name="PaymentController.php" hash="ebb0c817bbbef9134b31363594a4ff74"/></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"><dir name="Common"><dir name="ThePaymentGateway"><file name="PaymentSystem.php" hash="4ad38bdb85f865e967153d9f253390cd"/><file name="SOAP.php" hash="504dcb0cb7c60c134b25652881349cc3"/><file name="TPG_Common.php" hash="df1033ef855c7e0e715076a105acb84a"/></dir><file name="GlobalErrors.php" hash="a9c7bab60ebfe87967c794194e1e7208"/><file name="ISOCountries.php" hash="fc63d76fbe25458ba351f114782074cb"/><file name="ISOCurrencies.php" hash="89ac1e124e89c0713ef43a0cf6dd0e2b"/><file name="PaymentFormHelper.php" hash="d1a9cb006cafdb13c2d368620630aaf3"/></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><file name="Direct.php" hash="a06b0fb97d2e1d536506ac723d22749e"/><file name="Request.php" hash="a96e462ed3c1882048ea45f2c3a6662c"/></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>