Not 100% sure about bringing this (existing override) to the fore as opposed to a more granular one
but it does already exist?. The biggest problem is the temptation to do lots of altering from there which
might not be upgrade proof - as opposed to just addition as per here
return $object;
}
+ /**
+ * Opportunity for the payment processor to override the entire form build.
+ *
+ * @param CRM_Core_Form $form
+ *
+ * @return bool
+ * Should form building stop at this point?
+ */
+ public function buildForm(&$form) {
+ return FALSE;
+ }
+
/**
* Log payment notification message to forensic system log.
*
// $processor->buildForm appears to be an undocumented (possibly unused) option for payment processors
// which was previously available only in some form flows
if (!empty($form->_paymentProcessor) && !empty($form->_paymentProcessor['object']) && $form->_paymentProcessor['object']->isSupported('buildForm')) {
- $form->_paymentProcessor['object']->buildForm($form);
- return NULL;
+ if ($form->_paymentProcessor['object']->buildForm($form)) {
+ return NULL;
+ }
}
+
self::setPaymentFieldsByProcessor($form, $processor, empty($isBillingDataOptional));
self::addCommonFields($form, !$isBillingDataOptional, $form->_paymentFields);
self::addRules($form, $form->_paymentFields);
- self::addPaypalExpressCode($form);
return (!empty($form->_paymentFields));
}
}
}
- /**
- * Billing mode button is basically synonymous with paypal express - this is probably a good example of 'odds & sods' code we
- * need to find a way for the payment processor to assign. A tricky aspect is that the payment processor may need to set the order
- *
- * @param $form
- */
- protected static function addPaypalExpressCode(&$form) {
- if (empty($form->isBackOffice)) {
- if (CRM_Utils_Array::value('billing_mode', $form->_paymentProcessor) == 3
- ) {
- $form->_expressButtonName = $form->getButtonName('upload', 'express');
- $form->assign('expressButtonName', $form->_expressButtonName);
- $form->add('image',
- $form->_expressButtonName,
- $form->_paymentProcessor['url_button'],
- array('class' => 'crm-form-submit')
- );
- }
- }
- }
-
/**
* Validate the payment instrument values before passing it to the payment processor
* We want this to be overrideable by the payment processor, and default to using
return FALSE;
}
+ /**
+ * Opportunity for the payment processor to override the entire form build.
+ *
+ * @param CRM_Core_Form $form
+ *
+ * @return bool
+ * Should form building stop at this point?
+ */
+ public function buildForm(&$form) {
+ if ($this->_processorName == 'PayPal Express' || $this->_processorName == 'PayPal Pro') {
+ $this->addPaypalExpressCode($form);
+ }
+ return FALSE;
+ }
+
+ /**
+ * Billing mode button is basically synonymous with paypal express - this is probably a good example of 'odds & sods' code we
+ * need to find a way for the payment processor to assign. A tricky aspect is that the payment processor may need to set the order
+ *
+ * @param $form
+ */
+ protected static function addPaypalExpressCode(&$form) {
+ if (empty($form->isBackOffice)) {
+ $form->_expressButtonName = $form->getButtonName('upload', 'express');
+ $form->assign('expressButtonName', $form->_expressButtonName);
+ $form->add(
+ 'image',
+ $form->_expressButtonName,
+ $form->_paymentProcessor['url_button'],
+ array('class' => 'crm-form-submit')
+ );
+ }
+ }
+
/**
* Express checkout code. Check PayPal documentation for more information
*
</script>
{/if}
{/crmRegion}
+{crmRegion name="billing-block-post"}
+ {* Payment processors sometimes need to append something to the end of the billing block. We create a region for
+ clarity - the plan is to move to assigning this through the payment processor to this region *}
+ {include file= "CRM/Financial/Form/PaypalExpress.tpl"}
+{/crmRegion}
-{if $is_monetary}
- {crmRegion name="billing-block-post"}
- {* Payment processors sometimes need to append something to the end of the billing block. We create a region for
- clarity - the plan is to move to assigning this through the payment processor to this region *}
- {include file= "CRM/Financial/Form/PaypalExpress.tpl"}
- {/crmRegion}
-{/if}