Documentation

CRM_Core_Payment_Form
in package

Class for constructing the payment processor block.

Tags
copyright

CiviCRM LLC https://civicrm.org/licensing

Table of Contents

Methods

buildPaymentForm()  : mixed
getBillingAddressFields()  : array<string|int, mixed>
Get the billing fields that apply to this processor.
getBillingAddressMetadata()  : array<string|int, mixed>
getCreditCardExpirationMonth()  : int
Get the credit card expiration month.
getCreditCardExpirationYear()  : int
Get the credit card expiration year.
getPaymentFieldMetadata()  : array<string|int, mixed>
getPaymentFields()  : array<string|int, mixed>
Get the payment fields that apply to this processor.
getPaymentLabel()  : string
Get the label for the processor.
getPaymentTypeLabel()  : string
getPaymentTypeName()  : string
mapParams()  : mixed
Map address fields.
setDefaultValues()  : mixed
Set default values for the form.
setPaymentFieldsByProcessor()  : mixed
Add payment fields depending on payment processor.
validateCreditCard()  : mixed
Make sure that credit card number and cvv are valid.
validatePaymentInstrument()  : mixed
Validate the payment instrument values before passing it to the payment processor.
addCommonFields()  : mixed
Add the payment fields to the template.
addRules()  : void
setBillingAddressFields()  : mixed
Add general billing fields.

Methods

buildPaymentForm()

public static buildPaymentForm(CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main|CRM_Core_Payment_ProcessorForm|CRM_Contribute_Form_UpdateBilling &$form, array<string|int, mixed> $processor, int|string $billing_profile_id, bool $isBackOffice[, int $paymentInstrumentID = NULL ]) : mixed
Parameters
$form : CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main|CRM_Core_Payment_ProcessorForm|CRM_Contribute_Form_UpdateBilling
$processor : array<string|int, mixed>

Array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors.

$billing_profile_id : int|string

Id of a profile to be passed to the processor for the processor to merge with it's required fields. (currently only implemented by manual/ pay-later processor)

$isBackOffice : bool

Is this a backoffice form. This could affect the display of the cvn or whether some processors show, although the distinction is losing it's meaning as front end forms are used for back office and a permission for the 'enter without cvn' is probably more appropriate. Paypal std does not support another user entering details but once again the issue is not back office but 'another user'.

$paymentInstrumentID : int = NULL

Payment instrument ID.

getBillingAddressFields()

Get the billing fields that apply to this processor.

public static getBillingAddressFields(array<string|int, mixed> $paymentProcessor) : array<string|int, mixed>
Parameters
$paymentProcessor : array<string|int, mixed>
Tags
todo

sometimes things like the country alter the required fields (e.g postal code). We should possibly set these before calling getPaymentFormFields (as we identify them).

Return values
array<string|int, mixed>

getBillingAddressMetadata()

public static getBillingAddressMetadata(array<string|int, mixed> $paymentProcessor) : array<string|int, mixed>
Parameters
$paymentProcessor : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

getCreditCardExpirationMonth()

Get the credit card expiration month.

public static getCreditCardExpirationMonth(array<string|int, mixed> $src) : int

The date format for this field should typically be "M Y" (ex: Feb 2011) or "m Y" (02 2011) See CRM-9017

Parameters
$src : array<string|int, mixed>
Return values
int

getCreditCardExpirationYear()

Get the credit card expiration year.

public static getCreditCardExpirationYear(mixed $src) : int

The date format for this field should typically be "M Y" (ex: Feb 2011) or "m Y" (02 2011) This function exists only to make it consistent with getCreditCardExpirationMonth

Parameters
$src : mixed
Return values
int

getPaymentFieldMetadata()

public static getPaymentFieldMetadata(array<string|int, mixed> $paymentProcessor) : array<string|int, mixed>
Parameters
$paymentProcessor : array<string|int, mixed>
Return values
array<string|int, mixed>

getPaymentFields()

Get the payment fields that apply to this processor.

public static getPaymentFields(array<string|int, mixed> $paymentProcessor) : array<string|int, mixed>
Parameters
$paymentProcessor : array<string|int, mixed>
Tags
todo

