My problem refers to the integration with the sky and I've rolled everything, but without success.
I read this post: Request in Cielo's PHP API using cURL
"I understood" what I said in the post and did so:
<?
//string json contendo os dados de um funcionário
$request = '{
"MerchantOrderId":"2014111703",
"Customer":{
"Name":"Comprador crédito simples"
},
"Payment":{
"Type":"CreditCard",
"Amount":15700,
"Installments":1,
"SoftDescriptor":"123456789ABCD",
"CreditCard":{
"CardNumber":"1234123412341231",
"Holder":"Teste Holder",
"ExpirationDate":"12/2030",
"SecurityCode":"123",
"Brand":"Visa"
}
}
}';
$data_string = json_encode($request, true);
$MerchantID="meuid";
$MerchantKey="meukey";
$ch = curl_init("https://apisandbox.cieloecommerce.cielo.com.br/1/sales");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'MerchantId: ' . $MerchantID,
'MerchantKey: ' . $MerchantKey,
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
$result = json_decode($result, true);
echo "$result->ProofOfSale";
echo "$result->Tid";
echo "$result->AuthorizationCode";
echo "$result->SoftDescriptor";
echo "$result->PaymentId";
echo "$result->ECI";
echo "$result->Status";
echo "$result->ReturnCode";
echo "$result->ReturnMessage";
?>
The final part refers to the return variables that Heaven informs this manual: link
But it does not return anything. My intention is for the customer who purchases the product to make the purchase directly from within the site and not be directed to the sky environment.
I really do not understand anything about json and how it works in php.
If you could help me, I would be very grateful.