| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
-use Civi\Payment\PropertyBag;
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC https://civicrm.org/licensing
- */
+use Civi\Payment\PropertyBag;
/**
* This class provides support for canceling recurring subscriptions.
protected $_mode = NULL;
+ /**
+ * The contributor email
+ *
+ * @var string
+ */
+ protected $_donorEmail = '';
+
/**
* Should custom data be suppressed on this form.
*
'frequency_interval' => $this->getSubscriptionDetails()->frequency_interval,
'frequency_unit' => $this->getSubscriptionDetails()->frequency_unit,
'installments' => $this->getSubscriptionDetails()->installments,
+ 'selfService' => $this->isSelfService(),
];
if ($this->_crid) {
public function buildQuickForm() {
$this->buildQuickEntityForm();
// Determine if we can cancel recurring contribution via API with this processor
- $cancelSupported = $this->_paymentProcessorObj->supports('CancelRecurring');
- if ($cancelSupported) {
+ if ($this->_paymentProcessorObj->supports('CancelRecurringNotifyOptional')) {
$searchRange = [];
$searchRange[] = $this->createElement('radio', NULL, NULL, ts('Yes'), '1');
$searchRange[] = $this->createElement('radio', NULL, NULL, ts('No'), '0');
$searchRange,
'send_cancel_request',
ts('Send cancellation request to %1 ?',
- [1 => $this->_paymentProcessorObj->_processorName])
+ [1 => $this->_paymentProcessorObj->getTitle()])
);
}
else {
$this->assign('cancelRecurNotSupportedText', $this->_paymentProcessorObj->getText('cancelRecurNotSupportedText', []));
}
- $this->assign('cancelSupported', $cancelSupported);
- if ($this->_donorEmail) {
- $this->add('checkbox', 'is_notify', ts('Notify Contributor?'));
+ if (!empty($this->_donorEmail)) {
+ $this->add('checkbox', 'is_notify', ts('Notify Contributor?') . " ({$this->_donorEmail})");
}
if ($this->_mid) {
$cancelButton = ts('Cancel Automatic Membership Renewal');
/**
* Process the form submission.
+ *
+ * @throws \CRM_Core_Exception
*/
public function postProcess() {
$message = NULL;
$params['send_cancel_request'] = 1;
}
- if ($this->_donorEmail) {
+ if (!empty($this->_donorEmail)) {
$params['is_notify'] = 1;
}
}
- if (CRM_Utils_Array::value('send_cancel_request', $params) == 1) {
- try {
- $propertyBag = new PropertyBag();
- $propertyBag->setContributionRecurID($this->getSubscriptionDetails()->recur_id);
- $propertyBag->setRecurProcessorID($this->getSubscriptionDetails()->subscription_id);
- $message = $this->_paymentProcessorObj->doCancelRecurring($propertyBag)['message'];
- }
- catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
- CRM_Core_Error::statusBounce($e->getMessage());
+ try {
+ $propertyBag = new PropertyBag();
+ if (isset($params['send_cancel_request'])) {
+ $propertyBag->setIsNotifyProcessorOnCancelRecur(!empty($params['send_cancel_request']));
}
+ $propertyBag->setContributionRecurID($this->getSubscriptionDetails()->recur_id);
+ $propertyBag->setRecurProcessorID($this->getSubscriptionDetails()->processor_id);
+ $message = $this->_paymentProcessorObj->doCancelRecurring($propertyBag)['message'];
+ }
+ catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
+ CRM_Core_Error::statusBounce($e->getMessage());
}
if ($cancelSubscription) {