Working on the payfort payment api https://testfort.payfort.com/api/?#merchant-page I have got a problem with REST POST request using JSON after tokinization is performed. my code is
$requestParams=json_encode($requestParams);
$service_url = 'https://sbpaymentservices.payfort.com/FortAPI/paymentApi';
$curl = curl_init($service_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestParams);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($requestParams)));
$curl_response = curl_exec($curl);
$curl_response is always false
This one give the result
$requestParams['signature'] = $signature;
$requestParams=json_encode($requestParams);
$result = file_get_contents('https://sbpaymentservices.payfort.com/FortAPI/paymentApi', null, stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/json' . "\r\n"
. 'Content-Length: ' . strlen($requestParams) . "\r\n",
'content' => $requestParams,
),
)
));
$result=json_decode($result);