CoolCMS API

FormTrait

Table of Contents

Methods

onSubmit()  : void
onSuccess()  : void
createComponentForm()  : Form
applyTaxSnapshot()  : void
Tax snapshot of the payment: treatment code, date, rate country, clause, customer country, VAT id verification, flags and commodity code from the engine response at submit ({@see PriceTrait::buildTaxSnapshot()}). The invoice takes it over ({@see \App\UI\Api\Invoicer\Models\Generators\InvoiceGenerator}); an intermediary gate and credits carry only a marker (`INTERMEDIARY` / `CREDIT_REDEMPTION`) and produce no invoice.
buildPaymentItemSnapshot()  : array<int, PaymentItem>
Builds the snapshot from the selected paid items, from the same engine response that was charged ({@see PriceTrait::buildTaxedItems()}): base without VAT (a final price is split from the top), the engine rate (0 = no VAT charged) and the supply kind. A marked gate (SMS via intermediary, credits) means price 1:1 and rate 0; no invoice arises from such a payment.
buildPaymentItemSnapshotMeta()  : array<int, array{name: string, price: string, vatPercents: ?string, productTypeId: ?int, supplyKindId: ?int, sort: int}>
Accounting snapshot of the charged payment items (`cms_system_payment_items`) as `meta` rows of the payment insert: name, base, VAT rate and productType exactly as charged now. The invoice builds its lines from it ({@see \App\UI\Api\Invoicer\Models\Generators\InvoiceGenerator::addLinesFromPayment()}) and prefers it over the live price list, which may change between checkout and invoicing; the snapshot may not. Not to be confused with the activation `cms_mod_*_payment_items`, which the module saves through `paymentItemSaver`.
createNewPayment()  : Payment|null}
getFirstPaymentGateId()  : int|null
getFormValues()  : ArrayHash
hasSelectedItem()  : bool
At least one item of any group is selected.
normalizePaymentGateId()  : void
setDefaults()  : void

Methods

onSuccess()

public onSuccess(Form $form, ArrayHash $values) : void
Parameters
$form : Form
$values : ArrayHash

applyTaxSnapshot()

Tax snapshot of the payment: treatment code, date, rate country, clause, customer country, VAT id verification, flags and commodity code from the engine response at submit ({@see PriceTrait::buildTaxSnapshot()}). The invoice takes it over ({@see \App\UI\Api\Invoicer\Models\Generators\InvoiceGenerator}); an intermediary gate and credits carry only a marker (`INTERMEDIARY` / `CREDIT_REDEMPTION`) and produce no invoice.

private applyTaxSnapshot(Payment $payment, ArrayHash $values) : void
Parameters
$payment : Payment
$values : ArrayHash

buildPaymentItemSnapshot()

Builds the snapshot from the selected paid items, from the same engine response that was charged ({@see PriceTrait::buildTaxedItems()}): base without VAT (a final price is split from the top), the engine rate (0 = no VAT charged) and the supply kind. A marked gate (SMS via intermediary, credits) means price 1:1 and rate 0; no invoice arises from such a payment.

private buildPaymentItemSnapshot(ArrayHash $values) : array<int, PaymentItem>
Parameters
$values : ArrayHash
Return values
array<int, PaymentItem>

buildPaymentItemSnapshotMeta()

Accounting snapshot of the charged payment items (`cms_system_payment_items`) as `meta` rows of the payment insert: name, base, VAT rate and productType exactly as charged now. The invoice builds its lines from it ({@see \App\UI\Api\Invoicer\Models\Generators\InvoiceGenerator::addLinesFromPayment()}) and prefers it over the live price list, which may change between checkout and invoicing; the snapshot may not. Not to be confused with the activation `cms_mod_*_payment_items`, which the module saves through `paymentItemSaver`.

private buildPaymentItemSnapshotMeta(ArrayHash $values) : array<int, array{name: string, price: string, vatPercents: ?string, productTypeId: ?int, supplyKindId: ?int, sort: int}>

IMPORTANT: the Api saves the rows in the payment transaction, so a snapshot failure means no payment (the form shows an error), never a payment with part of its snapshot.

Parameters
$values : ArrayHash
Return values
array<int, array{name: string, price: string, vatPercents: ?string, productTypeId: ?int, supplyKindId: ?int, sort: int}>

createNewPayment()

private createNewPayment(ArrayHash $values, int $paymentGateId, float $totalPrice) : Payment|null}
Parameters
$values : ArrayHash
$paymentGateId : int
$totalPrice : float
Return values
Payment|null}

getFirstPaymentGateId()

private getFirstPaymentGateId() : int|null
Return values
int|null

getFormValues()

private getFormValues(Form $form) : ArrayHash
Parameters
$form : Form
Return values
ArrayHash

hasSelectedItem()

At least one item of any group is selected.

private hasSelectedItem(ArrayHash $values) : bool
Parameters
$values : ArrayHash
Return values
bool

normalizePaymentGateId()

private normalizePaymentGateId(Form $form, ArrayHash $values) : void
Parameters
$form : Form
$values : ArrayHash
On this page

Search results