2025-03-30 13:02:22 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2025-03-30 13:06:09 +02:00
|
|
|
* Dolibarr Module Descriptor for M-Pesa Payment
|
2025-03-30 13:02:22 +02:00
|
|
|
* Author: NESTICT INFOTECH
|
|
|
|
* Version: 1.0.0
|
|
|
|
*/
|
2025-03-30 13:06:09 +02:00
|
|
|
|
2025-03-30 13:02:22 +02:00
|
|
|
include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php";
|
|
|
|
|
|
|
|
class modMpesapay extends DolibarrModules
|
|
|
|
{
|
|
|
|
function __construct($db)
|
|
|
|
{
|
2025-03-30 13:06:09 +02:00
|
|
|
global $langs, $conf;
|
2025-03-30 13:02:22 +02:00
|
|
|
$this->db = $db;
|
2025-03-30 13:06:09 +02:00
|
|
|
|
2025-03-30 13:02:22 +02:00
|
|
|
$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';
|
2025-03-30 13:06:09 +02:00
|
|
|
|
|
|
|
$this->const = array(
|
|
|
|
array('MPESAPAY_PAYBILL', 'chaine', '', 'M-Pesa Paybill Number', 0, 'current', 1),
|
|
|
|
array('MPESAPAY_PASSKEY', 'chaine', '', 'M-Pesa Passkey', 0, 'current', 1)
|
|
|
|
);
|
|
|
|
|
2025-03-30 13:02:22 +02:00
|
|
|
$this->module_parts = array('hooks' => array('invoicecard', 'payment'));
|
2025-03-30 13:06:09 +02:00
|
|
|
|
|
|
|
$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}";
|
2025-03-30 13:02:22 +02:00
|
|
|
}
|
|
|
|
}
|
2025-03-30 13:06:09 +02:00
|
|
|
?>
|