CoolCMS API

PaymentFormTrait

Add/edit form of a payment.

The skeleton comes from BasePresenter::createForm(). A curated set of fields is edited: foreign keys via select/picker, customer data, status, prices and dates. System-generated fields (gateway fees, encryptedSignature, gatewayPaymentId, callback, success/cancel/notify URLs, paymentCallbackId/paymentEetId) are not in the form and stay unchanged on edit.

Table of Contents

Constants

PAY_DT_FORMAT  : mixed = 'Y-m-d\TH:i'
Value format of `<input type=datetime-local>`.

Methods

createComponentEditForm()  : Form
auditedPaymentValues()  : array<string, scalar|null>
Returns the audited payment fields as scalars (input of {@see PaymentEditAudit::diff()}).
hasIssuedInvoice()  : bool
Tells whether the payment has an issued document (invoice, cancellation, credit note).
prepareCurrencyOptions()  : array<int, string>
prepareLocalizationOptions()  : array<int, string>
preparePaymentGateOptions()  : array<int, string>
preparePaymentRegionOptions()  : array<int, string>
preparePaymentStatusOptions()  : array<int, string>
savePaymentForm()  : bool
selectedStatusOrNull()  : int|null
Returns the status `<select>` value as int, or null for the empty prompt. Code `0` (`UNKNOWN`) is a valid status, so the shared `intOrNull()` is not used: it would turn it into null.
setPaymentFormDefaults()  : void
tr()  : string
Translates a key in the form domain (for fields with `setTranslator(null)`).
translatedNameOr()  : string
Returns the translated entity name (current language, else the first non-empty, else `$fallback`).

Constants

PAY_DT_FORMAT

Value format of `<input type=datetime-local>`.

private mixed PAY_DT_FORMAT = 'Y-m-d\TH:i'

Methods

auditedPaymentValues()

Returns the audited payment fields as scalars (input of {@see PaymentEditAudit::diff()}).

private auditedPaymentValues(Payment $payment) : array<string, scalar|null>
Parameters
$payment : Payment
Return values
array<string, scalar|null>

hasIssuedInvoice()

Tells whether the payment has an issued document (invoice, cancellation, credit note).

private hasIssuedInvoice(int $paymentId) : bool
Parameters
$paymentId : int
Return values
bool

prepareCurrencyOptions()

private prepareCurrencyOptions() : array<int, string>
Return values
array<int, string>

prepareLocalizationOptions()

private prepareLocalizationOptions() : array<int, string>
Return values
array<int, string>

preparePaymentGateOptions()

private preparePaymentGateOptions() : array<int, string>
Return values
array<int, string>

preparePaymentRegionOptions()

private preparePaymentRegionOptions() : array<int, string>
Return values
array<int, string>

preparePaymentStatusOptions()

private preparePaymentStatusOptions() : array<int, string>
Return values
array<int, string>

savePaymentForm()

private savePaymentForm(ArrayHash<string|int, mixed> $values, Form|null $form) : bool
Parameters
$values : ArrayHash<string|int, mixed>
$form : Form|null
Return values
bool

selectedStatusOrNull()

Returns the status `<select>` value as int, or null for the empty prompt. Code `0` (`UNKNOWN`) is a valid status, so the shared `intOrNull()` is not used: it would turn it into null.

private selectedStatusOrNull(mixed $value) : int|null
Parameters
$value : mixed
Return values
int|null

tr()

Translates a key in the form domain (for fields with `setTranslator(null)`).

private tr(string $key) : string
Parameters
$key : string
Return values
string

translatedNameOr()

Returns the translated entity name (current language, else the first non-empty, else `$fallback`).

private translatedNameOr(object $entity, int|null $currentLang, string $fallback) : string
Parameters
$entity : object
$currentLang : int|null
$fallback : string
Return values
string
On this page

Search results