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/class/doleditor.class.php';
35$servicename =
'PayPal';
47$langs->loadLangs(array(
'admin',
'other',
'paypal',
'paybox',
'stripe'));
53$action =
GETPOST(
'action',
'aZ09');
56if ($action ==
'setvalue' && $user->admin) {
83 $result =
dolibarr_set_const($db,
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY",
GETPOST(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY',
'alpha'),
'chaine', 0,
'',
$conf->entity);
95 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_FORM",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_FORM',
'restricthtml'),
'chaine', 0,
'',
$conf->entity);
99 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_OK",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_OK',
'restricthtml'),
'chaine', 0,
'',
$conf->entity);
100 if (!($result > 0)) {
103 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_KO",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_KO',
'restricthtml'),
'chaine', 0,
'',
$conf->entity);
104 if (!($result > 0)) {
108 if (!($result > 0)) {
113 if (!($result > 0)) {
116 if (empty(
$conf->use_javascript_ajax)) {
117 $result =
dolibarr_set_const($db,
"PAYMENT_SECURITY_TOKEN_UNIQUE",
GETPOST(
'PAYMENT_SECURITY_TOKEN_UNIQUE',
'alpha'),
'chaine', 0,
'',
$conf->entity);
118 if (!($result > 0)) {
132if ($action ==
"setlive") {
150$form =
new Form($db);
152llxHeader(
'', $langs->trans(
"PaypalSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-paypal page-admin_paypal');
155$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
160print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
161print
'<input type="hidden" name="token" value="'.newToken().
'">';
162print
'<input type="hidden" name="action" value="setvalue">';
167print
'<span class="opacitymedium">'.$langs->trans(
"PaypalDesc").
"</span><br>\n";
170if (!function_exists(
'curl_version')) {
171 $langs->load(
"errors");
172 setEventMessages($langs->trans(
"ErrorPhpCurlNotInstalled"),
null,
'errors');
178print
'<div class="div-table-responsive-no-min">';
179print
'<table class="noborder centpercent">';
182print
'<tr class="liste_titre">';
183print
'<td>'.$langs->trans(
"AccountParameter").
'</td>';
184print
'<td>'.$langs->trans(
"Value").
'</td>';
187print
'<tr class="oddeven">';
189print $langs->trans(
"PaypalLiveEnabled").
'</td><td>';
191 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setlive&token='.
newToken().
'&value=0">';
192 print
img_picto($langs->trans(
"Activated"),
'switch_on');
194 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setlive&token='.
newToken().
'&value=1">';
195 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
199print
'<tr class="oddeven"><td class="fieldrequired">';
200print $langs->trans(
"PAYPAL_API_USER").
'</td><td>';
201print
'<input size="32" type="text" name="PAYPAL_API_USER" value="'.getDolGlobalString(
'PAYPAL_API_USER').
'">';
202print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': admin-facilitator_api1.example.com, paypal_api1.mywebsite.com</span>';
206print
'<tr class="oddeven"><td class="fieldrequired">';
207print $langs->trans(
"PAYPAL_API_PASSWORD").
'</td><td>';
208print
'<input size="32" type="text" name="PAYPAL_API_PASSWORD" value="'.getDolGlobalString(
'PAYPAL_API_PASSWORD').
'">';
212print
'<tr class="oddeven"><td class="fieldrequired">';
213print $langs->trans(
"PAYPAL_API_SIGNATURE").
'</td><td>';
214print
'<input size="64" type="text" name="PAYPAL_API_SIGNATURE" value="'.getDolGlobalString(
'PAYPAL_API_SIGNATURE').
'">';
215print
'<br><span class="opacitymedium">'.$langs->trans(
"Example").
': ASsqXEmw4KzmX-CPChWSVDNCNfd.A3YNR7uz-VncXXAERFDFDFDF</span>';
219print
'<tr class="oddeven"><td>';
220print $langs->trans(
"PAYPAL_SSLVERSION").
'</td><td>';
221print $form->selectarray(
"PAYPAL_SSLVERSION", array(
'1'=> $langs->trans(
'TLSv1'),
'6'=> $langs->trans(
'TLSv1.2')),
getDolGlobalString(
'PAYPAL_SSLVERSION'));
230print
'<div class="div-table-responsive-no-min">';
231print
'<table class="noborder centpercent">';
234print
'<tr class="liste_titre">';
235print
'<td>'.$langs->trans(
"UsageParameter").
'</td>';
236print
'<td>'.$langs->trans(
"Value").
'</td>';
240print
'<tr class="oddeven"><td>';
241print $langs->trans(
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY").
'</td><td>';
242print $form->selectarray(
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY", array(
'integral'=> $langs->trans(
'PaypalModeIntegral'),
'paypalonly'=> $langs->trans(
'PaypalModeOnlyPaypal')),
getDolGlobalString(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY'));
253print
'<tr class="oddeven"><td>';
254print $langs->trans(
"PublicVendorName").
'</td><td>';
255print
'<input size="64" type="text" name="ONLINE_PAYMENT_CREDITOR" value="'.getDolGlobalString(
'ONLINE_PAYMENT_CREDITOR').
'">';
256print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': '.$mysoc->name.
'</span>';
259if (isModEnabled(
"bank")) {
260 print
'<tr class="oddeven"><td>';
261 print $langs->trans(
"BankAccount").
'</td><td>';
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">'.$langs->trans(
"Example").
': http://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">'.$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');
333print
'<tr class="oddeven"><td>';
334print $langs->trans(
"SecurityTokenIsUnique").
'</td><td>';
335if (
$conf->use_javascript_ajax) {
336 print ajax_constantonoff(
'PAYMENT_SECURITY_TOKEN_UNIQUE');
338 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
339 print $form->selectarray(
"PAYMENT_SECURITY_TOKEN_UNIQUE", $arrval,
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN_UNIQUE'));
348print $form->buttonsSaveCancel(
"Save",
'');
355print
'<u>'.$langs->trans(
"InformationToFindParameters",
"Paypal").
'</u>:<br>';
356if (!empty(
$conf->use_javascript_ajax)) {
357 print
'<a class="reposition" id="apidoca">'.$langs->trans(
"ClickHere").
'...</a>';
360$realpaypalurl =
'www.paypal.com';
361$sandboxpaypalurl =
'developer.paypal.com';
363print
'<div id="apidoc">';
364print
'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>
3651. 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>
3662. Click the "Profile" or "Preferencies" subtab located under the My Account heading.<br>
3673. Click the link "API Access".<br>
3684. Click the View API Certificate link in the right column.<br>
3695. Click the Request API signature radio button on the Request API Credentials page.<br>
3706. Complete the Request API Credential Request form by clicking the agreement checkbox and clicking Submit.<br>
3717. Save the values for API Username, Password and Signature (make sure this long character signature is copied).<br>
3728. Click the "Modify" button after copying your API Username, Password, and Signature.
376if (!empty(
$conf->use_javascript_ajax)) {
377 print
"\n".
'<script type="text/javascript">';
378 print
'$(document).ready(function () {
380 $("#apidoca").click(function() {
381 console.log("We click on apidoca so we show/hide");
383 $("#apidoca").hide();
394include 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).
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.
Class to manage a WYSIWYG editor.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.