Audit Trail Docs

IpslAudit extends BaseAudit

Ipsl audit trail implementations

Table of Contents

Methods

billReferenceValidationLog()  : void
Log IPSL bill reference validation request
collectionTransactionCreatedLog()  : void
Log IPSL collection transaction created (successful IPN processing)
disbursementAccountValidationLog()  : void
Log IPSL account validation (disbursement / employee bank verification).
disbursementBulkPayoutLog()  : void
Log IPSL disbursement bulk payout completion.
disbursementPayoutLog()  : void
Log IPSL disbursement payout (single send).
disbursementStatusQueryLog()  : void
Log IPSL transaction status query.
ipnProcessingErrorLog()  : void
Log IPSL IPN processing error (runtime exception)
ipnReceivedLog()  : void
Log IPSL IPN (Instant Payment Notification) received
ipnWalletResolutionErrorLog()  : void
Log IPSL IPN processing error (wallet resolution failure)
ipslCreatedLog()  : void
Log Ipsl creation
ipslDeletedLog()  : void
Log Ipsl deletion
ipslUpdatedLog()  : void
Log Ipsl update
addAuditLog()  : void
Log an audit trail entry
getCompanyId()  : int
Extract company ID from various model types.
getUserId()  : int
Get the current authenticated user ID, or fallback to job context user ID.

Methods

billReferenceValidationLog()

Log IPSL bill reference validation request

public static billReferenceValidationLog(string $billRef, float $amount, bool $resolved[, int $companyId = 0 ][, int $userId = 0 ]) : void
Parameters
$billRef : string

Bill reference number

$amount : float

Payment amount

$resolved : bool

Whether the bill reference was resolved successfully

$companyId : int = 0

Company ID (optional, defaults to 0 for system-level)

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

IPSL Bill Reference Validation

audit-module

PAYMENT

audit-action

CREATE

audit-trigger

When IPSL sends a bill reference validation request

collectionTransactionCreatedLog()

Log IPSL collection transaction created (successful IPN processing)

public static collectionTransactionCreatedLog(mixed $mpesaRecord[, int $userId = 0 ]) : void
Parameters
$mpesaRecord : mixed

The created Mpesa record

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

IPSL Collection Transaction Created

audit-module

PAYMENT

audit-action

CREATE

audit-trigger

When a successful IPSL collection transaction is processed and Mpesa record is created

disbursementAccountValidationLog()

Log IPSL account validation (disbursement / employee bank verification).

public static disbursementAccountValidationLog(string $accountNo, string $bankCode, bool $valid[, string $accountName = '' ][, int $companyId = 0 ][, int $userId = 0 ]) : void
Parameters
$accountNo : string

Destination account number

$bankCode : string

Destination bank code

$valid : bool

Whether the account was valid

$accountName : string = ''

Account name returned (if any)

$companyId : int = 0

Optional company ID (0 if unknown)

$userId : int = 0

Optional user ID

Tags
audit-event

IPSL Account Validation

audit-module

PAYMENT

audit-action

CREATE

audit-trigger

When account validation is requested from IPSL

disbursementBulkPayoutLog()

Log IPSL disbursement bulk payout completion.

public static disbursementBulkPayoutLog(int $transactionLogId, int $total, int $successCount, int $failureCount[, int $companyId = 0 ][, int $userId = 0 ]) : void
Parameters
$transactionLogId : int

Transaction log ID for the batch

$total : int

Total items in batch

$successCount : int

Successful count

$failureCount : int

Failure count

$companyId : int = 0

Optional company ID (0 if unknown)

$userId : int = 0

Optional user ID

Tags
audit-event

IPSL Disbursement Bulk Payout

audit-module

PAYMENT

audit-action

UPDATE

audit-trigger

When a bulk disbursement run completes

disbursementPayoutLog()

Log IPSL disbursement payout (single send).

public static disbursementPayoutLog(mixed $mpesa, string $requestId[, bool $success = true ][, int $userId = 0 ]) : void
Parameters
$mpesa : mixed

Mpesa record after send (with status, requestId, transactionId, etc.)

$requestId : string

Request ID used for the payout

$success : bool = true

Whether the API call succeeded

$userId : int = 0

Optional user ID

Tags
audit-event

IPSL Disbursement Payout

audit-module

PAYMENT

audit-action

UPDATE

audit-trigger

When a single disbursement is sent to IPSL and Mpesa record is updated

disbursementStatusQueryLog()

Log IPSL transaction status query.

public static disbursementStatusQueryLog(mixed $mpesa[, bool $success = true ][, string|null $status = null ][, int $userId = 0 ]) : void
Parameters
$mpesa : mixed

Mpesa record (with id, requestId, transactionId)

$success : bool = true

Whether the status query succeeded

$status : string|null = null

Resulting status (if updated)

$userId : int = 0

Optional user ID

Tags
audit-event

IPSL Status Query

audit-module

PAYMENT

audit-action

UPDATE

audit-trigger

When a disbursement transaction status is queried from IPSL

ipnProcessingErrorLog()

Log IPSL IPN processing error (runtime exception)

