Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP5 Decoder for ionCube Encoder)
- *
- * @ Version : 3.5.0.0
- * @ Author : DeZender
- * @ Release on : 22.06.2018
- * @ Official site : http://DeZender.Net
- *
- */
- class Mage_Winbnk_WpayController extends Mage_Core_Controller_Front_Action
- {
- protected function _expireAjax()
- {
- if (!Mage::getsingleton('checkout/session')->getQuote()->hasItems()) {
- $this->getResponse()->setHeader('HTTP/1.1', '403 Session Expired');
- exit();
- }
- }
- public function getWinbnk()
- {
- return Mage::getsingleton('winbnk/wpay');
- }
- public function setWinbnkResponse($response)
- {
- if (count($response)) {
- $this->_winbnkResponse = $response;
- } else {
- $this->_winbnkResponse = null;
- }
- return $this;
- }
- public function redirectAction()
- {
- $session = Mage::getsingleton('checkout/session');
- $session->setWpayQuoteId($session->getQuoteId());
- $this->getResponse()->setBody($this->getLayout()->createBlock('winbnk/wpay_redirect')->toHtml());
- $session->unsQuoteId();
- $session->unsRedirectUrl();
- }
- public function WpokAction()
- {
- $session = Mage::getsingleton('checkout/session');
- $session->setWpayQuoteId($session->getQuoteId());
- if ($this->getRequest()->isPost()) {
- $this->setWinbnkResponse($this->getRequest()->getPost());
- if ($this->getWinbnk()->getConfigData('debug')) {
- $responseData = '';
- foreach ($this->_winbnkResponse as $key => $value) {
- $responseData .= $key . '=' . $value;
- }
- $debug = Mage::getmodel('paygate/authorizenet_debug')->setResponseBody($responseData)->save();
- }
- $orderID = explode(':', $this->_winbnkResponse['Parameters']);
- $order = Mage::getmodel('sales/order');
- $order->loadByIncrementId($orderID[0]);
- if ($this->_winbnkResponse['ResponseCode'] == '00' || $this->_winbnkResponse['ResponseCode'] == '08' || $this->_winbnkResponse['ResponseCode'] == '10' || $this->_winbnkResponse['ResponseCode'] == '11' || $this->_winbnkResponse['ResponseCode'] == '16') {
- $charge = number_format($order->getBaseGrandTotal(), 2, '.', '');
- $payment = $order->getPayment();
- if ($this->getWinbnk()->getConfigData('paytype') == 'Authorize') {
- $payment->setTransactionId($this->_winbnkResponse['TransactionId'])->setParentTransactionId(null)->setIsTransactionClosed(1)->registerAuthorizationNotification($charge);
- } else {
- $payment->setTransactionId($this->_winbnkResponse['TransactionId'])->setParentTransactionId(null)->setIsTransactionClosed(1)->registerCaptureNotification($charge);
- }
- $orderComment = 'SupportReferenceID: ' . $this->_winbnkResponse['SupportReferenceID'] . '<br />';
- $orderComment .= 'Installments: ' . $orderID[1] . '<br />';
- $orderComment .= 'Status: ' . $this->_winbnkResponse['StatusFlag'] . '<br />';
- $orderComment .= 'TransactionId: ' . $this->_winbnkResponse['TransactionId'] . '<br />';
- $orderComment .= 'ResponseCode: ' . $this->_winbnkResponse['ResponseCode'] . '<br />';
- $orderComment .= 'ResponseDescription: ' . $this->_winbnkResponse['ResponseDescription'] . '<br />';
- if ($this->getWinbnk()->getConfigData('order_status') == 'complete') {
- $order->setData('state', 'complete');
- $order->setStatus('complete');
- $history = $order->addStatusHistoryComment($orderComment, false);
- $history->setIsCustomerNotified(true);
- } else {
- $newstate = $this->getWinbnk()->getConfigData('order_status');
- $order->setData('state', $newstate);
- $order->setStatus($newstate);
- $history = $order->addStatusHistoryComment($orderComment, false);
- $history->setIsCustomerNotified(true);
- }
- if ($order->canInvoice()) {
- $order->getPayment()->setSkipTransactionCreation(false);
- $invoice = $order->prepareInvoice();
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
- $invoice->register();
- Mage::getmodel('core/resource_transaction')->addObject($invoice)->addObject($order)->save();
- ..............................................................
- ...................................
- ...........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement