dolibarr  17.0.4
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
27 require '../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 require_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 
36 if (!$user->admin) {
38 }
39 
40 $action = GETPOST('action', 'aZ09');
41 
42 
43 if ($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
124 if (empty($conf->global->PAYBOX_IBS_SITE)) {
125  $conf->global->PAYBOX_IBS_SITE = $IBS_SITE;
126 }
127 $IBS_RANG = "99"; // Rang test
128 if (empty($conf->global->PAYBOX_IBS_RANG)) {
129  $conf->global->PAYBOX_IBS_RANG = $IBS_RANG;
130 }
131 $IBS_DEVISE = "978"; // Euro
132 if (empty($conf->global->PAYBOX_IBS_DEVISE)) {
133  $conf->global->PAYBOX_IBS_DEVISE = $IBS_DEVISE;
134 }
135 
136 llxHeader();
137 
138 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
139 print 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 
149 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
150 print '<input type="hidden" name="token" value="'.newToken().'">';
151 print '<input type="hidden" name="action" value="setvalue">';
152 
153 print dol_get_fiche_head($head, 'payboxaccount', '', -1);
154 
155 print $langs->trans("PayBoxDesc")."<br>\n";
156 print '<br>';
157 
158 print '<table class="noborder centpercent">';
159 print '<tr class="liste_titre">';
160 print '<td>'.$langs->trans("AccountParameter").'</td>';
161 print '<td>'.$langs->trans("Value").'</td>';
162 print "</tr>\n";
163 
164 
165 print '<tr class="oddeven"><td>';
166 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_SITE").'</span></td><td>';
167 print '<input size="32" type="text" name="PAYBOX_IBS_SITE" value="'.$conf->global->PAYBOX_IBS_SITE.'">';
168 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 1999888 ('.$langs->trans("Test").')</span>';
169 print '</td></tr>';
170 
171 
172 print '<tr class="oddeven"><td>';
173 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_RANG").'</span></td><td>';
174 print '<input size="32" type="text" name="PAYBOX_IBS_RANG" value="'.$conf->global->PAYBOX_IBS_RANG.'">';
175 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 99 ('.$langs->trans("Test").')</span>';
176 print '</td></tr>';
177 
178 
179 print '<tr class="oddeven"><td>';
180 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_IDENTIFIANT").'</span></td><td>';
181 print '<input size="32" type="text" name="PAYBOX_PBX_IDENTIFIANT" value="'.$conf->global->PAYBOX_PBX_IDENTIFIANT.'">';
182 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 2 ('.$langs->trans("Test").')</span>';
183 print '</td></tr>';
184 
185 print '<tr class="oddeven"><td>';
186 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_HMAC_KEY").'</span></td><td>';
187 print '<input size="100" type="text" name="PAYBOX_HMAC_KEY" value="'.dol_decode($conf->global->PAYBOX_HMAC_KEY).'">';
188 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 1A2B3C4D5E6F</span>';
189 print '</td></tr>';
190 
191 print '<tr class="liste_titre">';
192 print '<td>'.$langs->trans("UsageParameter").'</td>';
193 print '<td>'.$langs->trans("Value").'</td>';
194 print "</tr>\n";
195 
196 /*
197 
198 print '<tr class="oddeven"><td>';
199 print $langs->trans("PAYBOX_IBS_DEVISE").'</td><td>';
200 print '<input size="32" type="text" name="PAYBOX_IBS_DEVISE" value="'.$conf->global->PAYBOX_IBS_DEVISE.'">';
201 print '<br>'.$langs->trans("Example").': 978 (EUR)';
202 print '</td></tr>';
203 */
204 
205 /*
206 
207 print '<tr class="oddeven"><td>';
208 print $langs->trans("PAYBOX_CGI_URL_V1").'</td><td>';
209 print '<input size="64" type="text" name="PAYBOX_CGI_URL_V1" value="'.$conf->global->PAYBOX_CGI_URL_V1.'">';
210 print '<br>'.$langs->trans("Example").': http://mysite/cgi-bin/module_linux.cgi';
211 print '</td></tr>';
212 */
213 
214 
215 print '<tr class="oddeven"><td>';
216 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_CGI_URL_V2").'</span></td><td>';
217 print '<input size="64" type="text" name="PAYBOX_CGI_URL_V2" value="'.$conf->global->PAYBOX_CGI_URL_V2.'">';
218 print '<span class="opacitymedium"><br>'.$langs->trans("Example").' (preprod): https://preprod-tpeweb.paybox.com/php/';
219 print '<br>'.$langs->trans("Example").' (prod): https://tpeweb.paybox.com/php/</span>';
220 print '</td></tr>';
221 
222 
223 print '<tr class="oddeven"><td>';
224 print $langs->trans("PublicVendorName").'</td><td>';
225 print '<input type="text" class="minwidth300" name="ONLINE_PAYMENT_CREDITOR" value="'.$conf->global->ONLINE_PAYMENT_CREDITOR.'">';
226 print '<br><span class="opacitymedium">'.$langs->trans("Example").': '.$mysoc->name.'</span>';
227 print '</td></tr>';
228 
229 
230 if (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 
238 print '<tr class="oddeven"><td>';
239 print $langs->trans("CSSUrlForPaymentForm").'</td><td>';
240 print '<input size="64" type="text" name="ONLINE_PAYMENT_CSS_URL" value="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'">';
241 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': http://mysite/mycss.css</span>';
242 print '</td></tr>';
243 
244 
245 print '<tr class="oddeven"><td>';
246 print $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();
249 print '</td></tr>';
250 
251 print '<tr class="oddeven"><td>';
252 print $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();
255 print '</td></tr>';
256 
257 
258 print '<tr class="oddeven"><td>';
259 print $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();
262 print '</td></tr>';
263 
264 
265 print '<tr class="oddeven"><td class="fieldrequired">';
266 print $langs->trans("ONLINE_PAYMENT_SENDEMAIL").'</td><td>';
267 print '<input size="32" type="text" name="ONLINE_PAYMENT_SENDEMAIL" value="'.$conf->global->ONLINE_PAYMENT_SENDEMAIL.'">';
268 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': myemail@myserver.com, Payment service &lt;myemail2@myserver2.com&gt;</span>';
269 print '</td></tr>';
270 
271 // Payment token for URL
272 print '<tr class="oddeven"><td>';
273 print $langs->trans("SecurityToken").'</td><td>';
274 print '<input size="48" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.'">';
275 if (!empty($conf->use_javascript_ajax)) {
276  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
277 }
278 print '</td></tr>';
279 
280 print '<tr class="oddeven"><td>';
281 print $langs->trans("SecurityTokenIsUnique").'</td><td>';
282 print $form->selectyesno("PAYMENT_SECURITY_TOKEN_UNIQUE", (empty($conf->global->PAYMENT_SECURITY_TOKEN) ? 0 : $conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE), 1);
283 print '</td></tr>';
284 
285 print '</table>';
286 
287 print dol_get_fiche_end();
288 
289 print $form->buttonsSaveCancel("Modify", '');
290 
291 print '</form>';
292 
293 print '<br><br>';
294 
295 include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php';
296 
297 // End of page
298 llxFooter();
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).
Definition: admin.lib.php:632
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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='')
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
isModEnabled($module)
Is Dolibarr module enabled.
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.