I'm using hook_form_alter() to perform calculations on various contributions on a civicrm_webform. I'd like to use the totals of these calculations to update the contribution amount and event amounts rather than use civicrm_webform's postprocessing.
What is the best way to do this? Can I overwrite the CiviCRM totals through the API?