Thank you. I have added some code to the pp_confirm.php page to create a unique discount code to be sent out via email for all customers (for a 5% discount on their next purchase). It also inserts this code into the couponcodeuser table. I have also added a delete server behavior to the page - to delete the code from the database once it has been used.
However I have obviously done something wrong because it now only goes to the checkout_failure.php page