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

Add installments to propertyBag #20023

Merged
merged 1 commit into from
Apr 11, 2021
Merged
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
27 changes: 27 additions & 0 deletions Civi/Payment/PropertyBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -990,6 +992,31 @@ public function setRecurFrequencyUnit($recurFrequencyUnit, $label = 'default') {
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.
*
Expand Down