Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/11/2017, 08:27
dinho2006
 
Fecha de Ingreso: febrero-2007
Mensajes: 12
Antigüedad: 17 años, 2 meses
Puntos: 0
Respuesta: Problemas con 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.

Código PHP:
Ver original
  1. <?php
  2. require_once "mercadopago.php";
  3.  
  4. $mp = new MP("*****", "*****");
  5. $PrecioItem=$_GET['PrecioItem'];
  6. //$PrecioItem = isset($_POST['PrecioItem']) ? $_POST['PrecioItem'] : NULL;
  7.  
  8.  
  9.     $preference_data = array(
  10.     "items" => array(
  11.         array(
  12.             "title" => "Pago de Producto",
  13.             "currency_id" => "ARG",
  14.             "category_id" => "Category",
  15.             "quantity" => 1,
  16.             //"unit_price" => 590)
  17.             "unit_price" => $PrecioItem)
  18.     )
  19. );
  20. $preference = $mp->create_preference($preference_data);
  21. echo $PrecioItem;
  22. ?>
  23. <!doctype html>
  24. <html>
  25.     <head>
  26.         <title>MercadoPago SDK - Create Preference and Show Checkout Example</title>
  27.     </head>
  28.     <body>
  29.    
  30.  
  31.         <form name="form1" method="post" action="">
  32.      
  33.         <input name="PrecioItem" type="text" id="PrecioItem" />
  34.         <a href="<?php echo $preference["response"]["init_point"]; ?>" name="MP-Checkout" class="orange-ar-m-sq-arall">Pagar</a>
  35.         <script type="text/javascript" src="http://mp-tools.mlstatic.com/buttons/render.js"></script>
  36.         </form>
  37.  
  38.  
  39. </body>
  40. </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

Última edición por Triby; 10/11/2017 a las 19:04 Razón: Código en Highlight y eliminar posibles datos privados.