I have created a payment module, following the devdocs approach by creating virtual types, request builder, transfer factory, the client (using Zend client - curl adapter) until validation handler for capture command.
After successful, the customer will be redirected back to Magento 2 store at specified URL (controller) with some response post data.
My current issues are since no location in the header, Zend client unable to do a redirect, thus I have to process the redirection to 3rd party gateway and halted the process in the middle from finishing the rest of client method placeRequest() up to response handler and validation. Now, since I have no choice but to receive the response data from the controller, I am not sure how to continue back from client up to validation and response handler.
From my gateway client, please check the comment section in the code:
Please advise, I have been in a circle for days, less sleep and its catching the dateline..
UPDATE: Found the answer. I will post later when I am free. Its just me that I dont understand the command gateway flow