[REF] extract internals of Payment.create into function on BAO class.
authoreileen <emcnaughton@wikimedia.org>
Sun, 30 Dec 2018 21:45:47 +0000 (10:45 +1300)
committereileen <emcnaughton@wikimedia.org>
Mon, 31 Dec 2018 00:19:34 +0000 (13:19 +1300)
commit5625fdf01ca99959f5761c768d75e6388decae6b
tree9d64455a78a5273b151dfbce0600b107fef17e4d
parent0e35e2aa2e0d33380f1ad8a1573ae9f76fe2d726
[REF] extract internals of Payment.create into function on BAO class.

This is a partial of https://github.com/civicrm/civicrm-core/pull/13330 - trying
to separate out the main code move from the changes. My only change was to change the name to
addPayment since that is what we are doing but here are some additionaly thoughts.

1) I'm inclined to put the class onto a new pseudo-bao CRM_Finanial_BAO_Payment. We already have this
pseudo-entity on the api level & it gives us a way to build up a place for the functions we are migrating
towards.

2) I think we should consider changing the input parameters to this function to be
- contributionID, total_amount & line_items or in some way limiting the parameters tha
t get passed through. We have historically gotten ourselves in trouble by
having people hacking in another parameter to go through whereas the strength of the api
is clear inputs & outputs. I note the api will need to support
'is_email_receipt' as will this fn & the CRM_Contribute_Form_AdditionalPayment::emailReceipt
should be moved off the form layer - possibly to our new BAO

3) I think the exceptions need to be CRM_Core_Exceptions if thrown in the BAO although this is kinda cosmetic

Change-Id: Ib5caf0d878e9c5cc735cb1a20c640f61da2dbfc6
CRM/Contribute/BAO/Contribution.php
api/v3/Payment.php