cjordan Posted November 20, 2019 Share Posted November 20, 2019 Hello im trying to send an http request to initiate order from a prestashop 1.7 payment module to a remote payment gateway, but have no idea on how to do so with prestashop functoins . Need some help Link to comment Share on other sites More sharing options...
besttechies Posted November 20, 2019 Share Posted November 20, 2019 I'm not so sure if Prestashop has specific functions to do an HTTP Post. I would recommend you to use Curl, I used this for the module I'm currently working on. private static function doPost($postUrl, array $params){ $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $postUrl, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $params, )); $response = curl_exec($curl); $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); switch ($http_status){ case 200: return $response; case 400: default: return false; } } It''s a POST method, but can be easily modified to GET. 1 Link to comment Share on other sites More sharing options...
cjordan Posted November 25, 2019 Author Share Posted November 25, 2019 Ok thanks @besttechies, after unsuccessfully searching for a built-in prestashop method for that, i finally used your method with Curl . It works perfectly. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now