return FALSE;
}
+ /**
+ * Does this processor support pre-approval.
+ *
+ * This would generally look like a redirect to enter credentials which can then be used in a later payment call.
+ *
+ * Currently Paypal express supports this, with a redirect to paypal after the 'Main' form is submitted in the
+ * contribution page. This token can then be processed at the confirm phase. Although this flow 'looks' like the
+ * 'notify' flow a key difference is that in the notify flow they don't have to return but in this flow they do.
+ *
+ * @return bool
+ */
+ protected function supportsPreApproval() {
+ return FALSE;
+ }
+
+ /**
+ * Can recurring contributions be set against pledges.
+ *
+ * In practice all processors that use the baseIPN function to finish transactions or
+ * call the completetransaction api support this by looking up previous contributions in the
+ * series and, if there is a prior contribution against a pledge, and the pledge is not complete,
+ * adding the new payment to the pledge.
+ *
+ * However, only enabling for processors it has been tested against.
+ *
+ * @return bool
+ */
+ protected function supportsRecurContributionsForPledges() {
+ return FALSE;
+ }
+
+ /**
+ * Function to action pre-approval if supported
+ *
+ * @param array $params
+ * Parameters from the form
+ *
+ * This function returns an array which should contain
+ * - pre_approval_parameters (this will be stored on the calling form & available later)
+ * - redirect_url (if set the browser will be redirected to this.
+ */
+ public function doPreApproval(&$params) {}
+
+ /**
+ * Get any details that may be available to the payment processor due to an approval process having happened.
+ *
+ * In some cases the browser is redirected to enter details on a processor site. Some details may be available as a
+ * result.
+ *
+ * @param array $storedDetails
+ *
+ * @return array
+ */
+ public function getPreApprovalDetails($storedDetails) {
+ return array();
+ }
+
/**
* Default payment instrument validation.
*
return FALSE;
}
+ /**
+ * Does this processor support pre-approval.
+ *
+ * This would generally look like a redirect to enter credentials which can then be used in a later payment call.
+ *
+ * Currently Paypal express supports this, with a redirect to paypal after the 'Main' form is submitted in the
+ * contribution page. This token can then be processed at the confirm phase. Although this flow 'looks' like the
+ * 'notify' flow a key difference is that in the notify flow they don't have to return but in this flow they do.
+ *
+ * @return bool
+ */
+ protected function supportsPreApproval() {
+ if ($this->_processorName == ts('PayPal Express')) {
+ return TRUE;
+ }
+ 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);
+ if ($this->_processorName == 'PayPal Express') {
+ CRM_Core_Region::instance('billing-block-post')->add(array(
+ 'template' => 'CRM/Financial/Form/PaypalExpress.tpl',
+ 'name' => 'paypal_express',
+ ));
+ }
+ if ($this->_processorName == 'PayPal Pro') {
+ CRM_Core_Region::instance('billing-block-pre')->add(array(
+ 'template' => 'CRM/Financial/Form/PaypalPro.tpl',
+ ));
+ }
+ }
+ 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 function addPaypalExpressCode(&$form) {
+ if (empty($form->isBackOffice)) {
+ $form->_expressButtonName = $form->getButtonName('upload', 'express');
+ $form->assign('expressButtonName', $form->_expressButtonName);
+ $form->add(
+ 'image',
+ $form->_expressButtonName,
+ $this->_paymentProcessor['url_button'],
+ array('class' => 'crm-form-submit')
+ );
+ }
+ }
+
+ /**
+ * Can recurring contributions be set against pledges.
+ *
+ * In practice all processors that use the baseIPN function to finish transactions or
+ * call the completetransaction api support this by looking up previous contributions in the
+ * series and, if there is a prior contribution against a pledge, and the pledge is not complete,
+ * adding the new payment to the pledge.
+ *
+ * However, only enabling for processors it has been tested against.
+ *
+ * @return bool
+ */
+ protected function supportsRecurContributionsForPledges() {
+ return TRUE;
+ }
+
/**
* Express checkout code. Check PayPal documentation for more information
*
* @return array
*/
public static function getAllPaymentProcessors($mode, $reset = FALSE) {
- /*
- * $cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . ($mode ? 'test' : 'all');
- * if (!$reset) {
- * $processors = CRM_Utils_Cache::singleton()->get($cacheKey);
- * if (!empty($processors)) {
- * return $processors;
- * }
- * }
- */
+
+ $cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . ($mode ? 'test' : 'all');
+ if (!$reset) {
+ $processors = CRM_Utils_Cache::singleton()->get($cacheKey);
+ if (!empty($processors)) {
+ return $processors;
+ }
+ }
+
$retrievalParameters = array(
'is_active' => TRUE,
+ 'domain_id' => CRM_Core_Config::domainID(),
'options' => array('sort' => 'is_default DESC, name'),
'api.payment_processor_type.getsingle' => 1,
);
LEFT JOIN civicrm_price_set ps ON ps.id = pf.price_set_id
LEFT JOIN civicrm_membership_type mt ON mt.id = pfv.membership_type_id
WHERE ps.id = %1
- $autoRenew = array();
- //FIXME: do a comprehensive check of whether
- //2 membership types can be selected
- //instead of comparing all of them
+ ";
+
+ $params = array(1 => array($id, 'Integer'));
+ $dao = CRM_Core_DAO::executeQuery($query, $params);
+
- //temp fix for #CRM-10370
- //if its NULL consider it '0' i.e. 'No auto-renew option'
- $daoAutoRenew = $dao->auto_renew;
- if ($daoAutoRenew === NULL) {
- $daoAutoRenew = 0;
++ $membershipTypes = array(
++ 'all' => array(),
++ 'autorenew' => array(),
++ 'autorenew_required' => array(),
++ 'autorenew_optional' => array(),
++ );
+ while ($dao->fetch()) {
- if (!empty($autoRenew) && !in_array($daoAutoRenew, $autoRenew)) {
- return TRUE;
++ if (empty($dao->membership_type_id)) {
++ continue;
+ }
- $autoRenew[] = $daoAutoRenew;
++ $membershipTypes['all'][] = $dao->membership_type_id;
++ if (!empty($dao->auto_renew)) {
++ $membershipTypes['autorenew'][] = $dao->membership_type_id;
++ if ($dao->auto_renew == 2) {
++ $membershipTypes['autorenew_required'][] = $dao->membership_type_id;
++ }
++ else {
++ $membershipTypes['autorenew_optional'][] = $dao->membership_type_id;
++ }
++ }
++ else {
++ $membershipTypes['non_renew'][] = $dao->membership_type_id;
+ }
- return FALSE;
+ }
++ return $membershipTypes;
+ }
+
+ /**
+ * Get an array of the membership types in a price set.
+ *
+ * @param int $id
+ *
+ * @return array(
+ * Membership types in the price set
+ */
+ public static function getMembershipTypesFromPriceSet($id) {
+ $query
+ = "SELECT pfv.id, pfv.price_field_id, pfv.name, pfv.membership_type_id, pf.html_type, mt.auto_renew
+ FROM civicrm_price_field_value pfv
+ LEFT JOIN civicrm_price_field pf ON pf.id = pfv.price_field_id
+ LEFT JOIN civicrm_price_set ps ON ps.id = pf.price_set_id
+ LEFT JOIN civicrm_membership_type mt ON mt.id = pfv.membership_type_id
+ WHERE ps.id = %1
";
$params = array(1 => array($id, 'Integer'));
|| $activityTypeFile EQ 'ChangeCaseStartDate'}
{include file="CRM/Case/Form/Activity/$activityTypeFile.tpl"}
<tr class="crm-case-activity-form-block-details">
- <td class="label">{ts}Notes{/ts}</td>
+ <td class="label">{ts}Details{/ts}</td>
<td class="view-value">
- {* If using plain textarea, assign class=huge to make input large enough. *}
- {if $defaultWysiwygEditor eq 0}{$form.details.html|crmAddClass:huge}{else}{$form.details.html}{/if}
+ {$form.details.html}
</td>
</tr>
{* Added Activity Details accordion tab *}