dolibarr 21.0.0-beta
paybox.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.org>
4 * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
31
32$servicename = 'PayBox';
33
44// Load translation files required by the page
45$langs->loadLangs(array('admin', 'other', 'paybox', 'paypal', 'stripe'));
46
47if (!$user->admin) {
49}
50
51$action = GETPOST('action', 'aZ09');
52$error = 0;
53
54if ($action == 'setvalue' && $user->admin) {
55 $db->begin();
56 //$result=dolibarr_set_const($db, "PAYBOX_IBS_DEVISE", GETPOST("PAYBOX_IBS_DEVISE"),'chaine',0,'',$conf->entity);
57 $result = dolibarr_set_const($db, "PAYBOX_CGI_URL_V1", GETPOST('PAYBOX_CGI_URL_V1', 'alpha'), 'chaine', 0, '', $conf->entity);
58 if (!($result > 0)) {
59 $error++;
60 }
61 $result = dolibarr_set_const($db, "PAYBOX_CGI_URL_V2", GETPOST('PAYBOX_CGI_URL_V2', 'alpha'), 'chaine', 0, '', $conf->entity);
62 if (!($result > 0)) {
63 $error++;
64 }
65 $result = dolibarr_set_const($db, "PAYBOX_IBS_SITE", GETPOST('PAYBOX_IBS_SITE', 'alpha'), 'chaine', 0, '', $conf->entity);
66 if (!($result > 0)) {
67 $error++;
68 }
69 $result = dolibarr_set_const($db, "PAYBOX_IBS_RANG", GETPOST('PAYBOX_IBS_RANG', 'alpha'), 'chaine', 0, '', $conf->entity);
70 if (!($result > 0)) {
71 $error++;
72 }
73 $result = dolibarr_set_const($db, "PAYBOX_PBX_IDENTIFIANT", GETPOST('PAYBOX_PBX_IDENTIFIANT', 'alpha'), 'chaine', 0, '', $conf->entity);
74 if (!($result > 0)) {
75 $error++;
76 }
77 $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR", GETPOST('ONLINE_PAYMENT_CREDITOR', 'alpha'), 'chaine', 0, '', $conf->entity);
78 if (!($result > 0)) {
79 $error++;
80 }
81 $result = dolibarr_set_const($db, "PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS", GETPOSTINT('PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS'), 'chaine', 0, '', $conf->entity);
82 if (!($result > 0)) {
83 $error++;
84 }
85 $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity);
86 if (!($result > 0)) {
87 $error++;
88 }
89 $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM", GETPOST('ONLINE_PAYMENT_MESSAGE_FORM', 'restricthtml'), 'chaine', 0, '', $conf->entity);
90 if (!($result > 0)) {
91 $error++;
92 }
93 $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_OK", GETPOST('ONLINE_PAYMENT_MESSAGE_OK', 'restricthtml'), 'chaine', 0, '', $conf->entity);
94 if (!($result > 0)) {
95 $error++;
96 }
97 $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_KO", GETPOST('ONLINE_PAYMENT_MESSAGE_KO', 'restricthtml'), 'chaine', 0, '', $conf->entity);
98 if (!($result > 0)) {
99 $error++;
100 }
101 $result = dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL", GETPOST('ONLINE_PAYMENT_SENDEMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
102 if (!($result > 0)) {
103 $error++;
104 }
105 // Payment token for URL
106 $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN", GETPOST('PAYMENT_SECURITY_TOKEN', 'alpha'), 'chaine', 0, '', $conf->entity);
107 if (!($result > 0)) {
108 $error++;
109 }
110 $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE", GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE', 'alpha'), 'chaine', 0, '', $conf->entity);
111 if (!($result > 0)) {
112 $error++;
113 }
114 $result = dolibarr_set_const($db, "PAYBOX_HMAC_KEY", dol_encode(GETPOST('PAYBOX_HMAC_KEY', 'alpha')), 'chaine', 0, '', $conf->entity);
115 if (!($result > 0)) {
116 $error++;
117 }
118
119
120 if (!$error) {
121 $db->commit();
122 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
123 } else {
124 $db->rollback();
125 dol_print_error($db);
126 }
127}
128
129
130/*
131 * View
132 */
133
134$IBS_SITE = "1999888"; // Site test
135if (!getDolGlobalString('PAYBOX_IBS_SITE')) {
136 $conf->global->PAYBOX_IBS_SITE = $IBS_SITE;
137}
138$IBS_RANG = "99"; // Rang test
139if (!getDolGlobalString('PAYBOX_IBS_RANG')) {
140 $conf->global->PAYBOX_IBS_RANG = $IBS_RANG;
141}
142$IBS_DEVISE = "978"; // Euro
143if (!getDolGlobalString('PAYBOX_IBS_DEVISE')) {
144 $conf->global->PAYBOX_IBS_DEVISE = $IBS_DEVISE;
145}
146
147llxHeader();
148
149$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
150print load_fiche_titre($langs->trans("PayBoxSetup"), $linkback, 'title_setup');
151
152$h = 0;
153$head = array();
154
155$head[$h][0] = DOL_URL_ROOT."/paybox/admin/paybox.php";
156$head[$h][1] = $langs->trans("PayBox");
157$head[$h][2] = 'payboxaccount';
158$h++;
159
160print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
161print '<input type="hidden" name="token" value="'.newToken().'">';
162print '<input type="hidden" name="action" value="setvalue">';
163
164print dol_get_fiche_head($head, 'payboxaccount', '', -1);
165
166print $langs->trans("PayBoxDesc")."<br>\n";
167print '<br>';
168
169print '<table class="noborder centpercent">';
170print '<tr class="liste_titre">';
171print '<td>'.$langs->trans("AccountParameter").'</td>';
172print '<td>'.$langs->trans("Value").'</td>';
173print "</tr>\n";
174
175
176print '<tr class="oddeven"><td>';
177print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_SITE").'</span></td><td>';
178print '<input size="32" type="text" name="PAYBOX_IBS_SITE" value="' . getDolGlobalString('PAYBOX_IBS_SITE').'">';
179print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 1999888 ('.$langs->trans("Test").')</span>';
180print '</td></tr>';
181
182
183print '<tr class="oddeven"><td>';
184print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_RANG").'</span></td><td>';
185print '<input size="32" type="text" name="PAYBOX_IBS_RANG" value="' . getDolGlobalString('PAYBOX_IBS_RANG').'">';
186print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 99 ('.$langs->trans("Test").')</span>';
187print '</td></tr>';
188
189
190print '<tr class="oddeven"><td>';
191print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_IDENTIFIANT").'</span></td><td>';
192print '<input size="32" type="text" name="PAYBOX_PBX_IDENTIFIANT" value="' . getDolGlobalString('PAYBOX_PBX_IDENTIFIANT').'">';
193print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 2 ('.$langs->trans("Test").')</span>';
194print '</td></tr>';
195
196print '<tr class="oddeven"><td>';
197print '<span class="fieldrequired">'.$langs->trans("PAYBOX_HMAC_KEY").'</span></td><td>';
198print '<input size="100" type="text" name="PAYBOX_HMAC_KEY" value="'.dol_decode($conf->global->PAYBOX_HMAC_KEY).'">';
199print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 1A2B3C4D5E6F</span>';
200print '</td></tr>';
201
202print '<tr class="liste_titre">';
203print '<td>'.$langs->trans("UsageParameter").'</td>';
204print '<td>'.$langs->trans("Value").'</td>';
205print "</tr>\n";
206
207/*
208
209print '<tr class="oddeven"><td>';
210print $langs->trans("PAYBOX_IBS_DEVISE").'</td><td>';
211print '<input size="32" type="text" name="PAYBOX_IBS_DEVISE" value="'.$conf->global->PAYBOX_IBS_DEVISE.'">';
212print '<br>'.$langs->trans("Example").': 978 (EUR)';
213print '</td></tr>';
214*/
215
216/*
217
218print '<tr class="oddeven"><td>';
219print $langs->trans("PAYBOX_CGI_URL_V1").'</td><td>';
220print '<input size="64" type="text" name="PAYBOX_CGI_URL_V1" value="'.$conf->global->PAYBOX_CGI_URL_V1.'">';
221print '<br>'.$langs->trans("Example").': http://mysite/cgi-bin/module_linux.cgi';
222print '</td></tr>';
223*/
224
225
226print '<tr class="oddeven"><td>';
227print '<span class="fieldrequired">'.$langs->trans("PAYBOX_CGI_URL_V2").'</span></td><td>';
228print '<input size="64" type="text" name="PAYBOX_CGI_URL_V2" value="' . getDolGlobalString('PAYBOX_CGI_URL_V2').'">';
229print '<span class="opacitymedium"><br>'.$langs->trans("Example").' (preprod): https://preprod-tpeweb.paybox.com/php/';
230print '<br>'.$langs->trans("Example").' (prod): https://tpeweb.paybox.com/php/</span>';
231print '</td></tr>';
232
233
234print '<tr class="oddeven"><td>';
235print $langs->trans("PublicVendorName").'</td><td>';
236print '<input type="text" class="minwidth300" name="ONLINE_PAYMENT_CREDITOR" value="' . getDolGlobalString('ONLINE_PAYMENT_CREDITOR').'">';
237print '<br><span class="opacitymedium">'.$langs->trans("Example").': '.$mysoc->name.'</span>';
238print '</td></tr>';
239
240
241if (isModEnabled("bank")) {
242 print '<tr class="oddeven"><td>';
243 print $langs->trans("BankAccount").'</td><td>';
244 $form->select_comptes($conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1);
245 print '</td></tr>';
246}
247
248
249print '<tr class="oddeven"><td>';
250print $langs->trans("CSSUrlForPaymentForm").'</td><td>';
251print '<input size="64" type="text" name="ONLINE_PAYMENT_CSS_URL" value="' . getDolGlobalString('ONLINE_PAYMENT_CSS_URL').'">';
252print '<span class="opacitymedium"><br>'.$langs->trans("Example").': http://mysite/mycss.css</span>';
253print '</td></tr>';
254
255
256print '<tr class="oddeven"><td>';
257print $langs->trans("MessageForm").'</td><td>';
258$doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_FORM', $conf->global->ONLINE_PAYMENT_MESSAGE_FORM, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
259$doleditor->Create();
260print '</td></tr>';
261
262print '<tr class="oddeven"><td>';
263print $langs->trans("MessageOK").'</td><td>';
264$doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_OK', $conf->global->ONLINE_PAYMENT_MESSAGE_OK, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
265$doleditor->Create();
266print '</td></tr>';
267
268
269print '<tr class="oddeven"><td>';
270print $langs->trans("MessageKO").'</td><td>';
271$doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_KO', $conf->global->ONLINE_PAYMENT_MESSAGE_KO, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
272$doleditor->Create();
273print '</td></tr>';
274
275
276print '<tr class="oddeven"><td class="fieldrequired">';
277print $langs->trans("ONLINE_PAYMENT_SENDEMAIL").'</td><td>';
278print '<input size="32" type="text" name="ONLINE_PAYMENT_SENDEMAIL" value="' . getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'">';
279print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': myemail@myserver.com, Payment service &lt;myemail2@myserver2.com&gt;</span>';
280print '</td></tr>';
281
282// Payment token for URL
283print '<tr class="oddeven"><td>';
284print $langs->trans("SecurityToken").'</td><td>';
285print '<input size="48" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="' . getDolGlobalString('PAYMENT_SECURITY_TOKEN').'">';
286if (!empty($conf->use_javascript_ajax)) {
287 print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
288}
289print '</td></tr>';
290
291print '<tr class="oddeven"><td>';
292print $langs->trans("SecurityTokenIsUnique").'</td><td>';
293print $form->selectyesno("PAYMENT_SECURITY_TOKEN_UNIQUE", (!getDolGlobalString('PAYMENT_SECURITY_TOKEN') ? 0 : $conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE), 1);
294print '</td></tr>';
295
296print '</table>';
297
298print dol_get_fiche_end();
299
300print $form->buttonsSaveCancel("Modify", '');
301
302print '</form>';
303
304print '<br><br>';
305
306include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php';
307
308// End of page
309llxFooter();
310$db->close();
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.
Definition wrapper.php:71
Class to manage a WYSIWYG editor.
llxFooter()
Footer empty.
Definition document.php:107
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.
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.
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...
Definition member.php:79
dol_encode($chain, $key='1')
Encode a string with base 64 algorithm + specific delta change.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.