From d7ee5ee5aca0b16e4c72c526c8992d70397b9c69 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Oct 2010 19:14:08 +0000 Subject: [PATCH] Work on paypal module --- htdocs/langs/en_US/paybox.lang | 4 + htdocs/langs/en_US/paypal.lang | 17 +++- htdocs/langs/fr_FR/paybox.lang | 3 + htdocs/langs/fr_FR/paypal.lang | 17 +++- htdocs/paypal/admin/paypal.php | 127 ++++++++++++++++++---------- htdocs/public/paybox/newpayment.php | 64 +++++++------- htdocs/public/paypal/newpayment.php | 71 ++++++++-------- 7 files changed, 185 insertions(+), 118 deletions(-) diff --git a/htdocs/langs/en_US/paybox.lang b/htdocs/langs/en_US/paybox.lang index 2c5f3113b89..75dc26fa426 100644 --- a/htdocs/langs/en_US/paybox.lang +++ b/htdocs/langs/en_US/paybox.lang @@ -24,3 +24,7 @@ YouCanAddTagOnUrl=You can also add url parameter &tag=value to any 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. +AccountParameter=Account parameters +UsageParameter=Usage parameters +InformationToFindParameters=Help to find your %s account information + diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang index 3851ec9b1b1..8e20415bb38 100644 --- a/htdocs/langs/en_US/paypal.lang +++ b/htdocs/langs/en_US/paypal.lang @@ -1,4 +1,13 @@ -# Dolibarr language file - en_US - paypal -CHARSET=UTF-8 -PaypalSetup=PayPal module setup -PaypalDesc=This module offer pages to allow payment on PayPal by customers. This can be used for a free payment or for a payment on a particular Dolibarr object (invoice, order, ...) \ No newline at end of file +# Dolibarr language file - en_US - paypal +CHARSET=UTF-8 +PaypalSetup=PayPal module setup +PaypalDesc=This module offer pages to allow payment on PayPal by customers. This can be used for a free payment or for a payment on a particular Dolibarr object (invoice, order, ...) +PaypalOrCBDoPayment=Pay with credit card or Paypal +PaypalDoPayment=Pay with Paypal +PaypalCBDoPayment=Pay with credit card +PAYPAL_API_SANDBOX=Mode test/sandbox +PAYPAL_API_USER=API username +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 diff --git a/htdocs/langs/fr_FR/paybox.lang b/htdocs/langs/fr_FR/paybox.lang index 7fd1b0979d3..7376fdb1efc 100644 --- a/htdocs/langs/fr_FR/paybox.lang +++ b/htdocs/langs/fr_FR/paybox.lang @@ -24,3 +24,6 @@ YouCanAddTagOnUrl=Vous pouvez de plus ajouter le paramètre url &tag=value SetupPayBoxToHavePaymentCreatedAutomatically=Configurez votre url PayBox à %s pour avoir le paiement créé automatiquement si validé. YourPaymentHasBeenRecorded=Cette page confirme que votre paiement a bien été enregistré. Merci. YourPaymentHasNotBeenRecorded=Votre paiement n'a pas été enregistré et la transaction a été annulée. Merci. +AccountParameter=Paramètres du compte +UsageParameter=Paramètres d'utilisation +InformationToFindParameters=Informations pour trouver vos paramètres de compte %s \ No newline at end of file diff --git a/htdocs/langs/fr_FR/paypal.lang b/htdocs/langs/fr_FR/paypal.lang index 6d51fa7938c..75ea7640c83 100644 --- a/htdocs/langs/fr_FR/paypal.lang +++ b/htdocs/langs/fr_FR/paypal.lang @@ -1,4 +1,13 @@ -# Dolibarr language file - fr_FR - paypal -CHARSET=UTF-8 -PaypalSetup=Configuration module PayPal -PaypalDesc=Ce module permet d'offrir une page de paiement via le prestataire Paypal pour réaliser un paiement quelconque ou un paiement par rapport à un objet Dolibarr (factures, commande...) +# Dolibarr language file - fr_FR - paypal +CHARSET=UTF-8 +PaypalSetup=Configuration module PayPal +PaypalDesc=Ce module permet d'offrir une page de paiement via le prestataire Paypal pour réaliser un paiement quelconque ou un paiement par rapport à un objet Dolibarr (factures, commande...) +PaypalOrCBDoPayment=Poursuivre le paiement par carte ou par Paypal +PaypalDoPayment=Poursuivre le paiement par Paypal +PaypalCBDoPayment=Poursuivre le paiement par carte +PAYPAL_API_SANDBOX=Mode test/bac à sable (sandbox) +PAYPAL_API_USER=Nom utilisateur API +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 diff --git a/htdocs/paypal/admin/paypal.php b/htdocs/paypal/admin/paypal.php index efb331ec4b6..65d890d7e49 100644 --- a/htdocs/paypal/admin/paypal.php +++ b/htdocs/paypal/admin/paypal.php @@ -38,14 +38,14 @@ if (!$user->admin) if ($_POST["action"] == 'setvalue' && $user->admin) { - $result=dolibarr_set_const($db, "PAYPAL_CSS_URL",$_POST["PAYPAL_CSS_URL"],'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_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); + $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_CSS_URL",$_POST["PAYPAL_CSS_URL"],'chaine',0,'',$conf->entity); + if ($result >= 0) { $mesg='
'.$langs->trans("SetupSaved").'
'; @@ -63,20 +63,26 @@ if ($_POST["action"] == 'setvalue' && $user->admin) $form=new Form($db); -$IBS_SITE="1999888"; # Site test -if (empty($conf->global->PAYPAL_IBS_SITE)) $conf->global->PAYPAL_IBS_SITE=$IBS_SITE; -$IBS_RANG="99"; # Rang test -if (empty($conf->global->PAYPAL_IBS_RANG)) $conf->global->PAYPAL_IBS_RANG=$IBS_RANG; -$IBS_DEVISE="978"; # Euro -if (empty($conf->global->PAYPAL_IBS_DEVISE)) $conf->global->PAYPAL_IBS_DEVISE=$IBS_DEVISE; - llxHeader(); + $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("PaypalSetup"),$linkback,'setup'); print $langs->trans("PaypalDesc")."
\n"; +if ($conf->use_javascript_ajax) +{ + print "\n".''; +} if ($mesg) print '
'.$mesg; @@ -85,52 +91,64 @@ print '
'; print ''; print ''; -$var=true; print ''; + +$var=true; print ''; -print ''; +print ''; print ''; print "\n"; -$var=!$var; -print ''; - -$var=!$var; -print ''; - -$var=!$var; -print ''; - -$var=!$var; -print ''; - -$var=!$var; -print ''; - $var=!$var; print ''; +$var=!$var; +print ''; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + +print '
'.$langs->trans("Parameter").''.$langs->trans("AccountParameter").''.$langs->trans("Value").'
'; -print ''.$langs->trans("PAYPAL_API_USER").''; -print ''; -print '
'.$langs->trans("Example").': paypal_api1.mywebsite.com'; -print '
'; -print ''.$langs->trans("PAYPAL_API_PASSWORD").''; -print ''; -print '
'; -print ''.$langs->trans("PAYPAL_API_SIGNATURE").''; -print ''; -print '
'.$langs->trans("Example").': ASsqXEmw4KzmX-CPChWSVDNCNfd.A3YNR7uz-VncXXAERFDFDFDF'; -print '
'; -print ''.$langs->trans("PAYPAL_API_INTEGRAL_OR_PAYPALONLY").''; -print $form->selectarray("PAYPAL_API_INTEGRAL_OR_PAYPALONLY",array('integral'=>'Integral','paypalonly'=>'Paypal only'),$conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY); -print '
'; -print ''.$langs->trans("PAYPAL_API_EXPRESS").''; -print $form->selectyesno("PAYPAL_API_EXPRESS",$conf->global->PAYPAL_API_EXPRESS); -print '
'; print $langs->trans("PAYPAL_API_SANDBOX").''; print $form->selectyesno("PAYPAL_API_SANDBOX",$conf->global->PAYPAL_API_SANDBOX); print '
'; +print $langs->trans("PAYPAL_API_USER").''; +print ''; +print '
'.$langs->trans("Example").': paypal_api1.mywebsite.com'; +print '
'; +print $langs->trans("PAYPAL_API_PASSWORD").''; +print ''; +print '
'; +print $langs->trans("PAYPAL_API_SIGNATURE").''; +print ''; +print '
'.$langs->trans("Example").': ASsqXEmw4KzmX-CPChWSVDNCNfd.A3YNR7uz-VncXXAERFDFDFDF'; +print '
'; + +print ''; + +$var=true; +print ''; +print ''; +print ''; +print "\n"; + +$var=!$var; +print ''; + +/*$var=!$var; +print ''; +*/ + $var=!$var; print '
'.$langs->trans("UsageParameter").''.$langs->trans("Value").'
'; +print $langs->trans("PAYPAL_API_INTEGRAL_OR_PAYPALONLY").''; +print $form->selectarray("PAYPAL_API_INTEGRAL_OR_PAYPALONLY",array('integral'=>'Integral','paypalonly'=>'Paypal only'),$conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY); +print '
'; +print ''.$langs->trans("PAYPAL_API_EXPRESS").''; +print $form->selectyesno("PAYPAL_API_EXPRESS",$conf->global->PAYPAL_API_EXPRESS); +print '
'; print $langs->trans("PAYPAL_CSS_URL").''; @@ -144,6 +162,27 @@ print '
'; print '

