How to implement a conditional redirect to a payment gateway?

Hello,

I have a custom payment gateway module
Now I want to check one function in my gateway via soap(wsdl) and if response was OK then I redirect customers to gateway
What is your idea for this method ?

I have afterPlaceOrder in my js file include redirectUrl but it redirect customers without checking my function to my gateway directly

This is my flow

  1. Customer click on Place order
  2. Module check the function in wsdl URL via soap
  3. if response was OK then customers redirect to gateway URL
  4. all of above should be after create order