Update core/mpesapay_setup.php
Signed-off-by: kevinowino869 <kevinowino869@www.codelab.nestict.africa>
This commit is contained in:
parent
3a06133a8c
commit
325d011128
@ -1,47 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* M-Pesa Payment Module - Setup Page
|
||||
* Dolipesa - M-Pesa Payment Module Setup Page
|
||||
* Author: NESTICT INFOTECH
|
||||
* Version: 1.0.0
|
||||
* Version: 1.0.1
|
||||
* License: GNU General Public License v3.0
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
|
||||
|
||||
$langs->load("admin");
|
||||
$langs->load("mpesapay");
|
||||
$langs->load('adminross('admin');
|
||||
$langs->load('dolipesa@dolipesa');
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
if ($action == 'save') {
|
||||
$paybill = GETPOST('MPESAPAY_PAYBILL', 'alpha');
|
||||
// Save settings
|
||||
if ($action === 'save') {
|
||||
$consumer_key = GETPOST('MPESAPAY_CONSUMER_KEY', 'alpha');
|
||||
$consumer_secret = GETPOST('MPESAPAY_CONSUMER_SECRET', 'alpha');
|
||||
$shortcode = GETPOST('MPESAPAY_SHORTCODE', 'alpha');
|
||||
$passkey = GETPOST('MPESAPAY_PASSKEY', 'alpha');
|
||||
$callback_url = GETPOST('MPESAPAY_CALLBACK_URL', 'alpha');
|
||||
|
||||
dolibarr_set_const($db, "MPESAPAY_PAYBILL", $paybill, 'chaine', 0, '', 1);
|
||||
dolibarr_set_const($db, "MPESAPAY_PASSKEY", $passkey, 'chaine', 0, '', 1);
|
||||
// Validate required fields
|
||||
if (empty($shortcode) || empty($passkey) || empty($consumer_key) || empty($consumer_secret)) {
|
||||
setEventMessages($langs->trans('ErrorFieldRequired'), null, 'errors');
|
||||
} else {
|
||||
// Store settings in Dolibarr configuration (encrypted for sensitive data)
|
||||
dolibarr_set_const($db, 'MPESAPAY_CONSUMER_KEY', $consumer_key, 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, 'MPESAPAY_CONSUMER_SECRET', dol_encrypt($consumer_secret), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, 'MPESAPAY_SHORTCODE', $shortcode, 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, 'MPESAPAY_PASSKEY', dol_encrypt($passkey), 'chaine', 0, '', $conf->entity);
|
||||
dolibarr_set_const($db, 'MPESAPAY_CALLBACK_URL', $callback_url, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
setEventMessages("Settings saved", null, 'mesgs');
|
||||
setEventMessages($langs->trans('SettingsSaved'), null, 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
print load_fiche_titre("M-Pesa Payment Module Configuration");
|
||||
print '<form method="POST">';
|
||||
// Page title
|
||||
print load_fiche_titre($langs->trans('MpesaPaymentModuleConfig'));
|
||||
|
||||
// Configuration form
|
||||
print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
|
||||
print '<input type="hidden" name="action" value="save">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><th>Setting</th><th>Value</th></tr>';
|
||||
print '<tr><td>M-Pesa Paybill Number</td>';
|
||||
print '<td><input type="text" name="MPESAPAY_PAYBILL" value="' . dolibarr_get_const($db, "MPESAPAY_PAYBILL") . '"></td></tr>';
|
||||
print '<tr><td>M-Pesa Passkey</td>';
|
||||
print '<td><input type="text" name="MPESAPAY_PASSKEY" value="' . dolibarr_get_const($db, "MPESAPAY_PASSKEY") . '"></td></tr>';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th>' . $langs->trans('Parameter') . '</th>';
|
||||
print '<th>' . $langs->trans('Value') . '</th>';
|
||||
print '</tr>';
|
||||
|
||||
// Consumer Key
|
||||
print '<tr class="oddeven">';
|
||||
print '<td><label for="consumer_key">' . $langs->trans('MpesaConsumerKey') . '</label></td>';
|
||||
print '<td><input type="text" name="MPESAPAY_CONSUMER_KEY" id="consumer_key" value="' . dolibarr_get_const($db, 'MPESAPAY_CONSUMER_KEY') . '" size="40"></td>';
|
||||
print '</tr>';
|
||||
|
||||
// Consumer Secret (decrypted for display)
|
||||
print '<tr class="oddeven">';
|
||||
print '<td><label for="consumer_secret">' . $langs->trans('MpesaConsumerSecret') . '</label></td>';
|
||||
print '<td><input type="text" name="MPESAPAY_CONSUMER_SECRET" id="consumer_secret" value="' . dol_decrypt(dolibarr_get_const($db, 'MPESAPAY_CONSUMER_SECRET')) . '" size="40"></td>';
|
||||
print '</tr>';
|
||||
|
||||
// Shortcode (Business Till/Paybill Number)
|
||||
print '<tr class="oddeven">';
|
||||
print '<td><label for="shortcode">' . $langs->trans('MpesaShortcode') . '</label></td>';
|
||||
print '<td><input type="text" name="MPESAPAY_SHORTCODE" id="shortcode" value="' . dolibarr_get_const($db, 'MPESAPAY_SHORTCODE') . '" size="20"></td>';
|
||||
print '</tr>';
|
||||
|
||||
// Passkey (decrypted for display)
|
||||
print '<tr class="oddeven">';
|
||||
print '<td><label for="passkey">' . $langs->trans('MpesaPasskey') . '</label></td>';
|
||||
print '<td><input type="text" name="MPESAPAY_PASSKEY" id="passkey" value="' . dol_decrypt(dolibarr_get_const($db, 'MPESAPAY_PASSKEY')) . '" size="40"></td>';
|
||||
print '</tr>';
|
||||
|
||||
// Callback URL
|
||||
print '<tr class="oddeven">';
|
||||
print '<td><label for="callback_url">' . $langs->trans('MpesaCallbackURL') . '</label></td>';
|
||||
print '<td><input type="text" name="MPESAPAY_CALLBACK_URL" id="callback_url" value="' . dolibarr_get_const($db, 'MPESAPAY_CALLBACK_URL') . '" size="60"></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<div class="center">';
|
||||
print '<button type="submit" class="button">Save</button>';
|
||||
print '<div class="center" style="margin-top: 20px;">';
|
||||
print '<input type="submit" class="button" value="' . $langs->trans('Save') . '">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
// Footer
|
||||
llxFooter();
|
||||
$db->close();
|
||||
?>
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user