Mohammed Khalid Khan
Mohammed Khalid Khan

Reputation: 147

Payfast payment gateway ITN request not working in Laravel 5.1

I have integrate payfast payment gateway in our Laravel 5.1 website, it is working perfect on our development server but when we move site on live server it give error in ITN request step, here is the error which I am getting:

HTTP/1.1 500 Internal Server Error
Date: Wed, 09 Nov 2016 14:10:09 GMT
Server: Apache
Cache-Control: no-cache, private
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

When I am searching for solution I got below option to enable ITN request without CSRF token

protected $except = [
//
'/itn'
];

but this also not working, I put sample code folder on my website root folder and try to do payment and that will working.

Also when I try to write notify response in text file it print success in response to the file.

Upvotes: 1

Views: 1327

Answers (1)

Mohammed Khalid Khan
Mohammed Khalid Khan

Reputation: 147

After debugging my code I found there is problem with the CURL post.

// Base settings
            $curlOpts = array(
            // Base options
            CURLOPT_USERAGENT => USER_AGENT, // Set user agent
            CURLOPT_RETURNTRANSFER => true, // Return output as string rather than outputting it
            CURLOPT_HEADER => false, // Don't include header in output
            CURLOPT_SSL_VERIFYHOST => true,
            CURLOPT_SSL_VERIFYPEER => false,
            // Standard settings
            CURLOPT_URL => 'https://' . $pfHost . '/eng/query/validate',
            CURLOPT_POST => true,
            CURLOPT_POSTFIELDS => $pfParamString,
            );
            curl_setopt_array($ch, $curlOpts);
            // Execute CURL
            $res = curl_exec($ch);
            curl_close($ch);

Main issue occurs because of these two line code

            CURLOPT_SSL_VERIFYHOST => true,
            CURLOPT_SSL_VERIFYPEER => false,

I change its value and it start working

            CURLOPT_SSL_VERIFYHOST => 2,
            CURLOPT_SSL_VERIFYPEER => true,

This will fix my problem and payfast working perfect after doing these changes.

Upvotes: 2

Related Questions