From b6be7472c3e5c3963479f40309783504bef4db31 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 4 May 2011 08:39:17 +0000 Subject: [PATCH] Works on enhancement of paypal module --- htdocs/paypal/lib/paypalfunctions.lib.php | 10 + htdocs/paypal/transaction.php | 213 ++++++++++++++++++++++ htdocs/public/paypal/newpayment.php | 8 - 3 files changed, 223 insertions(+), 8 deletions(-) create mode 100644 htdocs/paypal/transaction.php diff --git a/htdocs/paypal/lib/paypalfunctions.lib.php b/htdocs/paypal/lib/paypalfunctions.lib.php index de26f5942f9..0f5d4c3b82c 100755 --- a/htdocs/paypal/lib/paypalfunctions.lib.php +++ b/htdocs/paypal/lib/paypalfunctions.lib.php @@ -50,6 +50,16 @@ else $API_Url = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="; } +// Clean parameters +$PAYPAL_API_USER=""; +if ($conf->global->PAYPAL_API_USER) $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER; +$PAYPAL_API_PASSWORD=""; +if ($conf->global->PAYPAL_API_PASSWORD) $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD; +$PAYPAL_API_SIGNATURE=""; +if ($conf->global->PAYPAL_API_SIGNATURE) $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE; +$PAYPAL_API_SANDBOX=""; +if ($conf->global->PAYPAL_API_SANDBOX) $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX; + // Proxy $PROXY_HOST = $conf->global->MAIN_PROXY_HOST; $PROXY_PORT = $conf->global->MAIN_PROXY_PORT; diff --git a/htdocs/paypal/transaction.php b/htdocs/paypal/transaction.php new file mode 100644 index 00000000000..050159acaad --- /dev/null +++ b/htdocs/paypal/transaction.php @@ -0,0 +1,213 @@ + + * + * 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/transaction.php + * \ingroup paypal + * \brief Page to list transactions in paypal account + * \version $Id$ + */ + +require("../main.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'); +require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.lib.php"); + +$langs->load("paypal"); + +$action = GETPOST('action'); + +// Security check +//$result=restrictedArea($user,'paypal'); + + +/* + * Actions + */ + + + +/* + * View + */ + +$nvpStr=''; + +$startDateStr=GETPOST('startDateStr'); +$endDateStr=GETPOST('endDateStr'); +$transactionID=urlencode(GETPOST('transactionID')); + +if(isset($endDateStr) && ! empty($startDateStr)) { + $start_time = dol_stringtotime($startDateStr); + $iso_start = dol_print_date($start_time,'dayhourrfc'); + $nvpStr="&STARTDATE=$iso_start"; +} + +if(isset($endDateStr) && ! empty($endDateStr)) { + $end_time = dol_stringtotime($endDateStr); + $iso_end = dol_print_date($end_time,'dayhourrfc'); + $nvpStr.="&ENDDATE=$iso_end"; +} + +if(isset($transactionID) && ! empty($transactionID)) { + $nvpStr=$nvpStr."&TRANSACTIONID=$transactionID"; +} + +if (isset($startDateStr) && ! empty($startDateStr)) { + $start_date_str = $startDateStr; +} else { + $yesterdayDate = dol_now()-86400; + $start_date_str = dol_print_date($yesterdayDate,'day'); +} +if (isset($endDateStr) && ! empty($startDateStr)) { + $end_date_str = $endDateStr; +} else { + $currentDate = dol_now(); + $end_date_str = dol_print_date($currentDate,'day'); +} + +llxHeader(); + +?> + + + +'; +print ''; + +print ''; + +print ''; +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; + +print '
'.$langs->trans('DateStart').':
'.$langs->trans('DateEnd').':
'.$langs->trans('TransactionID').':
'; +print ''; + + +if (! empty($nvpStr)) +{ + $resArray=hash_call("TransactionSearch",$nvpStr); + + //var_dump($resArray); + + $reqArray=$_SESSION['nvpReqArray']; + + /* + $ack = strtoupper($resArray["ACK"]); + if($ack!="SUCCESS" && $ack!="SUCCESSWITHWARNING") + { + $_SESSION['reshash']=$resArray; + $location = "APIError.php"; + header("Location: $location"); + } + */ + + + print_barre_liste($title, $_GET['page'], $_SERVER['PHP_SELF'],'',$sortfield,$sortorder,'',$num); + + print ''; + print ''; + print_liste_field_titre($langs->trans('ID'),$_SERVER['PHP_SELF'],'','',''.$socid.'&viewstatut='.$viewstatut,'width="25%"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'','',''.$socid.'&viewstatut='.$viewstatut,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'','',''.$socid.'&viewstatut='.$viewstatut,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('ThirdPartyName'),$_SERVER['PHP_SELF'],'','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('GrossAmount'),$_SERVER['PHP_SELF'],'','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('FeeAmount'),$_SERVER['PHP_SELF'],'','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('NetAmount'),$_SERVER['PHP_SELF'],'','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield,$sortorder); + print ''; + + if(! isset($resArray["L_TRANSACTIONID0"])) + { + print ''; + print ''; + print ''; + } + else + { + $i=0; + + while (isset($resArray["L_TRANSACTIONID".$i])) + { + $transactionID = $resArray["L_TRANSACTIONID".$i]; + $timeStamp = dol_stringtotime($resArray["L_TIMESTAMP".$i]); + $payerName = $resArray["L_NAME".$i]; + $amount = $resArray["L_AMT".$i]; + $feeamount = $resArray["L_FEEAMT".$i]; + $netamount = $resArray["L_NETAMT".$i]; + $currency = $resArray["L_CURRENCYCODE".$i]; + $status = $resArray["L_STATUS".$i]; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $i++; + } + } + + print '
'.$langs->trans("NoTransactionSelected").'
'.$transactionID.''.dol_print_date($timeStamp,'dayhour').''.$status.''.$payerName.''.$amount.' '.$currency.''.$feeamount.' '.$currency.''.$netamount.' '.$currency.'
'; +} + +llxFooter('$Date$ - $Revision$'); + +?> \ No newline at end of file diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index 17ef84ec1fb..c5af46a6748 100755 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -120,14 +120,6 @@ $urlok=preg_replace('/&$/','',$urlok); // Remove last & $urlko=preg_replace('/&$/','',$urlko); // Remove last & // Clean parameters -$PAYPAL_API_USER=""; -if ($conf->global->PAYPAL_API_USER) $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER; -$PAYPAL_API_PASSWORD=""; -if ($conf->global->PAYPAL_API_PASSWORD) $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD; -$PAYPAL_API_SIGNATURE=""; -if ($conf->global->PAYPAL_API_SIGNATURE) $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE; -$PAYPAL_API_SANDBOX=""; -if ($conf->global->PAYPAL_API_SANDBOX) $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX; $PAYPAL_API_OK=""; if ($urlok) $PAYPAL_API_OK=$urlok; $PAYPAL_API_KO="";