MembershipExpressServiceProvider
in package
implements
ExpressServiceProviderInterface
Express SMS services of the user account: `<KEYWORD> UCET CLEN <user id>` (membership) and `<KEYWORD> UCET KREDIT <user id>` (credits).
The SMS carries only the phone number, so the object is the user id written in the text; the payment and its item belong to that user (anyone may pay for anyone — like a gift, the text cannot grant anything else). The user must exist, be activated, not banned and neither cancelled nor waiting for the cancellation of the account.
Price list: user tariffs have no quick prices; their price per payment region × gateway ×
currency (cms_system_user_tariff_prices) is the price of the SMS gateway row. The same rule
as everywhere: the number the SMS was sent to must cost exactly that price.
Services follow what the tariff gives, not its id: CLEN offers every tariff with a duration (it extends
member_until), KREDIT every tariff with credits (it adds them). A package tariff (time and credits) is
offered under both words; the number the SMS was sent to (its price) picks the tariff. The callback
SYSTEM_USER_PAYMENT (UserPaymentManager::updateStatusForPayment()) applies both fields of whichever
tariff was paid. A tariff that gives neither is not offered.
Table of Contents
Interfaces
- ExpressServiceProviderInterface
- A module that sells services payable by one express SMS.
Constants
- SERVICE_CREDITS : string = 'KREDIT'
- Service word of the SMS for a tariff that adds credits.
- SERVICE_MEMBERSHIP : string = 'CLEN'
- Service word of the SMS for a tariff that extends membership.
- CALLBACK_KEY : string = 'SYSTEM_USER_PAYMENT'
Properties
Methods
- __construct() : mixed
- createPaymentItems() : bool
- Inactive item of the paid user; the callback activates it (validity, `member_until`, credits).
- describe() : array<int, ExpressServiceDescription>
- Every express service the module offers right now through the gateway, for the administration overview and the Front offers.
- getModuleCode() : string
- Module word of the SMS text, one of {@see ExpressModuleCode}.
- hasPaymentItems() : bool
- Does the payment already have the module payment items? Read straight from the DB. The resumed processing of a redelivered SMS (the first run crashed after the payment was saved) asks before {@see createPaymentItems()} — a second set of items would activate twice.
- resolve() : ExpressResolution
- Validate the untrusted SMS data: the service must be one the module offers right now (an active quick price, or a tariff price for the gateway), the object must exist and be active.
- findOffers() : array<int, array{serviceCode: string, tariffId: int, tariffName: string, price: float, currencyId: int, paymentRegionId: int, productTypeId: ?int, supplyKindId: ?int}>
- Active service tariffs × their active non-zero prices for the gateway (one per region × currency).
- serviceCodesOf() : array<int, string>
- SMS service words of a tariff: `CLEN` when it has a duration, `KREDIT` when it has credits (both for a package).
Constants
SERVICE_CREDITS
Service word of the SMS for a tariff that adds credits.
public
string
SERVICE_CREDITS
= 'KREDIT'
SERVICE_MEMBERSHIP
Service word of the SMS for a tariff that extends membership.
public
string
SERVICE_MEMBERSHIP
= 'CLEN'
CALLBACK_KEY
private
string
CALLBACK_KEY
= 'SYSTEM_USER_PAYMENT'
Properties
$tariffManager read-only
private
TariffManager
$tariffManager
$userManager read-only
private
UserManager
$userManager
$userPaymentManager read-only
private
UserPaymentManager
$userPaymentManager
Methods
__construct()
public
__construct(UserManager $userManager, TariffManager $tariffManager, UserPaymentManager $userPaymentManager) : mixed
Parameters
- $userManager : UserManager
- $tariffManager : TariffManager
- $userPaymentManager : UserPaymentManager
createPaymentItems()
Inactive item of the paid user; the callback activates it (validity, `member_until`, credits).
public
createPaymentItems(ExpressTarget $target, int $paymentId) : bool
Inserted inactive, so UserPaymentManager::afterSave() neither extends nor credits anything.
Parameters
- $target : ExpressTarget
- $paymentId : int
Return values
booldescribe()
Every express service the module offers right now through the gateway, for the administration overview and the Front offers.
public
describe(int $paymentGateId) : array<int, ExpressServiceDescription>
Parameters
- $paymentGateId : int
Return values
array<int, ExpressServiceDescription>getModuleCode()
Module word of the SMS text, one of {@see ExpressModuleCode}.
public
getModuleCode() : string
Return values
stringhasPaymentItems()
Does the payment already have the module payment items? Read straight from the DB. The resumed processing of a redelivered SMS (the first run crashed after the payment was saved) asks before {@see createPaymentItems()} — a second set of items would activate twice.
public
hasPaymentItems(int $paymentId) : bool
Parameters
- $paymentId : int
Return values
boolresolve()
Validate the untrusted SMS data: the service must be one the module offers right now (an active quick price, or a tariff price for the gateway), the object must exist and be active.
public
resolve(string $serviceCode, int $objectId, int $paymentGateId) : ExpressResolution
Returns one target per payment region / tariff offering it — the System layer then picks the one whose price and currency equal the number the SMS was sent to.
$paymentGateId = the SMS gateway that received the message; modules whose prices differ per
gateway (user tariffs) read their price for it, quick price modules ignore it.
Parameters
- $serviceCode : string
- $objectId : int
- $paymentGateId : int
Return values
ExpressResolutionfindOffers()
Active service tariffs × their active non-zero prices for the gateway (one per region × currency).
private
findOffers(int $paymentGateId) : array<int, array{serviceCode: string, tariffId: int, tariffName: string, price: float, currencyId: int, paymentRegionId: int, productTypeId: ?int, supplyKindId: ?int}>
Parameters
- $paymentGateId : int
Return values
array<int, array{serviceCode: string, tariffId: int, tariffName: string, price: float, currencyId: int, paymentRegionId: int, productTypeId: ?int, supplyKindId: ?int}>serviceCodesOf()
SMS service words of a tariff: `CLEN` when it has a duration, `KREDIT` when it has credits (both for a package).
private
static serviceCodesOf(Tariff $tariff) : array<int, string>
Parameters
- $tariff : Tariff