29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
36$servicename =
'PayPal';
48$langs->loadLangs(array(
'admin',
'other',
'paypal',
'stripe'));
54$action =
GETPOST(
'action',
'aZ09');
57if ($action ==
'setvalue' && $user->admin) {
84 $result =
dolibarr_set_const($db,
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY",
GETPOST(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY',
'alpha'),
'chaine', 0,
'',
$conf->entity);
96 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_FORM",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_FORM',
'restricthtml'),
'chaine', 0,
'',
$conf->entity);
100 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_OK",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_OK',
'restricthtml'),
'chaine', 0,
'',
$conf->entity);
101 if (!($result > 0)) {
104 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_KO",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_KO',
'restricthtml'),
'chaine', 0,
'',
$conf->entity);
105 if (!($result > 0)) {
109 if (!($result > 0)) {
114 if (!($result > 0)) {
120 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
123 dol_print_error($db);
127if ($action ==
"setlive") {
134 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
136 setEventMessages($langs->trans(
"Error"),
null,
'errors');
145$form =
new Form($db);
147llxHeader(
'', $langs->trans(
"PaypalSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-paypal page-admin_paypal');
150$linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'restore_lastsearch_values' => 1]).
'">'.img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
155print
'<form method="post" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" spellcheck="false">';
156print
'<input type="hidden" name="token" value="'.newToken().
'">';
157print
'<input type="hidden" name="action" value="setvalue">';
162print
'<div class="info">'.$langs->trans(
"PaypalDesc").
"</div>\n";
165if (!function_exists(
'curl_version')) {
166 $langs->load(
"errors");
167 setEventMessages($langs->trans(
"ErrorPhpCurlNotInstalled"),
null,
'errors');
173print
'<div class="div-table-responsive-no-min">';
174print
'<table class="noborder centpercent">';
177print
'<tr class="liste_titre">';
178print
'<td>'.$langs->trans(
"AccountParameter").
'</td>';
179print
'<td>'.$langs->trans(
"Value").
'</td>';
182print
'<tr class="oddeven">';
184print $langs->trans(
"PaypalLiveEnabled").
'</td><td>';
186 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setlive&token='.
newToken().
'&value=0">';
187 print img_picto($langs->trans(
"Activated"),
'switch_on');
189 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setlive&token='.
newToken().
'&value=1">';
190 print img_picto($langs->trans(
"Disabled"),
'switch_off');
194print
'<tr class="oddeven"><td class="fieldrequired">';
195print $langs->trans(
"PAYPAL_API_USER").
'</td><td>';
196print
'<input size="32" type="text" name="PAYPAL_API_USER" value="'.getDolGlobalString(
'PAYPAL_API_USER').
'">';
197print
' <span class="opacitymedium small">'.$langs->trans(
"Example").
': admin-facilitator_api1.example.com, paypal_api1.mywebsite.com</span>';
201print
'<tr class="oddeven"><td class="fieldrequired">';
202print $langs->trans(
"PAYPAL_API_PASSWORD").
'</td><td>';
203print
'<input size="32" type="password" id="PAYPAL_API_PASSWORD" name="PAYPAL_API_PASSWORD" value="'.getDolGlobalString(
'PAYPAL_API_PASSWORD').
'">';
205 print
showEyeForField(
'eyePAYPAL_API_PASSWORD',
'PAYPAL_API_PASSWORD');
210print
'<tr class="oddeven"><td class="fieldrequired">';
211print $langs->trans(
"PAYPAL_API_SIGNATURE").
'</td><td>';
212print
'<input size="64" type="password" id="PAYPAL_API_SIGNATURE" name="PAYPAL_API_SIGNATURE" value="'.getDolGlobalString(
'PAYPAL_API_SIGNATURE').
'">';
214 print
showEyeForField(
'eyePAYPAL_API_SIGNATURE',
'PAYPAL_API_SIGNATURE');
216print
'<br><span class="opacitymedium small">'.$langs->trans(
"Example").
': ASsqXEmw4KzmX-CPChWSVDNCNfd.A3YNR7uz-VncXXAERFDFDFDF</span>';
220print
'<tr class="oddeven"><td>';
221print $langs->trans(
"PAYPAL_SSLVERSION").
'</td><td>';
222print $form->selectarray(
"PAYPAL_SSLVERSION", array(
'1'=> $langs->trans(
'TLSv1'),
'6'=> $langs->trans(
'TLSv1.2')),
getDolGlobalString(
'PAYPAL_SSLVERSION'));
231print
'<div class="div-table-responsive-no-min">';
232print
'<table class="noborder centpercent">';
235print
'<tr class="liste_titre">';
236print
'<td>'.$langs->trans(
"UsageParameter").
'</td>';
237print
'<td>'.$langs->trans(
"Value").
'</td>';
241print
'<tr class="oddeven"><td>';
242print $langs->trans(
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY").
'</td><td>';
243print $form->selectarray(
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY", array(
'integral'=> $langs->trans(
'PaypalModeIntegral'),
'paypalonly'=> $langs->trans(
'PaypalModeOnlyPaypal')),
getDolGlobalString(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY'));
254print
'<tr class="oddeven"><td>';
255print $langs->trans(
"PublicVendorName").
'</td><td>';
256print
'<input size="64" type="text" name="ONLINE_PAYMENT_CREDITOR" value="'.getDolGlobalString(
'ONLINE_PAYMENT_CREDITOR').
'" placeholder="'.dolPrintHTMLForAttribute(
$mysoc->name).
'">';
260 print
'<tr class="oddeven"><td>';
261 print $langs->trans(
"BankAccount").
'</td><td>';
262 print img_picto(
'',
'bank_account').
' ';
263 $form->select_comptes(
getDolGlobalString(
'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS'),
'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS', 0,
'', 1);
267print
'<tr class="oddeven"><td>';
268print $langs->trans(
"CSSUrlForPaymentForm").
'</td><td>';
269print
'<input size="64" type="text" name="ONLINE_PAYMENT_CSS_URL" value="'.getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'">';
270print
' <span class="opacitymedium small">'.$langs->trans(
"Example").
': https://mysite/mycss.css</span>';
274print
'<tr class="oddeven"><td>';
275print $langs->trans(
"PAYPAL_ADD_PAYMENT_URL").
'</td><td>';
276print $form->selectyesno(
"PAYPAL_ADD_PAYMENT_URL",
getDolGlobalString(
'PAYPAL_ADD_PAYMENT_URL'), 1);
280print
'<tr class="oddeven"><td>';
281print $langs->trans(
"MessageForm").
'</td><td>';
282$doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_FORM',
getDolGlobalString(
'ONLINE_PAYMENT_MESSAGE_FORM'),
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
287print
'<tr class="oddeven"><td>';
288print $langs->trans(
"MessageOK").
'</td><td>';
289$doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_OK',
getDolGlobalString(
'ONLINE_PAYMENT_MESSAGE_OK'),
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
294print
'<tr class="oddeven"><td>';
295print $langs->trans(
"MessageKO").
'</td><td>';
296$doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_KO',
getDolGlobalString(
'ONLINE_PAYMENT_MESSAGE_KO'),
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
301print
'<tr class="oddeven"><td>';
302print $langs->trans(
"ONLINE_PAYMENT_SENDEMAIL").
'</td><td>';
303print
'<input class="minwidth200" type="text" name="ONLINE_PAYMENT_SENDEMAIL" value="'.getDolGlobalString(
'ONLINE_PAYMENT_SENDEMAIL').
'">';
304print
' <span class="opacitymedium small">'.$langs->trans(
"Example").
': myemail@myserver.com, Payment service <myemail2@myserver2.com></span>';
312print
'<div class="div-table-responsive-no-min">';
313print
'<table class="noborder centpercent">';
315print
'<tr class="liste_titre">';
316print
'<td>'.$langs->trans(
"UrlGenerationParameters").
'</td>';
317print
'<td>'.$langs->trans(
"Value").
'</td>';
321print
'<tr class="oddeven"><td>';
322print $langs->trans(
"SecurityToken").
'</td><td>';
323print
'<input class="minwidth300" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.getDolGlobalString(
'PAYMENT_SECURITY_TOKEN').
'">';
324if (!empty(
$conf->use_javascript_ajax)) {
325 print
' '.img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_token" class="linkobject"');
328 $langs->load(
"errors");
329 print img_warning($langs->trans(
"WarningTheHiddenOptionIsOn",
'PAYMENT_SECURITY_ACCEPT_ANY_TOKEN'),
'',
'pictowarning marginleftonly');
338print $form->buttonsSaveCancel(
"Save",
'');
345print
'<u>'.$langs->trans(
"InformationToFindParameters",
"Paypal").
'</u>:<br>';
346if (!empty(
$conf->use_javascript_ajax)) {
347 print
'<a class="reposition" id="apidoca">'.$langs->trans(
"ClickHere").
'...</a>';
350$realpaypalurl =
'www.paypal.com';
351$sandboxpaypalurl =
'developer.paypal.com';
353print
'<div id="apidoc">';
354print
'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>
3551. 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>
3562. Click the "Profile" or "Preferencies" subtab located under the My Account heading.<br>
3573. Click the link "API Access".<br>
3584. Click the View API Certificate link in the right column.<br>
3595. Click the Request API signature radio button on the Request API Credentials page.<br>
3606. Complete the Request API Credential Request form by clicking the agreement checkbox and clicking Submit.<br>
3617. Save the values for API Username, Password and Signature (make sure this long character signature is copied).<br>
3628. Click the "Modify" button after copying your API Username, Password, and Signature.
366if (!empty(
$conf->use_javascript_ajax)) {
368 <script type="text/javascript">
369 $(document).ready(function () {
371 $("#apidoca").click(function() {
372 console.log("We click on apidoca so we show/hide");
374 $("#apidoca").hide();
386include DOL_DOCUMENT_ROOT.
'/core/tpl/onlinepaymentlinks.tpl.php';
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).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage a WYSIWYG editor.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
paypaladmin_prepare_head()
Define head array for tabs of paypal tools setup pages.
showEyeForField($htmlname, $htmlnameofinput)
Output the eye picto to show/hide a password HTML field.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.