diff --git a/CRM/Core/Payment/RecurOffline.php b/CRM/Core/Payment/RecurOffline.php
index 53e642a..a9ed738 100644
--- a/CRM/Core/Payment/RecurOffline.php
+++ b/CRM/Core/Payment/RecurOffline.php
@@ -7,16 +7,7 @@ class CRM_Core_Payment_RecurOffline extends CRM_Core_Payment {
protected $_mode = NULL;
- protected $_params = array();
-
- /**
- * We only need one instance of this object. So we use the singleton
- * pattern and cache the instance in this variable
- *
- * @var object
- * @static
- */
- static private $_singleton = NULL;
+ protected $_params = [];
/**
* Constructor
@@ -28,34 +19,15 @@ class CRM_Core_Payment_RecurOffline extends CRM_Core_Payment {
public function __construct($mode, &$paymentProcessor) {
$this->_mode = $mode;
$this->_paymentProcessor = $paymentProcessor;
- $this->_processorName = ts('Recurring Offline Placeholder Processor');
- }
-
- /**
- * singleton function used to manage this object
- *
- * @param string $mode the mode of operation: live or test
- *
- * @return object
- * @static
- *
- */
- static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) {
- $processorName = $paymentProcessor['name'];
- if (CRM_Utils_Array::value($processorName, self::$_singleton) === NULL) {
- self::$_singleton[$processorName] = new CRM_Core_Payment_RecurOffline($mode, $paymentProcessor);
- }
- return self::$_singleton[$processorName];
}
/**
- * @param array $params assoc array of input parameters for this transaction
+ * @param array|\Civi\Payment\PropertyBag $params
+ * @param string $component
*
- * @return array the result in a nice formatted array (or an error object)
- * @public
+ * @return array
*/
- function doDirectPayment(&$params) {
-
+ public function doPayment(&$params, $component = 'contribute') {
if ($this->_mode == 'test') {
$query = "SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id LIKE 'test\\_%'";
$p = array();
@@ -72,11 +44,11 @@ function doDirectPayment(&$params) {
$trxn_id = intval($trxn_id) + 1;
$params['trxn_id'] = sprintf('live_%08d', $trxn_id);
}
- $params['gross_amount'] = $params['amount'];
+ $params['payment_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
return $params;
}
- /**
+ /**
* Are back office payments supported.
*
* @return bool
diff --git a/CRM/Core/Payment/RecurOfflineACHEFT.php b/CRM/Core/Payment/RecurOfflineACHEFT.php
index b6d2a8e..785dfbf 100644
--- a/CRM/Core/Payment/RecurOfflineACHEFT.php
+++ b/CRM/Core/Payment/RecurOfflineACHEFT.php
@@ -7,16 +7,7 @@ class CRM_Core_Payment_RecurOfflineACHEFT extends CRM_Core_Payment {
protected $_mode = NULL;
- protected $_params = array();
-
- /**
- * We only need one instance of this object. So we use the singleton
- * pattern and cache the instance in this variable
- *
- * @var object
- * @static
- */
- static private $_singleton = NULL;
+ protected $_params = [];
/**
* Constructor
@@ -32,31 +23,12 @@ public function __construct($mode, &$paymentProcessor) {
}
/**
- * singleton function used to manage this object
- *
- * @param string $mode the mode of operation: live or test
- *
- * @return object
- * @static
+ * @param array|\Civi\Payment\PropertyBag $params
+ * @param string $component
*
+ * @return array
*/
- static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) {
- $processorName = $paymentProcessor['name'];
- if (CRM_Utils_Array::value($processorName, self::$_singleton) === NULL) {
- self::$_singleton[$processorName] = new CRM_Core_Payment_RecurOfflineACHEFT($mode, $paymentProcessor);
- }
- return self::$_singleton[$processorName];
- }
-
- /**
- *
- * @param array $params assoc array of input parameters for this transaction
- *
- * @return array the result in a nice formatted array (or an error object)
- * @public
- */
- function doDirectPayment(&$params) {
-
+ public function doPayment(&$params, $component = 'contribute') {
if ($this->_mode == 'test') {
$query = "SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id LIKE 'test\\_%'";
$p = array();
@@ -73,16 +45,16 @@ function doDirectPayment(&$params) {
$trxn_id = intval($trxn_id) + 1;
$params['trxn_id'] = sprintf('live_%08d', $trxn_id);
}
- $params['gross_amount'] = $params['amount'];
- $params['payment_status_id'] = 2;
+
+ $params['payment_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
return $params;
}
protected function getDirectDebitFormFields() {
return [];
}
-
- /**
+
+ /**
* Are back office payments supported.
*
* @return bool
diff --git a/CRM/Core/Payment/RecurOfflineBasic.php b/CRM/Core/Payment/RecurOfflineBasic.php
index e09d1d2..f61d801 100644
--- a/CRM/Core/Payment/RecurOfflineBasic.php
+++ b/CRM/Core/Payment/RecurOfflineBasic.php
@@ -13,8 +13,6 @@
class CRM_Core_Payment_RecurOfflineBasic extends CRM_Core_Payment {
- use CRM_Core_Payment_MJWTrait;
-
protected $_mode = NULL;
/**
@@ -88,19 +86,25 @@ public function getPaymentFormFieldsMetadata() {
* @param array|\Civi\Payment\PropertyBag $params
* @param string $component
*
- * @return array|\Civi\Payment\PropertyBag
+ * @return array
* @throws \CiviCRM_API3_Exception
*/
public function doPayment(&$params, $component = 'contribute') {
+ $propertyBag = \Civi\Payment\PropertyBag::cast($params);
+ if (!$propertyBag->has('isRecur')) {
+ // This defaults to false from 5.27 (https://github.com/civicrm/civicrm-core/pull/17452) so we can remove this when minVer = 5.27
+ $propertyBag->setIsRecur(FALSE);
+ }
+
// Set default contribution status
- $params['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
+ $returnParams['payment_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
- if (!empty($params['is_recur']) && !empty($this->getRecurringContributionId($params))) {
- $reference = CRM_Utils_Array::value('reference_id', $params);
+ if ($propertyBag->getIsRecur() && $propertyBag->getContributionRecurID()) {
+ $reference = $propertyBag->getCustomProperty('reference_id');
if ($reference) {
// Save the external reference
$recurParams = [
- 'id' => $this->getRecurringContributionId($params),
+ 'id' => $propertyBag->getContributionRecurID(),
'trxn_id' => $reference,
'processor_id' => $reference,
];
@@ -109,11 +113,7 @@ public function doPayment(&$params, $component = 'contribute') {
}
// We always complete the first contribution as we are "adding" it.
- $params['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
- // We need to set this to ensure that contributions are set to the correct status
- if (!empty($params['contribution_status_id'])) {
- $params['payment_status_id'] = $params['contribution_status_id'];
- }
+ $returnParams['payment_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
return $params;
}
@@ -136,5 +136,30 @@ function checkConfig() {
return NULL;
}
+ /**
+ * Does this processor support cancelling recurring contributions through code.
+ *
+ * If the processor returns true it must be possible to take action from within CiviCRM
+ * that will result in no further payments being processed.
+ *
+ * @return bool
+ */
+ protected function supportsCancelRecurring() {
+ return TRUE;
+ }
+
+ /**
+ * Does the processor support the user having a choice as to whether to cancel the recurring with the processor?
+ *
+ * If this returns TRUE then there will be an option to send a cancellation request in the cancellation form.
+ *
+ * This would normally be false for processors where CiviCRM maintains the schedule.
+ *
+ * @return bool
+ */
+ protected function supportsCancelRecurringNotifyOptional() {
+ return FALSE;
+ }
+
}
diff --git a/info.xml b/info.xml
index da05ece..f50e22c 100644
--- a/info.xml
+++ b/info.xml
@@ -13,11 +13,11 @@
https://mjw.pt/support/contributionrecur
http://www.gnu.org/licenses/agpl-3.0.html
- 2020-04-08
- 1.4
+ 2020-07-07
+ 1.5
stable
- 5.19
+ 5.24
mjwshared