diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php
index 921b24d5497..96ba8d3c7d2 100644
--- a/htdocs/paybox/admin/paybox.php
+++ b/htdocs/paybox/admin/paybox.php
@@ -167,26 +167,26 @@ print '
';
if ($conf->commande->enabled)
{
print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':
';
- print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=order&ref=order_ref'."
\n";
+ print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paybox/newpayment.php?source=order&ref=order_ref'."
\n";
print '
';
}
if ($conf->facture->enabled)
{
print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice",$servicename).':
';
- print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=invoice&ref=invoice_ref'."
\n";
+ print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paybox/newpayment.php?source=invoice&ref=invoice_ref'."
\n";
// print $langs->trans("SetupPayBoxToHavePaymentCreatedAutomatically",$langs->transnoentitiesnoconv("FeatureNotYetAvailable"))."
\n";
print '
';
}
if ($conf->contrat->enabled)
{
print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine",$servicename).':
';
- print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=contractline&ref=contractline_ref'."
\n";
+ print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paybox/newpayment.php?source=contractline&ref=contractline_ref'."
\n";
print '
';
}
if ($conf->adherent->enabled)
{
print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription",$servicename).':
';
- print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=membersubscription&ref=member_ref'."
\n";
+ print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paybox/newpayment.php?source=membersubscription&ref=member_ref'."
\n";
print '
';
}
print $langs->trans("YouCanAddTagOnUrl");
diff --git a/htdocs/paybox/lib/paybox.lib.php b/htdocs/paybox/lib/paybox.lib.php
index 3c02bce6487..0ef1af4838c 100755
--- a/htdocs/paybox/lib/paybox.lib.php
+++ b/htdocs/paybox/lib/paybox.lib.php
@@ -19,12 +19,10 @@
*/
/**
- * \file htdocs/paybox/paybox.lib.php
+ * \file htdocs/paybox/lib/paybox.lib.php
* \brief Library for common paybox functions
* \version $Id$
*/
-
-
function llxHeaderPaybox($title, $head = "")
{
global $user, $conf, $langs;
@@ -69,7 +67,7 @@ function print_paybox_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG)
{
global $conf, $langs, $db;
- dol_syslog("Paypal.lib::print_paybox_redirect", LOG_DEBUG);
+ dol_syslog("Paybox.lib::print_paybox_redirect", LOG_DEBUG);
// Clean parameters
$PBX_IDENTIFIANT="2"; # Identifiant pour v2 test
diff --git a/htdocs/paypal/admin/paypal.php b/htdocs/paypal/admin/paypal.php
index 7b876230abf..efb331ec4b6 100644
--- a/htdocs/paypal/admin/paypal.php
+++ b/htdocs/paypal/admin/paypal.php
@@ -38,17 +38,10 @@ if (!$user->admin)
if ($_POST["action"] == 'setvalue' && $user->admin)
{
- //$result=dolibarr_set_const($db, "PAYPAL_IBS_DEVISE",$_POST["PAYPAL_IBS_DEVISE"],'chaine',0,'',$conf->entity);
$result=dolibarr_set_const($db, "PAYPAL_CSS_URL",$_POST["PAYPAL_CSS_URL"],'chaine',0,'',$conf->entity);
-/* $result=dolibarr_set_const($db, "PAYPAL_CREDITOR",$_POST["PAYPAL_CREDITOR"],'chaine',0,'',$conf->entity);
- $result=dolibarr_set_const($db, "PAYPAL_CGI_URL_V1",$_POST["PAYPAL_CGI_URL_V1"],'chaine',0,'',$conf->entity);
- $result=dolibarr_set_const($db, "PAYPAL_CGI_URL_V2",$_POST["PAYPAL_CGI_URL_V2"],'chaine',0,'',$conf->entity);
- $result=dolibarr_set_const($db, "PAYPAL_IBS_SITE",$_POST["PAYPAL_IBS_SITE"],'chaine',0,'',$conf->entity);
- $result=dolibarr_set_const($db, "PAYPAL_IBS_RANG",$_POST["PAYPAL_IBS_RANG"],'chaine',0,'',$conf->entity);
- $result=dolibarr_set_const($db, "PAYPAL_PBX_IDENTIFIANT",$_POST["PAYPAL_PBX_IDENTIFIANT"],'chaine',0,'',$conf->entity);
-*/
+
$result=dolibarr_set_const($db, "PAYPAL_API_SANDBOX",$_POST["PAYPAL_API_SANDBOX"],'chaine',0,'',$conf->entity);
- $result=dolibarr_set_const($db, "PAYPAL_API_INTEGRAL",$_POST["PAYPAL_API_INTEGRAL"],'chaine',0,'',$conf->entity);
+ $result=dolibarr_set_const($db, "PAYPAL_API_INTEGRAL_OR_PAYPALONLY",$_POST["PAYPAL_API_INTEGRAL_OR_PAYPALONLY"],'chaine',0,'',$conf->entity);
$result=dolibarr_set_const($db, "PAYPAL_API_USER",$_POST["PAYPAL_API_USER"],'chaine',0,'',$conf->entity);
$result=dolibarr_set_const($db, "PAYPAL_API_PASSWORD",$_POST["PAYPAL_API_PASSWORD"],'chaine',0,'',$conf->entity);
$result=dolibarr_set_const($db, "PAYPAL_API_SIGNATURE",$_POST["PAYPAL_API_SIGNATURE"],'chaine',0,'',$conf->entity);
@@ -161,26 +154,26 @@ print '
';
if ($conf->commande->enabled)
{
print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':
';
- print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/newpayment.php?amount=order&ref=order_ref'."
\n";
+ print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/newpayment.php?source=order&ref=order_ref'."
\n";
print '
';
}
if ($conf->facture->enabled)
{
print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice",$servicename).':
';
- print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/newpayment.php?amount=invoice&ref=invoice_ref'."
\n";
+ print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/newpayment.php?source=invoice&ref=invoice_ref'."
\n";
// print $langs->trans("SetupPaypalToHavePaymentCreatedAutomatically",$langs->transnoentitiesnoconv("FeatureNotYetAvailable"))."
\n";
print '
';
}
if ($conf->contrat->enabled)
{
print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine",$servicename).':
';
- print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/newpayment.php?amount=contractline&ref=contractline_ref'."
\n";
+ print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/newpayment.php?source=contractline&ref=contractline_ref'."
\n";
print '
';
}
if ($conf->adherent->enabled)
{
print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription",$servicename).':
';
- print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/newpayment.php?amount=membersubscription&ref=member_ref'."
\n";
+ print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/newpayment.php?source=membersubscription&ref=member_ref'."
\n";
print '
';
}
print $langs->trans("YouCanAddTagOnUrl");
diff --git a/htdocs/paypal/expresscheckout.php b/htdocs/paypal/expresscheckout.php
new file mode 100644
index 00000000000..31262c9fbf3
--- /dev/null
+++ b/htdocs/paypal/expresscheckout.php
@@ -0,0 +1,82 @@
+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')
+{
+ $resArray = CallShortcutExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL);
+}
+// For payment with Credit card or Paypal
+if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral')
+{
+ $resArray = CallMarkExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL);
+}
+// 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/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php
index e20381f628b..77c9486f0ff 100755
--- a/htdocs/paypal/lib/paypal.lib.php
+++ b/htdocs/paypal/lib/paypal.lib.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2008-2010 Laurent Destailleur
* Copyright (C) 2005-2007 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
@@ -19,12 +19,10 @@
*/
/**
- * \file htdocs/paypal/paypal.lib.php
+ * \file htdocs/paypal/lib/paypal.lib.php
* \brief Library for common paypal functions
* \version $Id$
*/
-
-
function llxHeaderPaypal($title, $head = "")
{
global $user, $conf, $langs;
@@ -68,90 +66,53 @@ function llxFooterPaypal()
function print_paypal_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG)
{
global $conf, $langs, $db;
+ global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE;
+ global $PAYPAL_API_DEVISE, $PAYPAL_API_OK, $PAYPAL_API_KO;
+ global $PAYPAL_API_SANDBOX;
- dol_syslog("Paypal.lib::print_paybox_redirect", LOG_DEBUG);
+ dol_syslog("Paypal.lib::print_paypal_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";
+ $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;
- $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))
+ if (empty($PAYPAL_API_USER))
{
- dol_print_error('',"Paybox setup param PAYBOX_IBS_DEVISE not defined");
+ dol_print_error('',"Paypal setup param PAYPAL_API_USER not defined");
return -1;
}
- if (empty($URLPAYBOX))
+ if (empty($PAYPAL_API_PASSWORD))
{
- dol_print_error('',"Paybox setup param PAYBOX_CGI_URL_V1 and PAYBOX_CGI_URL_V2 undefined");
+ dol_print_error('',"Paypal setup param PAYPAL_API_PASSWORD not defined");
return -1;
}
- if (empty($IBS_SITE))
+ if (empty($PAYPAL_API_SIGNATURE))
{
- 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");
+ dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE 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="".$langsiso->trans("YouWillBeRedirectedOnPayBox")."
".$langsiso->trans("PleaseBePatient")."...
";
- $IBS_TXT=' '; // Use a space
- $IBS_BOUTPI=$langs->trans("Wait");
- //$IBS_BOUTPI='';
- $IBS_EFFECTUE=$urlok;
- $IBS_ANNULE=$urlko;
- $IBS_REFUSE=$urlko;
- $IBS_BKGD="#FFFFFF";
- $IBS_WAIT="2000";
- $IBS_LANG="GBR"; // By default GBR=english (FRA, GBR, ESP, ITA et DEU...)
- if (preg_match('/^FR/i',$langs->defaultlang)) $IBS_LANG="FRA";
- if (preg_match('/^ES/i',$langs->defaultlang)) $IBS_LANG="ESP";
- if (preg_match('/^IT/i',$langs->defaultlang)) $IBS_LANG="ITA";
- if (preg_match('/^DE/i',$langs->defaultlang)) $IBS_LANG="DEU";
- if (preg_match('/^NL/i',$langs->defaultlang)) $IBS_LANG="NLD";
- if (preg_match('/^SE/i',$langs->defaultlang)) $IBS_LANG="SWE";
- $IBS_OUTPUT='E';
- $PBX_SOURCE='HTML';
- $PBX_TYPEPAIEMENT='CARTE';
+ // Other
+ $PAYPAL_API_DEVISE="EUR";
+ if ($CURRENCY == 'EUR') $PAYPAL_API_DEVISE="EUR";
+ if ($CURRENCY == 'USD') $PAYPAL_API_DEVISE="USD";
+ $PAYPAL_API_OK=$urlok;
+ $PAYPAL_API_KO=$urlko;
- dol_syslog("Soumission Paybox", LOG_DEBUG);
- dol_syslog("IBS_MODE: $IBS_MODE", LOG_DEBUG);
- dol_syslog("IBS_SITE: $IBS_SITE", LOG_DEBUG);
- dol_syslog("IBS_RANG: $IBS_RANG", LOG_DEBUG);
- dol_syslog("IBS_TOTAL: $IBS_TOTAL", LOG_DEBUG);
- dol_syslog("IBS_DEVISE: $IBS_DEVISE", LOG_DEBUG);
- dol_syslog("IBS_CMD: $IBS_CMD", LOG_DEBUG);
- dol_syslog("IBS_PORTEUR: $IBS_PORTEUR", LOG_DEBUG);
- dol_syslog("IBS_RETOUR: $IBS_RETOUR", LOG_DEBUG);
- dol_syslog("IBS_EFFECTUE: $IBS_EFFECTUE", LOG_DEBUG);
- dol_syslog("IBS_ANNULE: $IBS_ANNULE", LOG_DEBUG);
- dol_syslog("IBS_REFUSE: $IBS_REFUSE", LOG_DEBUG);
- dol_syslog("IBS_BKGD: $IBS_BKGD", LOG_DEBUG);
- dol_syslog("IBS_WAIT: $IBS_WAIT", LOG_DEBUG);
- dol_syslog("IBS_LANG: $IBS_LANG", LOG_DEBUG);
- dol_syslog("IBS_OUTPUT: $IBS_OUTPUT", LOG_DEBUG);
- dol_syslog("PBX_IDENTIFIANT: $PBX_IDENTITIANT", LOG_DEBUG);
- dol_syslog("PBX_SOURCE: $PBX_SOURCE", LOG_DEBUG);
- dol_syslog("PBX_TYPEPAIEMENT: $PBX_TYPEPAIEMENT", LOG_DEBUG);
+ dol_syslog("Soumission Paypal", LOG_DEBUG);
+ dol_syslog("PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG);
+ dol_syslog("PAYPAL_API_PASSWORD: $PAYPAL_API_PASSWORD", LOG_DEBUG);
+ dol_syslog("PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG);
+ dol_syslog("PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG);
+ dol_syslog("PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG);
+ dol_syslog("PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG);
+ dol_syslog("PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", LOG_DEBUG);
header("Content-type: text/html; charset=".$conf->file->character_set_client);
@@ -162,62 +123,26 @@ function print_paypal_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG)
print ''."\n";
print "\n";
+ $_SESSION["Payment_Amount"]=$PRICE;
+
+ // A redirect is added if API call successfull
+ require_once(DOL_DOCUMENT_ROOT."/paypal/expresscheckout.php");
+
// Formulaire pour module Paybox
- print '";
+// print ''."\n";
- // For Paybox V1 (IBS_xxx)
- /*
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- */
-
- // For Paybox V2 (PBX_xxx)
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
-
- print ''."\n";
-
- // Formulaire pour module Paybox v2 (PBX_xxx)
+// print "\n";
+// print ''."\n";
+// print "\n";
- print "\n";
- print ''."\n";
- print "\n";
print '