Admins / users with "access CiviPledge" and "edit Pledge" permission can either "Record Payment (Check, Cash, EFT) OR if an applicable payment processor is configured they can "Submit Credit/Debit Card Payment" for a pending pledge_payment record.
These actions are linked from the Pledge Payment selector (
CRM-3244) for each payment record with status = Pending or Overdue. The actions link to the following URL (including the Pledge Payment record Id = ppid):
mode=live is added for the Submit CC link
Modify the Contribution form code as follows:
- check for the pledge payment record ID (ppid) in the GET params
- make sure the referenced pledge payment record has status = Pending or Overdue
- default the following form values by retrieving them from the Pledge record associated with the referenced pledge payment: Contribution Type, Paid By (payment_instrument - but only if mode != live), Total Amount, Honoree Info fields
- freeze the Total Amount field (we force contribution amount to be equal to pledge_payment.amount)
- on completion of contribution processing, call a new function - updatePledgePaymentStatus( $statusId ) which does the following:
If "final" contribution status is "Completed"
- - update referenced Pledge Payment record status to Completed
- - check associated Pledge conditions and update Pledge status if needed :
- - - If ALL payments are completed, set Pledge status = Completed (value = 1 )
- - - If 1 or more payments are Overdue, set Pledge status = Overdue (value = 6 )
- - - Else set Pledge status = In Progress (value = 5 )
If "final" contribution status is "Pending"
- - no change is made to either the Pledge Payment of Pledge status.
NOTE: The above function should be able to handle being invoked from this form postProcess as well as from the cron-driven Pledge Status update script.