Works on enhancement of paypal module
This commit is contained in:
parent
5d1e7c2d85
commit
1cdb3c37da
67
htdocs/paypal/ajaxtransactiondetails.php
Normal file
67
htdocs/paypal/ajaxtransactiondetails.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/paypal/ajaxtransactiondetails.php
|
||||
* \brief File to return Ajax response on paypal transaction details
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
|
||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
|
||||
|
||||
require('../main.inc.php');
|
||||
require_once(DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php');
|
||||
require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.lib.php");
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
// Ajout directives pour resoudre bug IE
|
||||
//header('Cache-Control: Public, must-revalidate');
|
||||
//header('Pragma: public');
|
||||
|
||||
//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
|
||||
top_httphead();
|
||||
|
||||
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
||||
|
||||
//print '<body class="nocellnopadd">'."\n";
|
||||
|
||||
dol_syslog(join(',',$_GET));
|
||||
|
||||
if (isset($_GET['transaction_id']) && ! empty($_GET['transaction_id']))
|
||||
{
|
||||
$resArray = GetTransactionDetails($_GET['transaction_id']);
|
||||
|
||||
foreach($resArray as $key => $value) {
|
||||
echo $key.': '.$value.'<br />';
|
||||
}
|
||||
|
||||
//print json_encode($resArray);
|
||||
}
|
||||
|
||||
//print "</body>";
|
||||
//print "</html>";
|
||||
?>
|
||||
@ -331,6 +331,34 @@ function GetDetails( $token )
|
||||
return $resArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get transaction details
|
||||
* @param transactionID Transaction id
|
||||
*/
|
||||
function GetTransactionDetails($transactionID)
|
||||
{
|
||||
global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT;
|
||||
global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE;
|
||||
|
||||
$transactionID=urlencode($transactionID);
|
||||
|
||||
/* Construct the request string that will be sent to PayPal.
|
||||
The variable $nvpstr contains all the variables and is a
|
||||
name value pair string with & as a delimiter */
|
||||
$nvpStr="&TRANSACTIONID=$transactionID";
|
||||
|
||||
/* Make the API call to PayPal, using API signature.
|
||||
The API response is stored in an associative array called $resArray */
|
||||
$resArray=hash_call("gettransactionDetails",$nvpStr);
|
||||
|
||||
/* Next, collect the API request in the associative array $reqArray
|
||||
as well to display back to the browser.
|
||||
Normally you wouldnt not need to do this, but its shown for testing */
|
||||
$reqArray=$_SESSION['nvpReqArray'];
|
||||
|
||||
return $resArray;
|
||||
}
|
||||
|
||||
/*
|
||||
'-------------------------------------------------------------------------------------------------------------------------------------------
|
||||
' Purpose: Validate payment
|
||||
|
||||
@ -32,17 +32,19 @@ $langs->load("paypal");
|
||||
// Security check
|
||||
//$result=restrictedArea($user,'paypal');
|
||||
|
||||
$action = GETPOST('action');
|
||||
$page = GETPOST("page",'int');
|
||||
$startDateStr=GETPOST('startDateStr');
|
||||
$endDateStr=GETPOST('endDateStr');
|
||||
$transactionID=urlencode(GETPOST('transactionID'));
|
||||
$action = GETPOST('action');
|
||||
$id = GETPOST('id');
|
||||
$page = GETPOST("page",'int');
|
||||
$startDateStr = GETPOST('startDateStr');
|
||||
$endDateStr = GETPOST('endDateStr');
|
||||
$transactionID = urlencode(GETPOST('transactionID'));
|
||||
|
||||
if ($page == -1) { $page = 0; }
|
||||
$offset = $conf->liste_limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
$errors='';
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -108,9 +110,32 @@ llxHeader();
|
||||
dates.not( this ).datepicker( "option", option, date );
|
||||
}
|
||||
});
|
||||
$( "div.paypal_link" ).click(function() {
|
||||
var id_value = $(this).attr("id");
|
||||
$.jnotify("<?php echo $langs->trans('PleaseBePatient'); ?>", 2000);
|
||||
$.get( "<?php echo DOL_URL_ROOT; ?>/paypal/ajaxtransactiondetails.php", {
|
||||
transaction_id: id_value
|
||||
},
|
||||
function(details) {
|
||||
$( "div #paypal_detail_content" ).html(details);
|
||||
$( "div #paypal-details" ).dialog({
|
||||
modal: true,
|
||||
width: 500,
|
||||
buttons: {
|
||||
Ok: function() {
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="paypal-details" title="<?php echo $langs->trans('TransactionDetails'); ?>" style="display: none;">
|
||||
<div id="paypal_detail_content"></div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
// Call Paypal API
|
||||
@ -123,7 +148,6 @@ if (! empty($nvpStr))
|
||||
$reqArray=$_SESSION['nvpReqArray'];
|
||||
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
$errors='';
|
||||
if($ack!="SUCCESS" && $ack!="SUCCESSWITHWARNING")
|
||||
{
|
||||
$_SESSION['reshash']=$resArray;
|
||||
@ -196,7 +220,7 @@ else
|
||||
$status = $resArray["L_STATUS".$i];
|
||||
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td><a id="transactiondetailslink'.$i.'" href="details.php?transactionID='.$transactionID.'">'.$transactionID.'</a></td>';
|
||||
print '<td><div id="'.$transactionID.'" class="paypal_link" style="font-weight:bold;cursor:pointer;">'.$transactionID.'</div></td>';
|
||||
print '<td align="center">'.dol_print_date($timeStamp,'dayhour').'</td>';
|
||||
print '<td align="center">'.$status.'</td>';
|
||||
print '<td align="right">'.$payerName.'</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user