public static ipnProcessingErrorLog(string $rrn, string $errorMessage[, array<string|int, mixed> $payload = [] ][, string|null $billRef = null ][, int $companyId = 0 ][, int $userId = 0 ]) : void
Parameters
$rrn : string

Request Reference Number

$errorMessage : string

Error message describing the failure

$payload : array<string|int, mixed> = []

IPN payload data

$billRef : string|null = null

Bill reference (if available)

$companyId : int = 0

Company ID (optional, defaults to 0 for system-level)

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

IPSL IPN Processing Error - Runtime Exception

audit-module

PAYMENT

audit-action

CREATE

audit-trigger

When IPSL IPN processing fails due to a runtime exception

ipnReceivedLog()

Log IPSL IPN (Instant Payment Notification) received

public static ipnReceivedLog(array<string|int, mixed> $payload[, int $companyId = 0 ][, int $userId = 0 ]) : void
Parameters
$payload : array<string|int, mixed>

IPN payload data

$companyId : int = 0

Company ID (optional, defaults to 0 for system-level)

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

IPSL IPN Received

audit-module

PAYMENT

audit-action

CREATE

audit-trigger

When IPSL sends an IPN callback

ipnWalletResolutionErrorLog()

Log IPSL IPN processing error (wallet resolution failure)

public static ipnWalletResolutionErrorLog(string $rrn, string $billRef, float $amount, string $errorMessage[, array<string|int, mixed> $payload = [] ][, int $companyId = 0 ][, int $userId = 0 ]) : void
Parameters
$rrn : string

Request Reference Number

$billRef : string

Bill reference that couldn't be resolved

$amount : float

Payment amount

$errorMessage : string

Error message describing the failure

$payload : array<string|int, mixed> = []

IPN payload data

$companyId : int = 0

Company ID (optional, defaults to 0 for system-level)

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

IPSL IPN Processing Error - Wallet Resolution Failed

audit-module

PAYMENT

audit-action

CREATE

audit-trigger

When IPSL IPN processing fails due to wallet resolution failure

ipslCreatedLog()

Log Ipsl creation

public static ipslCreatedLog(mixed $record[, int $userId = 0 ]) : void
Parameters
$record : mixed

The newly created Ipsl record

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

Ipsl Created

audit-module

PAYMENT

audit-action

CREATE

audit-trigger

When a new Ipsl is created in the system

ipslDeletedLog()

Log Ipsl deletion

public static ipslDeletedLog(mixed $record[, int $userId = 0 ]) : void
Parameters
$record : mixed

The Ipsl being deleted

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

Ipsl Deleted

audit-module

PAYMENT

audit-action

DELETE

audit-trigger

When a Ipsl is deleted from the system

ipslUpdatedLog()

Log Ipsl update

public static ipslUpdatedLog(mixed $oldRecord, mixed $newRecord[, int $userId = 0 ]) : void
Parameters
$oldRecord : mixed

The Ipsl data before the update

$newRecord : mixed

The Ipsl data after the update

$userId : int = 0

The ID of the user who performed the action (optional)

Tags
audit-event

Ipsl Updated

audit-module

PAYMENT

audit-action

UPDATE

audit-trigger

When an existing Ipsl is updated in the system

addAuditLog()

Log an audit trail entry

protected static addAuditLog(int|null $companyId, int $userId, string $message, string $module, string $action[, mixed|null $currentRecord = null ][, mixed|null $updatedRecord = null ][, string|null $objectName = null ][, string $queueName = 'audit-trails' ][, bool $afterCommit = false ][, string $type = AuditTypesEnum::COMPANY->value ]) : void
Parameters
$companyId : int|null

Company identifier, null for records that belong to no company (e.g. global payroll elements)

$userId : int

User identifier (default 0 for system actions)

$message : string

Human-readable audit message

$module : string

Module name (PAYROLL, LEAVE, PAYMENTS, etc.) - must be a valid AuditModulesEnum value

$action : string

Action type (CREATE, UPDATE, DELETE, etc.) - must be a valid AuditActionsEnum value

$currentRecord : mixed|null = null

Current data being logged

$updatedRecord : mixed|null = null

The updated data (for updates)

$objectName : string|null = null

Optional name of the object being logged - if not provided, will be inferred from the model

$queueName : string = 'audit-trails'

Optional queue name for async processing. Default 'audit-trails'

$afterCommit : bool = false

Whether to log after DB commit

$type : string = AuditTypesEnum::COMPANY->value
Tags
throws
ValueError

If invalid enum values are provided

getCompanyId()

Extract company ID from various model types.

protected static getCompanyId(mixed $model) : int

This method attempts to determine the company ID from the provided model instance.

It checks for a direct company_id property or navigates through related employee models.

Parameters
$model : mixed

Model instance

Tags
throws
Exception

When company ID cannot be determined

Return values
int —

Company ID

getUserId()

Get the current authenticated user ID, or fallback to job context user ID.

protected static getUserId() : int

This method first checks for an authenticated user via the auth() helper. If no user is authenticated, it looks for a user_id in the job context (for queued jobs).

To add a user ID to the job context, you can use this in your job setup:

 app()->instance('job_context', ['user_id' => $userId]);

If neither is available, it returns 0 to indicate a system action.

Return values
int —

The determined user ID, or 0 if none found


        
On this page

Search results