diff --git a/htdocs/langs/en_US/paybox.lang b/htdocs/langs/en_US/paybox.lang
index c4f4b9bdeda..2c5f3113b89 100644
--- a/htdocs/langs/en_US/paybox.lang
+++ b/htdocs/langs/en_US/paybox.lang
@@ -21,4 +21,6 @@ ToOfferALinkForOnlinePaymentOnContractLine=URL to offer a %s online payment user
ToOfferALinkForOnlinePaymentOnFreeAmount=URL to offer a %s online payment user interface for a free amount
ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online payment user interface for a member subscription
YouCanAddTagOnUrl=You can also add url parameter &tag=value to any of those URL (required only for free payment) to add your own payment comment tag.
-SetupPayBoxToHavePaymentCreatedAutomatically=Setup your PayBox with url %s to have payment created automatically when validated by paybox.
\ No newline at end of file
+SetupPayBoxToHavePaymentCreatedAutomatically=Setup your PayBox with url %s to have payment created automatically when validated by paybox.
+YourPaymentHasBeenRecorded=This page confirms that your payment has been recorded. Thank you.
+YourPaymentHasNotBeenRecorded=You payment has not been recorded and transaction has been canceled. Thank you.
diff --git a/htdocs/langs/fr_FR/paybox.lang b/htdocs/langs/fr_FR/paybox.lang
index ff8f568e5df..f890f707681 100644
--- a/htdocs/langs/fr_FR/paybox.lang
+++ b/htdocs/langs/fr_FR/paybox.lang
@@ -22,4 +22,5 @@ ToOfferALinkForOnlinePaymentOnFreeAmount=URL offrant une interface de paiement e
ToOfferALinkForOnlinePaymentOnMemberSubscription=URL offrant une interface de paiement en ligne %s sur la base d'une cotisation d'adhérent
YouCanAddTagOnUrl=Vous pouvez de plus ajouter le paramètre url &tag=value à n'importe quelles de ces URL (obligatoire pour le paiement libre uniquement) pour ajouter votre propre "code commentaire" du paiement.
SetupPayBoxToHavePaymentCreatedAutomatically=Configurez votre url PayBox à %s pour avoir le paiement créé automatiquement si validé.
-
\ No newline at end of file
+YourPaymentHasBeenRecorded=Cette page confirme que votre paiement a bien été enregistré. Merci.
+YourPaymentHasNotBeenRecorded=Votre paiement n'a pas été enregitré et la transaction a été annulée. Merci.
diff --git a/htdocs/paybox/paybox.lib.php b/htdocs/paybox/lib/paybox.lib.php
old mode 100644
new mode 100755
similarity index 99%
rename from htdocs/paybox/paybox.lib.php
rename to htdocs/paybox/lib/paybox.lib.php
index ec6a5ba895b..3c02bce6487
--- a/htdocs/paybox/paybox.lib.php
+++ b/htdocs/paybox/lib/paybox.lib.php
@@ -231,7 +231,7 @@ function print_paybox_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG)
* @param $fromcompany
* @param $langs
*/
-function html_print_footer($fromcompany,$langs)
+function html_print_paybox_footer($fromcompany,$langs)
{
global $conf;
diff --git a/htdocs/paypal/admin/paypal.php b/htdocs/paypal/admin/paypal.php
index 05d61adf1b1..7b876230abf 100644
--- a/htdocs/paypal/admin/paypal.php
+++ b/htdocs/paypal/admin/paypal.php
@@ -123,7 +123,7 @@ print '';
$var=!$var;
print '
';
$var=!$var;
diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php
new file mode 100755
index 00000000000..e20381f628b
--- /dev/null
+++ b/htdocs/paypal/lib/paypal.lib.php
@@ -0,0 +1,294 @@
+
+ * Copyright (C) 2005-2007 Regis Houssin
+ *
+ * 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.
+ * or see http://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/paypal/paypal.lib.php
+ * \brief Library for common paypal functions
+ * \version $Id$
+ */
+
+
+function llxHeaderPaypal($title, $head = "")
+{
+ global $user, $conf, $langs;
+
+ header("Content-type: text/html; charset=".$conf->file->character_set_client);
+
+ print '';
+ //print '';
+ print "\n";
+ print "\n";
+ print "\n";
+ print ''."\n";
+ print ''."\n";
+ print ''."\n";
+ print "".$title."\n";
+ if ($head) print $head."\n";
+ if ($conf->global->PAYPAL_CSS_URL) print ''."\n";
+ else
+ {
+ print ''."\n";
+ print '';
+ }
+ print "\n";
+ print ''."\n";
+}
+
+function llxFooterPaypal()
+{
+ print "\n";
+ print "\n";
+}
+
+
+/**
+ * \brief Create a redirect form to paypal form
+ * \return int 1 if OK, -1 if ERROR
+ */
+function print_paypal_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG)
+{
+ global $conf, $langs, $db;
+
+ dol_syslog("Paypal.lib::print_paybox_redirect", LOG_DEBUG);
+
+ // Clean parameters
+ $PBX_IDENTIFIANT="2"; # Identifiant pour v2 test
+ if ($conf->global->PAYBOX_PBX_IDENTIFIANT) $PBX_IDENTIFIANT=$conf->global->PAYBOX_PBX_IDENTIFIANT;
+ $IBS_SITE="1999888"; # Site test
+ if ($conf->global->PAYBOX_IBS_SITE) $IBS_SITE=$conf->global->PAYBOX_IBS_SITE;
+ $IBS_RANG="99"; # Rang test
+ if ($conf->global->PAYBOX_IBS_RANG) $IBS_RANG=$conf->global->PAYBOX_IBS_RANG;
+ $IBS_DEVISE="840"; # Currency (Dollar US by default)
+ if ($CURRENCY == 'EUR') $IBS_DEVISE="978";
+ if ($CURRENCY == 'USD') $IBS_DEVISE="840";
+
+ $URLPAYBOX="";
+ if ($conf->global->PAYBOX_CGI_URL_V1) $URLPAYBOX=$conf->global->PAYBOX_CGI_URL_V1;
+ if ($conf->global->PAYBOX_CGI_URL_V2) $URLPAYBOX=$conf->global->PAYBOX_CGI_URL_V2;
+
+ if (empty($IBS_DEVISE))
+ {
+ dol_print_error('',"Paybox setup param PAYBOX_IBS_DEVISE not defined");
+ return -1;
+ }
+ if (empty($URLPAYBOX))
+ {
+ dol_print_error('',"Paybox setup param PAYBOX_CGI_URL_V1 and PAYBOX_CGI_URL_V2 undefined");
+ return -1;
+ }
+ if (empty($IBS_SITE))
+ {
+ dol_print_error('',"Paybox setup param PAYBOX_IBS_SITE not defined");
+ return -1;
+ }
+ if (empty($IBS_RANG))
+ {
+ dol_print_error('',"Paybox setup param PAYBOX_IBS_RANG not defined");
+ return -1;
+ }
+
+ // Definition des parametres vente produit pour paybox
+ $IBS_CMD=$TAG;
+ $IBS_TOTAL=$PRICE*100; # En centimes
+ $IBS_MODE=1; # Mode formulaire
+ $IBS_PORTEUR=$EMAIL;
+ $IBS_RETOUR="montant:M;ref:R;auto:A;trans:T"; # Format des parametres du get de validation en reponse (url a definir sous paybox)
+ //$IBS_TXT="
'."\n";
+}
+
+?>
\ No newline at end of file
diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php
index 6fa4c4dfc8d..6e56d368f3b 100644
--- a/htdocs/public/paybox/newpayment.php
+++ b/htdocs/public/paybox/newpayment.php
@@ -30,7 +30,7 @@ define("NOLOGIN",1); // This means this output page does not require to be logg
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require("../../main.inc.php");
-require_once(DOL_DOCUMENT_ROOT."/paybox/paybox.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/paybox/lib/paybox.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
@@ -642,7 +642,7 @@ print '';
print ' ';
-html_print_footer($mysoc,$langs);
+html_print_paybox_footer($mysoc,$langs);
$db->close();
diff --git a/htdocs/public/paybox/paymentko.php b/htdocs/public/paybox/paymentko.php
index e8b16388f38..845d9f03672 100644
--- a/htdocs/public/paybox/paymentko.php
+++ b/htdocs/public/paybox/paymentko.php
@@ -29,7 +29,7 @@ define("NOLOGIN",1); // This means this output page does not require to be logg
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require("../../main.inc.php");
-require_once(DOL_DOCUMENT_ROOT."/paybox/paybox.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/paybox/lib/paybox.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
// Security check
@@ -37,10 +37,11 @@ if (empty($conf->paybox->enabled)) accessforbidden('',1,1,1);
$langs->load("main");
$langs->load("other");
-$langs->load("paybox");
$langs->load("dict");
$langs->load("bills");
$langs->load("companies");
+$langs->load("paybox");
+$langs->load("paypal");
@@ -60,8 +61,10 @@ $langs->load("companies");
llxHeaderPayBox($langs->trans("PaymentForm"));
+print $langs->trans("YourPaymentHasNotBeenRecorded");
-html_print_footer($mysoc,$langs);
+
+html_print_paybox_footer($mysoc,$langs);
$db->close();
diff --git a/htdocs/public/paybox/paymentok.php b/htdocs/public/paybox/paymentok.php
index 315c8f504c3..e5f20984eb3 100644
--- a/htdocs/public/paybox/paymentok.php
+++ b/htdocs/public/paybox/paymentok.php
@@ -29,7 +29,7 @@ define("NOLOGIN",1); // This means this output page does not require to be logg
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require("../../main.inc.php");
-require_once(DOL_DOCUMENT_ROOT."/paybox/paybox.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/paybox/lib/paybox.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
// Security check
@@ -37,10 +37,11 @@ if (empty($conf->paybox->enabled)) accessforbidden('',1,1,1);
$langs->load("main");
$langs->load("other");
-$langs->load("paybox");
$langs->load("dict");
$langs->load("bills");
$langs->load("companies");
+$langs->load("paybox");
+$langs->load("paypal");
@@ -59,8 +60,10 @@ $langs->load("companies");
llxHeaderPayBox($langs->trans("PaymentForm"));
+print $langs->trans("YourPaymentHasBeenRecorded");
-html_print_footer($mysoc,$langs);
+
+html_print_paybox_footer($mysoc,$langs);
$db->close();
diff --git a/htdocs/public/paypal/index.php b/htdocs/public/paypal/index.php
new file mode 100755
index 00000000000..a43eb42417c
--- /dev/null
+++ b/htdocs/public/paypal/index.php
@@ -0,0 +1,31 @@
+
+ *
+ * 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/public/paypal/index.php
+ * \ingroup core
+ * \brief A redirect page to an error
+ * \author Laurent Destailleur
+ * \version $Id$
+ */
+
+require("../../master.inc.php");
+
+header("Location: ".DOL_URL_ROOT.'/public/error-404.php');
+
+?>
diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php
new file mode 100755
index 00000000000..24c6a598978
--- /dev/null
+++ b/htdocs/public/paypal/newpayment.php
@@ -0,0 +1,651 @@
+
+ * Copyright (C) 2006-2009 Laurent Destailleur
+ * Copyright (C) 2009 Regis Houssin
+ *
+ * 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/public/paypal/newpayment.php
+ * \ingroup paypal
+ * \brief File to offer a way to make a payment for a particular Dolibarr entity
+ * \author Laurent Destailleur
+ * \version $Id$
+ */
+
+define("NOLOGIN",1); // This means this output page does not require to be logged.
+define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypal.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
+
+// Security check
+if (empty($conf->paypal->enabled)) accessforbidden('',1,1,1);
+
+// Creation d'un jeton contre les failles CSRF
+$token = md5(uniqid(mt_rand(),TRUE)); // Genere un hash d'un nombre aleatoire
+// roulement des jetons car cree a chaque appel
+if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken'];
+$_SESSION['newtoken'] = $token;
+
+// Verification de la presence et de la validite du jeton
+if (isset($_POST['token']) && isset($_SESSION['token']))
+{
+ if ($_POST['token'] != $_SESSION['token'])
+ {
+ unset($_POST);
+ }
+}
+
+$langs->load("main");
+$langs->load("other");
+$langs->load("dict");
+$langs->load("bills");
+$langs->load("companies");
+$langs->load("errors");
+$langs->load("paybox");
+$langs->load("paypal");
+
+// Input are:
+// type ('invoice','order','contractline'),
+// id (object id),
+// amount (required if id is empty),
+// tag (a free text, required if type is empty)
+// currency (iso code)
+
+if (empty($_REQUEST["currency"])) $currency=$conf->global->MAIN_MONNAIE;
+else $currency=$_REQUEST["currency"];
+if (empty($_REQUEST["amount"]))
+{
+ dol_print_error('','ErrorBadParameters');
+ session_destroy();
+ exit;
+}
+$amount=$_REQUEST["amount"];
+if (is_numeric($amount) && empty($_REQUEST["tag"]))
+{
+ dol_print_error('','ErrorBadParameters');
+ session_destroy();
+ exit;
+}
+if (! is_numeric($amount) && empty($_REQUEST["ref"]))
+{
+ dol_print_error('','ErrorBadParameters');
+ session_destroy();
+ exit;
+}
+$suffix=$_REQUEST["suffix"];
+
+
+
+/*
+ * Actions
+ */
+if ($_REQUEST["action"] == 'dopayment')
+{
+ $PRICE=$_REQUEST["newamount"];
+ $EMAIL=$_REQUEST["EMAIL"];
+ $urlok='';
+ $urlko='';
+ $TAG=$_REQUEST["newtag"];
+ $ID=$_REQUEST["id"];
+
+ $mesg='';
+ if (empty($PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount"));
+ elseif (empty($EMAIL)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail"));
+ elseif (! isValidEMail($EMAIL)) $mesg=$langs->trans("ErrorBadEMail",$EMAIL);
+ elseif (empty($TAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode"));
+
+ if (empty($mesg))
+ {
+ print_paypal_redirect($PRICE, $conf->monnaie, $EMAIL, $urlok, $urlko, $TAG, $ID);
+ session_destroy();
+ exit;
+ }
+}
+
+
+
+/*
+ * View
+ */
+
+llxHeaderPaypal($langs->trans("PaymentForm"));
+
+
+// Common variables
+$creditor=$mysoc->nom;
+$paramcreditor='PAYBOX_CREDITOR_'.$suffix;
+if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor;
+else if (! empty($conf->global->PAYBOX_CREDITOR)) $creditor=$conf->global->PAYBOX_CREDITOR;
+
+print '
';
+print '';
+print '
';
+print ' ';
+
+
+html_print_paypal_footer($mysoc,$langs);
+
+$db->close();
+
+llxFooterPaypal('$Date$ - $Revision$');
+?>
diff --git a/htdocs/public/paypal/paymentko.php b/htdocs/public/paypal/paymentko.php
new file mode 100755
index 00000000000..c265c2af580
--- /dev/null
+++ b/htdocs/public/paypal/paymentko.php
@@ -0,0 +1,70 @@
+
+ * Copyright (C) 2006-2009 Laurent Destailleur
+ *
+ * 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/public/paybox/paymentko.php
+ * \ingroup paybox
+ * \brief File to show page after a failed payment
+ * \author Laurent Destailleur
+ * \version $Id$
+ */
+
+define("NOLOGIN",1); // This means this output page does not require to be logged.
+define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypal.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
+
+// Security check
+if (empty($conf->paypal->enabled)) accessforbidden('',1,1,1);
+
+$langs->load("main");
+$langs->load("other");
+$langs->load("dict");
+$langs->load("bills");
+$langs->load("companies");
+$langs->load("paybox");
+$langs->load("paypal");
+
+
+/*
+ * Actions
+ */
+
+
+
+
+/*
+ * View
+ */
+
+llxHeaderPaypal($langs->trans("PaymentForm"));
+
+
+print $langs->trans("YourPaymentHasNotBeenRecorded");
+
+
+html_print_paypal_footer($mysoc,$langs);
+
+
+$db->close();
+
+llxFooterPaypal('$Date$ - $Revision$');
+?>
diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php
new file mode 100755
index 00000000000..9bb0f52cccd
--- /dev/null
+++ b/htdocs/public/paypal/paymentok.php
@@ -0,0 +1,72 @@
+
+ * Copyright (C) 2006-2009 Laurent Destailleur
+ *
+ * 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/public/paypal/paymentok.php
+ * \ingroup paypal
+ * \brief File to show page after a successful payment
+ * \author Laurent Destailleur
+ * \version $Id$
+ */
+
+define("NOLOGIN",1); // This means this output page does not require to be logged.
+define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypal.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
+
+// Security check
+if (empty($conf->paypal->enabled)) accessforbidden('',1,1,1);
+
+$langs->load("main");
+$langs->load("other");
+$langs->load("dict");
+$langs->load("bills");
+$langs->load("companies");
+$langs->load("paybox");
+$langs->load("paypal");
+
+
+
+/*
+ * Actions
+ */
+
+
+
+
+
+/*
+ * View
+ */
+
+llxHeaderPaypal($langs->trans("PaymentForm"));
+
+
+print $langs->trans("YourPaymentHasBeenRecorded");
+
+
+html_print_paypal_footer($mysoc,$langs);
+
+
+$db->close();
+
+llxFooterPaypal('$Date$ - $Revision$');
+?>