Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show recurring contribution links based on payment processor capabilities #12821

Merged
merged 1 commit into from
Oct 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions CRM/Contribute/Page/Tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,29 @@ public static function &recurLinks($recurID = FALSE, $context = 'contribution')
if ($recurID) {
$links = self::$_links;
$paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($recurID, 'recur', 'obj');
if (is_object($paymentProcessorObj) && $paymentProcessorObj->supports('cancelRecurring')) {
if (!is_object($paymentProcessorObj)) {
unset($links[CRM_Core_Action::DISABLE]);
unset($links[CRM_Core_Action::UPDATE]);
return $links;
}
if ($paymentProcessorObj->supports('cancelRecurring')) {
unset($links[CRM_Core_Action::DISABLE]['extra'], $links[CRM_Core_Action::DISABLE]['ref']);
$links[CRM_Core_Action::DISABLE]['url'] = "civicrm/contribute/unsubscribe";
$links[CRM_Core_Action::DISABLE]['qs'] = "reset=1&crid=%%crid%%&cid=%%cid%%&context={$context}";
}

if (is_object($paymentProcessorObj) && $paymentProcessorObj->isSupported('updateSubscriptionBillingInfo')) {
if ($paymentProcessorObj->supports('UpdateSubscriptionBillingInfo')) {
$links[CRM_Core_Action::RENEW] = array(
'name' => ts('Change Billing Details'),
'title' => ts('Change Billing Details'),
'url' => 'civicrm/contribute/updatebilling',
'qs' => "reset=1&crid=%%crid%%&cid=%%cid%%&context={$context}",
);
}

if (!$paymentProcessorObj->supports('ChangeSubscriptionAmount') && !$paymentProcessorObj->supports('EditRecurringContribution')) {
unset($links[CRM_Core_Action::UPDATE]);
}
return $links;
}

Expand Down Expand Up @@ -251,13 +260,6 @@ private function buildRecurringContributionsArray($recurContributions) {
}

if ($recurContributions[$recurId]['is_active']) {
$details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recurContributions[$recurId]['id'], 'recur');
$hideUpdate = $details->membership_id & $details->auto_renew;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattwire this PR makes sense to me with an exception about the doubts of this one line. It seems the intention of this line was to suppress the editing in the case where auto_renew is set (although the use of a bitwise operator is confusing!).

This is described as.

'Some systems allow contributor to set a number of installments - but then auto-renew the subscription or commitment if they do not cancel.'

TBH I can barely understand what that means & the code rarely helps! However it seems the issue is not that it is being suppressed for memberships per se but that it is being suppressed for auto_renew memberships. So we need to try to figure out what the impact of auto_renew is....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this is kind of a "change" but it was already agreed and implemented in https://issues.civicrm.org/jira/browse/CRM-21512 ... It's just we missed this bit. You have been able to navigate directly to the "Edit recurring contribution" page since CRM-21512 was implemented (4.7.30) but the link was not being displayed next to the recurring contribution because of this bit of code.

What it actually means is:

  • BEFORE: Core did not allow editing a recurring contribution if linked to a membership.
  • AFTER: Core does not restrict editing a recurring contribution if linked to a membership.

The "auto_renew" really just means the membership has an associated recurring contribution.


if ($hideUpdate) {
$action -= CRM_Core_Action::UPDATE;
}

$recurContributions[$recurId]['action'] = CRM_Core_Action::formLink(self::recurLinks($recurId), $action,
array(
'cid' => $this->_contactId,
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Contribute/Form/UpdateSubscription.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div class="help">
{$changeHelpText}
{if $recurMembership}
<br/><strong> {ts}'WARNING: This recurring contribution is linked to membership:{/ts}
<br/><strong> {ts}WARNING: This recurring contribution is linked to membership:{/ts}
<a class="crm-hover-button" href='{crmURL p="civicrm/contact/view/membership" q="action=view&reset=1&cid=`$contactId`&id=`$recurMembership.membership_id`&context=membership&selectedChild=member"}'>{$recurMembership.membership_name}</a>
</strong>
{/if}
Expand Down