$this->_isBillingAddressRequiredForPayLater = CRM_Utils_Array::value('is_billing_required', $this->_values);
$this->assign('isBillingAddressRequiredForPayLater', $this->_isBillingAddressRequiredForPayLater);
}
-
- // We save the fact that the profile 'billing' is required on the payment form.
- // Currently pay-later is the only 'processor' that takes notice of this - but ideally
- // 1) it would be possible to select the minimum_billing_profile_id for the contribution form
- // 2) that profile_id would be set on the payment processor
- // 3) the payment processor would return a billing form that combines these user-configured
- // minimums with the payment processor minimums. This would lead to fields like 'postal_code'
- // only being on the form if either the admin has configured it as wanted or the processor
- // requires it.
- $this->assign('billing_profile_id', ($this->_isBillingAddressRequiredForPayLater ? 'billing' : ''));
-
}
/**
else {
throw new CRM_Core_Exception(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).'));
}
+
}
/**
CRM_Financial_Form_Payment::addCreditCardJs();
}
$this->assign('paymentProcessorID', $this->_paymentProcessorID);
+ // We save the fact that the profile 'billing' is required on the payment form.
+ // Currently pay-later is the only 'processor' that takes notice of this - but ideally
+ // 1) it would be possible to select the minimum_billing_profile_id for the contribution form
+ // 2) that profile_id would be set on the payment processor
+ // 3) the payment processor would return a billing form that combines these user-configured
+ // minimums with the payment processor minimums. This would lead to fields like 'postal_code'
+ // only being on the form if either the admin has configured it as wanted or the processor
+ // requires it.
+ $this->assign('billing_profile_id', (CRM_Utils_Array::value('is_billing_required', $this->_values) ? 'billing' : ''));
}
/**
/**
* This function checks to see if we have the right config values.
- *
- * @return string
- * the error message if any
*/
- public function checkConfig() {
- }
+ public function checkConfig() {}
/**
* Get billing fields required for this processor.
public function getPaymentTypeLabel() {
return '';
}
+
}
CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
// validate payment instrument values (e.g. credit card number)
- CRM_Core_Payment_Form::validatePaymentInstrument($self->_paymentProcessor['id'], $fields, $errors, $self);
+ CRM_Core_Payment_Form::validatePaymentInstrument($self->_paymentProcessor['id'], $fields, $errors, NULL);
}
return empty($errors) ? TRUE : $errors;
}
/**
+ * @todo this should surely go! Test & remove.
* @return bool
*/
public function validate() {
if (!empty($values['payment_processor_id'])) {
// make sure that payment instrument values (e.g. credit card number and cvv) are valid
- CRM_Core_Payment_Form::validatePaymentInstrument($values['payment_processor_id'], $values, $errorMsg, $self);
+ CRM_Core_Payment_Form::validatePaymentInstrument($values['payment_processor_id'], $values, $errorMsg, NULL);
}
if (!empty($values['record_contribution'])) {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
$this->_eventId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$this->_values['event']['campaign_id'] = $campID;
}
+ // Set the same value for is_billing_required as contribution page so code can be shared.
+ $this->_values['is_billing_required'] = CRM_Utils_Array::value('is_billing_required', $this->_values['event']);
// check if billing block is required for pay later
+ // note that I have started removing the use of isBillingAddressRequiredForPayLater in favour of letting
+ // the CRM_Core_Payment_Manual class handle it - but there are ~300 references to it in the code base so only
+ // removing in very limited cases.
if (CRM_Utils_Array::value('is_pay_later', $this->_values['event'])) {
$this->_isBillingAddressRequiredForPayLater = CRM_Utils_Array::value('is_billing_required', $this->_values['event']);
$this->assign('isBillingAddressRequiredForPayLater', $this->_isBillingAddressRequiredForPayLater);
// validate supplied payment instrument values (e.g. credit card number and cvv)
$payment_processor_id = $self->_params[0]['payment_processor'];
- CRM_Core_Payment_Form::validatePaymentInstrument($payment_processor_id, $self->_params[0], $errors, $self);
+ CRM_Core_Payment_Form::validatePaymentInstrument($payment_processor_id, $self->_params[0], $errors, (!$self->_isBillingAddressRequiredForPayLater ? NULL : 'billing'));
if (!empty($errors)) {
return FALSE;
//consider total amount.
$this->assign('isAmountzero', ($this->_totalAmount <= 0) ? TRUE : FALSE);
+ // @todo this needs to GO! We are getting rid of references to processor types in the code base in favour of
+ // over-ride-able functions on them.
+ // The processor effectively has a 'buildForm' hook it can use if it needs to.
+ // The tricky thing is that we have no way of testing this code out - perhaps it hasn't worked for years!
if ($this->_paymentProcessor['payment_processor_type'] == 'Google_Checkout' && empty($this->_params[0]['is_pay_later']) && !($this->_params[0]['amount'] == 0) &&
!$this->_allowWaitlist && !$this->_requireApproval
) {
/**
* This class generates form components for processing Event
- *
*/
class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
}
}
+ // @todo - can we remove the 'is_monetary' concept?
if ($self->_values['event']['is_monetary']) {
if (empty($self->_requireApproval) && !empty($fields['amount']) && $fields['amount'] > 0 && !isset
($fields['payment_processor_id'])) {
$errors['payment_processor_id'] = ts('Please select a Payment Method');
}
- // return if this is express mode
- if ($self->_paymentProcessor &&
- $self->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON
- ) {
- if (!empty($fields[$self->_expressButtonName . '_x']) || !empty($fields[$self->_expressButtonName . '_y']) ||
- CRM_Utils_Array::value($self->_expressButtonName, $fields)
- ) {
- return empty($errors) ? TRUE : $errors;
- }
- }
$isZeroAmount = $skipPaymentValidation = FALSE;
if (!empty($fields['priceSetId'])) {
$skipPaymentValidation = TRUE;
}
- // also return if paylater mode or zero fees for valid members
- if (!empty($fields['is_pay_later']) || !empty($fields['bypass_payment']) ||
+ // also return if zero fees for valid members
+ if (!empty($fields['bypass_payment']) ||
$skipPaymentValidation ||
(!$self->_allowConfirmation && ($self->_requireApproval || $self->_allowWaitlist))
) {
return empty($errors) ? TRUE : $errors;
}
- CRM_Core_Payment_Form::validatePaymentInstrument($self->_paymentProcessorID, $fields, $errors, $self);
+ CRM_Core_Payment_Form::validatePaymentInstrument(
+ $fields['payment_processor_id'],
+ $fields,
+ $errors,
+ (!$self->_isBillingAddressRequiredForPayLater ? NULL : 'billing')
+ );
}
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
// Add the pay-later pseudo-processor.
$processors['values'][0] = array(
- 'object' => new CRM_Core_Payment_Manual(),
+ 'object' => new CRM_Core_Payment_Manual(),
'id' => 0,
'payment_processor_type_id' => 0,
+ // This shouldn't be required but there are still some processors hacked into core with nasty 'if's.
+ 'payment_processor_type' => 'Manual',
'class_name' => 'Payment_Manual',
'name' => 'pay_later',
'billing_mode' => '',
if (!empty($params['payment_processor_id'])) {
// validate payment instrument (e.g. credit card number)
- CRM_Core_Payment_Form::validatePaymentInstrument($params['payment_processor_id'], $params, $errors, $self);
+ CRM_Core_Payment_Form::validatePaymentInstrument($params['payment_processor_id'], $params, $errors, NULL);
}
$joinDate = NULL;