ModelForms module

PaymentElement

Entity for collecting payment

A model in the Forms module, with 42 members for templates, 32 API properties and 36 members for admin templates.

View
What Smarty and Twig templates receive. Properties in REST API responses and job payloads. What admin screen templates receive when you override them.

Templates view

Properties 40

Take no arguments.

# getType()
string
# getPaymentError()
?string
Returns the payment processing error message, if any.
# getCurrencyCode()
?string
Returns the ISO 4217 currency code configured for this element (e.g. 'USD').
# getCurrency()
Currency
Returns the currency object configured for this element.
# getAmounts()
array
Returns the preset payment amounts configured for this element, hydrated as major-unit decimal strings.
# getAmountsAsMoney()
array
Returns the preset payment amounts configured for this element, hydrated as Money objects.
# getSettings()
?array
# getMode()
string
Returns the payment capture mode: 'authorizeCapture' or 'authorizeOnly'.
# getPaymentMethodIds()
array
Returns the IDs of the payment methods configured for this element.
# getTaxCategoryId()
?int
Returns the tax category ID configured for this element, if any.
# isAllowCustomAmount()
bool
Returns whether the user is permitted to enter a custom payment amount.
# getBillingFieldDescriptors()
array
Resolves the billing field set for this element from the framework-owned catalogue. This is the single source of truth read by validation ({@see \Forms\Services\FormPaymentService}), the renderer ({@see \Forms\Models\Frontend\Response\PaymentElement}), and — via {@see BillingFieldContract} — persistence ({@see \Forms\Services\FormInvoiceService}). The mandatory minimum and the field catalogue are framework-owned; only selection (above the minimum), order, labels, and requiredness ride the element's settings JSON under the billingFields key, so there is no DB/schema change. Input shape of that override (all sub-keys optional, each falling back to the catalogue default): settings['billingFields'] = { "<fieldName>": { "enabled": bool, "required": bool, "label": string, "position": int } } where <fieldName> is a {@see BillingFieldContract::CATALOGUE} key. Mandatory fields ignore enabled/required. This is an API/settings-level surface today — there is no form-builder UI writing this key yet (admin UI is a planned follow-up). Each returned descriptor: ['name', 'label', 'required', 'type', 'idSuffix', 'colClass', 'position']. With no per-element configuration the result reproduces the legacy billing-address.html field set exactly (ten fields, postcode required, suburb hidden).
# getRequiredBillingFieldNames()
array
Returns the billing field names that must be present for a valid submission. The invoice-mandatory minimum is always enforced; any optional field the author has marked required (above the minimum) is added. With no per-element configuration this returns the legacy six-field required set.
# getFormId()
?int
Returns the id of the form this element belongs to, if resolvable. Convenience accessor for the provider mount blocks' data-form-id JS hook, so a hand-rolled theme does not have to walk getRevision()->getForm()->getId() with its own null guards.
# getAmountsJson()
string
Returns the preset amounts (major-unit decimal strings) as a JSON array. Convenience accessor for the provider mount blocks' data-amounts JS hook so a hand-rolled theme emits exactly the shape the bundled amount-selector JS expects.
# getEntity()
?string
# getId()
?int
# getName()
?string
Gets element name. It could be used in html to identify input, e.g. '<input name="{getName()}" ...>'.
# getHelp()
?string
Gets help text for the element. It could be used as a tooltip or in HTML as a title attribute, e.g. '<input title="{getHelp()}" ...>'.
# getEditor()
?string
# getText()
?string
Text for the element that usually is used for element's label
# getDefaultValue()
?string
# getPlaceholder()
?string
# isRequired()
?bool
# getRegex()
?string
# getPosition()
?int
# getRevision()
?FormRevision
# getStep()
?Step
# getValidationRules()
?Collection<ValidationRule>
# getValidationConditions()
?Collection<ValidationCondition>
# getParent()
?ElementGroup
# getElementId()
?string
# isNewRecord() Not in API & Jobs
bool
Check if the record is a new record
# isHierarchicalModel() Not in API & Jobs
bool
Check whether a model is a hierarchical model, i.e. can have children
# isVersionedModel() Not in API & Jobs
bool
Check whether a model is versioned
# getHtml() Templates only
string
# getBillingFields() Templates only
array
Builds the element-pattern billing fields for this element. The contract (which fields, in what order, with what labels and requiredness) comes from {@see \Forms\Models\PaymentElement::getBillingFieldDescriptors()}; this method turns each descriptor into a renderable {@see BillingField}, supplying the country option list and any submitted value to repopulate on re-render. Exposed so a theme can hand-roll its own markup.
# getBillingAddressHtml() Templates only
string
Renders the billing address fieldset by looping the billing fields, structurally identical to {@see ElementGroup::getHtml()}. Section seam for partial-render integrations.
# getPaymentMethodsHtml() Templates only
string
Renders the provider mount blocks for each active configured payment method. Section seam for partial-render integrations. A misconfigured single method (e.g. an unresolvable provider key) is logged and skipped rather than blanking the whole element.
# getPaymentMethods() Templates only
array
Returns the active configured payment methods as Response models, for fully hand-rolled markup. Exposes the per-method JS-hook getter surface (getId, getName, getPaymentServiceProviderType, getPublishableKey, isTestMode, getHostedButtonId — already on the Invoices Frontend Response models) so a theme can emit its own mount blocks. Combine with the element-level hooks ({@see \Forms\Models\PaymentElement::getName()}, {@see \Forms\Models\PaymentElement::getAmountsJson()}, {@see \Forms\Models\PaymentElement::getCurrencyCode()}, {@see \Forms\Models\PaymentElement::isAllowCustomAmount()}, {@see \Forms\Models\PaymentElement::getFormId()}).

