class CRM_Core_Payment_Form

Class for constructing the payment processor block.

Methods

static 
setPaymentFieldsByProcessor(CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main $form, array $processor, int $billing_profile_id = NULL, bool $isBackOffice = FALSE, int $paymentInstrumentID = NULL)

Add payment fields depending on payment processor.

static 
setBillingAddressFields(CRM_Core_Form $form, CRM_Core_Payment $processor)

Add general billing fields.

static 
addCommonFields(CRM_Core_Form $form, array $paymentFields)

Add the payment fields to the template.

static array
getPaymentFields(array $paymentProcessor)

Get the payment fields that apply to this processor.

static array
getPaymentFieldMetadata(array $paymentProcessor)

No description

static array
getBillingAddressFields(array $paymentProcessor, int $billingLocationID)

Get the billing fields that apply to this processor.

static array
getBillingAddressMetadata(array $paymentProcessor, int $billingLocationID)

No description

static string
getPaymentTypeName(array $paymentProcessor)

No description

static string
getPaymentTypeLabel(array $paymentProcessor)

No description

static bool
buildPaymentForm(CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main|CRM_Core_Payment_ProcessorForm|CRM_Contribute_Form_UpdateBilling $form, array $processor, int|string $billing_profile_id, bool $isBackOffice, int $paymentInstrumentID = NULL)

No description

static 
addRules($form, $paymentFields)

No description

static 
validatePaymentInstrument(int $payment_processor_id, array $values, array $errors, int $billing_profile_id)

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

static 
getCreditCardCSSNames($creditCards = array())

The credit card pseudo constant results only the CC label, not the key ID So we normalize the name to use it as a CSS class.

static 
setDefaultValues(CRM_Core_Form $form, int $contactID)

Set default values for the form.

static 
validateCreditCard(array $values, array $errors, int $processorID = NULL)

Make sure that credit card number and cvv are valid.

static 
mapParams(int $id, array $src, array $dst, bool $reverse = FALSE)

Map address fields.

static int
getCreditCardExpirationMonth($src)

Get the credit card expiration month.

static int
getCreditCardExpirationYear($src)

Get the credit card expiration year.

Details

at line 58
static setPaymentFieldsByProcessor(CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main $form, array $processor, int $billing_profile_id = NULL, bool $isBackOffice = FALSE, int $paymentInstrumentID = NULL)

Add payment fields depending on payment processor.

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

CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main $form
array $processor Array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors.
int $billing_profile_id Display billing fields even for pay later.
bool $isBackOffice Is this a back office function? If so the option to suppress the cvn needs to be evaluated.
int $paymentInstrumentID ID of the payment processor.

at line 88
static protected setBillingAddressFields(CRM_Core_Form $form, CRM_Core_Payment $processor)

Add general billing fields.

Parameters

CRM_Core_Form $form
CRM_Core_Payment $processor

at line 116
static protected addCommonFields(CRM_Core_Form $form, array $paymentFields)

Add the payment fields to the template.

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

CRM_Core_Form $form Form that the payment fields are to be added to.
array $paymentFields Fields that are to be shown on the payment form.

at line 150
static array getPaymentFields(array $paymentProcessor)

Get the payment fields that apply to this processor.

Parameters

array $paymentProcessor

Return Value

array

at line 159
static array getPaymentFieldMetadata(array $paymentProcessor)

Parameters

array $paymentProcessor

Return Value

array

at line 175
static array getBillingAddressFields(array $paymentProcessor, int $billingLocationID)

Get the billing fields that apply to this processor.

Parameters

array $paymentProcessor
int $billingLocationID ID of billing location type.

Return Value

array

at line 187
static array getBillingAddressMetadata(array $paymentProcessor, int $billingLocationID)

Parameters

array $paymentProcessor
int $billingLocationID

Return Value

array

Exceptions

CRM_Core_Exception

at line 200
static string getPaymentTypeName(array $paymentProcessor)

Parameters

array $paymentProcessor

Return Value

string

at line 209
static string getPaymentTypeLabel(array $paymentProcessor)

Parameters

array $paymentProcessor

Return Value

string

at line 232
static bool buildPaymentForm(CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main|CRM_Core_Payment_ProcessorForm|CRM_Contribute_Form_UpdateBilling $form, array $processor, int|string $billing_profile_id, bool $isBackOffice, int $paymentInstrumentID = NULL)

Parameters

CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main|CRM_Core_Payment_ProcessorForm|CRM_Contribute_Form_UpdateBilling $form
array $processor Array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors.
int|string $billing_profile_id 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)
bool $isBackOffice 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'.
int $paymentInstrumentID Payment instrument ID.

Return Value

bool

at line 255
static protected addRules($form, $paymentFields)

Parameters

$form
$paymentFields

at line 280
static validatePaymentInstrument(int $payment_processor_id, array $values, array $errors, int $billing_profile_id)

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

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

int $payment_processor_id
array $values
array $errors
int $billing_profile_id

at line 290
static getCreditCardCSSNames($creditCards = array())

The credit card pseudo constant results only the CC label, not the key ID So we normalize the name to use it as a CSS class.

Parameters

$creditCards

at line 313
static setDefaultValues(CRM_Core_Form $form, int $contactID)

Set default values for the form.

Parameters

CRM_Core_Form $form
int $contactID

at line 339
static validateCreditCard(array $values, array $errors, int $processorID = NULL)

Make sure that credit card number and cvv are valid.

Called within the scope of a QF formRule function

Parameters

array $values
array $errors
int $processorID

at line 368
static mapParams(int $id, array $src, array $dst, bool $reverse = FALSE)

Map address fields.

Parameters

int $id
array $src
array $dst
bool $reverse

at line 406
static int getCreditCardExpirationMonth($src)

Get the credit card expiration month.

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

Parameters

$src

Return Value

int

at line 423
static int getCreditCardExpirationYear($src)

Get the credit card expiration year.

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

Return Value

int