Ver Mensaje Individual
  #8 (permalink)  
Antiguo 10/11/2017, 09:48
dinho2006
 
Fecha de Ingreso: febrero-2007
Mensajes: 12
Antigüedad: 18 años
Puntos: 0
Respuesta: Problemas con variable array

Hola chicos, aca les dejo el codigo completo por si alguien me puede ayudar, ese es todo el codigo, no me permite la variable $PrecioItem en unit_price ya se me quemaron los libros.

<?php
require_once "mercadopago.php";

$mp = new MP("8423900065991950", "89flWUaGyUe5CE6PlQMX7smNLVWqCuNz");
$PrecioItem=$_GET['PrecioItem'];
//$PrecioItem = isset($_POST['PrecioItem']) ? $_POST['PrecioItem'] : NULL;


$preference_data = array(
"items" => array(
array(
"title" => "Pago de Producto",
"currency_id" => "ARG",
"category_id" => "Category",
"quantity" => 1,
//"unit_price" => 590)
"unit_price" => $PrecioItem)
)
);
$preference = $mp->create_preference($preference_data);
echo $PrecioItem;
?>
<!doctype html>
<html>
<head>
<title>MercadoPago SDK - Create Preference and Show Checkout Example</title>
</head>
<body>


<form name="form1" method="post" action="">

<input name="PrecioItem" type="text" id="PrecioItem" />
<a href="<?php echo $preference["response"]["init_point"]; ?>" name="MP-Checkout" class="orange-ar-m-sq-arall">Pagar</a>
<script type="text/javascript" src="http://mp-tools.mlstatic.com/buttons/render.js"></script>
</form>


</body>
</html>

sale el error:
Fatal error: Uncaught exception 'Exception' with message 'unit_price needed' in /home/mass2014mass/public_html/mercadopago/mercadopago.php:419 Stack trace: #0 /home/mass2014mass/public_html/mercadopago/mercadopago.php(432): MPRestClient::exec('POST', '/checkout/prefe...', Array, 'application/jso...') #1 /home/mass2014mass/public_html/mercadopago/mercadopago.php(177): MPRestClient::post('/checkout/prefe...', Array) #2 /home/mass2014mass/public_html/mercadopago/button.php(20): MP->create_preference(Array) #3 {main} thrown in /home/mass2014mass/public_html/mercadopago/mercadopago.php on line 419

Sin embargo yo hago una comprobacion con la variable $PrecioItem y si me trae el valor.

Gracias a todos de antemano