Methods 2

Take arguments. The API serialises only getters that need none.

# getValues(ElementSubmission $submission)
?array
Gets array representation of given submission value. Payment submissions are inherently structured (amount, currency, payment method, transaction id), so the array form is the natural shape. Returns null if values are not set.
# getPaymentMethodHtml(int $paymentMethodId) Templates only
string
Renders the provider mount block for a single payment method by id, or '' if it is missing or inactive. Partial-render seam: a theme can loop {@see getPaymentMethodIds()} and place each block in its own arrangement. Takes an id (not a model) so it is callable from a template without passing a Response model back into typed PHP.

API & Jobs view

API & JobsEach property is a key in REST API responses and job payloads. Its name is the template getter without get, is or has. Methods that need arguments are not available here.

Properties 32

Read-only values on the record.

# type
string
# paymentError
?string
Returns the payment processing error message, if any.
# currencyCode
?string
Returns the ISO 4217 currency code configured for this element (e.g. 'USD').
# currency
Currency
Returns the currency object configured for this element.
# amounts
array
Returns the preset payment amounts configured for this element, hydrated as major-unit decimal strings.
# amountsAsMoney
array
Returns the preset payment amounts configured for this element, hydrated as Money objects.
# settings
?array
# mode
string
Returns the payment capture mode: 'authorizeCapture' or 'authorizeOnly'.
# paymentMethodIds
array
Returns the IDs of the payment methods configured for this element.
# taxCategoryId
?int
Returns the tax category ID configured for this element, if any.
# allowCustomAmount
bool
Returns whether the user is permitted to enter a custom payment amount.
# billingFieldDescriptors
array
Resolves the billing field set for this element from the framework-owned catalogue. This is the single source of truth read by validation ({@see \Forms\Services\FormPaymentService}), the renderer ({@see \Forms\Models\Frontend\PaymentElement}), and — via {@see BillingFieldContract} — persistence ({@see \Forms\Services\FormInvoiceService}). The mandatory minimum and the field catalogue are framework-owned; only selection (above the minimum), order, labels, and requiredness ride the element's settings JSON under the billingFields key, so there is no DB/schema change. Input shape of that override (all sub-keys optional, each falling back to the catalogue default): settings['billingFields'] = { "<fieldName>": { "enabled": bool, "required": bool, "label": string, "position": int } } where <fieldName> is a {@see BillingFieldContract::CATALOGUE} key. Mandatory fields ignore enabled/required. This is an API/settings-level surface today — there is no form-builder UI writing this key yet (admin UI is a planned follow-up). Each returned descriptor: ['name', 'label', 'required', 'type', 'idSuffix', 'colClass', 'position']. With no per-element configuration the result reproduces the legacy billing-address.html field set exactly (ten fields, postcode required, suburb hidden).
# requiredBillingFieldNames
array
Returns the billing field names that must be present for a valid submission. The invoice-mandatory minimum is always enforced; any optional field the author has marked required (above the minimum) is added. With no per-element configuration this returns the legacy six-field required set.
# formId
?int
Returns the id of the form this element belongs to, if resolvable. Convenience accessor for the provider mount blocks' data-form-id JS hook, so a hand-rolled theme does not have to walk getRevision()->getForm()->getId() with its own null guards.
# amountsJson
string
Returns the preset amounts (major-unit decimal strings) as a JSON array. Convenience accessor for the provider mount blocks' data-amounts JS hook so a hand-rolled theme emits exactly the shape the bundled amount-selector JS expects.
# entity
?string
# id
?int
# name
?string
Gets element name. It could be used in html to identify input, e.g. '<input name="{getName()}" ...>'.
# help
?string
Gets help text for the element. It could be used as a tooltip or in HTML as a title attribute, e.g. '<input title="{getHelp()}" ...>'.
# editor
?string
# text
?string
Text for the element that usually is used for element's label
# defaultValue
?string
# placeholder
?string
# required
?bool
# regex
?string
# position
?int
# revision
?FormRevision
# step
?Step
# validationRules
?Collection<ValidationRule>
# validationConditions
?Collection<ValidationCondition>
# parent
?ElementGroup
# elementId
?string

