Update modMpesapay.class.php

Signed-off-by: kevinowino869 <kevinowino869@www.codelab.nestict.africa>
This commit is contained in:
kevinowino869 2025-03-30 13:06:09 +02:00
parent 0b2f411c8b
commit 99d93bf68a

View File

@ -1,23 +1,43 @@
<?php
/**
* Dolibarr M-Pesa Payment Module
* Dolibarr Module Descriptor for M-Pesa Payment
* Author: NESTICT INFOTECH
* Version: 1.0.0
*/
include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php";
class modMpesapay extends DolibarrModules
{
function __construct($db)
{
global $langs, $conf;
$this->db = $db;
$this->numero = 104900;
$this->rights_class = 'mpesapay';
$this->family = 'payment';
$this->name = "M-Pesa Payment Module";
$this->description = "Accept M-Pesa payments in Dolibarr.";
$this->version = '1.0.0';
$this->const = array(
array('MPESAPAY_PAYBILL', 'chaine', '', 'M-Pesa Paybill Number', 0, 'current', 1),
array('MPESAPAY_PASSKEY', 'chaine', '', 'M-Pesa Passkey', 0, 'current', 1)
);
$this->module_parts = array('hooks' => array('invoicecard', 'payment'));
$this->config_page_url = "mpesapay_setup.php";
$this->dirs = array('/mpesapay');
$this->picto = 'payment';
}
// Generate Payment URL
function generatePaymentUrl($invoiceId)
{
$token = base64_encode(hash('sha256', $invoiceId . time()));
return DOL_URL_ROOT . "/custom/mpesapay/payment.php?invoice_id={$invoiceId}&token={$token}";
}
}
?>
?>