28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32require_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');
45if ($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)) {
121if ($action ==
"setlive") {
122 $liveenable =
GETPOST(
'value',
'int') ? 0 : 1;
123 $res =
dolibarr_set_const($db,
"PAYPAL_API_SANDBOX", $liveenable,
'yesno', 0,
'', $conf->entity);
139$form =
new Form($db);
141llxHeader(
'', $langs->trans(
"PaypalSetup"));
144$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
149print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
150print
'<input type="hidden" name="token" value="'.newToken().
'">';
151print
'<input type="hidden" name="action" value="setvalue">';
156print
'<span class="opacitymedium">'.$langs->trans(
"PaypalDesc").
"</span><br>\n";
159if (!function_exists(
'curl_version')) {
160 $langs->load(
"errors");
161 setEventMessages($langs->trans(
"ErrorPhpCurlNotInstalled"),
null,
'errors');
167print
'<div class="div-table-responsive-no-min">';
168print
'<table class="noborder centpercent">';
171print
'<tr class="liste_titre">';
172print
'<td>'.$langs->trans(
"AccountParameter").
'</td>';
173print
'<td>'.$langs->trans(
"Value").
'</td>';
176print
'<tr class="oddeven">';
178print $langs->trans(
"PaypalLiveEnabled").
'</td><td>';
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');
188print
'<tr class="oddeven"><td class="fieldrequired">';
189print $langs->trans(
"PAYPAL_API_USER").
'</td><td>';
190print
'<input size="32" type="text" name="PAYPAL_API_USER" value="'.getDolGlobalString(
'PAYPAL_API_USER').
'">';
191print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': admin-facilitator_api1.example.com, paypal_api1.mywebsite.com</span>';
195print
'<tr class="oddeven"><td class="fieldrequired">';
196print $langs->trans(
"PAYPAL_API_PASSWORD").
'</td><td>';
197print
'<input size="32" type="text" name="PAYPAL_API_PASSWORD" value="'.getDolGlobalString(
'PAYPAL_API_PASSWORD').
'">';
201print
'<tr class="oddeven"><td class="fieldrequired">';
202print $langs->trans(
"PAYPAL_API_SIGNATURE").
'</td><td>';
203print
'<input size="64" type="text" name="PAYPAL_API_SIGNATURE" value="'.getDolGlobalString(
'PAYPAL_API_SIGNATURE').
'">';
204print
'<br><span class="opacitymedium">'.$langs->trans(
"Example").
': ASsqXEmw4KzmX-CPChWSVDNCNfd.A3YNR7uz-VncXXAERFDFDFDF</span>';
208print
'<tr class="oddeven"><td>';
209print $langs->trans(
"PAYPAL_SSLVERSION").
'</td><td>';
210print $form->selectarray(
"PAYPAL_SSLVERSION", array(
'1'=> $langs->trans(
'TLSv1'),
'6'=> $langs->trans(
'TLSv1.2')),
getDolGlobalString(
'PAYPAL_SSLVERSION'));
219print
'<div class="div-table-responsive-no-min">';
220print
'<table class="noborder centpercent">';
223print
'<tr class="liste_titre">';
224print
'<td>'.$langs->trans(
"UsageParameter").
'</td>';
225print
'<td>'.$langs->trans(
"Value").
'</td>';
229print
'<tr class="oddeven"><td>';
230print $langs->trans(
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY").
'</td><td>';
231print $form->selectarray(
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY", array(
'integral'=> $langs->trans(
'PaypalModeIntegral'),
'paypalonly'=> $langs->trans(
'PaypalModeOnlyPaypal')),
getDolGlobalString(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY'));
242print
'<tr class="oddeven"><td>';
243print $langs->trans(
"PublicVendorName").
'</td><td>';
244print
'<input size="64" type="text" name="ONLINE_PAYMENT_CREDITOR" value="'.getDolGlobalString(
'ONLINE_PAYMENT_CREDITOR').
'">';
245print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': '.$mysoc->name.
'</span>';
248if (isModEnabled(
"banque")) {
249 print
'<tr class="oddeven"><td>';
250 print $langs->trans(
"BankAccount").
'</td><td>';
252 $form->select_comptes(
getDolGlobalString(
'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS'),
'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS', 0,
'', 1);
256print
'<tr class="oddeven"><td>';
257print $langs->trans(
"CSSUrlForPaymentForm").
'</td><td>';
258print
'<input size="64" type="text" name="ONLINE_PAYMENT_CSS_URL" value="'.getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'">';
259print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': http://mysite/mycss.css</span>';
263print
'<tr class="oddeven"><td>';
264print $langs->trans(
"PAYPAL_ADD_PAYMENT_URL").
'</td><td>';
265print $form->selectyesno(
"PAYPAL_ADD_PAYMENT_URL",
getDolGlobalString(
'PAYPAL_ADD_PAYMENT_URL'), 1);
269print
'<tr class="oddeven"><td>';
270print $langs->trans(
"MessageForm").
'</td><td>';
271$doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_FORM',
getDolGlobalString(
'ONLINE_PAYMENT_MESSAGE_FORM'),
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
276print
'<tr class="oddeven"><td>';
277print $langs->trans(
"MessageOK").
'</td><td>';
278$doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_OK',
getDolGlobalString(
'ONLINE_PAYMENT_MESSAGE_OK'),
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
283print
'<tr class="oddeven"><td>';
284print $langs->trans(
"MessageKO").
'</td><td>';
285$doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_KO',
getDolGlobalString(
'ONLINE_PAYMENT_MESSAGE_KO'),
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
290print
'<tr class="oddeven"><td>';
291print $langs->trans(
"ONLINE_PAYMENT_SENDEMAIL").
'</td><td>';
292print
'<input class="minwidth200" type="text" name="ONLINE_PAYMENT_SENDEMAIL" value="'.getDolGlobalString(
'ONLINE_PAYMENT_SENDEMAIL').
'">';
293print
' <span class="opacitymedium">'.$langs->trans(
"Example").
': myemail@myserver.com, Payment service <myemail2@myserver2.com></span>';
301print
'<div class="div-table-responsive-no-min">';
302print
'<table class="noborder centpercent">';
304print
'<tr class="liste_titre">';
305print
'<td>'.$langs->trans(
"UrlGenerationParameters").
'</td>';
306print
'<td>'.$langs->trans(
"Value").
'</td>';
310print
'<tr class="oddeven"><td>';
311print $langs->trans(
"SecurityToken").
'</td><td>';
312print
'<input class="minwidth300" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.getDolGlobalString(
'PAYMENT_SECURITY_TOKEN').
'">';
313if (!empty($conf->use_javascript_ajax)) {
314 print
' '.img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_token" class="linkobject"');
317 $langs->load(
"errors");
318 print
img_warning($langs->trans(
"WarningTheHiddenOptionIsOn",
'PAYMENT_SECURITY_ACCEPT_ANY_TOKEN'),
'',
'pictowarning marginleftonly');
322print
'<tr class="oddeven"><td>';
323print $langs->trans(
"SecurityTokenIsUnique").
'</td><td>';
324if ($conf->use_javascript_ajax) {
325 print ajax_constantonoff(
'PAYMENT_SECURITY_TOKEN_UNIQUE');
327 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
328 print $form->selectarray(
"PAYMENT_SECURITY_TOKEN_UNIQUE", $arrval,
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN_UNIQUE'));
337print $form->buttonsSaveCancel(
"Modify",
'');
344print
'<u>'.$langs->trans(
"InformationToFindParameters",
"Paypal").
'</u>:<br>';
345if (!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';
352print
'<div id="apidoc">';
353print
'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>
3541. 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>
3552. Click the "Profile" or "Preferencies" subtab located under the My Account heading.<br>
3563. Click the link "API Access".<br>
3574. Click the View API Certificate link in the right column.<br>
3585. Click the Request API signature radio button on the Request API Credentials page.<br>
3596. Complete the Request API Credential Request form by clicking the agreement checkbox and clicking Submit.<br>
3607. Save the values for API Username, Password and Signature (make sure this long character signature is copied).<br>
3618. Click the "Modify" button after copying your API Username, Password, and Signature.
365if (!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 so we show/hide");
372 $("#apidoca").hide();
383include 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()
Empty header.
Class to manage a WYSIWYG editor.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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_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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.