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

Provide more granular self-serve options #337

Merged
merged 1 commit into from
Oct 27, 2020
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
22 changes: 9 additions & 13 deletions CRM/Core/Payment/Faps.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,13 @@ public function buildForm(&$form) {
*
* @return bool
*/
protected function allowSelfService() {
protected function allowSelfService($action) {
if ('CRM_Core_Payment_FapsACH' == CRM_Utils_System::getClassName($this)) {
return FALSE;
}
elseif (!CRM_Core_Permission::check('access CiviContribution')) {
// disable self-service update of billing info if the admin has not allowed it
if (FALSE == $this->getSettings('enable_update_subscription_billing_info')) {
return FALSE;
}
elseif (FALSE == $this->getSettings('enable_'.$action)) {
// disable self-service action if the admin has not allowed it
return FALSE;
}
return TRUE;
}
Expand All @@ -239,22 +237,20 @@ public function supportsFutureRecurStartDate() {
* @return bool
*/

/* always allow default ability to update subscription billing info
public function supportsUpdateSubscriptionBillingInfo() {
return $this->allowSelfService();
public function supportsUpdateSubscriptionBillingInfo() {
return $this->allowSelfService('update_subscription_billing_info');
}
*/

public function supportsEditRecurringContribution() {
return $this->allowSelfService();
return $this->allowSelfService('change_subscription_amount');
}

public function supportsChangeSubscriptionAmount() {
return $this->allowSelfService();
return $this->allowSelfService('change_subscription_amount');
}

public function supportsCancelRecurring() {
return $this->allowSelfService();
return $this->allowSelfService('cancel_recurring');
}

/**
Expand Down
21 changes: 9 additions & 12 deletions CRM/Core/Payment/iATSService.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,13 @@ public function isSupported($method) {
*
* @return bool
*/
protected function allowSelfService() {
protected function allowSelfService($action) {
if ('CRM_Core_Payment_iATSServiceACHEFT' == CRM_Utils_System::getClassName($this)) {
return FALSE;
}
elseif (!CRM_Core_Permission::check('access CiviContribution')) {
// disable self-service update of billing info if the admin has not allowed it
if (FALSE == $this->getSettings('enable_update_subscription_billing_info')) {
return FALSE;
}
elseif (FALSE == $this->getSettings('enable_'.$action)) {
// disable self-service 'action' if the admin has not allowed it
return FALSE;
}
return TRUE;
}
Expand All @@ -147,22 +145,21 @@ public function supportsFutureRecurStartDate() {
*
* @return bool
*/
/* always allow default ability to update subscription billing info

public function supportsUpdateSubscriptionBillingInfo() {
return $this->allowSelfService();
return $this->allowSelfService('update_subscription_billing_info');
}
*/

public function supportsEditRecurringContribution() {
return $this->allowSelfService();
return $this->allowSelfService('change_subscription_amount');
}

public function supportsChangeSubscriptionAmount() {
return $this->allowSelfService();
return $this->allowSelfService('change_subscription_amount');
}

public function supportsCancelRecurring() {
return $this->allowSelfService();
return $this->allowSelfService('cancel_recurring');
}

/**
Expand Down
12 changes: 12 additions & 0 deletions CRM/Iats/Form/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ public function buildQuickForm() {
ts('Enable self-service updates to recurring contribution Contact Billing Info.')
);

$this->add(
'checkbox',
'enable_change_subscription_amount',
ts('Allow self-service updates to recurring contribution amount.')
);

$this->add(
'checkbox',
'enable_cancel_recurring',
ts('Enable self-service cancellation of a recurring contribution.')
);

/* These checkboxes are not yet implemented, ignore for now
$this->add(
'checkbox', // field type
Expand Down