Details
-
Type: Improvement
-
Status: Done/Fixed
-
Priority: Trivial
-
Resolution: Fixed/Completed
-
Affects Version/s: 2.2.8
-
Fix Version/s: 2.2.8
-
Component/s: None
-
Labels:None
Description
At the point where hook_civicrm_post is run for new contributions (through Contribute/Form/Contribution/Confirm.php), the financial data hasn't yet been saved to the financial_trxn table. $transaction->commit is called right at the end of processContribution() in Confirm.php, whereas CRM_Contribute_BAO_Contribution::add() is called midway down that function, which is where the post hook is fired and, the financial record is not written until right before the commit, after the call to the hook.
This means that the full details of the transaction are not available in hook_civicrm_post, making it impossible to for example, use this hook to send details of the transaction to another system via SOAP.
As a fix, I suggest altering processContribution in Confirm.php to pass in the extra details to CRM_Contribute_BAO_Contribution::add(). The details would still be stored in the financial_trxn table, but they would also be available immediately in the new $contribution object, and hence, in hook_civicrm_post()