multiple http POST in magento extension
I am creating a payment extension for magento and I have utiizar an API that uses 3 steps of communication. That is, I send an HTTP Post, receive information from the gateway, insert customer information, realize another HTTP POST, and finally, after generating the client choose the number of parcels and realize a final HTTP POST to confirm the transaction.
I've created my payment extension but how do the three HTTP post if the form of payment step allows me to submit one. Can not I create a single http post with all the details because of the above depending on the gateway.
To circumvent this, I'm doing the HTTP POST Js and running only the last HTTP POST in php extension. But this seems so insecure and very untraditional magento development, being an inappropriate solution.
Any better ideas?
You can use php cURL solution for the consecutive requests.
Magento has it's own curl adapter - Varien_Http_Adapter_Curl, if you would like to use it.
Here's an example of using it:
$curlAdapter = new Varien_Http_Adapter_Curl(); $curlAdapter->connect(your_host[, opt_port, opt_secure]); $curlAdapter->write(Zend_Http_Client::POST, Zend_Uri_Http $url, [opt_http_ver, opt_headers, opt_body]); $result = $curlAdapter->read();
opt_body are your post fields