CoolCMS API

MembershipExpressServiceProvider
in package
implements ExpressServiceProviderInterface

FinalYes

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

$tariffManager  : TariffManager
$userManager  : UserManager
$userPaymentManager  : UserPaymentManager

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

Properties

Methods

hasPaymentItems()

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
bool

resolve()

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
ExpressResolution

findOffers()

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
Return values
array<int, string>
On this page

Search results