Changed the service to throw an error if cdogs fails to generate the pdf or html. This error is caught by the controller which in turn is caught by the frontend which will let the user know that there was an error and that they were not charged.
In order to properly handle throwing errors to the frontend, the way the controller handles returning values needed to be changed to use the response object to directly.
The flow is now:
User requests to generate email/document
Nest generates the document, throwing an error if it gets one
If there are no errors, continue to the payment API
If the payment is successful, send the email or return the document.
Changed the service to throw an error if cdogs fails to generate the pdf or html. This error is caught by the controller which in turn is caught by the frontend which will let the user know that there was an error and that they were not charged.
In order to properly handle throwing errors to the frontend, the way the controller handles returning values needed to be changed to use the response object to directly.
The flow is now: