Payment verification on Web Forms

I have a webform which is connected with Razorpay for collecting payment from the user. How is the payment verified by Frappe? i assume the record is created in the doctype as soon as the user submits the form before going to the payment gateway. Or is it like, the record is created only for the successful paid forms?

I have seen the multiple records from the same user, for eg., he submits the form and his payment fails, and he tries again. Each try is created as a record in the system. How can we differentiate if the submission is paid or not?