try {
//echo json_encode($data);
$data = http_build_query($data);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$xml = curl_exec($curl);
$oxml = new SimpleXMLElement($xml);
if ($oxml->code) {
$oxml->error = false;
$oxml->url = 'https://sandbox.pagseguro.uol.com.br/v2/checkout/payment.html?code=' . $oxml->code;
} else {
$oxml->error = false;
}
echo json_encode($oxml);
} catch (Exception $ex) {
echo '{"error": "true"}';
}