dolibarr  13.0.2
stripe.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
3  * Copyright (C) 2017 Olivier Geffroy <jeff@jeffinfo.com>
4  * Copyright (C) 2017 Saasprov <saasprov@gmail.com>
5  * Copyright (C) 2018-2019 Thibault FOUCART <support@ptibogxiv.net>
6  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
34 
35 $servicename = 'Stripe';
36 
37 // Load translation files required by the page
38 $langs->loadLangs(array('admin', 'other', 'paypal', 'paybox', 'stripe'));
39 
40 if (!$user->admin) accessforbidden();
41 
42 $action = GETPOST('action', 'aZ09');
43 
44 
45 /*
46  * Actions
47  */
48 
49 if ($action == 'setvalue' && $user->admin)
50 {
51  $db->begin();
52 
53  if (empty($conf->stripeconnect->enabled)) {
54  $result = dolibarr_set_const($db, "STRIPE_TEST_PUBLISHABLE_KEY", GETPOST('STRIPE_TEST_PUBLISHABLE_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
55  if (!$result > 0)
56  $error++;
57  $result = dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY", GETPOST('STRIPE_TEST_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
58  if (!$result > 0)
59  $error++;
60  $result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_ID", GETPOST('STRIPE_TEST_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity);
61  if (!$result > 0)
62  $error++;
63  $result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_KEY", GETPOST('STRIPE_TEST_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
64  if (!$result > 0)
65  $error++;
66  $result = dolibarr_set_const($db, "STRIPE_LIVE_PUBLISHABLE_KEY", GETPOST('STRIPE_LIVE_PUBLISHABLE_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
67  if (!$result > 0)
68  $error++;
69  $result = dolibarr_set_const($db, "STRIPE_LIVE_SECRET_KEY", GETPOST('STRIPE_LIVE_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
70  if (!$result > 0)
71  $error++;
72  $result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_ID", GETPOST('STRIPE_LIVE_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity);
73  if (!$result > 0)
74  $error++;
75  $result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_KEY", GETPOST('STRIPE_LIVE_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
76  if (!$result > 0)
77  $error++;
78  }
79  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR", GETPOST('ONLINE_PAYMENT_CREDITOR', 'alpha'), 'chaine', 0, '', $conf->entity);
80  if (!$result > 0)
81  $error++;
82  $result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_PAYMENTS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 'int'), 'chaine', 0, '', $conf->entity);
83  if (!$result > 0)
84  $error++;
85  $result = dolibarr_set_const($db, "STRIPE_USER_ACCOUNT_FOR_ACTIONS", GETPOST('STRIPE_USER_ACCOUNT_FOR_ACTIONS', 'int'), 'chaine', 0, '', $conf->entity);
86  if (!$result > 0) {
87  $error++;
88  }
89  $result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 'int'), 'chaine', 0, '', $conf->entity);
90  if (!$result > 0)
91  $error++;
92  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity);
93  if (!$result > 0)
94  $error++;
95  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM", GETPOST('ONLINE_PAYMENT_MESSAGE_FORM', 'alpha'), 'chaine', 0, '', $conf->entity);
96  if (!$result > 0)
97  $error++;
98  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_OK", GETPOST('ONLINE_PAYMENT_MESSAGE_OK', 'alpha'), 'chaine', 0, '', $conf->entity);
99  if (!$result > 0)
100  $error++;
101  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_KO", GETPOST('ONLINE_PAYMENT_MESSAGE_KO', 'alpha'), 'chaine', 0, '', $conf->entity);
102  if (!$result > 0)
103  $error++;
104  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL", GETPOST('ONLINE_PAYMENT_SENDEMAIL'), 'chaine', 0, '', $conf->entity);
105  if (!$result > 0)
106  $error++;
107  // Stock decrement
108  //$result = dolibarr_set_const($db, "ONLINE_PAYMENT_WAREHOUSE", (GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') > 0 ? GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
109  //if (! $result > 0)
110  // $error ++;
111 
112  // Payment token for URL
113  $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN", GETPOST('PAYMENT_SECURITY_TOKEN', 'alpha'), 'chaine', 0, '', $conf->entity);
114  if (!$result > 0) {
115  $error++;
116  }
117  if (empty($conf->use_javascript_ajax)) {
118  $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE", GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE', 'alpha'), 'chaine', 0, '', $conf->entity);
119  if (!$result > 0) {
120  $error++;
121  }
122  }
123 
124  if (!$error) {
125  $db->commit();
126  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
127  } else {
128  $db->rollback();
129  dol_print_error($db);
130  }
131 }
132 
133 if ($action == "setlive")
134 {
135  $liveenable = GETPOST('value', 'int');
136  $res = dolibarr_set_const($db, "STRIPE_LIVE", $liveenable, 'yesno', 0, '', $conf->entity);
137  if ($res > 0) {
138  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
139  } else {
140  setEventMessages($langs->trans("Error"), null, 'errors');
141  }
142 }
143 //TODO: import script for stripe account saving in alone or connect mode for stripe.class.php
144 
145 
146 /*
147  * View
148  */
149 
150 $form = new Form($db);
151 $formproduct = new FormProduct($db);
152 
153 llxHeader('', $langs->trans("StripeSetup"));
154 
155 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
156 print load_fiche_titre($langs->trans("ModuleSetup").' Stripe', $linkback);
157 
158 $head = stripeadmin_prepare_head();
159 
160 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
161 print '<input type="hidden" name="token" value="'.newToken().'">';
162 print '<input type="hidden" name="action" value="setvalue">';
163 
164 print dol_get_fiche_head($head, 'stripeaccount', '', -1);
165 
166 $stripearrayofwebhookevents = array('account.updated', 'payout.created', 'payout.paid', 'charge.pending', 'charge.refunded', 'charge.succeeded', 'charge.failed', 'payment_intent.succeeded', 'payment_intent.payment_failed', 'payment_method.attached', 'payment_method.updated', 'payment_method.card_automatically_updated', 'payment_method.detached', 'source.chargeable', 'customer.deleted');
167 
168 print '<span class="opacitymedium">'.$langs->trans("StripeDesc")."</span><br>\n";
169 
170 print '<br>';
171 
172 print '<div class="div-table-responsive-no-min">';
173 print '<table class="noborder centpercent">';
174 print '<tr class="liste_titre">';
175 print '<td>'.$langs->trans("AccountParameter").'</td>';
176 print '<td>'.$langs->trans("Value").'</td>';
177 print '<td></td>';
178 print "</tr>\n";
179 
180 print '<tr class="oddeven">';
181 print '<td>';
182 print $langs->trans("StripeLiveEnabled").'</td><td>';
183 if ($conf->use_javascript_ajax) {
184  print ajax_constantonoff('STRIPE_LIVE');
185 } else {
186  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
187  print $form->selectarray("STRIPE_LIVE", $arrval, $conf->global->STRIPE_LIVE);
188 }
189 print '</td><td></td></tr>';
190 
191 if (empty($conf->stripeconnect->enabled))
192 {
193  print '<tr class="oddeven"><td>';
194  print '<span class="fieldrequired">'.$langs->trans("STRIPE_TEST_PUBLISHABLE_KEY").'</span></td><td>';
195  print '<input class="minwidth300" type="text" name="STRIPE_TEST_PUBLISHABLE_KEY" value="'.$conf->global->STRIPE_TEST_PUBLISHABLE_KEY.'">';
196  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': pk_test_xxxxxxxxxxxxxxxxxxxxxxxx</span>';
197  print '</td><td></td></tr>';
198 
199  print '<tr class="oddeven"><td>';
200  print '<span class="titlefield fieldrequired">'.$langs->trans("STRIPE_TEST_SECRET_KEY").'</span></td><td>';
201  print '<input class="minwidth300" type="text" name="STRIPE_TEST_SECRET_KEY" value="'.$conf->global->STRIPE_TEST_SECRET_KEY.'">';
202  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': sk_test_xxxxxxxxxxxxxxxxxxxxxxxx<</span>';
203  print '</td><td></td></tr>';
204 
205  print '<tr class="oddeven"><td>';
206  print '<span class="titlefield">'.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").'</span></td><td>';
207  if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
208  print '<input class="minwidth300" type="text" name="STRIPE_TEST_WEBHOOK_ID" value="'.$conf->global->STRIPE_TEST_WEBHOOK_ID.'">';
209  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx</span><br>';
210  }
211  print '<input class="minwidth300" type="text" name="STRIPE_TEST_WEBHOOK_KEY" value="'.$conf->global->STRIPE_TEST_WEBHOOK_KEY.'">';
212  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx</span>';
213  $out = img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForTestWebhook").'</span> ';
214  $url = dol_buildpath('/public/stripe/ipn.php?test', 3);
215  $out .= '<input type="text" id="onlinetestwebhookurl" class="minwidth500" value="'.$url.'" disabled>';
216  $out .= ajax_autoselect("onlinetestwebhookurl", 0);
217  print '<br>'.$out;
218  print '</td><td>';
219  if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
220  {
221  if (!empty($conf->global->STRIPE_TEST_WEBHOOK_KEY) && !empty($conf->global->STRIPE_TEST_SECRET_KEY) && !empty($conf->global->STRIPE_TEST_WEBHOOK_ID))
222  {
223  \Stripe\Stripe::setApiKey($conf->global->STRIPE_TEST_SECRET_KEY);
224  $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID);
225  $endpoint->enabled_events = $stripearrayofwebhookevents;
226  if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_TEST_WEBHOOK_ID) {
227  if (!GETPOST('status', 'alpha')) {
228  $endpoint->disabled = true;
229  } else {
230  $endpoint->disabled = false;
231  }
232  }
233  $endpoint->url = dol_buildpath('/public/stripe/ipn.php?test', 3);
234  $endpoint->save();
235  if ($endpoint->status == 'enabled')
236  {
237  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">';
238  print img_picto($langs->trans("Activated"), 'switch_on');
239  } else {
240  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=1">';
241  print img_picto($langs->trans("Disabled"), 'switch_off');
242  }
243  //print $endpoint;
244  } else {
245  print img_picto($langs->trans("inactive"), 'statut5');
246  }
247  }
248  print'</td></tr>';
249 } else {
250  print '<tr class="oddeven"><td>'.$langs->trans("StripeConnect").'</td>';
251  print '<td><b>'.$langs->trans("StripeConnect_Mode").'</b><br/>';
252  print $langs->trans("STRIPE_APPLICATION_FEE_PLATFORM").' ';
253  print price($conf->global->STRIPE_APPLICATION_FEE_PERCENT);
254  print '% + ';
255  print price($conf->global->STRIPE_APPLICATION_FEE);
256  print ' '.$langs->getCurrencySymbol($conf->currency).' '.$langs->trans("minimum").' '.price($conf->global->STRIPE_APPLICATION_FEE_MINIMAL).' '.$langs->getCurrencySymbol($conf->currency);
257  print '</td><td></td></tr>';
258 }
259 
260 if (empty($conf->stripeconnect->enabled))
261 {
262  print '<tr class="oddeven"><td>';
263  print '<span class="fieldrequired">'.$langs->trans("STRIPE_LIVE_PUBLISHABLE_KEY").'</span></td><td>';
264  print '<input class="minwidth300" type="text" name="STRIPE_LIVE_PUBLISHABLE_KEY" value="'.$conf->global->STRIPE_LIVE_PUBLISHABLE_KEY.'">';
265  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': pk_live_xxxxxxxxxxxxxxxxxxxxxxxx</span>';
266  print '</td><td></td></tr>';
267 
268  print '<tr class="oddeven"><td>';
269  print '<span class="fieldrequired">'.$langs->trans("STRIPE_LIVE_SECRET_KEY").'</span></td><td>';
270  print '<input class="minwidth300" type="text" name="STRIPE_LIVE_SECRET_KEY" value="'.$conf->global->STRIPE_LIVE_SECRET_KEY.'">';
271  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': sk_live_xxxxxxxxxxxxxxxxxxxxxxxx</span>';
272  print '</td><td></td></tr>';
273 
274  print '<tr class="oddeven"><td>';
275  print '<span class="titlefield">'.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").'</span></td><td>';
276  if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
277  print '<input class="minwidth300" type="text" name="STRIPE_LIVE_WEBHOOK_ID" value="'.$conf->global->STRIPE_LIVE_WEBHOOK_ID.'">';
278  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx</span><br>';
279  }
280  print '<input class="minwidth300" type="text" name="STRIPE_LIVE_WEBHOOK_KEY" value="'.$conf->global->STRIPE_LIVE_WEBHOOK_KEY.'">';
281  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx</span>';
282  $out = img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForLiveWebhook").'</span> ';
283  $url = dol_buildpath('/public/stripe/ipn.php', 3);
284  $out .= '<input type="text" id="onlinelivewebhookurl" class="minwidth500" value="'.$url.'" disabled>';
285  $out .= ajax_autoselect("onlinelivewebhookurl", 0);
286  print '<br>'.$out;
287  print '</td><td>';
288  if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
289  {
290  if (!empty($conf->global->STRIPE_LIVE_WEBHOOK_KEY) && !empty($conf->global->STRIPE_LIVE_SECRET_KEY) && !empty($conf->global->STRIPE_LIVE_WEBHOOK_ID))
291  {
292  \Stripe\Stripe::setApiKey($conf->global->STRIPE_LIVE_SECRET_KEY);
293  $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_LIVE_WEBHOOK_ID);
294  $endpoint->enabled_events = $stripearrayofwebhookevents;
295  if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_LIVE_WEBHOOK_ID) {
296  if (empty(GETPOST('status', 'alpha'))) {
297  $endpoint->disabled = true;
298  } else {
299  $endpoint->disabled = false;
300  }
301  }
302  $endpoint->url = dol_buildpath('/public/stripe/ipn.php', 3);
303  $endpoint->save();
304  if ($endpoint->status == 'enabled')
305  {
306  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">';
307  print img_picto($langs->trans("Activated"), 'switch_on');
308  } else {
309  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=1">';
310  print img_picto($langs->trans("Disabled"), 'switch_off');
311  }
312  //print $endpoint;
313  } else {
314  print img_picto($langs->trans("inactive"), 'statut5');
315  }
316  }
317  print '</td></tr>';
318 } else {
319  print '<tr class="oddeven"><td>'.$langs->trans("StripeConnect").'</td>';
320  print '<td>'.$langs->trans("StripeConnect_Mode").'</td><td></td></tr>';
321 }
322 
323 
324 print '</table>';
325 print '</div>';
326 
327 print '<br>';
328 
329 
330 print '<div class="div-table-responsive-no-min">';
331 print '<table class="noborder centpercent">';
332 print '<tr class="liste_titre">';
333 print '<td>'.$langs->trans("UsageParameter").'</td>';
334 print '<td>'.$langs->trans("Value").'</td>';
335 print "</tr>\n";
336 
337 print '<tr class="oddeven"><td>';
338 print $langs->trans("PublicVendorName").'</td><td>';
339 print '<input class="minwidth300" type="text" name="ONLINE_PAYMENT_CREDITOR" value="'.$conf->global->ONLINE_PAYMENT_CREDITOR.'">';
340 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': '.$mysoc->name.'</span>';
341 print '</td></tr>';
342 
343 print '<tr class="oddeven"><td>';
344 print $langs->trans("StripeUserAccountForActions").'</td><td>';
345 print img_picto('', 'user').$form->select_dolusers($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS, 'STRIPE_USER_ACCOUNT_FOR_ACTIONS', 0);
346 print '</td></tr>';
347 
348 print '<tr class="oddeven"><td>';
349 print $langs->trans("BankAccount").'</td><td>';
350 print img_picto('', 'bank_account').' ';
351 $form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS, 'STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1);
352 print '</td></tr>';
353 
354 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is this for ?
355 {
356  print '<tr class="oddeven"><td>';
357  print $langs->trans("BankAccountForBankTransfer").'</td><td>';
358  $form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS, 'STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 0, '', 1);
359  print '</td></tr>';
360 }
361 
362 // Activate Payment Request API
363 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
364 {
365  print '<tr class="oddeven"><td>';
366  print $langs->trans("STRIPE_PAYMENT_REQUEST_API").'</td><td>';
367  if ($conf->use_javascript_ajax) {
368  print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API');
369  } else {
370  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
371  print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API);
372  }
373  print '</td></tr>';
374 }
375 
376 // Activate SEPA DIRECT_DEBIT
377 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
378 {
379  print '<tr class="oddeven"><td>';
380  print $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").'</td><td>';
381  if ($conf->use_javascript_ajax) {
382  print ajax_constantonoff('STRIPE_SEPA_DIRECT_DEBIT');
383  } else {
384  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
385  print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT);
386  }
387  print '</td></tr>';
388 }
389 
390 // Activate iDEAL
391 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
392 {
393  print '<tr class="oddeven"><td>';
394  print $langs->trans("STRIPE_IDEAL").'</td><td>';
395  if ($conf->use_javascript_ajax) {
396  print ajax_constantonoff('STRIPE_IDEAL');
397  } else {
398  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
399  print $form->selectarray("STRIPE_IDEAL", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT);
400  }
401  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("ExampleOnlyForNLCustomers").'</span>';
402  print '</td></tr>';
403 }
404 
405 // Warehouse for automatic decrement
406 //if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // warehouse to reduce stock for online payment
407 //{
408 // print '<tr class="oddeven"><td>';
409 // print $langs->trans("ONLINE_PAYMENT_WAREHOUSE").'</td><td>';
410 // print $formproduct->selectWarehouses($conf->global->ONLINE_PAYMENT_WAREHOUSE, 'ONLINE_PAYMENT_WAREHOUSE', '', 1, $disabled);
411 // print '</td></tr>';
412 //}
413 
414 print '<tr class="oddeven"><td>';
415 print $langs->trans("CSSUrlForPaymentForm").'</td><td>';
416 print '<input size="64" type="text" name="ONLINE_PAYMENT_CSS_URL" value="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'">';
417 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': http://mysite/mycss.css</span>';
418 print '</td></tr>';
419 
420 print '<tr class="oddeven"><td>';
421 print $langs->trans("MessageForm").'</td><td>';
422 $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_FORM', $conf->global->ONLINE_PAYMENT_MESSAGE_FORM, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
423 $doleditor->Create();
424 print '</td></tr>';
425 
426 print '<tr class="oddeven"><td>';
427 print $langs->trans("MessageOK").'</td><td>';
428 $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_OK', $conf->global->ONLINE_PAYMENT_MESSAGE_OK, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
429 $doleditor->Create();
430 print '</td></tr>';
431 
432 print '<tr class="oddeven"><td>';
433 print $langs->trans("MessageKO").'</td><td>';
434 $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_KO', $conf->global->ONLINE_PAYMENT_MESSAGE_KO, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
435 $doleditor->Create();
436 print '</td></tr>';
437 
438 print '<tr class="oddeven"><td>';
439 print $langs->trans("ONLINE_PAYMENT_SENDEMAIL").'</td><td>';
440 print '<input class="minwidth200" type="text" name="ONLINE_PAYMENT_SENDEMAIL" value="'.$conf->global->ONLINE_PAYMENT_SENDEMAIL.'">';
441 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': myemail@myserver.com, Payment service &lt;myemail2@myserver2.com&gt;</span>';
442 print '</td></tr>';
443 
444 print '</table>';
445 print '</div>';
446 
447 print '<br>';
448 
449 print '<div class="div-table-responsive-no-min">';
450 print '<table class="noborder centpercent">';
451 
452 print '<tr class="liste_titre">';
453 print '<td>'.$langs->trans("UrlGenerationParameters").'</td>';
454 print '<td>'.$langs->trans("Value").'</td>';
455 print "</tr>\n";
456 
457 // Payment token for URL
458 print '<tr class="oddeven"><td>';
459 print $langs->trans("SecurityToken").'</td><td>';
460 print '<input class="minwidth300" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.'">';
461 if (!empty($conf->use_javascript_ajax)) {
462  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
463 }
464 if (!empty($conf->global->PAYMENT_SECURITY_ACCEPT_ANY_TOKEN)) {
465  $langs->load("errors");
466  print img_warning($langs->trans("WarningTheHiddenOptionIsOn", 'PAYMENT_SECURITY_ACCEPT_ANY_TOKEN'), '', 'pictowarning marginleftonly');
467 }
468 print '</td></tr>';
469 
470 print '<tr class="oddeven"><td>';
471 print $langs->trans("SecurityTokenIsUnique").'</td><td>';
472 if ($conf->use_javascript_ajax) {
473  print ajax_constantonoff('PAYMENT_SECURITY_TOKEN_UNIQUE');
474 } else {
475  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
476  print $form->selectarray("PAYMENT_SECURITY_TOKEN_UNIQUE", $arrval, $conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE);
477 }
478 print '</td></tr>';
479 
480 print '</table>';
481 print '</div>';
482 
484 
485 print '<div class="center"><input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></div>';
486 
487 print '</form>';
488 
489 print '<br><br>';
490 
491 
492 $token = '';
493 
494 include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php';
495 
496 print info_admin($langs->trans("ExampleOfTestCreditCard", '4242424242424242 (no 3DSecure) or 4000000000003063 (3DSecure required) or 4000002760003184 (3DSecure2 required on all transaction) or 4000003800000446 (3DSecure2 required the off-seesion allowed)', '4000000000000101', '4000000000000069', '4000000000000341'));
497 
498 if (!empty($conf->use_javascript_ajax))
499 {
500  print "\n".'<script type="text/javascript">';
501  print '$(document).ready(function () {
502  $("#apidoc").hide();
503  $("#apidoca").click(function() {
504  console.log("We click on apidoca show/hide");
505  $("#apidoc").show();
506  $("#apidoca").hide();
507  return false;
508  });
509  });';
510  print '</script>';
511 }
512 
513 // End of page
514 llxFooter();
515 $db->close();
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).
Definition: admin.lib.php:575
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
stripeadmin_prepare_head()
Define head array for tabs of stripe tools setup pages.
Definition: stripe.lib.php:31
Class with static methods for building HTML components related to products Only components common to ...
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
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&#39;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.
Definition: ajax.lib.php:503
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 ...
ajax_autoselect($htmlname, $addlink= '')
Make content of an input box selected when we click into input field.
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.
Definition: index.php:89
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.
Class to manage a WYSIWYG editor.
llxFooter()
Empty footer.
Definition: wrapper.php:59
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.