If I run the below direct curl, I get a valid response but when I ran the PHP curl call below with exactly the same information I get a Malformed Request: Transaction Type missing. What am I doing wrong? Any help would be greatly appreciated.
curl -u 'xxx:xxx' -H 'Content-Type: application/json; charset=UTF-8' -H 'Accept: application/json' -d '{"transaction_type":"34","transaction_tag":"xxx","authorization_num":"xxx","amount":"2800","gateway_id":"xxx","password":"xxx","username":"xxx","customer_ref":"xxx","reference_no":"xxx","currency_code":"USD"}' https://api.demo.globalgatewaye4.firstdata.com/transaction
$params = array(
'transaction_type' => "34",
'transaction_tag' => "xxx",
'authorization_num' => "xxx",
'amount' => "2800",
'gateway_id' => "xxx",
'password' => "xxx",
'username' => "xxx",
'customer_ref' => "xxx",
'reference_no' => "xxx",
'currency_code' => 'USD'
);
$json_data = json_encode($params);
$headers = array(
'Content-Type' => "application/json; charset=UTF-8",
'Accept' => 'application/json'
);
//setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 90);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_URL, "https://api.demo.globalgatewaye4.firstdata.com/transaction");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_USERPWD, "xxx:xxx");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$response = curl_exec($ch);
if (curl_error($ch)) {
echo 'Curl error: ' . curl_error($ch);
}
else {
echo $response;
}