cancel
Showing results for 
Search instead for 
Did you mean: 

How to use cUrl in Magento 2?

How to use cUrl in Magento 2?


 

Can be it possible to use curl in Magento 2 payment module to set up a custom payment?

If possible, how can I do that?

2 REPLIES 2

Re: How to use cUrl in Magento 2?

Hi @bbbmishucs,

 

This is here I explored the internet for your queries Payment module in magento 2 you can try this one 
https://webkul.com/blog/use-curl-magento-2/ 
If it's use full for you, then you give kudos and accept as solutions

 

Re: How to use cUrl in Magento 2?

Hey @bbbmishucs

You can use cUrl in magento like:

 protected $curlClient;  

in construct  you have to add:

public function __construct(     
        \Magento\Framework\HTTP\Client\Curl $curl

    ) {        $this->curlClient = $curl;
    }

 Then you can use cUrl like using this:

$this->curlClient->post($serviceUrl, []);

 As we know we have many options for curl so for this you can check 
"vendor\magento\framework\HTTP\Client\Curl.php" This file for more functions.Some of them are:

addHeader()

setCredentials()

addCookie()

get() // for get request

makeRequest() // for make request

setOption() // set curl options

Hope this help if you find this useful accept it as solution and kudos thanks.