使用JSON的Payfort REST POST请求 [英] Payfort REST POST request using JSON
本文介绍了使用JSON的Payfort REST POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Payfort Payment API https://testfort.payfort.com/api/?#merchant-page 执行Tokinization后,使用JSON的REST POST请求出现问题.我的代码是
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始终为假
$curl_response is always false
推荐答案
此给出结果
$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);
这篇关于使用JSON的Payfort REST POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文