Skip to content
Snippets Groups Projects
Commit 2e271402 authored by Rich's avatar Rich
Browse files

Merge branch 'changesubscriptionamount' into 'main'

Standardisation/fix when calling changeSubscriptionAmount

See merge request extensions/upgraderecur!3
parents 30616fc2 af762699
No related branches found
No related tags found
No related merge requests found
......@@ -249,9 +249,14 @@ class UpdaterecurWorker {
public function changeSubscriptionAmount(array $changeActivity, array $recur, CRM_Core_Payment $paymentProcessorObject) :string {
// Old (current, as of 5.49) method
$message = '';
$newAmount = $changeActivity['updaterecur_activity_fields.updaterecur_new_amount'];
// contributionRecurID is the "correct" parameter per propertyBag, but it wasn't well defined before 5.70
// so we need to pass in id as well as some PaymentProcessors will expect that.
// Older payment processors will still expect `subscriptionId` which is really processor_id but we don't support that.
$paymentProcessorObject->changeSubscriptionAmount($message, [
'contributionRecurID' => $recur['id'],
'id' => $recur['id'],
'amount' => $changeActivity['updaterecur_activity_fields.updaterecur_new_amount'],
'amount' => $newAmount,
]);
// As it succeeded, we can update the ContributionRecur
......@@ -308,7 +313,7 @@ class UpdaterecurWorker {
->addSelect('id', 'qty', 'unit_price', 'line_total')
->execute();
if ($lineItems->count() >1) {
if ($lineItems->count() > 1) {
throw new CannotUpdateRecordsException(E::ts('The template contribution (id %3) for recurring contribution ID %1 includes %2 line items. This extension is not advanced enough to know which one to change!',
[
1 => $recurID,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment