dolibarr  13.0.2
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'));
34 
35 if (!$user->admin)
37 
38 $action = GETPOST('action', 'aZ09');
39 
40 
41 if ($action == 'setvalue' && $user->admin)
42 {
43  $db->begin();
44  //$result=dolibarr_set_const($db, "PAYBOX_IBS_DEVISE",$_POST["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) $error++;
47  $result = dolibarr_set_const($db, "PAYBOX_CGI_URL_V2", GETPOST('PAYBOX_CGI_URL_V2', 'alpha'), 'chaine', 0, '', $conf->entity);
48  if (!$result > 0) $error++;
49  $result = dolibarr_set_const($db, "PAYBOX_IBS_SITE", GETPOST('PAYBOX_IBS_SITE', 'alpha'), 'chaine', 0, '', $conf->entity);
50  if (!$result > 0) $error++;
51  $result = dolibarr_set_const($db, "PAYBOX_IBS_RANG", GETPOST('PAYBOX_IBS_RANG', 'alpha'), 'chaine', 0, '', $conf->entity);
52  if (!$result > 0) $error++;
53  $result = dolibarr_set_const($db, "PAYBOX_PBX_IDENTIFIANT", GETPOST('PAYBOX_PBX_IDENTIFIANT', 'alpha'), 'chaine', 0, '', $conf->entity);
54  if (!$result > 0) $error++;
55  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR", GETPOST('ONLINE_PAYMENT_CREDITOR', 'alpha'), 'chaine', 0, '', $conf->entity);
56  if (!$result > 0) $error++;
57  $result = dolibarr_set_const($db, "PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS", GETPOST('PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 'int'), 'chaine', 0, '', $conf->entity);
58  if (!$result > 0) $error++;
59  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity);
60  if (!$result > 0) $error++;
61  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM", GETPOST('ONLINE_PAYMENT_MESSAGE_FORM', 'alpha'), 'chaine', 0, '', $conf->entity);
62  if (!$result > 0) $error++;
63  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_OK", GETPOST('ONLINE_PAYMENT_MESSAGE_OK', 'alpha'), 'chaine', 0, '', $conf->entity);
64  if (!$result > 0) $error++;
65  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_KO", GETPOST('ONLINE_PAYMENT_MESSAGE_KO', 'alpha'), 'chaine', 0, '', $conf->entity);
66  if (!$result > 0) $error++;
67  $result = dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL", GETPOST('ONLINE_PAYMENT_SENDEMAIL'), 'chaine', 0, '', $conf->entity);
68  if (!$result > 0) $error++;
69  // Payment token for URL
70  $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN", GETPOST('PAYMENT_SECURITY_TOKEN', 'alpha'), 'chaine', 0, '', $conf->entity);
71  if (!$result > 0) $error++;
72  $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE", GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE', 'alpha'), 'chaine', 0, '', $conf->entity);
73  if (!$result > 0) $error++;
74  $result = dolibarr_set_const($db, "PAYBOX_HMAC_KEY", dol_encode(GETPOST('PAYBOX_HMAC_KEY', 'alpha')), 'chaine', 0, '', $conf->entity);
75  if (!$result > 0) $error++;
76 
77 
78  if (!$error)
79  {
80  $db->commit();
81  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
82  } else {
83  $db->rollback();
84  dol_print_error($db);
85  }
86 }
87 
88 
89 /*
90  * View
91  */
92 
93 $IBS_SITE = "1999888"; // Site test
94 if (empty($conf->global->PAYBOX_IBS_SITE)) $conf->global->PAYBOX_IBS_SITE = $IBS_SITE;
95 $IBS_RANG = "99"; // Rang test
96 if (empty($conf->global->PAYBOX_IBS_RANG)) $conf->global->PAYBOX_IBS_RANG = $IBS_RANG;
97 $IBS_DEVISE = "978"; // Euro
98 if (empty($conf->global->PAYBOX_IBS_DEVISE)) $conf->global->PAYBOX_IBS_DEVISE = $IBS_DEVISE;
99 
100 llxHeader();
101 
102 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
103 print load_fiche_titre($langs->trans("PayBoxSetup"), $linkback, 'title_setup');
104 
105 $h = 0;
106 $head = array();
107 
108 $head[$h][0] = DOL_URL_ROOT."/paybox/admin/paybox.php";
109 $head[$h][1] = $langs->trans("PayBox");
110 $head[$h][2] = 'payboxaccount';
111 $h++;
112 
113 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
114 print '<input type="hidden" name="token" value="'.newToken().'">';
115 print '<input type="hidden" name="action" value="setvalue">';
116 
117 print dol_get_fiche_head($head, 'payboxaccount', '', -1);
118 
119 print $langs->trans("PayBoxDesc")."<br>\n";
120 print '<br>';
121 
122 print '<table class="noborder centpercent">';
123 print '<tr class="liste_titre">';
124 print '<td>'.$langs->trans("AccountParameter").'</td>';
125 print '<td>'.$langs->trans("Value").'</td>';
126 print "</tr>\n";
127 
128 
129 print '<tr class="oddeven"><td>';
130 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_SITE").'</span></td><td>';
131 print '<input size="32" type="text" name="PAYBOX_IBS_SITE" value="'.$conf->global->PAYBOX_IBS_SITE.'">';
132 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 1999888 ('.$langs->trans("Test").')</span>';
133 print '</td></tr>';
134 
135 
136 print '<tr class="oddeven"><td>';
137 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_RANG").'</span></td><td>';
138 print '<input size="32" type="text" name="PAYBOX_IBS_RANG" value="'.$conf->global->PAYBOX_IBS_RANG.'">';
139 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 99 ('.$langs->trans("Test").')</span>';
140 print '</td></tr>';
141 
142 
143 print '<tr class="oddeven"><td>';
144 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_IDENTIFIANT").'</span></td><td>';
145 print '<input size="32" type="text" name="PAYBOX_PBX_IDENTIFIANT" value="'.$conf->global->PAYBOX_PBX_IDENTIFIANT.'">';
146 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 2 ('.$langs->trans("Test").')</span>';
147 print '</td></tr>';
148 
149 print '<tr class="oddeven"><td>';
150 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_HMAC_KEY").'</span></td><td>';
151 print '<input size="100" type="text" name="PAYBOX_HMAC_KEY" value="'.dol_decode($conf->global->PAYBOX_HMAC_KEY).'">';
152 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 1A2B3C4D5E6F</span>';
153 print '</td></tr>';
154 
155 print '<tr class="liste_titre">';
156 print '<td>'.$langs->trans("UsageParameter").'</td>';
157 print '<td>'.$langs->trans("Value").'</td>';
158 print "</tr>\n";
159 
160 /*
161 
162 print '<tr class="oddeven"><td>';
163 print $langs->trans("PAYBOX_IBS_DEVISE").'</td><td>';
164 print '<input size="32" type="text" name="PAYBOX_IBS_DEVISE" value="'.$conf->global->PAYBOX_IBS_DEVISE.'">';
165 print '<br>'.$langs->trans("Example").': 978 (EUR)';
166 print '</td></tr>';
167 */
168 
169 /*
170 
171 print '<tr class="oddeven"><td>';
172 print $langs->trans("PAYBOX_CGI_URL_V1").'</td><td>';
173 print '<input size="64" type="text" name="PAYBOX_CGI_URL_V1" value="'.$conf->global->PAYBOX_CGI_URL_V1.'">';
174 print '<br>'.$langs->trans("Example").': http://mysite/cgi-bin/module_linux.cgi';
175 print '</td></tr>';
176 */
177 
178 
179 print '<tr class="oddeven"><td>';
180 print '<span class="fieldrequired">'.$langs->trans("PAYBOX_CGI_URL_V2").'</span></td><td>';
181 print '<input size="64" type="text" name="PAYBOX_CGI_URL_V2" value="'.$conf->global->PAYBOX_CGI_URL_V2.'">';
182 print '<span class="opacitymedium"><br>'.$langs->trans("Example").' (preprod): https://preprod-tpeweb.paybox.com/php/';
183 print '<br>'.$langs->trans("Example").' (prod): https://tpeweb.paybox.com/php/</span>';
184 print '</td></tr>';
185 
186 
187 print '<tr class="oddeven"><td>';
188 print $langs->trans("PublicVendorName").'</td><td>';
189 print '<input type="text" class="minwidth300" name="ONLINE_PAYMENT_CREDITOR" value="'.$conf->global->ONLINE_PAYMENT_CREDITOR.'">';
190 print '<br><span class="opacitymedium">'.$langs->trans("Example").': '.$mysoc->name.'</span>';
191 print '</td></tr>';
192 
193 
194 if (!empty($conf->banque->enabled))
195 {
196  print '<tr class="oddeven"><td>';
197  print $langs->trans("BankAccount").'</td><td>';
198  $form->select_comptes($conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1);
199  print '</td></tr>';
200 }
201 
202 
203 print '<tr class="oddeven"><td>';
204 print $langs->trans("CSSUrlForPaymentForm").'</td><td>';
205 print '<input size="64" type="text" name="ONLINE_PAYMENT_CSS_URL" value="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'">';
206 print '<span class="opacitymedium"><br>'.$langs->trans("Example").': http://mysite/mycss.css</span>';
207 print '</td></tr>';
208 
209 
210 print '<tr class="oddeven"><td>';
211 print $langs->trans("MessageForm").'</td><td>';
212 $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_FORM', $conf->global->ONLINE_PAYMENT_MESSAGE_FORM, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
213 $doleditor->Create();
214 print '</td></tr>';
215 
216 print '<tr class="oddeven"><td>';
217 print $langs->trans("MessageOK").'</td><td>';
218 $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_OK', $conf->global->ONLINE_PAYMENT_MESSAGE_OK, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
219 $doleditor->Create();
220 print '</td></tr>';
221 
222 
223 print '<tr class="oddeven"><td>';
224 print $langs->trans("MessageKO").'</td><td>';
225 $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_KO', $conf->global->ONLINE_PAYMENT_MESSAGE_KO, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
226 $doleditor->Create();
227 print '</td></tr>';
228 
229 
230 print '<tr class="oddeven"><td>';
231 print $langs->trans("ONLINE_PAYMENT_SENDEMAIL").'</td><td>';
232 print '<input size="32" type="text" name="ONLINE_PAYMENT_SENDEMAIL" value="'.$conf->global->ONLINE_PAYMENT_SENDEMAIL.'">';
233 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': myemail@myserver.com, Payment service &lt;myemail2@myserver2.com&gt;</span>';
234 print '</td></tr>';
235 
236 // Payment token for URL
237 print '<tr class="oddeven"><td>';
238 print $langs->trans("SecurityToken").'</td><td>';
239 print '<input size="48" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.'">';
240 if (!empty($conf->use_javascript_ajax))
241  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
242 print '</td></tr>';
243 
244 print '<tr class="oddeven"><td>';
245 print $langs->trans("SecurityTokenIsUnique").'</td><td>';
246 print $form->selectyesno("PAYMENT_SECURITY_TOKEN_UNIQUE", (empty($conf->global->PAYMENT_SECURITY_TOKEN) ? 0 : $conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE), 1);
247 print '</td></tr>';
248 
249 print '</table>';
250 
252 
253 print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
254 
255 print '</form>';
256 
257 print '<br><br>';
258 
259 include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php';
260 
261 // End of page
262 llxFooter();
263 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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:575
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
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 Calling this function terminate execution ...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
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.
Class to manage a WYSIWYG editor.
llxFooter()
Empty footer.
Definition: wrapper.php:59