Advertisement
Guest User

Untitled

a guest
Jul 11th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. <?php
  2. /*
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 3.5.0.0
  8. * @ Author : DeZender
  9. * @ Release on : 22.06.2018
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class Mage_Winbnk_WpayController extends Mage_Core_Controller_Front_Action
  15. {
  16. protected function _expireAjax()
  17. {
  18. if (!Mage::getsingleton('checkout/session')->getQuote()->hasItems()) {
  19. $this->getResponse()->setHeader('HTTP/1.1', '403 Session Expired');
  20.  
  21. exit();
  22. }
  23. }
  24.  
  25. public function getWinbnk()
  26. {
  27. return Mage::getsingleton('winbnk/wpay');
  28. }
  29.  
  30. public function setWinbnkResponse($response)
  31. {
  32. if (count($response)) {
  33. $this->_winbnkResponse = $response;
  34. } else {
  35. $this->_winbnkResponse = null;
  36. }
  37.  
  38. return $this;
  39. }
  40.  
  41. public function redirectAction()
  42. {
  43. $session = Mage::getsingleton('checkout/session');
  44. $session->setWpayQuoteId($session->getQuoteId());
  45. $this->getResponse()->setBody($this->getLayout()->createBlock('winbnk/wpay_redirect')->toHtml());
  46. $session->unsQuoteId();
  47. $session->unsRedirectUrl();
  48. }
  49.  
  50. public function WpokAction()
  51. {
  52. $session = Mage::getsingleton('checkout/session');
  53. $session->setWpayQuoteId($session->getQuoteId());
  54.  
  55. if ($this->getRequest()->isPost()) {
  56. $this->setWinbnkResponse($this->getRequest()->getPost());
  57.  
  58. if ($this->getWinbnk()->getConfigData('debug')) {
  59. $responseData = '';
  60.  
  61. foreach ($this->_winbnkResponse as $key => $value) {
  62. $responseData .= $key . '=' . $value;
  63. }
  64. $debug = Mage::getmodel('paygate/authorizenet_debug')->setResponseBody($responseData)->save();
  65. }
  66.  
  67. $orderID = explode(':', $this->_winbnkResponse['Parameters']);
  68. $order = Mage::getmodel('sales/order');
  69. $order->loadByIncrementId($orderID[0]);
  70.  
  71. if ($this->_winbnkResponse['ResponseCode'] == '00' || $this->_winbnkResponse['ResponseCode'] == '08' || $this->_winbnkResponse['ResponseCode'] == '10' || $this->_winbnkResponse['ResponseCode'] == '11' || $this->_winbnkResponse['ResponseCode'] == '16') {
  72. $charge = number_format($order->getBaseGrandTotal(), 2, '.', '');
  73. $payment = $order->getPayment();
  74.  
  75. if ($this->getWinbnk()->getConfigData('paytype') == 'Authorize') {
  76. $payment->setTransactionId($this->_winbnkResponse['TransactionId'])->setParentTransactionId(null)->setIsTransactionClosed(1)->registerAuthorizationNotification($charge);
  77. } else {
  78. $payment->setTransactionId($this->_winbnkResponse['TransactionId'])->setParentTransactionId(null)->setIsTransactionClosed(1)->registerCaptureNotification($charge);
  79. }
  80.  
  81. $orderComment = 'SupportReferenceID: ' . $this->_winbnkResponse['SupportReferenceID'] . '<br />';
  82. $orderComment .= 'Installments: ' . $orderID[1] . '<br />';
  83. $orderComment .= 'Status: ' . $this->_winbnkResponse['StatusFlag'] . '<br />';
  84. $orderComment .= 'TransactionId: ' . $this->_winbnkResponse['TransactionId'] . '<br />';
  85. $orderComment .= 'ResponseCode: ' . $this->_winbnkResponse['ResponseCode'] . '<br />';
  86. $orderComment .= 'ResponseDescription: ' . $this->_winbnkResponse['ResponseDescription'] . '<br />';
  87.  
  88. if ($this->getWinbnk()->getConfigData('order_status') == 'complete') {
  89. $order->setData('state', 'complete');
  90. $order->setStatus('complete');
  91. $history = $order->addStatusHistoryComment($orderComment, false);
  92. $history->setIsCustomerNotified(true);
  93. } else {
  94. $newstate = $this->getWinbnk()->getConfigData('order_status');
  95. $order->setData('state', $newstate);
  96. $order->setStatus($newstate);
  97. $history = $order->addStatusHistoryComment($orderComment, false);
  98. $history->setIsCustomerNotified(true);
  99. }
  100.  
  101. if ($order->canInvoice()) {
  102. $order->getPayment()->setSkipTransactionCreation(false);
  103. $invoice = $order->prepareInvoice();
  104. $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
  105. $invoice->register();
  106. Mage::getmodel('core/resource_transaction')->addObject($invoice)->addObject($order)->save();
  107. ..............................................................
  108. ...................................
  109. ...........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement