dolibarr  16.0.5
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-2021 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 (empty($user->admin)) {
42 }
43 if (empty($conf->stripe->enabled)) {
45 }
46 
47 $action = GETPOST('action', 'aZ09');
48 
49 
50 /*
51  * Actions
52  */
53 
54 if ($action == 'setvalue' && $user->admin) {
55  $db->begin();
56 
57  if (empty($conf->stripeconnect->enabled)) {
58  $result = dolibarr_set_const($db, "STRIPE_TEST_PUBLISHABLE_KEY", GETPOST('STRIPE_TEST_PUBLISHABLE_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
59  if (!($result > 0)) {
60  $error++;
61  }
62  $result = dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY", GETPOST('STRIPE_TEST_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
63  if (!($result > 0)) {
64  $error++;
65  }
66  $result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_ID", GETPOST('STRIPE_TEST_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity);
67  if (!($result > 0)) {
68  $error++;
69  }
70  $result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_KEY", GETPOST('STRIPE_TEST_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
71  if (!($result > 0)) {
72  $error++;
73  }
74  $result = dolibarr_set_const($db, "STRIPE_LIVE_PUBLISHABLE_KEY", GETPOST('STRIPE_LIVE_PUBLISHABLE_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
75  if (!($result > 0)) {
76  $error++;
77  }
78  $result = dolibarr_set_const($db, "STRIPE_LIVE_SECRET_KEY", GETPOST('STRIPE_LIVE_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
79  if (!($result > 0)) {
80  $error++;
81  }
82  $result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_ID", GETPOST('STRIPE_LIVE_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity);
83  if (!($result > 0)) {
84  $error++;
85  }
86  $result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_KEY", GETPOST('STRIPE_LIVE_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
87  if (!($result > 0)) {
88  $error++;
89  }
90  }
91  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR", GETPOST('ONLINE_PAYMENT_CREDITOR', 'alpha'), 'chaine', 0, '', $conf->entity);
92  if (!($result > 0)) {
93  $error++;
94  }
95  $result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_PAYMENTS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 'int'), 'chaine', 0, '', $conf->entity);
96  if (!($result > 0)) {
97  $error++;
98  }
99  $result = dolibarr_set_const($db, "STRIPE_USER_ACCOUNT_FOR_ACTIONS", GETPOST('STRIPE_USER_ACCOUNT_FOR_ACTIONS', 'int'), 'chaine', 0, '', $conf->entity);
100  if (!($result > 0)) {
101  $error++;
102  }
103  $result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 'int'), 'chaine', 0, '', $conf->entity);
104  if (!($result > 0)) {
105  $error++;
106  }
107  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity);
108  if (!($result > 0)) {
109  $error++;
110  }
111  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM", GETPOST('ONLINE_PAYMENT_MESSAGE_FORM', 'restricthtml'), 'chaine', 0, '', $conf->entity);
112  if (!($result > 0)) {
113  $error++;
114  }
115  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_OK", GETPOST('ONLINE_PAYMENT_MESSAGE_OK', 'restricthtml'), 'chaine', 0, '', $conf->entity);
116  if (!($result > 0)) {
117  $error++;
118  }
119  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_KO", GETPOST('ONLINE_PAYMENT_MESSAGE_KO', 'restricthtml'), 'chaine', 0, '', $conf->entity);
120  if (!($result > 0)) {
121  $error++;
122  }
123  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL", GETPOST('ONLINE_PAYMENT_SENDEMAIL'), 'chaine', 0, '', $conf->entity);
124  if (!($result > 0)) {
125  $error++;
126  }
127  // Stock decrement
128  //$result = dolibarr_set_const($db, "ONLINE_PAYMENT_WAREHOUSE", (GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') > 0 ? GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
129  //if (! $result > 0)
130  // $error ++;
131 
132  // Payment token for URL
133  $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN", GETPOST('PAYMENT_SECURITY_TOKEN', 'alpha'), 'chaine', 0, '', $conf->entity);
134  if (!($result > 0)) {
135  $error++;
136  }
137  if (empty($conf->use_javascript_ajax)) {
138  $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE", GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE', 'alpha'), 'chaine', 0, '', $conf->entity);
139  if (!($result > 0)) {
140  $error++;
141  }
142  }
143 
144  if (!$error) {
145  $db->commit();
146  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
147  } else {
148  $db->rollback();
149  dol_print_error($db);
150  }
151 }
152 
153 if ($action == "setlive") {
154  $liveenable = GETPOST('value', 'int');
155  $res = dolibarr_set_const($db, "STRIPE_LIVE", $liveenable, 'yesno', 0, '', $conf->entity);
156  if ($res > 0) {
157  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
158  } else {
159  setEventMessages($langs->trans("Error"), null, 'errors');
160  }
161 }
162 //TODO: import script for stripe account saving in alone or connect mode for stripe.class.php
163 
164 
165 /*
166  * View
167  */
168 
169 $form = new Form($db);
170 $formproduct = new FormProduct($db);
171 
172 llxHeader('', $langs->trans("StripeSetup"));
173 
174 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
175 print load_fiche_titre($langs->trans("ModuleSetup").' Stripe', $linkback);
176 
177 $head = stripeadmin_prepare_head();
178 
179 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
180 print '<input type="hidden" name="token" value="'.newToken().'">';
181 print '<input type="hidden" name="action" value="setvalue">';
182 
183 print dol_get_fiche_head($head, 'stripeaccount', '', -1);
184 
185 $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');
186 
187 print '<span class="opacitymedium">'.$langs->trans("StripeDesc")."</span><br>\n";
188 
189 print '<br>';
190 
191 print '<div class="div-table-responsive-no-min">';
192 print '<table class="noborder centpercent">';
193 print '<tr class="liste_titre">';
194 print '<td>'.$langs->trans("AccountParameter").'</td>';
195 print '<td>'.$langs->trans("Value").'</td>';
196 print '<td></td>';
197 print "</tr>\n";
198 
199 print '<tr class="oddeven">';
200 print '<td>';
201 print $langs->trans("StripeLiveEnabled").'</td><td>';
202 if ($conf->use_javascript_ajax) {
203  print ajax_constantonoff('STRIPE_LIVE');
204 } else {
205  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
206  print $form->selectarray("STRIPE_LIVE", $arrval, $conf->global->STRIPE_LIVE);
207 }
208 print '</td><td></td></tr>';
209 
210 if (empty($conf->stripeconnect->enabled)) {
211  print '<tr class="oddeven"><td>';
212  print '<span class="fieldrequired">'.$langs->trans("STRIPE_TEST_PUBLISHABLE_KEY").'</span></td><td>';
213  print '<input class="minwidth300" type="text" name="STRIPE_TEST_PUBLISHABLE_KEY" value="'.$conf->global->STRIPE_TEST_PUBLISHABLE_KEY.'" placeholder="'.$langs->trans("Example").': pk_test_xxxxxxxxxxxxxxxxxxxxxxxx">';
214  print '</td><td></td></tr>';
215 
216  print '<tr class="oddeven"><td>';
217  print '<span class="titlefield fieldrequired">'.$langs->trans("STRIPE_TEST_SECRET_KEY").'</span></td><td>';
218  print '<input class="minwidth300" type="text" name="STRIPE_TEST_SECRET_KEY" value="'.$conf->global->STRIPE_TEST_SECRET_KEY.'" placeholder="'.$langs->trans("Example").': sk_test_xxxxxxxxxxxxxxxxxxxxxxxx">';
219  print '</td><td></td></tr>';
220 
221  print '<tr class="oddeven"><td>';
222  print '<span class="titlefield">'.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").'</span></td><td>';
223  if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
224  print '<input class="minwidth300" type="text" name="STRIPE_TEST_WEBHOOK_ID" value="'.getDolGlobalString('STRIPE_TEST_WEBHOOK_ID').'" placeholder="'.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx">';
225  print '<br>';
226  }
227  print '<input class="minwidth300" type="text" name="STRIPE_TEST_WEBHOOK_KEY" value="'.getDolGlobalString('STRIPE_TEST_WEBHOOK_KEY').'" placeholder="'.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx">';
228  $out = img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForTestWebhook").'</span> ';
229  $url = dol_buildpath('/public/stripe/ipn.php?test', 3);
230  $out .= '<input type="text" id="onlinetestwebhookurl" class="minwidth500" value="'.$url.'" disabled>';
231  $out .= ajax_autoselect("onlinetestwebhookurl", 0);
232  print '<br>'.$out;
233  print '</td><td>';
234  if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
235  if (!empty($conf->global->STRIPE_TEST_WEBHOOK_KEY) && !empty($conf->global->STRIPE_TEST_SECRET_KEY) && !empty($conf->global->STRIPE_TEST_WEBHOOK_ID)) {
236  \Stripe\Stripe::setApiKey($conf->global->STRIPE_TEST_SECRET_KEY);
237  $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID);
238  $endpoint->enabled_events = $stripearrayofwebhookevents;
239  if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_TEST_WEBHOOK_ID) {
240  if (!GETPOST('status', 'alpha')) {
241  $endpoint->disabled = true;
242  } else {
243  $endpoint->disabled = false;
244  }
245  }
246  $endpoint->url = dol_buildpath('/public/stripe/ipn.php?test', 3);
247  $endpoint->save();
248  if ($endpoint->status == 'enabled') {
249  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">';
250  print img_picto($langs->trans("Activated"), 'switch_on');
251  } else {
252  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=1">';
253  print img_picto($langs->trans("Disabled"), 'switch_off');
254  }
255  //print $endpoint;
256  } else {
257  print img_picto($langs->trans("Inactive"), 'statut5');
258  }
259  }
260  print'</td></tr>';
261 } else {
262  print '<tr class="oddeven"><td>'.$langs->trans("StripeConnect").'</td>';
263  print '<td><b>'.$langs->trans("StripeConnect_Mode").'</b><br>';
264  print $langs->trans("STRIPE_APPLICATION_FEE_PLATFORM").' ';
265  print price($conf->global->STRIPE_APPLICATION_FEE_PERCENT);
266  print '% + ';
267  print price($conf->global->STRIPE_APPLICATION_FEE);
268  print ' '.$langs->getCurrencySymbol($conf->currency).' '.$langs->trans("minimum").' '.price($conf->global->STRIPE_APPLICATION_FEE_MINIMAL).' '.$langs->getCurrencySymbol($conf->currency);
269  print '</td><td></td></tr>';
270 }
271 
272 if (empty($conf->stripeconnect->enabled)) {
273  print '<tr class="oddeven"><td>';
274  print '<span class="fieldrequired">'.$langs->trans("STRIPE_LIVE_PUBLISHABLE_KEY").'</span></td><td>';
275  print '<input class="minwidth300" type="text" name="STRIPE_LIVE_PUBLISHABLE_KEY" value="'.getDolGlobalString('STRIPE_LIVE_PUBLISHABLE_KEY').'" placeholder="'.$langs->trans("Example").': pk_live_xxxxxxxxxxxxxxxxxxxxxxxx">';
276  print '</td><td></td></tr>';
277 
278  print '<tr class="oddeven"><td>';
279  print '<span class="fieldrequired">'.$langs->trans("STRIPE_LIVE_SECRET_KEY").'</span></td><td>';
280  print '<input class="minwidth300" type="text" name="STRIPE_LIVE_SECRET_KEY" value="'.getDolGlobalString('STRIPE_LIVE_SECRET_KEY').'" placeholder="'.$langs->trans("Example").': sk_live_xxxxxxxxxxxxxxxxxxxxxxxx">';
281  print '</td><td></td></tr>';
282 
283  print '<tr class="oddeven"><td>';
284  print '<span class="titlefield">'.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").'</span></td><td>';
285  if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
286  print '<input class="minwidth300" type="text" name="STRIPE_LIVE_WEBHOOK_ID" value="'.getDolGlobalString('STRIPE_LIVE_WEBHOOK_ID').'" placeholder="'.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx">';
287  print '<br>';
288  }
289  print '<input class="minwidth300" type="text" name="STRIPE_LIVE_WEBHOOK_KEY" value="'.$conf->global->STRIPE_LIVE_WEBHOOK_KEY.'" placeholder="'.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx">';
290  $out = img_picto('', 'globe', 'class="pictofixedwidth"').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForLiveWebhook").'</span> ';
291  $url = dol_buildpath('/public/stripe/ipn.php', 3);
292  $out .= '<input type="text" id="onlinelivewebhookurl" class="minwidth500" value="'.$url.'" disabled>';
293  $out .= ajax_autoselect("onlinelivewebhookurl", 0);
294  print '<br>'.$out;
295  print '</td><td>';
296  if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
297  if (!empty($conf->global->STRIPE_LIVE_WEBHOOK_KEY) && !empty($conf->global->STRIPE_LIVE_SECRET_KEY) && !empty($conf->global->STRIPE_LIVE_WEBHOOK_ID)) {
298  \Stripe\Stripe::setApiKey($conf->global->STRIPE_LIVE_SECRET_KEY);
299  $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_LIVE_WEBHOOK_ID);
300  $endpoint->enabled_events = $stripearrayofwebhookevents;
301  if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_LIVE_WEBHOOK_ID) {
302  if (empty(GETPOST('status', 'alpha'))) {
303  $endpoint->disabled = true;
304  } else {
305  $endpoint->disabled = false;
306  }
307  }
308  $endpoint->url = dol_buildpath('/public/stripe/ipn.php', 3);
309  $endpoint->save();
310  if ($endpoint->status == 'enabled') {
311  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">';
312  print img_picto($langs->trans("Activated"), 'switch_on');
313  } else {
314  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=1">';
315  print img_picto($langs->trans("Disabled"), 'switch_off');
316  }
317  //print $endpoint;
318  } else {
319  print img_picto($langs->trans("Inactive"), 'statut5');
320  }
321  }
322  print '</td></tr>';
323 } else {
324  print '<tr class="oddeven"><td>'.$langs->trans("StripeConnect").'</td>';
325  print '<td>'.$langs->trans("StripeConnect_Mode").'</td><td></td></tr>';
326 }
327 
328 
329 print '</table>';
330 print '</div>';
331 
332 print '<br>';
333 
334 
335 print '<div class="div-table-responsive-no-min">';
336 print '<table class="noborder centpercent">';
337 print '<tr class="liste_titre">';
338 print '<td>'.$langs->trans("UsageParameter").'</td>';
339 print '<td>'.$langs->trans("Value").'</td>';
340 print "</tr>\n";
341 
342 print '<tr class="oddeven"><td>';
343 print $langs->trans("PublicVendorName").'</td><td>';
344 print '<input class="minwidth300" type="text" name="ONLINE_PAYMENT_CREDITOR" value="'.getDolGlobalString('ONLINE_PAYMENT_CREDITOR').'">';
345 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': '.$mysoc->name.'</span>';
346 print '</td></tr>';
347 
348 print '<tr class="oddeven"><td>';
349 print $langs->trans("StripeUserAccountForActions").'</td><td>';
350 print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers(getDolGlobalString('STRIPE_USER_ACCOUNT_FOR_ACTIONS'), 'STRIPE_USER_ACCOUNT_FOR_ACTIONS', 0);
351 print '</td></tr>';
352 
353 print '<tr class="oddeven"><td>';
354 print $langs->trans("BankAccount").'</td><td>';
355 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
356 $form->select_comptes(getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'), 'STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1);
357 print '</td></tr>';
358 
359 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // What is this for ?
360  print '<tr class="oddeven"><td>';
361  print $langs->trans("BankAccountForBankTransfer").'</td><td>';
362  print img_picto('', 'bank_account', 'class="pictofixedwidth"');
363  $form->select_comptes(getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS'), 'STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 0, '', 1);
364  print '</td></tr>';
365 }
366 
367 // Activate Payment Request API
368 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
369  print '<tr class="oddeven"><td>';
370  print $langs->trans("STRIPE_PAYMENT_REQUEST_API").' ?? Not used, what is it for ??</td><td>';
371  if ($conf->use_javascript_ajax) {
372  print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API');
373  } else {
374  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
375  print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, getDolGlobalString('STRIPE_PAYMENT_REQUEST_API'));
376  }
377  print '</td></tr>';
378 }
379 
380 // Activate SEPA DIRECT_DEBIT
381 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
382  print '<tr class="oddeven"><td>';
383  print $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").'</td><td>';
384  if ($conf->use_javascript_ajax) {
385  print ajax_constantonoff('STRIPE_SEPA_DIRECT_DEBIT');
386  } else {
387  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
388  print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, getDolGlobalString('STRIPE_SEPA_DIRECT_DEBIT'));
389  }
390  print '</td></tr>';
391 }
392 
393 // Activate Klarna
394 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
395  print '<tr class="oddeven"><td>';
396  print $langs->trans("STRIPE_KLARNA").'</td><td>';
397  if ($conf->use_javascript_ajax) {
398  print ajax_constantonoff('STRIPE_KLARNA');
399  } else {
400  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
401  print $form->selectarray("STRIPE_KLARNA", $arrval, $conf->global->STRIPE_KLARNA);
402  }
403  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("ExampleOnlyForKlarnaCustomers").'</span>';
404  print '</td></tr>';
405 }
406 
407 // Activate Bancontact
408 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
409  print '<tr class="oddeven"><td>';
410  print $langs->trans("STRIPE_BANCONTACT").'</td><td>';
411  if ($conf->use_javascript_ajax) {
412  print ajax_constantonoff('STRIPE_BANCONTACT');
413  } else {
414  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
415  print $form->selectarray("STRIPE_BANCONTACT", $arrval, $conf->global->STRIPE_BANCONTACT);
416  }
417  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("ExampleOnlyForBECustomers").'</span>';
418  print '</td></tr>';
419 }
420 
421 // Activate iDEAL
422 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
423  print '<tr class="oddeven"><td>';
424  print $langs->trans("STRIPE_IDEAL").'</td><td>';
425  if ($conf->use_javascript_ajax) {
426  print ajax_constantonoff('STRIPE_IDEAL');
427  } else {
428  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
429  print $form->selectarray("STRIPE_IDEAL", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT);
430  }
431  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("ExampleOnlyForNLCustomers").'</span>';
432  print '</td></tr>';
433 }
434 
435 // Activate Giropay
436 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
437  print '<tr class="oddeven"><td>';
438  print $langs->trans("STRIPE_GIROPAY").'</td><td>';
439  if ($conf->use_javascript_ajax) {
440  print ajax_constantonoff('STRIPE_GIROPAY');
441  } else {
442  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
443  print $form->selectarray("STRIPE_GIROPAY", $arrval, $conf->global->STRIPE_GIROPAY);
444  }
445  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("ExampleOnlyForDECustomers").'</span>';
446  print '</td></tr>';
447 }
448 
449 // Activate Sofort
450 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
451  print '<tr class="oddeven"><td>';
452  print $langs->trans("STRIPE_SOFORT").'</td><td>';
453  if ($conf->use_javascript_ajax) {
454  print ajax_constantonoff('STRIPE_SOFORT');
455  } else {
456  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
457  print $form->selectarray("STRIPE_SOFORT", $arrval, $conf->global->STRIPE_SOFORT);
458  }
459  print ' &nbsp; <span class="opacitymedium">'.$langs->trans("ExampleOnlyForATBEDEITNLESCustomers").'</span>';
460  print '</td></tr>';
461 }
462 
463 print '<tr class="oddeven"><td>';
464 print $langs->trans("CSSUrlForPaymentForm").'</td><td>';
465 print '<input size="64" type="text" name="ONLINE_PAYMENT_CSS_URL" value="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'">';
466 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': http://mysite/mycss.css</span>';
467 print '</td></tr>';
468 
469 print '<tr class="oddeven"><td>';
470 print $langs->trans("MessageForm").'</td><td>';
471 $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_FORM', $conf->global->ONLINE_PAYMENT_MESSAGE_FORM, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
472 $doleditor->Create();
473 print '</td></tr>';
474 
475 print '<tr class="oddeven"><td>';
476 print $langs->trans("MessageOK").'</td><td>';
477 $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_OK', $conf->global->ONLINE_PAYMENT_MESSAGE_OK, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
478 $doleditor->Create();
479 print '</td></tr>';
480 
481 print '<tr class="oddeven"><td>';
482 print $langs->trans("MessageKO").'</td><td>';
483 $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_KO', $conf->global->ONLINE_PAYMENT_MESSAGE_KO, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
484 $doleditor->Create();
485 print '</td></tr>';
486 
487 print '<tr class="oddeven"><td>';
488 print $langs->trans("ONLINE_PAYMENT_SENDEMAIL").'</td><td>';
489 print img_picto('', 'email', 'class="pictofixedwidth"');
490 print '<input class="minwidth200" type="text" name="ONLINE_PAYMENT_SENDEMAIL" value="'.$conf->global->ONLINE_PAYMENT_SENDEMAIL.'">';
491 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': myemail@myserver.com, Payment service &lt;myemail2@myserver2.com&gt;</span>';
492 print '</td></tr>';
493 
494 print '</table>';
495 print '</div>';
496 
497 print '<br>';
498 
499 print '<div class="div-table-responsive-no-min">';
500 print '<table class="noborder centpercent">';
501 
502 print '<tr class="liste_titre">';
503 print '<td>'.$langs->trans("UrlGenerationParameters").'</td>';
504 print '<td>'.$langs->trans("Value").'</td>';
505 print "</tr>\n";
506 
507 // Payment token for URL
508 print '<tr class="oddeven"><td>';
509 print $langs->trans("SecurityToken").'</td><td>';
510 print '<input class="minwidth300" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.'">';
511 if (!empty($conf->use_javascript_ajax)) {
512  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
513 }
514 if (!empty($conf->global->PAYMENT_SECURITY_ACCEPT_ANY_TOKEN)) {
515  $langs->load("errors");
516  print img_warning($langs->trans("WarningTheHiddenOptionIsOn", 'PAYMENT_SECURITY_ACCEPT_ANY_TOKEN'), '', 'pictowarning marginleftonly');
517 }
518 print '</td></tr>';
519 
520 print '<tr class="oddeven"><td>';
521 print $langs->trans("SecurityTokenIsUnique").'</td><td>';
522 if ($conf->use_javascript_ajax) {
523  print ajax_constantonoff('PAYMENT_SECURITY_TOKEN_UNIQUE', null, null, 0, 0, 1);
524 } else {
525  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
526  print $form->selectarray("PAYMENT_SECURITY_TOKEN_UNIQUE", $arrval, $conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE);
527 }
528 print '</td></tr>';
529 
530 print '</table>';
531 print '</div>';
532 
533 print dol_get_fiche_end();
534 
535 print $form->buttonsSaveCancel("Save", '');
536 
537 print '</form>';
538 
539 print '<br><br>';
540 
541 
542 $token = '';
543 
544 include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php';
545 
546 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-session allowed)', '4000000000000101', '4000000000000069', '4000000000000341'));
547 
548 if (!empty($conf->use_javascript_ajax)) {
549  print "\n".'<script type="text/javascript">';
550  print '$(document).ready(function () {
551  $("#apidoc").hide();
552  $("#apidoca").click(function() {
553  console.log("We click on apidoca show/hide");
554  $("#apidoc").show();
555  $("#apidoca").hide();
556  return false;
557  });
558  });';
559  print '</script>';
560 }
561 
562 // End of page
563 llxFooter();
564 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
stripeadmin_prepare_head
stripeadmin_prepare_head()
Define head array for tabs of stripe tools setup pages.
Definition: stripe.lib.php:31
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
img_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)
Definition: functions.lib.php:3880
ajax_constantonoff
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='')
On/off button for constant.
Definition: ajax.lib.php:573
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
info_admin
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
Definition: functions.lib.php:4800
FormProduct
Class with static methods for building HTML components related to products Only components common to ...
Definition: html.formproduct.class.php:30
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
dolibarr_set_const
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:627
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
price
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.
Definition: functions.lib.php:5541
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
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 ...
Definition: security.lib.php:933
ajax_autoselect
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
Definition: functions.lib.php:9681
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:93
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30