PaymentActivationAuditManager
in package
Probe for "paid but not activated" payments.
The payment callback (PaymentProcessorTrait::runCallbackForTransaction) consumes the right to
run and only then calls the module handler. If the process dies midway or the handler fails, the
payment stays completed in the DB but the paid items are inactive and nobody knows. Recovery stays
manual; this class only makes sure an administrator learns about it.
Missing activation is derived from module data (read-only):
system:cms_system_user_payment_items.active = 0on a payment item,bazaar/comcat/discussion:..._payment_items.active = 0(the handler turns it on withupdateColumns(['active' => true])),eshop: the payment is paired (order_payments) with a non-canceled order still in a payable state (waiting-on-payment / created / approved). Such an order may also be one the hook deliberately did not switch (underpayment, expired reservation); it already got anORDER_PAYMENT_ATTENTIONnotification and this one is a summary.
Only payments older than $minAgeMinutes are searched (a running callback must not be declared
a failure) and younger than $lookbackDays (older data from before the probe would flood the bell).
One notification per payment: the marker is a cms_system_payment_error_logs row with the action
MARKER_ACTION, so no schema change is needed and it is visible in the payment detail.
Table of Contents
Constants
- BATCH_LIMIT : int = 50
- Cap of payments per run (the rest comes in the next one).
- DEFAULT_LOOKBACK_DAYS : int = 14
- DEFAULT_MIN_AGE_MINUTES : int = 15
- MARKER_ACTION : string = 'activationMissingNotified'
- `status_text` of the payment log row meaning "administrator already notified".
- NOTIFICATION_TYPE : string = 'PAYMENT_NOT_ACTIVATED'
- Notification type in the admin bell.
- ESHOP_PAYABLE_KEYS : string = "'WAITING-ON-PAYMENT','CREATED','APPROVED'"
- Order states from which a payment switches the order (mirrors `EshopPaymentHook`).
Properties
- $adminAlertManager : AdminAlertManager
- $connection : Connection
Methods
- __construct() : mixed
- describe() : string
- Builds the notification text: a language-free technical addendum (the bell shows the translated type name and a link to the payment detail).
- findMissing() : array<int, array{paymentId: int, gateId: ?int, gate: string, amount: string, currency: string, module: string, paidAt: string}>
- Returns paid payments with missing activation that were not reported yet.
- notifyMissing() : array{found: int, notified: int}
- Finds paid payments without activation, notifies about them and marks them.
- markNotified() : void
- toInt() : int
Constants
BATCH_LIMIT
Cap of payments per run (the rest comes in the next one).
public
int
BATCH_LIMIT
= 50
DEFAULT_LOOKBACK_DAYS
public
int
DEFAULT_LOOKBACK_DAYS
= 14
DEFAULT_MIN_AGE_MINUTES
public
int
DEFAULT_MIN_AGE_MINUTES
= 15
MARKER_ACTION
`status_text` of the payment log row meaning "administrator already notified".
public
string
MARKER_ACTION
= 'activationMissingNotified'
NOTIFICATION_TYPE
Notification type in the admin bell.
public
string
NOTIFICATION_TYPE
= 'PAYMENT_NOT_ACTIVATED'
ESHOP_PAYABLE_KEYS
Order states from which a payment switches the order (mirrors `EshopPaymentHook`).
private
string
ESHOP_PAYABLE_KEYS
= "'WAITING-ON-PAYMENT','CREATED','APPROVED'"
Properties
$adminAlertManager read-only
private
AdminAlertManager
$adminAlertManager
$connection read-only
private
Connection
$connection
Methods
__construct()
public
__construct(Connection $connection, AdminAlertManager $adminAlertManager) : mixed
Parameters
- $connection : Connection
- $adminAlertManager : AdminAlertManager
describe()
Builds the notification text: a language-free technical addendum (the bell shows the translated type name and a link to the payment detail).
public
static describe(array{paymentId: int, gateId: ?int, gate: string, amount: string, currency: string, module: string, paidAt: string} $row) : string
Parameters
- $row : array{paymentId: int, gateId: ?int, gate: string, amount: string, currency: string, module: string, paidAt: string}
Return values
stringfindMissing()
Returns paid payments with missing activation that were not reported yet.
public
findMissing(DateTimeImmutable $olderThan, DateTimeImmutable $since[, int $limit = self::BATCH_LIMIT ]) : array<int, array{paymentId: int, gateId: ?int, gate: string, amount: string, currency: string, module: string, paidAt: string}>
Parameters
- $olderThan : DateTimeImmutable
- $since : DateTimeImmutable
- $limit : int = self::BATCH_LIMIT
Return values
array<int, array{paymentId: int, gateId: ?int, gate: string, amount: string, currency: string, module: string, paidAt: string}>notifyMissing()
Finds paid payments without activation, notifies about them and marks them.
public
notifyMissing([int $minAgeMinutes = self::DEFAULT_MIN_AGE_MINUTES ][, int $lookbackDays = self::DEFAULT_LOOKBACK_DAYS ][, DateTimeImmutable|null $now = null ]) : array{found: int, notified: int}
Parameters
- $minAgeMinutes : int = self::DEFAULT_MIN_AGE_MINUTES
- $lookbackDays : int = self::DEFAULT_LOOKBACK_DAYS
- $now : DateTimeImmutable|null = null
Return values
array{found: int, notified: int}markNotified()
private
markNotified(array{paymentId: int, gateId: ?int, gate: string, amount: string, currency: string, module: string, paidAt: string} $row) : void
Parameters
- $row : array{paymentId: int, gateId: ?int, gate: string, amount: string, currency: string, module: string, paidAt: string}
toInt()
private
static toInt(mixed $value) : int
Parameters
- $value : mixed