diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 6f3680c10c1..162a4503ee2 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -2910,11 +2910,11 @@ class Form
/**
- * \brief Return an html string with a select combo box to choose yes or no
- * \param name Name of html select field
- * \param value Pre-selected value
- * \param option 0 return yes/no, 1 return 1/0
- * \return int or string See option
+ * Return an html string with a select combo box to choose yes or no
+ * @param name Name of html select field
+ * @param value Pre-selected value
+ * @param option 0 return yes/no, 1 return 1/0
+ * @return int or string See option
*/
function selectyesno($htmlname,$value='',$option=0)
{
diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php
index 19cbcfb6f20..7c153bf08e0 100644
--- a/htdocs/core/class/translate.class.php
+++ b/htdocs/core/class/translate.class.php
@@ -113,13 +113,15 @@ class Translate {
/**
- * \brief Return active language code for current user
- * \remarks Accessor for this->defaultlang
- * \return string Language code used (en_US, en_AU, fr_FR, ...)
+ * Return active language code for current user
+ * It's an accessor for this->defaultlang
+ * @param mode 0=Long language code, 1=Short language code
+ * @return string Language code used (en_US, en_AU, fr_FR, ...)
*/
- function getDefaultLang()
+ function getDefaultLang($mode=0)
{
- return $this->defaultlang;
+ if (empty($mode)) return $this->defaultlang;
+ else return substr($this->defaultlang,0,2);
}
diff --git a/htdocs/includes/modules/modPaypal.class.php b/htdocs/includes/modules/modPaypal.class.php
index 5e0acb9781a..5c07ed5014e 100644
--- a/htdocs/includes/modules/modPaypal.class.php
+++ b/htdocs/includes/modules/modPaypal.class.php
@@ -57,7 +57,7 @@ class modPaypal extends DolibarrModules
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
$this->description = "Module to offer an online payment page by credit card with PayPal";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
- $this->version = 'development';
+ $this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=other)
diff --git a/htdocs/langs/en_US/paybox.lang b/htdocs/langs/en_US/paybox.lang
index 556e713c9de..211dce8df1e 100644
--- a/htdocs/langs/en_US/paybox.lang
+++ b/htdocs/langs/en_US/paybox.lang
@@ -30,4 +30,5 @@ InformationToFindParameters=Help to find your %s account information
PAYBOX_CGI_URL_V2=Url of Paybox CGI module for payment
VendorName=Name of vendor
CSSUrlForPaymentForm=CSS style sheet url for payment form
-
+MessageOK=Message on validated payment return page
+MessageKO=Message on canceled payment return page
diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang
index 8e20415bb38..5adf942e205 100644
--- a/htdocs/langs/en_US/paypal.lang
+++ b/htdocs/langs/en_US/paypal.lang
@@ -11,3 +11,4 @@ PAYPAL_API_PASSWORD=API password
PAYPAL_API_SIGNATURE=API signature
PAYPAL_API_INTEGRAL_OR_PAYPALONLY=Offer payment "integral" (Credit card+Paypal) or "Paypal" only
PAYPAL_CSS_URL=Optionnal Url of CSS style sheet on payment page
+ThisIsTransactionId=This is id of transaction: %s
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/paybox.lang b/htdocs/langs/fr_FR/paybox.lang
index 32435fc41b0..04a55508dfd 100644
--- a/htdocs/langs/fr_FR/paybox.lang
+++ b/htdocs/langs/fr_FR/paybox.lang
@@ -30,3 +30,5 @@ InformationToFindParameters=Informations pour trouver vos paramètres de compte
PAYBOX_CGI_URL_V2=Url du module CGI Paybox de paiement
VendorName=Nom du vendeur
CSSUrlForPaymentForm=Url feuille style css pour le formulaire de paiement
+MessageOK=Message sur page de retour de paiement validé
+MessageKO=Message sur page de retour de paiement annulé
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/paypal.lang b/htdocs/langs/fr_FR/paypal.lang
index 75ea7640c83..894deac480f 100644
--- a/htdocs/langs/fr_FR/paypal.lang
+++ b/htdocs/langs/fr_FR/paypal.lang
@@ -11,3 +11,4 @@ PAYPAL_API_PASSWORD=Mot de passe utilisateur API
PAYPAL_API_SIGNATURE=Signature API
PAYPAL_API_INTEGRAL_OR_PAYPALONLY=Proposer le paiement intégral (Carte+Paypal) ou Paypal seul
PAYPAL_CSS_URL=Url optionnelle de la feuille de style CSS de la page de paiement
+ThisIsTransactionId=Voici l'identifiant de la transaction: %s
\ No newline at end of file
diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php
index 3227e8ea377..5aed431b249 100644
--- a/htdocs/paybox/admin/paybox.php
+++ b/htdocs/paybox/admin/paybox.php
@@ -25,6 +25,7 @@
require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$servicename='PayBox';
@@ -48,6 +49,9 @@ if ($_POST["action"] == 'setvalue' && $user->admin)
$result=dolibarr_set_const($db, "PAYBOX_CREDITOR",$_POST["PAYBOX_CREDITOR"],'chaine',0,'',$conf->entity);
$result=dolibarr_set_const($db, "PAYBOX_CSS_URL",$_POST["PAYBOX_CSS_URL"],'chaine',0,'',$conf->entity);
+ $result=dolibarr_set_const($db, "PAYBOX_MESSAGE_OK",$_POST["PAYBOX_MESSAGE_OK"],'chaine',0,'',$conf->entity);
+ $result=dolibarr_set_const($db, "PAYBOX_MESSAGE_KO",$_POST["PAYBOX_MESSAGE_KO"],'chaine',0,'',$conf->entity);
+
if ($result >= 0)
{
$mesg='
\n";
html_print_paybox_footer($mysoc,$langs);
diff --git a/htdocs/public/paypal/expresscheckout.php b/htdocs/public/paypal/expresscheckout.php
deleted file mode 100755
index 86cb887efeb..00000000000
--- a/htdocs/public/paypal/expresscheckout.php
+++ /dev/null
@@ -1,110 +0,0 @@
-
- *
- * 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/expresscheckout.php
- * \ingroup paypal
- * \brief Page with Paypal redirect page. Code provided by Paypal.
- * \version $Id$
- */
-
-// This file is not called directly but is included into another one
-require_once (DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.php");
-
-// ==================================
-// PayPal Express Checkout Module
-// ==================================
-
-
-//'------------------------------------
-//' The paymentAmount is the total value of
-//' the shopping cart, that was set
-//' earlier in a session variable
-//' by the shopping cart page
-//'------------------------------------
-$paymentAmount = $_SESSION["Payment_Amount"];
-
-//'------------------------------------
-//' The currencyCodeType and paymentType
-//' are set to the selections made on the Integration Assistant
-//'------------------------------------
-$currencyCodeType = $PAYPAL_API_DEVISE; // "EUR"
-$paymentType = "Sale";
-
-//'------------------------------------
-//' The returnURL is the location where buyers return to when a
-//' payment has been succesfully authorized.
-//'
-//' This is set to the value entered on the Integration Assistant
-//'------------------------------------
-$returnURL = $PAYPAL_API_OK;
-
-//'------------------------------------
-//' The cancelURL is the location buyers are sent to when they hit the
-//' cancel button during authorization of payment during the PayPal flow
-//'
-//' This is set to the value entered on the Integration Assistant
-//'------------------------------------
-$cancelURL = $PAYPAL_API_KO;
-
-//'------------------------------------
-//' Calls the SetExpressCheckout API call
-//'
-//'-------------------------------------------------
-
-if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral';
-
-// For payment with Paypal only
-if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly')
-{
- dol_syslog("expresscheckout redirect with CallShortcutExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL");
- $resArray = CallShortcutExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL);
-}
-// For payment with Credit card or Paypal
-if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral')
-{
- dol_syslog("expresscheckout redirect with CallMarkExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum");
- //$resArray = CallMarkExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL);
- $resArray = CallMarkExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL,
- $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum);
-}
-// For direct payment with credit card
-if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'cconly')
-{
- //$resArray = DirectPayment (...);
-}
-
-$ack = strtoupper($resArray["ACK"]);
-if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
-{
- RedirectToPayPal ( $resArray["TOKEN"] );
-}
-else
-{
- //Display a user friendly Error on the page using any of the following error information returned by PayPal
- $ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
- $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
- $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
- $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
-
- echo "SetExpressCheckout API call failed. ";
- echo "Detailed Error Message: " . $ErrorLongMsg;
- echo "Short Error Message: " . $ErrorShortMsg;
- echo "Error Code: " . $ErrorCode;
- echo "Error Severity Code: " . $ErrorSeverityCode;
-}
-?>
\ No newline at end of file
diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php
index 0e6bd883d13..100c9203d9b 100755
--- a/htdocs/public/paypal/newpayment.php
+++ b/htdocs/public/paypal/newpayment.php
@@ -31,6 +31,7 @@ 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."/paypal/lib/paypalfunctions.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");
@@ -38,12 +39,6 @@ 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;
-
$langs->load("main");
$langs->load("other");
$langs->load("dict");
@@ -53,6 +48,10 @@ $langs->load("errors");
$langs->load("paybox");
$langs->load("paypal");
+$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root);
+$urlok=$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/paymentok.php?';
+$urlko=$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/paymentko.php?';
+
// Input are:
// type ('invoice','order','contractline'),
// id (object id),
@@ -84,24 +83,50 @@ if (! GETPOST("action"))
}
}
-$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root);
-$urlok=$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/paymentok.php?';
-$urlko=$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/paymentko.php?';
-
+// Complete urls
$TAG=GETPOST("tag");
$FULLTAG=GETPOST("fulltag"); // fulltag is tag with more informations
-
if (!empty($TAG))
{
- $urlok.='tag='.$TAG.'&';
- $urlko.='tag='.$TAG.'&';
+ $urlok.='tag='.urlencode($TAG).'&';
+ $urlko.='tag='.urlencode($TAG).'&';
}
if (!empty($FULLTAG))
{
- $urlok.='fulltag='.$FULLTAG.'&';
- $urlko.='fulltag='.$FULLTAG.'&';
+ $urlok.='fulltag='.urlencode($FULLTAG).'&';
+ $urlko.='fulltag='.urlencode($FULLTAG).'&';
}
+$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="";
+if ($urlko) $PAYPAL_API_KO=$urlko;
+if (empty($PAYPAL_API_USER))
+{
+ dol_print_error('',"Paypal setup param PAYPAL_API_USER not defined");
+ return -1;
+}
+if (empty($PAYPAL_API_PASSWORD))
+{
+ dol_print_error('',"Paypal setup param PAYPAL_API_PASSWORD not defined");
+ return -1;
+}
+if (empty($PAYPAL_API_SIGNATURE))
+{
+ dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE not defined");
+ return -1;
+}
/*
@@ -109,9 +134,10 @@ if (!empty($FULLTAG))
*/
if (GETPOST("action") == 'dopayment')
{
- $PAYPAL_API_PRICE=price2num(GETPOST("newamount"));
+ $PAYPAL_API_PRICE=price2num(GETPOST("newamount"),'MT');
$EMAIL=GETPOST("EMAIL");
$ID=GETPOST("id");
+ $PAYPAL_PAYMENT_TYPE='Sale';
$shipToName=GETPOST("shipToName");
$shipToStreet=GETPOST("shipToStreet");
@@ -123,7 +149,7 @@ if (GETPOST("action") == 'dopayment')
$phoneNum=GETPOST("phoneNum");
$mesg='';
- if (empty($PAYPAL_API_PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount"));
+ if (empty($PAYPAL_API_PRICE) || ! is_numeric($PAYPAL_API_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($FULLTAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode"));
@@ -133,36 +159,6 @@ if (GETPOST("action") == 'dopayment')
{
dol_syslog("newpayment.php call paypal api and do redirect", LOG_DEBUG);
- // 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="";
- if ($urlko) $PAYPAL_API_KO=$urlko;
-
- if (empty($PAYPAL_API_USER))
- {
- dol_print_error('',"Paypal setup param PAYPAL_API_USER not defined");
- return -1;
- }
- if (empty($PAYPAL_API_PASSWORD))
- {
- dol_print_error('',"Paypal setup param PAYPAL_API_PASSWORD not defined");
- return -1;
- }
- if (empty($PAYPAL_API_SIGNATURE))
- {
- dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE not defined");
- return -1;
- }
-
// Other
$PAYPAL_API_DEVISE="EUR";
if ($CURRENCY == 'EUR') $PAYPAL_API_DEVISE="EUR";
@@ -198,7 +194,7 @@ if (GETPOST("action") == 'dopayment')
$_SESSION["Payment_Amount"]=$PAYPAL_API_PRICE;
// A redirect is added if API call successfull
- require_once(DOL_DOCUMENT_ROOT."/public/paypal/expresscheckout.php");
+ RedirectToPaypal($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG);
print '