1

Scenario is a membership / subscription. The amount to be charged has increased.

Does this require the amount to be updated just at the PayPal end, or are changes also needed at the civi end to ensure that the new amount is specified in the receipt which civi sends out

1 Answer 1

3

Depends upon the recurring contribution, if the recurring contribution has a single line item for membership type than its not needed if not then yes its needed so that the line items for subsequent payment are added correctly.

How I did for Paypal Standard is

  1. Updated the subscription amount at Paypal.

  2. Using sql queries

    2.1 Update the total_amount in contribution recur table

For Single Line item:

1. Find for the template contribution: 
     SELECT id FROM civicrm_contribution 
     WHERE contribution_recur_id = 123
       AND is_template = 1
     ORDER BY id DESC
2. If found update the total_amount field for the contribution and line item line total
    UPDATE civicrm_contribution
    SET total_amount = 100
    WHERE id = 122;

    UPDATE civicrm_line_item
    SET line_total = 100
    WHERE contribution_id = 122;
3. Incase there isn't the template contribution create one using the last contribution for recurring contribution and also line item.
     SELECT id FROM civicrm_contribution 
     WHERE contribution_recur_id = 123
     ORDER BY id DESC;

For Multiple Line item:

1. Find for the template contribution: 
     SELECT id FROM civicrm_contribution 
     WHERE contribution_recur_id = 123
       AND is_template = 1
     ORDER BY id DESC
2. If found update the total_amount field for the contribution and line item line total
    UPDATE civicrm_contribution
    SET total_amount = 120
    WHERE id = 122;

    UPDATE civicrm_line_item
    SET line_total = 100
    WHERE contribution_id = 122 AND membership_type_id = 2; 

3. Incase there isn't the template contribution create one using the last contribution for recurring contribution and also line item.
     SELECT id FROM civicrm_contribution 
     WHERE contribution_recur_id = 123
     ORDER BY id DESC;

HTH

Pradeep

2
  • Thanks. a) Both step 3's are missing something: there is nothing created, just an id is found. b) is not possible (and safer) to do this via API? If not, that seems like a gap in the API.
    – Aidan
    Jan 28, 2022 at 6:53
  • It may be possible to use API4 to do above as per my queries but you wont be able to do using api3. Also it would be any problem if we use COntribution api3 or api4 incase of single line item. But multiple line item i doubt hence i choose sql queries Jan 28, 2022 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.