Admin view

AdminAvailable in cdna-admin templates. Copy an admin template into your site repository to change how this record is edited.

Properties 35

Take no arguments.

# getType()
string
# getPaymentError()
?string
Returns the payment processing error message, if any.
# getCurrencyCode()
?string
Returns the ISO 4217 currency code configured for this element (e.g. 'USD').
# getCurrency()
Currency
Returns the currency object configured for this element.
# getAmounts()
array
Returns the preset payment amounts configured for this element, hydrated as major-unit decimal strings.
# getAmountsAsMoney()
array
Returns the preset payment amounts configured for this element, hydrated as Money objects.
# getSettings()
?array
# getMode()
string
Returns the payment capture mode: 'authorizeCapture' or 'authorizeOnly'.
# getPaymentMethodIds()
array
Returns the IDs of the payment methods configured for this element.
# getTaxCategoryId()
?int
Returns the tax category ID configured for this element, if any.
# isAllowCustomAmount()
bool
Returns whether the user is permitted to enter a custom payment amount.
# getBillingFieldDescriptors()
array
Resolves the billing field set for this element from the framework-owned catalogue. This is the single source of truth read by validation ({@see \Forms\Services\FormPaymentService}), the renderer ({@see \Forms\Models\Frontend\PaymentElement}), and — via {@see BillingFieldContract} — persistence ({@see \Forms\Services\FormInvoiceService}). The mandatory minimum and the field catalogue are framework-owned; only selection (above the minimum), order, labels, and requiredness ride the element's settings JSON under the billingFields key, so there is no DB/schema change. Input shape of that override (all sub-keys optional, each falling back to the catalogue default): settings['billingFields'] = { "<fieldName>": { "enabled": bool, "required": bool, "label": string, "position": int } } where <fieldName> is a {@see BillingFieldContract::CATALOGUE} key. Mandatory fields ignore enabled/required. This is an API/settings-level surface today — there is no form-builder UI writing this key yet (admin UI is a planned follow-up). Each returned descriptor: ['name', 'label', 'required', 'type', 'idSuffix', 'colClass', 'position']. With no per-element configuration the result reproduces the legacy billing-address.html field set exactly (ten fields, postcode required, suburb hidden).
# getRequiredBillingFieldNames()
array
Returns the billing field names that must be present for a valid submission. The invoice-mandatory minimum is always enforced; any optional field the author has marked required (above the minimum) is added. With no per-element configuration this returns the legacy six-field required set.
# getFormId()
?int
Returns the id of the form this element belongs to, if resolvable. Convenience accessor for the provider mount blocks' data-form-id JS hook, so a hand-rolled theme does not have to walk getRevision()->getForm()->getId() with its own null guards.
# getAmountsJson()
string
Returns the preset amounts (major-unit decimal strings) as a JSON array. Convenience accessor for the provider mount blocks' data-amounts JS hook so a hand-rolled theme emits exactly the shape the bundled amount-selector JS expects.
# getEntity()
?string
# getId()
?int
# getName()
?string
Gets element name. It could be used in html to identify input, e.g. '<input name="{getName()}" ...>'.
# getHelp()
?string
Gets help text for the element. It could be used as a tooltip or in HTML as a title attribute, e.g. '<input title="{getHelp()}" ...>'.
# getEditor()
?string
# getText()
?string
Text for the element that usually is used for element's label
# getDefaultValue()
?string
# getPlaceholder()
?string
# isRequired()
?bool
# getRegex()
?string
# getPosition()
?int
# getRevision()
?FormRevision
# getStep()
?Step
# getValidationRules()
?Collection<ValidationRule>
# getValidationConditions()
?Collection<ValidationCondition>
# getParent()
?ElementGroup
# getElementId()
?string
# isNewRecord() Not in API & Jobs
bool
Check if the record is a new record
# isHierarchicalModel() Not in API & Jobs
bool
Check whether a model is a hierarchical model, i.e. can have children
# isVersionedModel() Not in API & Jobs
bool
Check whether a model is versioned

Methods 1

Take arguments. The API serialises only getters that need none.

# getValues(ElementSubmission $submission)
?array
Gets array representation of given submission value. Payment submissions are inherently structured (amount, currency, payment method, transaction id), so the array form is the natural shape. Returns null if values are not set.