From ba863924dcb488836bb739231ff53eedeb9e4263 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Sat, 3 Apr 2021 18:06:00 +0100 Subject: [PATCH] Add installments to propertyBag --- Civi/Payment/PropertyBag.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Civi/Payment/PropertyBag.php b/Civi/Payment/PropertyBag.php index 06f96d42fa..daf716c7c0 100644 --- a/Civi/Payment/PropertyBag.php +++ b/Civi/Payment/PropertyBag.php @@ -62,6 +62,8 @@ class PropertyBag implements \ArrayAccess { 'frequency_interval' => 'recurFrequencyInterval', 'recurFrequencyUnit' => TRUE, 'frequency_unit' => 'recurFrequencyUnit', + 'recurInstallments' => TRUE, + 'installments' => 'recurInstallments', 'subscriptionId' => 'recurProcessorID', 'recurProcessorID' => TRUE, 'transactionID' => TRUE, @@ -990,6 +992,31 @@ class PropertyBag implements \ArrayAccess { return $this->set('recurFrequencyUnit', $label, $recurFrequencyUnit); } + /** + * @param string $label + * + * @return int + */ + public function getRecurInstallments($label = 'default') { + return $this->get('recurInstallments', $label); + } + + /** + * @param int $recurInstallments + * @param string $label + * + * @return \Civi\Payment\PropertyBag + * @throws \CRM_Core_Exception + */ + public function setRecurInstallments($recurInstallments, $label = 'default') { + // Counts zero as positive which is ok - means no installments + if (!\CRM_Utils_Type::validate($recurInstallments, 'Positive')) { + throw new InvalidArgumentException('recurInstallments must be 0 or a positive integer'); + } + + return $this->set('recurInstallments', $label, (int) $recurInstallments); + } + /** * Set the unique payment processor service provided ID for a particular subscription. * -- 2.25.1