Is it possible to stop a webform form during submission? The webform module is being used for a form that takes a payment. The data is validated as much as it can and then in a submit handler it is finally sent to the payment processor.

The result can be a failure (wrong card number, or no funds etc.), which should result in the form being re-presented giving the user the opportunity to check their fat fingers didn't type in the wrong card details, try another card etc.

In a vanilla Drupal form I could do a $form_state['redirect'] = FALSE; and it would return the form as-is, but this does not work when working within webform because it deals with that itself.

So this is a weird one because it's basically validation done in a submit handler. This is because we need to make sure everything's valid before submitting it to the third party, but there are clearly two ways to frame this question:


As the title says, is it possible for a submit handler to tell webform to stay on this page and not consider it complete?

or
If I move the submission code into a validation handler, how can I ensure my validation handler happens after all the others, and then check that there aren't any other validation errors before I proceed with the payment submission?
First is I'm not sure if it's best practice to do validations in the submit handler because as you've said, you need to validate first. So I can only answer your second question.
To make your validation run after every validation present for that form, you need to add it in the end of the #validate attribute. Example is like:
$form['submit']['#validate'][] = 'your_last_needed_validation_func';
To check if there are validation errors before your validation function, you can use the form_get_errors function.