Skip to content
Permalink
Browse files

#1086 pp_standart ipn delay fix. added new page for pending payment c…

…onfirmation from ipn
  • Loading branch information
abolabo committed Apr 4, 2018
1 parent c8fd549 commit 0a5adf666a869393ee30f1d38689fb09b6fd1cbe
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<extension>
<id>default_pp_standart</id>
<version>1.0.2</version>
<version>1.0.3</version>
<type>payment</type>
<category>payment</category>
<cartversions>
@@ -0,0 +1,54 @@
<?php
/*------------------------------------------------------------------------------
$Id$
AbanteCart, Ideal OpenSource Ecommerce Solution
http://www.AbanteCart.com
Copyright © 2011-2017 Belavier Commerce LLC
This source file is subject to Open Software License (OSL 3.0)
Licence details is bundled with this package in the file LICENSE.txt.
It is also available at this URL:
<http://www.opensource.org/licenses/OSL-3.0>
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.
------------------------------------------------------------------------------*/

if ( ! defined( 'DIR_CORE' ) ) {
header( 'Location: static_pages/' );
}

/**
* Class ExtensionDefaultPpPro
*/
class ExtensionDefaultPpStandart 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['pp_standart_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'] != 'default_pp_standart') {
return null;
}
//set sign to prevent double redirect (see above)
$that->session->data['pp_standart_pending_ipn_skip'] = true;
redirect($that->html->getSecureURL('extension/default_pp_standart/pending_payment'));
}
//delete sign after success
public function onControllerPagesCheckoutSuccess_UpdateData()
{
unset($this->baseObject->session->data['pp_standart_pending_ipn_skip']);
}

}
@@ -17,33 +17,41 @@
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/' );
if ( ! defined( 'DIR_CORE' ) ) {
header( 'Location: static_pages/' );
}

if ( ! class_exists( 'ExtensionDefaultPpStandart' ) ) {
require_once( DIR_EXT.'default_pp_standart/core/default_pp_standart_hooks.php' );
}

$controllers = array(
'storefront' => array(
'pages/extension/default_pp_standart',
'responses/extension/default_pp_standart'
),
'admin' => array( ),
'responses/extension/default_pp_standart',
),
'admin' => array(),
);

$models = array(
'storefront' => array( 'extension/default_pp_standart' ),
'admin' => array( ),
'admin' => array(),
);

$languages = array(
'storefront' => array(
'default_pp_standart/default_pp_standart'),
'admin' => array(
'default_pp_standart/default_pp_standart'));
'default_pp_standart/default_pp_standart',
),
'admin' => array(
'default_pp_standart/default_pp_standart',
),
);

$templates = array(
'storefront' => array(
'responses/default_pp_standart.tpl' ),
'admin' => array(
'pages/extension/default_pp_standart_settings.tpl'
)
'responses/default_pp_standart.tpl',
'responses/pending_ipn.tpl',
),
'admin' => array(
'pages/extension/default_pp_standart_settings.tpl',
),
);
@@ -294,4 +294,37 @@ public function callback(){
$this->model_checkout_order->updatePaymentMethodData($this->session->data['order_id'], $response);
}
}

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/default_pp_standart/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'] != 'default_pp_standart' ) {
$result = true;
} else {
$result = false;
}
}

$this->load->library('json');
$this->response->addJSONHeader();
$this->response->setOutput(AJson::encode(array('result'=>$result)));
}
}
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo $direction; ?>" lang="<?php echo $lang; ?>" xml:lang="<?php echo $lang; ?>" <?php echo $this->getHookVar('hk_html_attribute'); ?>>
<head><?php echo $head; ?></head>
<body>
<div class="container-fixed">
<div class="contentpanel" style="margin-top: 5%">
<h3 class=" col-sm-5 col-sm-offset-4"><i class="fa fa-spinner fa-pulse"></i> <?php echo $text_message; ?></h3>
</div>
</div>
<script type="text/javascript" src="<?php echo $this->templateResource('/javascript/bootstrap.min.js'); ?>" defer></script>
<script language="JavaScript" type="application/javascript">
var timeout = 30;
(function worker() {
if(timeout <=0){
location = '<?php echo $success_url;?>';
return;
}
timeout -=5;
$.ajax({
url: '<?php echo $test_url;?>',
success: function (data) {
console.log(data);
if(data['result'] == true) {
$('h3').html('..redirecting');
location = '<?php echo $success_url;?>';
return false;
}
},
complete: function () {
// Schedule the next request when the current one's complete
setTimeout(worker, 5000);
}
});
})();
</script>
</body></html>

0 comments on commit 0a5adf6

Please sign in to comment.
You can’t perform that action at this time.