sometimes things like the country alter the required fields (e.g direct debit fields). We should possibly set these before calling getPaymentFormFields (as we identify them).

Return values
array<string|int, mixed>

getPaymentLabel()

Get the label for the processor.

public static getPaymentLabel(CRM_Core_Payment $processor) : string

We do not use a label if there are no enterable fields.

Parameters
$processor : CRM_Core_Payment
Return values
string

getPaymentTypeName()

public static getPaymentTypeName(array<string|int, mixed> $paymentProcessor) : string
Parameters
$paymentProcessor : array<string|int, mixed>
Return values
string

mapParams()

Map address fields.

public static mapParams(null $id, array<string|int, mixed> $src, array<string|int, mixed> &$dst[, bool $reverse = FALSE ]) : mixed
Parameters
$id : null

unused

$src : array<string|int, mixed>
$dst : array<string|int, mixed>
$reverse : bool = FALSE

setDefaultValues()

Set default values for the form.

public static setDefaultValues(CRM_Core_Form &$form, int $contactID) : mixed
Parameters
$form : CRM_Core_Form
$contactID : int

setPaymentFieldsByProcessor()

Add payment fields depending on payment processor.

public static setPaymentFieldsByProcessor(CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main &$form, array<string|int, mixed> $processor[, int $billing_profile_id = NULL ][, bool $isBackOffice = FALSE ][, int $paymentInstrumentID = NULL ]) : mixed

The payment processor can implement the following functions to override the built in fields.

  • getPaymentFormFields()
  • getPaymentFormFieldsMetadata() (planned - getBillingDetailsFormFields(), getBillingDetailsFormFieldsMetadata()

Note that this code is written to accommodate the possibility CiviCRM will switch to implementing pay later as a manual processor in future

Parameters
$form : CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main
$processor : array<string|int, mixed>

Array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors.

$billing_profile_id : int = NULL

Display billing fields even for pay later.

$isBackOffice : bool = FALSE

Is this a back office function? If so the option to suppress the cvn needs to be evaluated.

$paymentInstrumentID : int = NULL

ID of the payment processor.

validateCreditCard()

Make sure that credit card number and cvv are valid.

public static validateCreditCard(array<string|int, mixed> $values, array<string|int, mixed> &$errors[, int $processorID = NULL ]) : mixed

Called within the scope of a QF formRule function

Parameters
$values : array<string|int, mixed>
$errors : array<string|int, mixed>
$processorID : int = NULL

validatePaymentInstrument()

Validate the payment instrument values before passing it to the payment processor.

public static validatePaymentInstrument(int $payment_processor_id, array<string|int, mixed> $values, array<string|int, mixed> &$errors, int $billing_profile_id) : mixed

We want this to be able to be overridden by the payment processor, and default to using this object's validCreditCard for credit cards (implemented as the default in the Payment class).

Parameters
$payment_processor_id : int
$values : array<string|int, mixed>
$errors : array<string|int, mixed>
$billing_profile_id : int

addCommonFields()

Add the payment fields to the template.

protected static addCommonFields(CRM_Core_Form &$form, array<string|int, mixed> $paymentFields) : mixed

Generally this is the payment processor fields & the billing fields required for the payment processor. However, this has been complicated by adding pay later billing fields into this mix

We now have the situation where the required fields cannot be set as required on the form level if they are required for the payment processor, as another processor might be selected and the validation will then be incorrect.

However, if they are required for pay later we DO set them on the form level, presumably assuming they will be required whatever happens.

As a side-note this seems to re-enforce the argument for making pay later operate as a payment processor rather than as a 'special thing on its own'.

Parameters
$form : CRM_Core_Form

Form that the payment fields are to be added to.

$paymentFields : array<string|int, mixed>

Fields that are to be shown on the payment form.

addRules()

protected static addRules(CRM_Core_Form &$form, array<string|int, mixed> $paymentFields) : void
Parameters
$form : CRM_Core_Form
$paymentFields : array<string|int, mixed>

Array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors.


        
On this page

Search results