28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
34 $servicename =
'PayPal';
37 $langs->loadLangs(array(
'admin',
'other',
'paypal',
'paybox',
'stripe'));
43 $action =
GETPOST(
'action',
'aZ09');
45 if ($action ==
'setvalue' && $user->admin) {
48 $result =
dolibarr_set_const($db,
"PAYPAL_API_USER",
GETPOST(
'PAYPAL_API_USER',
'alpha'),
'chaine', 0,
'', $conf->entity);
52 $result =
dolibarr_set_const($db,
"PAYPAL_API_PASSWORD",
GETPOST(
'PAYPAL_API_PASSWORD',
'alpha'),
'chaine', 0,
'', $conf->entity);
56 $result =
dolibarr_set_const($db,
"PAYPAL_API_SIGNATURE",
GETPOST(
'PAYPAL_API_SIGNATURE',
'alpha'),
'chaine', 0,
'', $conf->entity);
60 $result =
dolibarr_set_const($db,
"PAYPAL_SSLVERSION",
GETPOST(
'PAYPAL_SSLVERSION',
'alpha'),
'chaine', 0,
'', $conf->entity);
64 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_CREDITOR",
GETPOST(
'ONLINE_PAYMENT_CREDITOR',
'alpha'),
'chaine', 0,
'', $conf->entity);
68 $result =
dolibarr_set_const($db,
"PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS",
GETPOST(
'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS',
'int'),
'chaine', 0,
'', $conf->entity);
72 $result =
dolibarr_set_const($db,
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY",
GETPOST(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY',
'alpha'),
'chaine', 0,
'', $conf->entity);
76 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_CSS_URL",
GETPOST(
'ONLINE_PAYMENT_CSS_URL',
'alpha'),
'chaine', 0,
'', $conf->entity);
80 $result =
dolibarr_set_const($db,
"PAYPAL_ADD_PAYMENT_URL",
GETPOST(
'PAYPAL_ADD_PAYMENT_URL',
'alpha'),
'chaine', 0,
'', $conf->entity);
84 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_FORM",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_FORM',
'restricthtml'),
'chaine', 0,
'', $conf->entity);
88 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_OK",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_OK',
'restricthtml'),
'chaine', 0,
'', $conf->entity);
92 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_KO",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_KO',
'restricthtml'),
'chaine', 0,
'', $conf->entity);
96 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_SENDEMAIL",
GETPOST(
'ONLINE_PAYMENT_SENDEMAIL',
'alpha'),
'chaine', 0,
'', $conf->entity);
101 $result =
dolibarr_set_const($db,
"PAYMENT_SECURITY_TOKEN",
GETPOST(
'PAYMENT_SECURITY_TOKEN',
'alpha'),
'chaine', 0,
'', $conf->entity);
102 if (!($result > 0)) {
105 if (empty($conf->use_javascript_ajax)) {
106 $result =
dolibarr_set_const($db,
"PAYMENT_SECURITY_TOKEN_UNIQUE",
GETPOST(
'PAYMENT_SECURITY_TOKEN_UNIQUE',
'alpha'),
'chaine', 0,
'', $conf->entity);
107 if (!($result > 0)) {
121 if ($action ==
"setlive") {
122 $liveenable =
GETPOST(
'value',
'int') ? 0 : 1;
123 $res =
dolibarr_set_const($db,
"PAYPAL_API_SANDBOX", $liveenable,
'yesno', 0,
'', $conf->entity);
141 llxHeader(
'', $langs->trans(
"PaypalSetup"));
144 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
149 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
150 print
'<input type="hidden" name="token" value="'.newToken().
'">';
151 print
'<input type="hidden" name="action" value="setvalue">';
156 print
'<span class="opacitymedium">'.$langs->trans(
"PaypalDesc").
"</span><br>\n";
159 if (!function_exists(
'curl_version')) {
160 $langs->load(
"errors");
161 setEventMessages($langs->trans(
"ErrorPhpCurlNotInstalled"),
null,
'errors');
167 print
'<div class="div-table-responsive-no-min">';
168 print
'<table class="noborder centpercent">';
171 print
'<tr class="liste_titre">';
172 print
'<td>'.$langs->trans(
"AccountParameter").
'</td>';
173 print
'<td>'.$langs->trans(
"Value").
'</td>';
176 print
'<tr class="oddeven">';
178 print $langs->trans(
"PaypalLiveEnabled").
'</td><td>';
179 if (empty($conf->global->PAYPAL_API_SANDBOX)) {
180 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setlive&token='.
newToken().
'&value=0">';
181 print
img_picto($langs->trans(
"Activated"),
'switch_on');
183 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setlive&token='.
newToken().
'&value=1">';
184 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
188 print
'<tr class="oddeven"><td class="fieldrequired">';
189 print $langs->trans(
"PAYPAL_API_USER").
'</td><td>';
190 print
'<input size="32" type="text" name="PAYPAL_API_USER" value="'.$conf->global->PAYPAL_API_USER.
'">';
191 print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': admin-facilitator_api1.example.com, paypal_api1.mywebsite.com</span>';
195 print
'<tr class="oddeven"><td class="fieldrequired">';
196 print $langs->trans(
"PAYPAL_API_PASSWORD").
'</td><td>';
197 print
'<input size="32" type="text" name="PAYPAL_API_PASSWORD" value="'.$conf->global->PAYPAL_API_PASSWORD.
'">';
201 print
'<tr class="oddeven"><td class="fieldrequired">';
202 print $langs->trans(
"PAYPAL_API_SIGNATURE").
'</td><td>';
203 print
'<input size="64" type="text" name="PAYPAL_API_SIGNATURE" value="'.$conf->global->PAYPAL_API_SIGNATURE.
'">';
204 print
'<br><span class="opacitymedium">'.$langs->trans(
"Example").
': ASsqXEmw4KzmX-CPChWSVDNCNfd.A3YNR7uz-VncXXAERFDFDFDF</span>';
208 print
'<tr class="oddeven"><td>';
209 print $langs->trans(
"PAYPAL_SSLVERSION").
'</td><td>';
210 print
$form->selectarray(
"PAYPAL_SSLVERSION", array(
'1'=> $langs->trans(
'TLSv1'),
'6'=> $langs->trans(
'TLSv1.2')), $conf->global->PAYPAL_SSLVERSION);
219 print
'<div class="div-table-responsive-no-min">';
220 print
'<table class="noborder centpercent">';
223 print
'<tr class="liste_titre">';
224 print
'<td>'.$langs->trans(
"UsageParameter").
'</td>';
225 print
'<td>'.$langs->trans(
"Value").
'</td>';
229 print
'<tr class="oddeven"><td>';
230 print $langs->trans(
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY").
'</td><td>';
231 print
$form->selectarray(
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY", array(
'integral'=> $langs->trans(
'PaypalModeIntegral'),
'paypalonly'=> $langs->trans(
'PaypalModeOnlyPaypal')), $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY);
242 print
'<tr class="oddeven"><td>';
243 print $langs->trans(
"PublicVendorName").
'</td><td>';
244 print
'<input size="64" type="text" name="ONLINE_PAYMENT_CREDITOR" value="'.$conf->global->ONLINE_PAYMENT_CREDITOR.
'">';
245 print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': '.$mysoc->name.
'</span>';
249 print
'<tr class="oddeven"><td>';
250 print $langs->trans(
"BankAccount").
'</td><td>';
252 $form->select_comptes($conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS,
'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS', 0,
'', 1);
256 print
'<tr class="oddeven"><td>';
257 print $langs->trans(
"CSSUrlForPaymentForm").
'</td><td>';
258 print
'<input size="64" type="text" name="ONLINE_PAYMENT_CSS_URL" value="'.$conf->global->ONLINE_PAYMENT_CSS_URL.
'">';
259 print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': http://mysite/mycss.css</span>';
263 print
'<tr class="oddeven"><td>';
264 print $langs->trans(
"PAYPAL_ADD_PAYMENT_URL").
'</td><td>';
265 print
$form->selectyesno(
"PAYPAL_ADD_PAYMENT_URL", $conf->global->PAYPAL_ADD_PAYMENT_URL, 1);
269 print
'<tr class="oddeven"><td>';
270 print $langs->trans(
"MessageForm").
'</td><td>';
271 $doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_FORM', $conf->global->ONLINE_PAYMENT_MESSAGE_FORM,
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
272 $doleditor->Create();
276 print
'<tr class="oddeven"><td>';
277 print $langs->trans(
"MessageOK").
'</td><td>';
278 $doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_OK', $conf->global->ONLINE_PAYMENT_MESSAGE_OK,
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
279 $doleditor->Create();
283 print
'<tr class="oddeven"><td>';
284 print $langs->trans(
"MessageKO").
'</td><td>';
285 $doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_KO', $conf->global->ONLINE_PAYMENT_MESSAGE_KO,
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
286 $doleditor->Create();
290 print
'<tr class="oddeven"><td>';
291 print $langs->trans(
"ONLINE_PAYMENT_SENDEMAIL").
'</td><td>';
292 print
'<input class="minwidth200" type="text" name="ONLINE_PAYMENT_SENDEMAIL" value="'.$conf->global->ONLINE_PAYMENT_SENDEMAIL.
'">';
293 print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': myemail@myserver.com, Payment service <myemail2@myserver2.com></span>';
301 print
'<div class="div-table-responsive-no-min">';
302 print
'<table class="noborder centpercent">';
304 print
'<tr class="liste_titre">';
305 print
'<td>'.$langs->trans(
"UrlGenerationParameters").
'</td>';
306 print
'<td>'.$langs->trans(
"Value").
'</td>';
310 print
'<tr class="oddeven"><td>';
311 print $langs->trans(
"SecurityToken").
'</td><td>';
312 print
'<input class="minwidth300" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.
'">';
313 if (!empty($conf->use_javascript_ajax)) {
314 print
' '.img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_token" class="linkobject"');
316 if (!empty($conf->global->PAYMENT_SECURITY_ACCEPT_ANY_TOKEN)) {
317 $langs->load(
"errors");
318 print
img_warning($langs->trans(
"WarningTheHiddenOptionIsOn",
'PAYMENT_SECURITY_ACCEPT_ANY_TOKEN'),
'',
'pictowarning marginleftonly');
322 print
'<tr class="oddeven"><td>';
323 print $langs->trans(
"SecurityTokenIsUnique").
'</td><td>';
324 if ($conf->use_javascript_ajax) {
327 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
328 print
$form->selectarray(
"PAYMENT_SECURITY_TOKEN_UNIQUE", $arrval, $conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE);
337 print
$form->buttonsSaveCancel(
"Modify",
'');
344 print
'<u>'.$langs->trans(
"InformationToFindParameters",
"Paypal").
'</u>:<br>';
345 if (!empty($conf->use_javascript_ajax)) {
346 print
'<a class="reposition" id="apidoca">'.$langs->trans(
"ClickHere").
'...</a>';
349 $realpaypalurl =
'www.paypal.com';
350 $sandboxpaypalurl =
'developer.paypal.com';
352 print
'<div id="apidoc">';
353 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>
354 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>
355 2. Click the "Profile" or "Preferencies" subtab located under the My Account heading.<br>
356 3. Click the link "API Access".<br>
357 4. Click the View API Certificate link in the right column.<br>
358 5. Click the Request API signature radio button on the Request API Credentials page.<br>
359 6. Complete the Request API Credential Request form by clicking the agreement checkbox and clicking Submit.<br>
360 7. Save the values for API Username, Password and Signature (make sure this long character signature is copied).<br>
361 8. Click the "Modify" button after copying your API Username, Password, and Signature.
365 if (!empty($conf->use_javascript_ajax)) {
366 print
"\n".
'<script type="text/javascript">';
367 print
'$(document).ready(function () {
369 $("#apidoca").click(function() {
370 console.log("We click on apidoca show/hide");
372 $("#apidoca").hide();
383 include 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).
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='')
On/off button for constant.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage a WYSIWYG editor.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
Return value of a param into GET or POST supervariable.
isModEnabled($module)
Is Dolibarr module enabled.
paypaladmin_prepare_head()
Define head array for tabs of paypal tools setup pages.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.