diff --git a/public_html/extensions/2checkout/core/hooks.php b/public_html/extensions/2checkout/core/hooks.php
new file mode 100644
index 0000000000..0160680a48
--- /dev/null
+++ b/public_html/extensions/2checkout/core/hooks.php
@@ -0,0 +1,49 @@
+
+
+ UPGRADE NOTE:
+ Do not edit or add to this file if you wish to upgrade AbanteCart to newer
+ versions in the future. If you wish to customize AbanteCart for your
+ needs please refer to http://www.AbanteCart.com for more information.
+------------------------------------------------------------------------------*/
+
+
+class Extension2Checkout extends Extension
+{
+ //payment confirmation pending page
+ public function onControllerPagesCheckoutSuccess_InitData()
+ {
+ $that = $this->baseObject;
+ $order_id = (int)$that->session->data['order_id'];
+ if (!$order_id || $that->session->data['2checkout_pending_ipn_skip']) {
+ return null;
+ }
+ $that->loadModel('checkout/order');
+ $order_info = $that->model_checkout_order->getOrder($order_id);
+ //do nothing if order confirmed or it's not created with paypal standart
+ if ((int)$order_info['order_status_id'] != 0 || $order_info['payment_method_key'] != '2checkout') {
+ return null;
+ }
+ //set sign to prevent double redirect (see above)
+ $that->session->data['2checkout_pending_ipn_skip'] = true;
+ redirect($that->html->getSecureURL('extension/2checkout/pending_payment'));
+ }
+
+ //delete sign after success
+ public function onControllerPagesCheckoutSuccess_UpdateData()
+ {
+ unset($this->baseObject->session->data['2checkout_pending_ipn_skip']);
+ }
+
+}
diff --git a/public_html/extensions/2checkout/main.php b/public_html/extensions/2checkout/main.php
index d45c74c9de..50aba9224d 100755
--- a/public_html/extensions/2checkout/main.php
+++ b/public_html/extensions/2checkout/main.php
@@ -8,7 +8,7 @@
Copyright © 2011-2018 Belavier Commerce LLC
This source file is subject to Open Software License (OSL 3.0)
- Lincence details is bundled with this package in the file LICENSE.txt.
+ Licence details is bundled with this package in the file LICENSE.txt.
It is also available at this URL:
@@ -17,10 +17,7 @@
versions in the future. If you wish to customize AbanteCart for your
needs please refer to http://www.AbanteCart.com for more information.
------------------------------------------------------------------------------*/
-if (!defined('DIR_CORE')) {
- header('Location: static_pages/');
-}
-
+require_once(__DIR__.DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.'hooks.php');
$controllers = array(
'storefront' => array('responses/extension/2checkout'),
'admin' => array(),
@@ -43,6 +40,7 @@
$templates = array(
'storefront' => array(
'responses/2checkout.tpl',
+ 'responses/pending_ipn.tpl'
),
'admin' => array(),
);
\ No newline at end of file
diff --git a/public_html/extensions/2checkout/storefront/controller/responses/extension/2checkout.php b/public_html/extensions/2checkout/storefront/controller/responses/extension/2checkout.php
index 1bced582f0..1262635688 100755
--- a/public_html/extensions/2checkout/storefront/controller/responses/extension/2checkout.php
+++ b/public_html/extensions/2checkout/storefront/controller/responses/extension/2checkout.php
@@ -88,7 +88,12 @@ public function main()
'name' => $product['name'],
'description' => $product['name'],
'quantity' => $product['quantity'],
- 'price' => $this->currency->format($product['price'], $order_info['currency'], $order_info['value'], false),
+ 'price' => $this->currency->format(
+ $product['price'],
+ $order_info['currency'],
+ $order_info['value'],
+ false
+ ),
);
}
@@ -115,7 +120,12 @@ public function callback()
}
$post = $this->request->post;
// hash check
- if (!md5($post['sale_id'].$this->config->get('2checkout_account').$post['invoice_id'].$this->config->get('2checkout_secret')) == strtolower($post['md5_hash'])) {
+ if (!md5(
+ $post['sale_id']
+ .$this->config->get('2checkout_account')
+ .$post['invoice_id']
+ .$this->config->get('2checkout_secret')) == strtolower($post['md5_hash'])
+ ){
exit;
}
@@ -128,18 +138,68 @@ public function callback()
}
$this->load->model('extension/2checkout');
if ($post['message_type'] == 'ORDER_CREATED') {
- $this->model_checkout_order->confirm((int)$post['vendor_order_id'], $this->config->get('2checkout_order_status_id'));
+ $this->model_checkout_order->confirm(
+ (int)$post['vendor_order_id'],
+ $this->config->get('2checkout_order_status_id')
+ );
} elseif ($post['message_type'] == 'REFUND_ISSUED') {
$order_status_id = $this->model_extension_2checkout->getOrderStatusIdByName('failed');
- $this->model_checkout_order->update((int)$post['vendor_order_id'], $order_status_id, 'Status changed by 2Checkout INS');
+ $this->model_checkout_order->update(
+ (int)$post['vendor_order_id'],
+ $order_status_id,
+ 'Status changed by 2Checkout INS'
+ );
} elseif ($post['message_type'] == 'FRAUD_STATUS_CHANGED' && $post['fraud_status'] == 'pass') {
$order_status_id = $this->model_extension_2checkout->getOrderStatusIdByName('processing');
- $this->model_checkout_order->update((int)$post['vendor_order_id'], $order_status_id, 'Status changed by 2Checkout INS');
+ $this->model_checkout_order->update(
+ (int)$post['vendor_order_id'],
+ $order_status_id,
+ 'Status changed by 2Checkout INS'
+ );
} elseif ($post['message_type'] == 'SHIP_STATUS_CHANGED' && $post['ship_status'] == 'shipped') {
$order_status_id = $this->model_extension_2checkout->getOrderStatusIdByName('complete');
- $this->model_checkout_order->update((int)$post['vendor_order_id'], $order_status_id, 'Status changed by 2Checkout INS');
+ $this->model_checkout_order->update(
+ (int)$post['vendor_order_id'],
+ $order_status_id,
+ 'Status changed by 2Checkout INS'
+ );
} else {
redirect($this->html->getSecureURL('checkout/confirm'));
}
}
+
+ public function pending_payment()
+ {
+ $this->addChild('common/head', 'head', 'common/head.tpl');
+ $this->addChild('common/footer', 'footer', 'common/footer.tpl');
+ $this->document->setTitle('waiting for payment');
+ $this->view->assign('text_message', 'waiting for payment confirmation');
+ $this->view->assign('text_redirecting', 'redirecting');
+ $this->view->assign('test_url', $this->html->getSecureURL('r/extension/2checkout/is_confirmed'));
+ $this->view->assign('success_url', $this->html->getSecureURL('checkout/success'));
+ $this->processTemplate('responses/pending_ipn.tpl');
+ }
+
+ public function is_confirmed()
+ {
+ $order_id = (int)$this->session->data['order_id'];
+ if (!$order_id) {
+ $result = true;
+ } else {
+ $this->loadModel('checkout/order');
+ $order_info = $this->model_checkout_order->getOrder($order_id);
+ //do nothing if order confirmed or it's not created with paypal standart
+ if ((int)$order_info['order_status_id'] != 0
+ || $order_info['payment_method_key'] != '2checkout'
+ ) {
+ $result = true;
+ } else {
+ $result = false;
+ }
+ }
+
+ $this->load->library('json');
+ $this->response->addJSONHeader();
+ $this->response->setOutput(AJson::encode(array('result' => $result)));
+ }
}
\ No newline at end of file
diff --git a/public_html/extensions/2checkout/storefront/view/default/template/responses/pending_ipn.tpl b/public_html/extensions/2checkout/storefront/view/default/template/responses/pending_ipn.tpl
new file mode 100755
index 0000000000..7a22855b9e
--- /dev/null
+++ b/public_html/extensions/2checkout/storefront/view/default/template/responses/pending_ipn.tpl
@@ -0,0 +1,37 @@
+
+getHookVar('hk_html_attribute'); ?>>
+
+
+
+
+
+
+
\ No newline at end of file