dolibarr  16.0.5
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 require '../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
29 
30 $servicename = 'PayBox';
31 
32 // Load translation files required by the page
33 $langs->loadLangs(array('admin', 'other', 'paybox', 'paypal', 'stripe'));
34 
35 if (!$user->admin) {
37 }
38 
39 $action = GETPOST('action', 'aZ09');
40 
41 
42 if ($action == 'setvalue' && $user->admin) {
43  $db->begin();
44  //$result=dolibarr_set_const($db, "PAYBOX_IBS_DEVISE", GETPOST("PAYBOX_IBS_DEVISE"),'chaine',0,'',$conf->entity);
45  $result = dolibarr_set_const($db, "PAYBOX_CGI_URL_V1", GETPOST('PAYBOX_CGI_URL_V1', 'alpha'), 'chaine', 0, '', $conf->entity);
46  if (!($result > 0)) {
47  $error++;
48  }
49  $result = dolibarr_set_const($db, "PAYBOX_CGI_URL_V2", GETPOST('PAYBOX_CGI_URL_V2', 'alpha'), 'chaine', 0, '', $conf->entity);
50  if (!($result > 0)) {
51  $error++;
52  }
53  $result = dolibarr_set_const($db, "PAYBOX_IBS_SITE", GETPOST('PAYBOX_IBS_SITE', 'alpha'), 'chaine', 0, '', $conf->entity);
54  if (!($result > 0)) {
55  $error++;
56  }
57  $result = dolibarr_set_const($db, "PAYBOX_IBS_RANG", GETPOST('PAYBOX_IBS_RANG', 'alpha'), 'chaine', 0, '', $conf->entity);
58  if (!($result > 0)) {
59  $error++;
60  }
61  $result = dolibarr_set_const($db, "PAYBOX_PBX_IDENTIFIANT", GETPOST('PAYBOX_PBX_IDENTIFIANT', 'alpha'), 'chaine', 0, '', $conf->entity);
62  if (!($result > 0)) {
63  $error++;
64  }
65  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR", GETPOST('ONLINE_PAYMENT_CREDITOR', 'alpha'), 'chaine', 0, '', $conf->entity);
66  if (!($result > 0)) {
67  $error++;
68  }
69  $result = dolibarr_set_const($db, "PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS", GETPOST('PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 'int'), 'chaine', 0, '', $conf->entity);
70  if (!($result > 0)) {
71  $error++;
72  }
73  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity);
74  if (!($result > 0)) {
75  $error++;
76  }
77  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM", GETPOST('ONLINE_PAYMENT_MESSAGE_FORM', 'restricthtml'), 'chaine', 0, '', $conf->entity);
78  if (!($result > 0)) {
79  $error++;
80  }
81  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_OK", GETPOST('ONLINE_PAYMENT_MESSAGE_OK', 'restricthtml'), 'chaine', 0, '', $conf->entity);
82  if (!($result > 0)) {
83  $error++;
84  }
85  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_KO", GETPOST('ONLINE_PAYMENT_MESSAGE_KO', 'restricthtml'), 'chaine', 0, '', $conf->entity);
86  if (!($result > 0)) {
87  $error++;
88  }
89  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL", GETPOST('ONLINE_PAYMENT_SENDEMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
90  if (!($result > 0)) {
91  $error++;
92  }
93  // Payment token for URL
94  $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN", GETPOST('PAYMENT_SECURITY_TOKEN', 'alpha'), 'chaine', 0, '', $conf->entity);
95  if (!($result > 0)) {
96  $error++;
97  }
98  $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE", GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE', 'alpha'), 'chaine', 0, '', $conf->entity);
99  if (!($result > 0)) {
100  $error++;
101  }
102  $result = dolibarr_set_const($db, "PAYBOX_HMAC_KEY", dol_encode(GETPOST('PAYBOX_HMAC_KEY', 'alpha')), 'chaine', 0, '', $conf->entity);
103  if (!($result > 0)) {
104  $error++;
105  }
106 
107 
108  if (!$error) {
109  $db->commit();
110  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
111  } else {
112  $db->rollback();
113  dol_print_error($db);
114  }
115 }
116 
117 
118 /*
119  * View
120  */
121 
122 $IBS_SITE = "1999888"; // Site test
123 if (empty($conf->global->PAYBOX_IBS_SITE)) {
124  $conf->global->PAYBOX_IBS_SITE = $IBS_SITE;
125 }
126 $IBS_RANG = "99"; // Rang test
127 if (empty($conf->global->PAYBOX_IBS_RANG)) {
128  $conf->global->PAYBOX_IBS_RANG = $IBS_RANG;
129 }
130 $IBS_DEVISE = "978"; // Euro
131 if (empty($conf->global->PAYBOX_IBS_DEVISE)) {
132  $conf->global->PAYBOX_IBS_DEVISE = $IBS_DEVISE;
133 }
134 
135 llxHeader();
136 
137 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
138 print load_fiche_titre($langs->trans("PayBoxSetup"), $linkback, 'title_setup');
139 
140 $h = 0;
141 $head = array();
142 
143 $head[$h][0] = DOL_URL_ROOT."/paybox/admin/paybox.php";
144 $head[$h][1] = $langs->trans("PayBox");
145 $head[$h][2] = 'payboxaccount';
146 $h++;
147 
148 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
149 print '<input type="hidden" name="token" value="'.newToken().'">';
150 print '<input type="hidden" name="action" value="setvalue">';
151 
152 print dol_get_fiche_head($head, 'payboxaccount', '', -1);
153 
154 print $langs->trans("PayBoxDesc")."<br>\n";
155 print '<br>';
156 
157 print '<table class="noborder centpercent">';
158 print '<tr class="liste_titre">';
159 print '<td>'.$langs->trans("AccountParameter").'</td>';
160 print '<td>'.$langs->trans("Value").'</td>';
161 print "</tr>\n";
162 
163 
164 print '<tr class="oddeven"><td>';
165 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_SITE").'</span></td><td>';
166 print '<input size="32" type="text" name="PAYBOX_IBS_SITE" value="'.$conf->global->PAYBOX_IBS_SITE.'">';
167 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 1999888 ('.$langs->trans("Test").')</span>';
168 print '</td></tr>';
169 
170 
171 print '<tr class="oddeven"><td>';
172 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_RANG").'</span></td><td>';
173 print '<input size="32" type="text" name="PAYBOX_IBS_RANG" value="'.$conf->global->PAYBOX_IBS_RANG.'">';
174 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 99 ('.$langs->trans("Test").')</span>';
175 print '</td></tr>';
176 
177 
178 print '<tr class="oddeven"><td>';
179 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_IDENTIFIANT").'</span></td><td>';
180 print '<input size="32" type="text" name="PAYBOX_PBX_IDENTIFIANT" value="'.$conf->global->PAYBOX_PBX_IDENTIFIANT.'">';
181 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 2 ('.$langs->trans("Test").')</span>';
182 print '</td></tr>';
183 
184 print '<tr class="oddeven"><td>';
185 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_HMAC_KEY").'</span></td><td>';
186 print '<input size="100" type="text" name="PAYBOX_HMAC_KEY" value="'.dol_decode($conf->global->PAYBOX_HMAC_KEY).'">';
187 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 1A2B3C4D5E6F</span>';
188 print '</td></tr>';
189 
190 print '<tr class="liste_titre">';
191 print '<td>'.$langs->trans("UsageParameter").'</td>';
192 print '<td>'.$langs->trans("Value").'</td>';
193 print "</tr>\n";
194 
195 /*
196 
197 print '<tr class="oddeven"><td>';
198 print $langs->trans("PAYBOX_IBS_DEVISE").'</td><td>';
199 print '<input size="32" type="text" name="PAYBOX_IBS_DEVISE" value="'.$conf->global->PAYBOX_IBS_DEVISE.'">';
200 print '<br>'.$langs->trans("Example").': 978 (EUR)';
201 print '</td></tr>';
202 */
203 
204 /*
205 
206 print '<tr class="oddeven"><td>';
207 print $langs->trans("PAYBOX_CGI_URL_V1").'</td><td>';
208 print '<input size="64" type="text" name="PAYBOX_CGI_URL_V1" value="'.$conf->global->PAYBOX_CGI_URL_V1.'">';
209 print '<br>'.$langs->trans("Example").': http://mysite/cgi-bin/module_linux.cgi';
210 print '</td></tr>';
211 */
212 
213 
214 print '<tr class="oddeven"><td>';
215 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_CGI_URL_V2").'</span></td><td>';
216 print '<input size="64" type="text" name="PAYBOX_CGI_URL_V2" value="'.$conf->global->PAYBOX_CGI_URL_V2.'">';
217 print '<span class="opacitymedium"><br>'.$langs->trans("Example").' (preprod): https://preprod-tpeweb.paybox.com/php/';
218 print '<br>'.$langs->trans("Example").' (prod): https://tpeweb.paybox.com/php/</span>';
219 print '</td></tr>';
220 
221 
222 print '<tr class="oddeven"><td>';
223 print $langs->trans("PublicVendorName").'</td><td>';
224 print '<input type="text" class="minwidth300" name="ONLINE_PAYMENT_CREDITOR" value="'.$conf->global->ONLINE_PAYMENT_CREDITOR.'">';
225 print '<br><span class="opacitymedium">'.$langs->trans("Example").': '.$mysoc->name.'</span>';
226 print '</td></tr>';
227 
228 
229 if (!empty($conf->banque->enabled)) {
230  print '<tr class="oddeven"><td>';
231  print $langs->trans("BankAccount").'</td><td>';
232  $form->select_comptes($conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1);
233  print '</td></tr>';
234 }
235 
236 
237 print '<tr class="oddeven"><td>';
238 print $langs->trans("CSSUrlForPaymentForm").'</td><td>';
239 print '<input size="64" type="text" name="ONLINE_PAYMENT_CSS_URL" value="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'">';
240 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': http://mysite/mycss.css</span>';
241 print '</td></tr>';
242 
243 
244 print '<tr class="oddeven"><td>';
245 print $langs->trans("MessageForm").'</td><td>';
246 $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_FORM', $conf->global->ONLINE_PAYMENT_MESSAGE_FORM, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
247 $doleditor->Create();
248 print '</td></tr>';
249 
250 print '<tr class="oddeven"><td>';
251 print $langs->trans("MessageOK").'</td><td>';
252 $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_OK', $conf->global->ONLINE_PAYMENT_MESSAGE_OK, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
253 $doleditor->Create();
254 print '</td></tr>';
255 
256 
257 print '<tr class="oddeven"><td>';
258 print $langs->trans("MessageKO").'</td><td>';
259 $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_KO', $conf->global->ONLINE_PAYMENT_MESSAGE_KO, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
260 $doleditor->Create();
261 print '</td></tr>';
262 
263 
264 print '<tr class="oddeven"><td class="fieldrequired">';
265 print $langs->trans("ONLINE_PAYMENT_SENDEMAIL").'</td><td>';
266 print '<input size="32" type="text" name="ONLINE_PAYMENT_SENDEMAIL" value="'.$conf->global->ONLINE_PAYMENT_SENDEMAIL.'">';
267 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': myemail@myserver.com, Payment service &lt;myemail2@myserver2.com&gt;</span>';
268 print '</td></tr>';
269 
270 // Payment token for URL
271 print '<tr class="oddeven"><td>';
272 print $langs->trans("SecurityToken").'</td><td>';
273 print '<input size="48" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.'">';
274 if (!empty($conf->use_javascript_ajax)) {
275  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
276 }
277 print '</td></tr>';
278 
279 print '<tr class="oddeven"><td>';
280 print $langs->trans("SecurityTokenIsUnique").'</td><td>';
281 print $form->selectyesno("PAYMENT_SECURITY_TOKEN_UNIQUE", (empty($conf->global->PAYMENT_SECURITY_TOKEN) ? 0 : $conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE), 1);
282 print '</td></tr>';
283 
284 print '</table>';
285 
286 print dol_get_fiche_end();
287 
288 print $form->buttonsSaveCancel("Modify", '');
289 
290 print '</form>';
291 
292 print '<br><br>';
293 
294 include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php';
295 
296 // End of page
297 llxFooter();
298 $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
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
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
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
dol_encode
dol_encode($chain, $key='1')
Encode a string with base 64 algorithm + specific delta change.
Definition: security.lib.php:38
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
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
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