paybox.php 11 KB

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