'; +// Help doc +print ''.$langs->trans("InformationToFindParameters","Paypal").':
'; +if ($conf->use_javascript_ajax) print ''.$langs->trans("ClickHere").'...'; + +print '
'; +print 'Your API authentication information can be found with following steps. We recommend that you open a separate Web browser session when carrying out this procedure.
+1. Log in to your PayPal Premier or Business account.
+2. Click the Profile subtab located under the My Account heading.
+3. Click the API Access link under the Account Information header.
+4. Click the View API Certificate link in the right column.
+5. Click the Request API signature radio button on the Request API Credentials page.
+6. Complete the Request API Credential Request form by clicking the agreement checkbox and clicking Submit.
+7. Save the values for API Username, Password and Signature (make sure this long character signature is copied).
+8. Click the "Modify" button after copying your API Username, Password, and Signature. +'; +print '
'; + + +print '

'; + +// Url list print ''.$langs->trans("FollowingUrlAreAvailableToMakePayments").':
'; // Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr' $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root); diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php index 3d90b755558..5819b370554 100644 --- a/htdocs/public/paybox/newpayment.php +++ b/htdocs/public/paybox/newpayment.php @@ -44,22 +44,13 @@ $token = md5(uniqid(mt_rand(),TRUE)); // Genere un hash d'un nombre aleatoire 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("paybox"); $langs->load("dict"); $langs->load("bills"); $langs->load("companies"); $langs->load("errors"); +$langs->load("paybox"); // Input are: // type ('invoice','order','contractline'), @@ -70,26 +61,27 @@ $langs->load("errors"); if (empty($_REQUEST["currency"])) $currency=$conf->global->MAIN_MONNAIE; else $currency=$_REQUEST["currency"]; -if (empty($_REQUEST["amount"]) && empty($_REQUEST["source"])) + +if (! GETPOST("action")) { - dol_print_error('','ErrorBadParameters'); - session_destroy(); - exit; + if (empty($_REQUEST["amount"]) && empty($_REQUEST["source"])) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - amount or source"); + exit; + } + $amount=$_REQUEST["amount"]; + if (is_numeric($amount) && empty($_REQUEST["tag"]) && empty($_REQUEST["source"])) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - tag or source"); + exit; + } + if (! empty($REQUEST["source"]) && empty($_REQUEST["ref"])) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - ref"); + exit; + } } -$amount=$_REQUEST["amount"]; -if (is_numeric($amount) && empty($_REQUEST["tag"]) && empty($_REQUEST["source"])) -{ - dol_print_error('','ErrorBadParameters'); - session_destroy(); - exit; -} -if (! empty($REQUEST["source"]) && empty($_REQUEST["ref"])) -{ - dol_print_error('','ErrorBadParameters'); - session_destroy(); - exit; -} -$suffix=$_REQUEST["suffix"]; +$suffix=GETPOST("suffix"); @@ -306,7 +298,9 @@ if ($_REQUEST["source"] == 'order') $var=!$var; print ''.$langs->trans("YourEMail"); print ' ('.$langs->trans("ToComplete").')'; - print ''."\n"; + $email=$order->client->email; + $email=(GETPOST("EMAIL")?GETPOST("EMAIL"):(isValidEmail($email)?$email:'')); + print ''."\n"; } @@ -382,7 +376,9 @@ if ($_REQUEST["source"] == 'invoice') $var=!$var; print ''.$langs->trans("YourEMail"); print ' ('.$langs->trans("ToComplete").')'; - print ''."\n"; + $email=$invoice->client->email; + $email=(GETPOST("EMAIL")?GETPOST("EMAIL"):(isValidEmail($email)?$email:'')); + print ''."\n"; } // Payment on contract line @@ -546,7 +542,9 @@ if ($_REQUEST["source"] == 'contractline') $var=!$var; print ''.$langs->trans("YourEMail"); print ' ('.$langs->trans("ToComplete").')'; - print ''."\n"; + $email=$contract->client->email; + $email=(GETPOST("EMAIL")?GETPOST("EMAIL"):(isValidEmail($email)?$email:'')); + print ''."\n"; } @@ -623,7 +621,9 @@ if ($_REQUEST["source"] == 'membersubscription') $var=!$var; print ''.$langs->trans("YourEMail"); print ' ('.$langs->trans("ToComplete").')'; - print ''."\n"; + $email=$member->client->email; + $email=(GETPOST("EMAIL")?GETPOST("EMAIL"):(isValidEmail($email)?$email:'')); + print ''."\n"; } diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index 1436ace9a88..2a55e83a4d1 100755 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -44,15 +44,6 @@ $token = md5(uniqid(mt_rand(),TRUE)); // Genere un hash d'un nombre aleatoire 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"); @@ -71,33 +62,35 @@ $langs->load("paypal"); if (empty($_REQUEST["currency"])) $currency=$conf->global->MAIN_MONNAIE; else $currency=$_REQUEST["currency"]; -if (empty($_REQUEST["amount"]) && empty($_REQUEST["source"])) + +var_dump($_POST); +if (! GETPOST("action")) { - dol_print_error('','ErrorBadParameters'); - session_destroy(); - exit; + if (empty($_REQUEST["amount"]) && empty($_REQUEST["source"])) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - amount or source"); + exit; + } + $amount=$_REQUEST["amount"]; + if (is_numeric($amount) && empty($_REQUEST["tag"]) && empty($_REQUEST["source"])) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - tag or source"); + exit; + } + if (! empty($REQUEST["source"]) && empty($_REQUEST["ref"])) + { + dol_print_error('',$langs->trans('ErrorBadParameters')." - ref"); + exit; + } } -$amount=$_REQUEST["amount"]; -if (is_numeric($amount) && empty($_REQUEST["tag"]) && empty($_REQUEST["source"])) -{ - dol_print_error('','ErrorBadParameters'); - session_destroy(); - exit; -} -if (! empty($REQUEST["source"]) && empty($_REQUEST["ref"])) -{ - dol_print_error('','ErrorBadParameters'); - session_destroy(); - exit; -} -$suffix=$_REQUEST["suffix"]; +$suffix=GETPOST("suffix"); /* * Actions */ -if ($_REQUEST["action"] == 'dopayment') +if (GETPOST("action") == 'dopayment') { $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root); @@ -116,9 +109,11 @@ if ($_REQUEST["action"] == 'dopayment') if (empty($mesg)) { - //print_paypal_redirect($PAYPAL_API_PRICE, $conf->monnaie, $EMAIL, $urlok, $urlko, $TAG, $ID); + /* + print_paypal_redirect($PAYPAL_API_PRICE, $conf->monnaie, $EMAIL, $urlok, $urlko, $TAG, $ID); + exit; - /*global $conf, $langs, $db; + 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; @@ -395,7 +390,9 @@ if ($_REQUEST["source"] == 'order') $var=!$var; print ''.$langs->trans("YourEMail"); print ' ('.$langs->trans("ToComplete").')'; - print ''."\n"; + $email=$order->client->email; + $email=(GETPOST("EMAIL")?GETPOST("EMAIL"):(isValidEmail($email)?$email:'')); + print ''."\n"; } @@ -471,7 +468,9 @@ if ($_REQUEST["source"] == 'invoice') $var=!$var; print ''.$langs->trans("YourEMail"); print ' ('.$langs->trans("ToComplete").')'; - print ''."\n"; + $email=$invoice->client->email; + $email=(GETPOST("EMAIL")?GETPOST("EMAIL"):(isValidEmail($email)?$email:'')); + print ''."\n"; } // Payment on contract line @@ -635,7 +634,9 @@ if ($_REQUEST["source"] == 'contractline') $var=!$var; print ''.$langs->trans("YourEMail"); print ' ('.$langs->trans("ToComplete").')'; - print ''."\n"; + $email=$contract->client->email; + $email=(GETPOST("EMAIL")?GETPOST("EMAIL"):(isValidEmail($email)?$email:'')); + print ''."\n"; } @@ -712,7 +713,9 @@ if ($_REQUEST["source"] == 'membersubscription') $var=!$var; print ''.$langs->trans("YourEMail"); print ' ('.$langs->trans("ToComplete").')'; - print ''."\n"; + $email=$member->client->email; + $email=(GETPOST("EMAIL")?GETPOST("EMAIL"):(isValidEmail($email)?$email:'')); + print ''."\n"; }