paybox.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. /**
  20. * \file htdocs/paybox/admin/paybox.php
  21. * \ingroup paybox
  22. * \brief Page to setup paybox module
  23. */
  24. require '../../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  27. $servicename = 'PayBox';
  28. // Load translation files required by the page
  29. $langs->loadLangs(array('admin', 'other', 'paybox', 'paypal', 'stripe'));
  30. if (!$user->admin) {
  31. accessforbidden();
  32. }
  33. $action = GETPOST('action', 'aZ09');
  34. if ($action == 'setvalue' && $user->admin) {
  35. $db->begin();
  36. //$result=dolibarr_set_const($db, "PAYBOX_IBS_DEVISE", GETPOST("PAYBOX_IBS_DEVISE"),'chaine',0,'',$conf->entity);
  37. $result = dolibarr_set_const($db, "PAYBOX_CGI_URL_V1", GETPOST('PAYBOX_CGI_URL_V1', 'alpha'), 'chaine', 0, '', $conf->entity);
  38. if (!$result > 0) {
  39. $error++;
  40. }
  41. $result = dolibarr_set_const($db, "PAYBOX_CGI_URL_V2", GETPOST('PAYBOX_CGI_URL_V2', 'alpha'), 'chaine', 0, '', $conf->entity);
  42. if (!$result > 0) {
  43. $error++;
  44. }
  45. $result = dolibarr_set_const($db, "PAYBOX_IBS_SITE", GETPOST('PAYBOX_IBS_SITE', 'alpha'), 'chaine', 0, '', $conf->entity);
  46. if (!$result > 0) {
  47. $error++;
  48. }
  49. $result = dolibarr_set_const($db, "PAYBOX_IBS_RANG", GETPOST('PAYBOX_IBS_RANG', 'alpha'), 'chaine', 0, '', $conf->entity);
  50. if (!$result > 0) {
  51. $error++;
  52. }
  53. $result = dolibarr_set_const($db, "PAYBOX_PBX_IDENTIFIANT", GETPOST('PAYBOX_PBX_IDENTIFIANT', 'alpha'), 'chaine', 0, '', $conf->entity);
  54. if (!$result > 0) {
  55. $error++;
  56. }
  57. $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR", GETPOST('ONLINE_PAYMENT_CREDITOR', 'alpha'), 'chaine', 0, '', $conf->entity);
  58. if (!$result > 0) {
  59. $error++;
  60. }
  61. $result = dolibarr_set_const($db, "PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS", GETPOST('PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 'int'), 'chaine', 0, '', $conf->entity);
  62. if (!$result > 0) {
  63. $error++;
  64. }
  65. $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity);
  66. if (!$result > 0) {
  67. $error++;
  68. }
  69. $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM", GETPOST('ONLINE_PAYMENT_MESSAGE_FORM', 'restricthtml'), 'chaine', 0, '', $conf->entity);
  70. if (!$result > 0) {
  71. $error++;
  72. }
  73. $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_OK", GETPOST('ONLINE_PAYMENT_MESSAGE_OK', 'restricthtml'), 'chaine', 0, '', $conf->entity);
  74. if (!$result > 0) {
  75. $error++;
  76. }
  77. $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_KO", GETPOST('ONLINE_PAYMENT_MESSAGE_KO', 'restricthtml'), 'chaine', 0, '', $conf->entity);
  78. if (!$result > 0) {
  79. $error++;
  80. }
  81. $result = dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL", GETPOST('ONLINE_PAYMENT_SENDEMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
  82. if (!$result > 0) {
  83. $error++;
  84. }
  85. // Payment token for URL
  86. $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN", GETPOST('PAYMENT_SECURITY_TOKEN', 'alpha'), 'chaine', 0, '', $conf->entity);
  87. if (!$result > 0) {
  88. $error++;
  89. }
  90. $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE", GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE', 'alpha'), 'chaine', 0, '', $conf->entity);
  91. if (!$result > 0) {
  92. $error++;
  93. }
  94. $result = dolibarr_set_const($db, "PAYBOX_HMAC_KEY", dol_encode(GETPOST('PAYBOX_HMAC_KEY', 'alpha')), 'chaine', 0, '', $conf->entity);
  95. if (!$result > 0) {
  96. $error++;
  97. }
  98. if (!$error) {
  99. $db->commit();
  100. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  101. } else {
  102. $db->rollback();
  103. dol_print_error($db);
  104. }
  105. }
  106. /*
  107. * View
  108. */
  109. $IBS_SITE = "1999888"; // Site test
  110. if (empty($conf->global->PAYBOX_IBS_SITE)) {
  111. $conf->global->PAYBOX_IBS_SITE = $IBS_SITE;
  112. }
  113. $IBS_RANG = "99"; // Rang test
  114. if (empty($conf->global->PAYBOX_IBS_RANG)) {
  115. $conf->global->PAYBOX_IBS_RANG = $IBS_RANG;
  116. }
  117. $IBS_DEVISE = "978"; // Euro
  118. if (empty($conf->global->PAYBOX_IBS_DEVISE)) {
  119. $conf->global->PAYBOX_IBS_DEVISE = $IBS_DEVISE;
  120. }
  121. llxHeader();
  122. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  123. print load_fiche_titre($langs->trans("PayBoxSetup"), $linkback, 'title_setup');
  124. $h = 0;
  125. $head = array();
  126. $head[$h][0] = DOL_URL_ROOT."/paybox/admin/paybox.php";
  127. $head[$h][1] = $langs->trans("PayBox");
  128. $head[$h][2] = 'payboxaccount';
  129. $h++;
  130. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  131. print '<input type="hidden" name="token" value="'.newToken().'">';
  132. print '<input type="hidden" name="action" value="setvalue">';
  133. print dol_get_fiche_head($head, 'payboxaccount', '', -1);
  134. print $langs->trans("PayBoxDesc")."<br>\n";
  135. print '<br>';
  136. print '<table class="noborder centpercent">';
  137. print '<tr class="liste_titre">';
  138. print '<td>'.$langs->trans("AccountParameter").'</td>';
  139. print '<td>'.$langs->trans("Value").'</td>';
  140. print "</tr>\n";
  141. print '<tr class="oddeven"><td>';
  142. print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_SITE").'</span></td><td>';
  143. print '<input size="32" type="text" name="PAYBOX_IBS_SITE" value="'.$conf->global->PAYBOX_IBS_SITE.'">';
  144. print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 1999888 ('.$langs->trans("Test").')</span>';
  145. print '</td></tr>';
  146. print '<tr class="oddeven"><td>';
  147. print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_RANG").'</span></td><td>';
  148. print '<input size="32" type="text" name="PAYBOX_IBS_RANG" value="'.$conf->global->PAYBOX_IBS_RANG.'">';
  149. print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 99 ('.$langs->trans("Test").')</span>';
  150. print '</td></tr>';
  151. print '<tr class="oddeven"><td>';
  152. print '<span class="fieldrequired">'.$langs->trans("PAYBOX_PBX_IDENTIFIANT").'</span></td><td>';
  153. print '<input size="32" type="text" name="PAYBOX_PBX_IDENTIFIANT" value="'.$conf->global->PAYBOX_PBX_IDENTIFIANT.'">';
  154. print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 2 ('.$langs->trans("Test").')</span>';
  155. print '</td></tr>';
  156. print '<tr class="oddeven"><td>';
  157. print '<span class="fieldrequired">'.$langs->trans("PAYBOX_HMAC_KEY").'</span></td><td>';
  158. print '<input size="100" type="text" name="PAYBOX_HMAC_KEY" value="'.dol_decode($conf->global->PAYBOX_HMAC_KEY).'">';
  159. print '<span class="opacitymedium"><br>'.$langs->trans("Example").': 1A2B3C4D5E6F</span>';
  160. print '</td></tr>';
  161. print '<tr class="liste_titre">';
  162. print '<td>'.$langs->trans("UsageParameter").'</td>';
  163. print '<td>'.$langs->trans("Value").'</td>';
  164. print "</tr>\n";
  165. /*
  166. print '<tr class="oddeven"><td>';
  167. print $langs->trans("PAYBOX_IBS_DEVISE").'</td><td>';
  168. print '<input size="32" type="text" name="PAYBOX_IBS_DEVISE" value="'.$conf->global->PAYBOX_IBS_DEVISE.'">';
  169. print '<br>'.$langs->trans("Example").': 978 (EUR)';
  170. print '</td></tr>';
  171. */
  172. /*
  173. print '<tr class="oddeven"><td>';
  174. print $langs->trans("PAYBOX_CGI_URL_V1").'</td><td>';
  175. print '<input size="64" type="text" name="PAYBOX_CGI_URL_V1" value="'.$conf->global->PAYBOX_CGI_URL_V1.'">';
  176. print '<br>'.$langs->trans("Example").': http://mysite/cgi-bin/module_linux.cgi';
  177. print '</td></tr>';
  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. print '<tr class="oddeven"><td>';
  186. print $langs->trans("PublicVendorName").'</td><td>';
  187. print '<input type="text" class="minwidth300" name="ONLINE_PAYMENT_CREDITOR" value="'.$conf->global->ONLINE_PAYMENT_CREDITOR.'">';
  188. print '<br><span class="opacitymedium">'.$langs->trans("Example").': '.$mysoc->name.'</span>';
  189. print '</td></tr>';
  190. if (!empty($conf->banque->enabled)) {
  191. print '<tr class="oddeven"><td>';
  192. print $langs->trans("BankAccount").'</td><td>';
  193. $form->select_comptes($conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1);
  194. print '</td></tr>';
  195. }
  196. print '<tr class="oddeven"><td>';
  197. print $langs->trans("CSSUrlForPaymentForm").'</td><td>';
  198. print '<input size="64" type="text" name="ONLINE_PAYMENT_CSS_URL" value="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'">';
  199. print '<span class="opacitymedium"><br>'.$langs->trans("Example").': http://mysite/mycss.css</span>';
  200. print '</td></tr>';
  201. print '<tr class="oddeven"><td>';
  202. print $langs->trans("MessageForm").'</td><td>';
  203. $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_FORM', $conf->global->ONLINE_PAYMENT_MESSAGE_FORM, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
  204. $doleditor->Create();
  205. print '</td></tr>';
  206. print '<tr class="oddeven"><td>';
  207. print $langs->trans("MessageOK").'</td><td>';
  208. $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_OK', $conf->global->ONLINE_PAYMENT_MESSAGE_OK, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
  209. $doleditor->Create();
  210. print '</td></tr>';
  211. print '<tr class="oddeven"><td>';
  212. print $langs->trans("MessageKO").'</td><td>';
  213. $doleditor = new DolEditor('ONLINE_PAYMENT_MESSAGE_KO', $conf->global->ONLINE_PAYMENT_MESSAGE_KO, '', 100, 'dolibarr_details', 'In', false, true, true, ROWS_2, '90%');
  214. $doleditor->Create();
  215. print '</td></tr>';
  216. print '<tr class="oddeven"><td class="fieldrequired">';
  217. print $langs->trans("ONLINE_PAYMENT_SENDEMAIL").'</td><td>';
  218. print '<input size="32" type="text" name="ONLINE_PAYMENT_SENDEMAIL" value="'.$conf->global->ONLINE_PAYMENT_SENDEMAIL.'">';
  219. print ' &nbsp; <span class="opacitymedium">'.$langs->trans("Example").': myemail@myserver.com, Payment service &lt;myemail2@myserver2.com&gt;</span>';
  220. print '</td></tr>';
  221. // Payment token for URL
  222. print '<tr class="oddeven"><td>';
  223. print $langs->trans("SecurityToken").'</td><td>';
  224. print '<input size="48" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.'">';
  225. if (!empty($conf->use_javascript_ajax)) {
  226. print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
  227. }
  228. print '</td></tr>';
  229. print '<tr class="oddeven"><td>';
  230. print $langs->trans("SecurityTokenIsUnique").'</td><td>';
  231. print $form->selectyesno("PAYMENT_SECURITY_TOKEN_UNIQUE", (empty($conf->global->PAYMENT_SECURITY_TOKEN) ? 0 : $conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE), 1);
  232. print '</td></tr>';
  233. print '</table>';
  234. print dol_get_fiche_end();
  235. print $form->buttonsSaveCancel("Modify", '');
  236. print '</form>';
  237. print '<br><br>';
  238. include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php';
  239. // End of page
  240. llxFooter();
  241. $db->close();