Go to the documentation of this file.
27 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
33 $servicename =
'PayPal';
36 $langs->loadLangs(array(
'admin',
'other',
'paypal',
'paybox',
'stripe'));
42 $action =
GETPOST(
'action',
'aZ09');
44 if ($action ==
'setvalue' && $user->admin) {
47 $result =
dolibarr_set_const($db,
"PAYPAL_API_USER",
GETPOST(
'PAYPAL_API_USER',
'alpha'),
'chaine', 0,
'', $conf->entity);
51 $result =
dolibarr_set_const($db,
"PAYPAL_API_PASSWORD",
GETPOST(
'PAYPAL_API_PASSWORD',
'alpha'),
'chaine', 0,
'', $conf->entity);
55 $result =
dolibarr_set_const($db,
"PAYPAL_API_SIGNATURE",
GETPOST(
'PAYPAL_API_SIGNATURE',
'alpha'),
'chaine', 0,
'', $conf->entity);
59 $result =
dolibarr_set_const($db,
"PAYPAL_SSLVERSION",
GETPOST(
'PAYPAL_SSLVERSION',
'alpha'),
'chaine', 0,
'', $conf->entity);
63 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_CREDITOR",
GETPOST(
'ONLINE_PAYMENT_CREDITOR',
'alpha'),
'chaine', 0,
'', $conf->entity);
67 $result =
dolibarr_set_const($db,
"PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS",
GETPOST(
'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS',
'int'),
'chaine', 0,
'', $conf->entity);
71 $result =
dolibarr_set_const($db,
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY",
GETPOST(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY',
'alpha'),
'chaine', 0,
'', $conf->entity);
75 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_CSS_URL",
GETPOST(
'ONLINE_PAYMENT_CSS_URL',
'alpha'),
'chaine', 0,
'', $conf->entity);
79 $result =
dolibarr_set_const($db,
"PAYPAL_ADD_PAYMENT_URL",
GETPOST(
'PAYPAL_ADD_PAYMENT_URL',
'alpha'),
'chaine', 0,
'', $conf->entity);
83 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_FORM",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_FORM',
'restricthtml'),
'chaine', 0,
'', $conf->entity);
87 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_OK",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_OK',
'restricthtml'),
'chaine', 0,
'', $conf->entity);
91 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_KO",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_KO',
'restricthtml'),
'chaine', 0,
'', $conf->entity);
95 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_SENDEMAIL",
GETPOST(
'ONLINE_PAYMENT_SENDEMAIL',
'alpha'),
'chaine', 0,
'', $conf->entity);
100 $result =
dolibarr_set_const($db,
"PAYMENT_SECURITY_TOKEN",
GETPOST(
'PAYMENT_SECURITY_TOKEN',
'alpha'),
'chaine', 0,
'', $conf->entity);
101 if (!($result > 0)) {
104 if (empty($conf->use_javascript_ajax)) {
105 $result =
dolibarr_set_const($db,
"PAYMENT_SECURITY_TOKEN_UNIQUE",
GETPOST(
'PAYMENT_SECURITY_TOKEN_UNIQUE',
'alpha'),
'chaine', 0,
'', $conf->entity);
106 if (!($result > 0)) {
120 if ($action ==
"setlive") {
121 $liveenable =
GETPOST(
'value',
'int') ? 0 : 1;
122 $res =
dolibarr_set_const($db,
"PAYPAL_API_SANDBOX", $liveenable,
'yesno', 0,
'', $conf->entity);
140 llxHeader(
'', $langs->trans(
"PaypalSetup"));
143 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
148 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
149 print
'<input type="hidden" name="token" value="'.newToken().
'">';
150 print
'<input type="hidden" name="action" value="setvalue">';
155 print
'<span class="opacitymedium">'.$langs->trans(
"PaypalDesc").
"</span><br>\n";
158 if (!function_exists(
'curl_version')) {
159 $langs->load(
"errors");
160 setEventMessages($langs->trans(
"ErrorPhpCurlNotInstalled"),
null,
'errors');
166 print
'<div class="div-table-responsive-no-min">';
167 print
'<table class="noborder centpercent">';
170 print
'<tr class="liste_titre">';
171 print
'<td>'.$langs->trans(
"AccountParameter").
'</td>';
172 print
'<td>'.$langs->trans(
"Value").
'</td>';
175 print
'<tr class="oddeven">';
177 print $langs->trans(
"PaypalLiveEnabled").
'</td><td>';
178 if (empty($conf->global->PAYPAL_API_SANDBOX)) {
179 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setlive&token='.
newToken().
'&value=0">';
180 print
img_picto($langs->trans(
"Activated"),
'switch_on');
182 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setlive&token='.
newToken().
'&value=1">';
183 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
187 print
'<tr class="oddeven"><td class="fieldrequired">';
188 print $langs->trans(
"PAYPAL_API_USER").
'</td><td>';
189 print
'<input size="32" type="text" name="PAYPAL_API_USER" value="'.$conf->global->PAYPAL_API_USER.
'">';
190 print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': admin-facilitator_api1.example.com, paypal_api1.mywebsite.com</span>';
194 print
'<tr class="oddeven"><td class="fieldrequired">';
195 print $langs->trans(
"PAYPAL_API_PASSWORD").
'</td><td>';
196 print
'<input size="32" type="text" name="PAYPAL_API_PASSWORD" value="'.$conf->global->PAYPAL_API_PASSWORD.
'">';
200 print
'<tr class="oddeven"><td class="fieldrequired">';
201 print $langs->trans(
"PAYPAL_API_SIGNATURE").
'</td><td>';
202 print
'<input size="64" type="text" name="PAYPAL_API_SIGNATURE" value="'.$conf->global->PAYPAL_API_SIGNATURE.
'">';
203 print
'<br><span class="opacitymedium">'.$langs->trans(
"Example").
': ASsqXEmw4KzmX-CPChWSVDNCNfd.A3YNR7uz-VncXXAERFDFDFDF</span>';
207 print
'<tr class="oddeven"><td>';
208 print $langs->trans(
"PAYPAL_SSLVERSION").
'</td><td>';
209 print
$form->selectarray(
"PAYPAL_SSLVERSION", array(
'1'=> $langs->trans(
'TLSv1'),
'6'=> $langs->trans(
'TLSv1.2')), $conf->global->PAYPAL_SSLVERSION);
218 print
'<div class="div-table-responsive-no-min">';
219 print
'<table class="noborder centpercent">';
222 print
'<tr class="liste_titre">';
223 print
'<td>'.$langs->trans(
"UsageParameter").
'</td>';
224 print
'<td>'.$langs->trans(
"Value").
'</td>';
228 print
'<tr class="oddeven"><td>';
229 print $langs->trans(
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY").
'</td><td>';
230 print
$form->selectarray(
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY", array(
'integral'=> $langs->trans(
'PaypalModeIntegral'),
'paypalonly'=> $langs->trans(
'PaypalModeOnlyPaypal')), $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY);
241 print
'<tr class="oddeven"><td>';
242 print $langs->trans(
"PublicVendorName").
'</td><td>';
243 print
'<input size="64" type="text" name="ONLINE_PAYMENT_CREDITOR" value="'.$conf->global->ONLINE_PAYMENT_CREDITOR.
'">';
244 print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': '.$mysoc->name.
'</span>';
247 if (!empty($conf->banque->enabled)) {
248 print
'<tr class="oddeven"><td>';
249 print $langs->trans(
"BankAccount").
'</td><td>';
251 $form->select_comptes($conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS,
'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS', 0,
'', 1);
255 print
'<tr class="oddeven"><td>';
256 print $langs->trans(
"CSSUrlForPaymentForm").
'</td><td>';
257 print
'<input size="64" type="text" name="ONLINE_PAYMENT_CSS_URL" value="'.$conf->global->ONLINE_PAYMENT_CSS_URL.
'">';
258 print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': http://mysite/mycss.css</span>';
262 print
'<tr class="oddeven"><td>';
263 print $langs->trans(
"PAYPAL_ADD_PAYMENT_URL").
'</td><td>';
264 print
$form->selectyesno(
"PAYPAL_ADD_PAYMENT_URL", $conf->global->PAYPAL_ADD_PAYMENT_URL, 1);
268 print
'<tr class="oddeven"><td>';
269 print $langs->trans(
"MessageForm").
'</td><td>';
270 $doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_FORM', $conf->global->ONLINE_PAYMENT_MESSAGE_FORM,
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
271 $doleditor->Create();
275 print
'<tr class="oddeven"><td>';
276 print $langs->trans(
"MessageOK").
'</td><td>';
277 $doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_OK', $conf->global->ONLINE_PAYMENT_MESSAGE_OK,
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
278 $doleditor->Create();
282 print
'<tr class="oddeven"><td>';
283 print $langs->trans(
"MessageKO").
'</td><td>';
284 $doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_KO', $conf->global->ONLINE_PAYMENT_MESSAGE_KO,
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
285 $doleditor->Create();
289 print
'<tr class="oddeven"><td>';
290 print $langs->trans(
"ONLINE_PAYMENT_SENDEMAIL").
'</td><td>';
291 print
'<input class="minwidth200" type="text" name="ONLINE_PAYMENT_SENDEMAIL" value="'.$conf->global->ONLINE_PAYMENT_SENDEMAIL.
'">';
292 print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': myemail@myserver.com, Payment service <myemail2@myserver2.com></span>';
300 print
'<div class="div-table-responsive-no-min">';
301 print
'<table class="noborder centpercent">';
303 print
'<tr class="liste_titre">';
304 print
'<td>'.$langs->trans(
"UrlGenerationParameters").
'</td>';
305 print
'<td>'.$langs->trans(
"Value").
'</td>';
309 print
'<tr class="oddeven"><td>';
310 print $langs->trans(
"SecurityToken").
'</td><td>';
311 print
'<input class="minwidth300" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.
'">';
312 if (!empty($conf->use_javascript_ajax)) {
313 print
' '.img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_token" class="linkobject"');
315 if (!empty($conf->global->PAYMENT_SECURITY_ACCEPT_ANY_TOKEN)) {
316 $langs->load(
"errors");
317 print
img_warning($langs->trans(
"WarningTheHiddenOptionIsOn",
'PAYMENT_SECURITY_ACCEPT_ANY_TOKEN'),
'',
'pictowarning marginleftonly');
321 print
'<tr class="oddeven"><td>';
322 print $langs->trans(
"SecurityTokenIsUnique").
'</td><td>';
323 if ($conf->use_javascript_ajax) {
326 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
327 print
$form->selectarray(
"PAYMENT_SECURITY_TOKEN_UNIQUE", $arrval, $conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE);
336 print
$form->buttonsSaveCancel(
"Modify",
'');
343 print
'<u>'.$langs->trans(
"InformationToFindParameters",
"Paypal").
'</u>:<br>';
344 if (!empty($conf->use_javascript_ajax)) {
345 print
'<a class="reposition" id="apidoca">'.$langs->trans(
"ClickHere").
'...</a>';
348 $realpaypalurl =
'www.paypal.com';
349 $sandboxpaypalurl =
'developer.paypal.com';
351 print
'<div id="apidoc">';
352 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.<br>
353 1. Log in to your PayPal account (on real paypal <a href="https://'.$realpaypalurl.
'" target="_blank" rel="noopener noreferrer external">'.$realpaypalurl.
'</a> (or sandbox <a href="https://'.$sandboxpaypalurl.
'" target="_blank" rel="noopener noreferrer external">'.$sandboxpaypalurl.
'</a>).<br>
354 2. Click the "Profile" or "Preferencies" subtab located under the My Account heading.<br>
355 3. Click the link "API Access".<br>
356 4. Click the View API Certificate link in the right column.<br>
357 5. Click the Request API signature radio button on the Request API Credentials page.<br>
358 6. Complete the Request API Credential Request form by clicking the agreement checkbox and clicking Submit.<br>
359 7. Save the values for API Username, Password and Signature (make sure this long character signature is copied).<br>
360 8. Click the "Modify" button after copying your API Username, Password, and Signature.
364 if (!empty($conf->use_javascript_ajax)) {
365 print
"\n".
'<script type="text/javascript">';
366 print
'$(document).ready(function () {
368 $("#apidoca").click(function() {
369 console.log("We click on apidoca show/hide");
371 $("#apidoca").hide();
382 include DOL_DOCUMENT_ROOT.
'/core/tpl/onlinepaymentlinks.tpl.php';
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='')
On/off button for constant.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
paypaladmin_prepare_head()
Define head array for tabs of paypal tools setup pages.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage a WYSIWYG editor.