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'));
40 $action =
GETPOST(
'action',
'aZ09');
42 if ($action ==
'setvalue' && $user->admin)
46 $result =
dolibarr_set_const($db,
"PAYPAL_API_USER",
GETPOST(
'PAYPAL_API_USER',
'alpha'),
'chaine', 0,
'', $conf->entity);
47 if (!$result > 0) $error++;
48 $result =
dolibarr_set_const($db,
"PAYPAL_API_PASSWORD",
GETPOST(
'PAYPAL_API_PASSWORD',
'alpha'),
'chaine', 0,
'', $conf->entity);
49 if (!$result > 0) $error++;
50 $result =
dolibarr_set_const($db,
"PAYPAL_API_SIGNATURE",
GETPOST(
'PAYPAL_API_SIGNATURE',
'alpha'),
'chaine', 0,
'', $conf->entity);
51 if (!$result > 0) $error++;
52 $result =
dolibarr_set_const($db,
"PAYPAL_SSLVERSION",
GETPOST(
'PAYPAL_SSLVERSION',
'alpha'),
'chaine', 0,
'', $conf->entity);
53 if (!$result > 0) $error++;
54 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_CREDITOR",
GETPOST(
'ONLINE_PAYMENT_CREDITOR',
'alpha'),
'chaine', 0,
'', $conf->entity);
55 if (!$result > 0) $error++;
56 $result =
dolibarr_set_const($db,
"PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS",
GETPOST(
'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS',
'int'),
'chaine', 0,
'', $conf->entity);
57 if (!$result > 0) $error++;
58 $result =
dolibarr_set_const($db,
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY",
GETPOST(
'PAYPAL_API_INTEGRAL_OR_PAYPALONLY',
'alpha'),
'chaine', 0,
'', $conf->entity);
59 if (!$result > 0) $error++;
60 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_CSS_URL",
GETPOST(
'ONLINE_PAYMENT_CSS_URL',
'alpha'),
'chaine', 0,
'', $conf->entity);
61 if (!$result > 0) $error++;
62 $result =
dolibarr_set_const($db,
"PAYPAL_ADD_PAYMENT_URL",
GETPOST(
'PAYPAL_ADD_PAYMENT_URL',
'alpha'),
'chaine', 0,
'', $conf->entity);
63 if (!$result > 0) $error++;
64 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_FORM",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_FORM'),
'chaine', 0,
'', $conf->entity);
65 if (!$result > 0) $error++;
66 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_OK",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_OK'),
'chaine', 0,
'', $conf->entity);
67 if (!$result > 0) $error++;
68 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_MESSAGE_KO",
GETPOST(
'ONLINE_PAYMENT_MESSAGE_KO'),
'chaine', 0,
'', $conf->entity);
69 if (!$result > 0) $error++;
70 $result =
dolibarr_set_const($db,
"ONLINE_PAYMENT_SENDEMAIL",
GETPOST(
'ONLINE_PAYMENT_SENDEMAIL'),
'chaine', 0,
'', $conf->entity);
71 if (!$result > 0) $error++;
73 $result =
dolibarr_set_const($db,
"PAYMENT_SECURITY_TOKEN",
GETPOST(
'PAYMENT_SECURITY_TOKEN',
'alpha'),
'chaine', 0,
'', $conf->entity);
74 if (!$result > 0) $error++;
75 if (empty($conf->use_javascript_ajax)) {
76 $result =
dolibarr_set_const($db,
"PAYMENT_SECURITY_TOKEN_UNIQUE",
GETPOST(
'PAYMENT_SECURITY_TOKEN_UNIQUE',
'alpha'),
'chaine', 0,
'', $conf->entity);
91 if ($action ==
"setlive")
93 $liveenable =
GETPOST(
'value',
'int') ? 0 : 1;
94 $res =
dolibarr_set_const($db,
"PAYPAL_API_SANDBOX", $liveenable,
'yesno', 0,
'', $conf->entity);
95 if (!($res > 0)) $error++;
109 $form =
new Form($db);
111 llxHeader(
'', $langs->trans(
"PaypalSetup"));
114 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
119 print '<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
120 print '<input type="hidden" name="token" value="'.newToken().
'">';
121 print '<input type="hidden" name="action" value="setvalue">';
126 print '<span class="opacitymedium">'.$langs->trans(
"PaypalDesc").
"</span><br>\n";
129 if (!function_exists(
'curl_version'))
131 $langs->load(
"errors");
132 setEventMessages($langs->trans(
"ErrorPhpCurlNotInstalled"), null,
'errors');
138 print '<div class="div-table-responsive-no-min">';
139 print '<table class="noborder centpercent">';
142 print '<tr class="liste_titre">';
143 print '<td>'.$langs->trans(
"AccountParameter").
'</td>';
144 print '<td>'.$langs->trans(
"Value").
'</td>';
147 print '<tr class="oddeven">';
149 print $langs->trans(
"PaypalLiveEnabled").
'</td><td>';
150 if (empty($conf->global->PAYPAL_API_SANDBOX))
152 print '<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setlive&token='.
newToken().
'&value=0">';
155 print '<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=setlive&token='.
newToken().
'&value=1">';
160 print '<tr class="oddeven"><td class="fieldrequired">';
161 print $langs->trans(
"PAYPAL_API_USER").
'</td><td>';
162 print '<input size="32" type="text" name="PAYPAL_API_USER" value="'.$conf->global->PAYPAL_API_USER.
'">';
163 print ' <span class="opacitymedium">'.$langs->trans(
"Example").
': admin-facilitator_api1.example.com, paypal_api1.mywebsite.com</span>';
167 print '<tr class="oddeven"><td class="fieldrequired">';
168 print $langs->trans(
"PAYPAL_API_PASSWORD").
'</td><td>';
169 print '<input size="32" type="text" name="PAYPAL_API_PASSWORD" value="'.$conf->global->PAYPAL_API_PASSWORD.
'">';
173 print '<tr class="oddeven"><td class="fieldrequired">';
174 print $langs->trans(
"PAYPAL_API_SIGNATURE").
'</td><td>';
175 print '<input size="64" type="text" name="PAYPAL_API_SIGNATURE" value="'.$conf->global->PAYPAL_API_SIGNATURE.
'">';
176 print '<br><span class="opacitymedium">'.$langs->trans(
"Example").
': ASsqXEmw4KzmX-CPChWSVDNCNfd.A3YNR7uz-VncXXAERFDFDFDF</span>';
180 print '<tr class="oddeven"><td>';
181 print $langs->trans(
"PAYPAL_SSLVERSION").
'</td><td>';
182 print $form->selectarray(
"PAYPAL_SSLVERSION", array(
'1'=> $langs->trans(
'TLSv1'),
'6'=> $langs->trans(
'TLSv1.2')), $conf->global->PAYPAL_SSLVERSION);
191 print '<div class="div-table-responsive-no-min">';
192 print '<table class="noborder centpercent">';
195 print '<tr class="liste_titre">';
196 print '<td>'.$langs->trans(
"UsageParameter").
'</td>';
197 print '<td>'.$langs->trans(
"Value").
'</td>';
201 print '<tr class="oddeven"><td>';
202 print $langs->trans(
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY").
'</td><td>';
203 print $form->selectarray(
"PAYPAL_API_INTEGRAL_OR_PAYPALONLY", array(
'integral'=> $langs->trans(
'PaypalModeIntegral'),
'paypalonly'=> $langs->trans(
'PaypalModeOnlyPaypal')), $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY);
214 print '<tr class="oddeven"><td>';
215 print $langs->trans(
"PublicVendorName").
'</td><td>';
216 print '<input size="64" type="text" name="ONLINE_PAYMENT_CREDITOR" value="'.$conf->global->ONLINE_PAYMENT_CREDITOR.
'">';
217 print ' <span class="opacitymedium">'.$langs->trans(
"Example").
': '.$mysoc->name.
'</span>';
220 if (!empty($conf->banque->enabled))
222 print '<tr class="oddeven"><td>';
223 print $langs->trans(
"BankAccount").
'</td><td>';
225 $form->select_comptes($conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS,
'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS', 0,
'', 1);
229 print '<tr class="oddeven"><td>';
230 print $langs->trans(
"CSSUrlForPaymentForm").
'</td><td>';
231 print '<input size="64" type="text" name="ONLINE_PAYMENT_CSS_URL" value="'.$conf->global->ONLINE_PAYMENT_CSS_URL.
'">';
232 print ' <span class="opacitymedium">'.$langs->trans(
"Example").
': http://mysite/mycss.css</span>';
236 print '<tr class="oddeven"><td>';
237 print $langs->trans(
"PAYPAL_ADD_PAYMENT_URL").
'</td><td>';
238 print $form->selectyesno(
"PAYPAL_ADD_PAYMENT_URL", $conf->global->PAYPAL_ADD_PAYMENT_URL, 1);
242 print '<tr class="oddeven"><td>';
243 print $langs->trans(
"MessageForm").
'</td><td>';
244 $doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_FORM', $conf->global->ONLINE_PAYMENT_MESSAGE_FORM,
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
245 $doleditor->Create();
249 print '<tr class="oddeven"><td>';
250 print $langs->trans(
"MessageOK").
'</td><td>';
251 $doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_OK', $conf->global->ONLINE_PAYMENT_MESSAGE_OK,
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
252 $doleditor->Create();
256 print '<tr class="oddeven"><td>';
257 print $langs->trans(
"MessageKO").
'</td><td>';
258 $doleditor =
new DolEditor(
'ONLINE_PAYMENT_MESSAGE_KO', $conf->global->ONLINE_PAYMENT_MESSAGE_KO,
'', 100,
'dolibarr_details',
'In',
false,
true,
true, ROWS_4,
'90%');
259 $doleditor->Create();
263 print '<tr class="oddeven"><td>';
264 print $langs->trans(
"ONLINE_PAYMENT_SENDEMAIL").
'</td><td>';
265 print '<input class="minwidth200" type="text" name="ONLINE_PAYMENT_SENDEMAIL" value="'.$conf->global->ONLINE_PAYMENT_SENDEMAIL.
'">';
266 print ' <span class="opacitymedium">'.$langs->trans(
"Example").
': myemail@myserver.com, Payment service <myemail2@myserver2.com></span>';
274 print '<div class="div-table-responsive-no-min">';
275 print '<table class="noborder centpercent">';
277 print '<tr class="liste_titre">';
278 print '<td>'.$langs->trans(
"UrlGenerationParameters").
'</td>';
279 print '<td>'.$langs->trans(
"Value").
'</td>';
283 print '<tr class="oddeven"><td>';
284 print $langs->trans(
"SecurityToken").
'</td><td>';
285 print '<input class="minwidth300" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.
'">';
286 if (!empty($conf->use_javascript_ajax)) {
287 print ' '.img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_token" class="linkobject"');
289 if (!empty($conf->global->PAYMENT_SECURITY_ACCEPT_ANY_TOKEN)) {
290 $langs->load(
"errors");
291 print img_warning($langs->trans(
"WarningTheHiddenOptionIsOn",
'PAYMENT_SECURITY_ACCEPT_ANY_TOKEN'),
'',
'pictowarning marginleftonly');
295 print '<tr class="oddeven"><td>';
296 print $langs->trans(
"SecurityTokenIsUnique").
'</td><td>';
297 if ($conf->use_javascript_ajax) {
300 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
301 print $form->selectarray(
"PAYMENT_SECURITY_TOKEN_UNIQUE", $arrval, $conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE);
310 print '<div class="center"><input type="submit" class="button" value="'.$langs->trans(
"Modify").
'"></div>';
317 print '<u>'.$langs->trans(
"InformationToFindParameters",
"Paypal").
'</u>:<br>';
318 if (!empty($conf->use_javascript_ajax))
319 print '<a class="reposition" id="apidoca">'.$langs->trans(
"ClickHere").
'...</a>';
321 $realpaypalurl =
'www.paypal.com';
322 $sandboxpaypalurl =
'developer.paypal.com';
324 print '<div id="apidoc">';
325 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>
326 1. Log in to your PayPal account (on real paypal <a href="https://'.$realpaypalurl.
'" target="_blank">'.$realpaypalurl.
'</a> (or sandbox <a href="https://'.$sandboxpaypalurl.
'" target="_blank">'.$sandboxpaypalurl.
'</a>).<br>
327 2. Click the "Profile" or "Preferencies" subtab located under the My Account heading.<br>
328 3. Click the link "API Access".<br>
329 4. Click the View API Certificate link in the right column.<br>
330 5. Click the Request API signature radio button on the Request API Credentials page.<br>
331 6. Complete the Request API Credential Request form by clicking the agreement checkbox and clicking Submit.<br>
332 7. Save the values for API Username, Password and Signature (make sure this long character signature is copied).<br>
333 8. Click the "Modify" button after copying your API Username, Password, and Signature.
337 if (!empty($conf->use_javascript_ajax))
339 print "\n".
'<script type="text/javascript">';
340 print '$(document).ready(function () {
342 $("#apidoca").click(function() {
343 console.log("We click on apidoca show/hide");
345 $("#apidoca").hide();
356 include DOL_DOCUMENT_ROOT.
'/core/tpl/onlinepaymentlinks.tpl.php';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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).
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
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)
On/off button for constant.
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 ...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
Class to manage a WYSIWYG editor.
paypaladmin_prepare_head()
Define head array for tabs of paypal tools setup pages.