CoolCMS API

AbstractQuickPriceExpressServiceProvider
in package
implements ExpressServiceProviderInterface

AbstractYes

Express services of a module with quick prices (Bazaar, Comcat, Discussion): topping, highlight, topbox… = the module tariffs with an active quick price (`cms_mod_bazaar_advert_tariff_quick_prices`, `cms_mod_comcat_advert_tariff_quick_prices`, `cms_mod_discussion_message_tariff_quick_prices`).

The modules share the schema (tariff → quick price per payment region, payment item = object + tariff + payment), so the logic lives once here and the module class only supplies the storage access through its own (typed) managers, its payment item entity and its callback key. Modules whose object is not an advert override the object hooks (isObjectActive(), bindPaymentItemObject()).

The quick price IS the express price list of these modules, so the payment gateway does not change the price (resolve() ignores $paymentGateId); the number of the gateway still has to cost exactly the quick price.

Table of Contents

Interfaces

ExpressServiceProviderInterface
A module that sells services payable by one express SMS.

Methods

createPaymentItems()  : bool
Create the module payment items (inactive) for a payment the System layer just created.
describe()  : array<int, ExpressServiceDescription>
Every express service the module offers right now through the gateway, for the administration overview and the Front offers.
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.
bindPaymentItemObject()  : bool
Point the new payment item at the object. Advert default: `setAdvertId()`.
buildObjectLabel()  : string
Short label of the object for the customer reply, e.g. `inzerat 956` (SMS = `ASCII`).
createPaymentItemEntity()  : BaseEntity
New, empty module payment item entity.
findActiveTariffs()  : iterable<string|int, BaseEntity>
Active tariffs with `translations` and `quickPrices` loaded.
findObject()  : BaseEntity|null
Object by id (module Api manager), null = does not exist.
findPaymentItemByPayment()  : BaseEntity|null
Any module payment item of the payment (module Api manager), null = none yet.
getCallbackKey()  : string
`cms_system_payment_callbacks.callback_key` of the module (activates its payment items).
isObjectActive()  : bool
Can the object still be paid for? Advert default: `active = 1` (approved, paid, not banned, deactivated nor sold — the advert entity folds that into one column).
savePaymentItem()  : bool
Persist a new module payment item through the module manager (its save hooks included).
findOffers()  : array<int, array{serviceCode: string, tariffId: int, tariffName: string, price: float, currencyId: int, paymentRegionId: ?int, productTypeId: ?int, supplyKindId: ?int}>
Active tariffs × their usable quick prices. A quick price row exists for every region the moment a tariff is saved, so `active` alone is not enough — it also needs a keyword, a currency and a non-zero price (mirror of `ExpressPaymentTrait::isExpressPaymentOffered()`).
isDeleted()  : bool

Methods

createPaymentItems()

Create the module payment items (inactive) for a payment the System layer just created.

public createPaymentItems(ExpressTarget $target, int $paymentId) : bool

The payment callback activates them once the payment is completed.

Parameters
$target : ExpressTarget
$paymentId : int
Return values
bool

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

bindPaymentItemObject()

Point the new payment item at the object. Advert default: `setAdvertId()`.

protected bindPaymentItemObject(BaseEntity $paymentItem, int $objectId) : bool

False = the item entity has no such setter (wrong wiring) → the SMS fails with a claim code.

Parameters
$paymentItem : BaseEntity
$objectId : int
Return values
bool

buildObjectLabel()

Short label of the object for the customer reply, e.g. `inzerat 956` (SMS = `ASCII`).

protected abstract buildObjectLabel(int $objectId) : string
Parameters
$objectId : int
Return values
string

getCallbackKey()

`cms_system_payment_callbacks.callback_key` of the module (activates its payment items).

protected abstract getCallbackKey() : string
Return values
string

isObjectActive()

Can the object still be paid for? Advert default: `active = 1` (approved, paid, not banned, deactivated nor sold — the advert entity folds that into one column).

protected isObjectActive(BaseEntity $object) : bool
Parameters
$object : BaseEntity
Return values
bool

findOffers()

Active tariffs × their usable quick prices. A quick price row exists for every region the moment a tariff is saved, so `active` alone is not enough — it also needs a keyword, a currency and a non-zero price (mirror of `ExpressPaymentTrait::isExpressPaymentOffered()`).

private findOffers() : array<int, array{serviceCode: string, tariffId: int, tariffName: string, price: float, currencyId: int, paymentRegionId: ?int, productTypeId: ?int, supplyKindId: ?int}>
Return values
array<int, array{serviceCode: string, tariffId: int, tariffName: string, price: float, currencyId: int, paymentRegionId: ?int, productTypeId: ?int, supplyKindId: ?int}>
On this page

Search results