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