create_access_data($Client_id,$Client_secret);
unset($authService);
if(gettype($accessData)==’string’)
{
throw new exception($checkoutPreference);
}
}
catch (Exception $e) {//catch exception
echo $e->getMessage();
}
$handle = curl_init();
$header[] = ‘Accept: application/json’;
$header[] = ‘Content-Type: application/json’;
$order_total = floatval(number_format($importe, 2, ‘.’, »));
$items[] = array( ‘id’ => $order->ORDER_ID,
‘currency_id’ => ‘ARS’,
‘title’ => ‘Concepto: ‘. $concepto,
‘description’ => $concepto,
‘quantity’ => 1,
‘unit_price’ => $order_total
);
$payer = array(‘email’ => $email,
‘name’ => $nombre . » » . $apellido);
$back_urls = array(‘success’ => «http://www.pardes.org.ar/gracias/»,
‘pending’ => «http://www.pardes.org.ar/gracias/»);
$attributes = array( ‘external_reference’ => 1,
‘items’ => $items,
‘payer’ => $payer,
‘back_urls’ => $back_urls
);
$postData = is_array($attributes) ? json_encode($attributes) : $attributes;
curl_setopt($handle, CURLOPT_URL, ‘https://api.mercadolibre.com/checkout/preferences?access_token=’.$accessData->getAccessToken());
curl_setopt($handle, CURLOPT_HEADER, false);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_HTTPHEADER, $header);
curl_setopt($handle, CURLOPT_POSTFIELDS, $postData);
curl_setopt($handle, CURLOPT_FRESH_CONNECT, true);
curl_setopt($handle, CURLOPT_FORBID_REUSE, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$ret = json_decode(curl_exec($handle));
$info = curl_getinfo($handle);
curl_close($handle);
echo «Redireccionando a Mercado Pago»;
if($ret != null){
echo ‘‘;
}
}
?>