Custom Submit Handler to Integrate Payment Gateway in a Webform

I would like users filling up a webform in my site to make a payment before the form is submitted. The form should be submitted if the payment is successful else an error message should be displayed.

Is a custom submit handler with the payment gateways code/api in submitForm() a good way go about doing this?

Thanks for your help