Skip to content

Commit

Permalink
Merge pull request iATSPayments#337 from iATSPayments/configurable-se…
Browse files Browse the repository at this point in the history
…lf-serve

Provide more granular self-serve options
  • Loading branch information
adixon authored Oct 27, 2020
2 parents c54b185 + 9758227 commit f6056f1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
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

0 comments on commit f6056f1

Please sign in to comment.