Esto es lo que tengo que generar :
Código PHP:
$preference_data = array(
"items" => array(
array(
"id" => "item-ID-1234",
"title" => "item",
"quantity" => 1,
"currency_id" => "ARS", // Available currencies at: https://api.mercadopago.com/currencies
"picture_url" => "https://www.mercadopago.com/org-img/MP3/home/logomp3.gif",
"description" => "Item description",
"category_id" => "art", // Available categories at https://api.mercadopago.com/item_categories
"unit_price" => 10.00
),
array(
"id" => "item-ID-12343",
"title" => "item2",
"quantity" => 1,
"currency_id" => "ARS", // Available currencies at: https://api.mercadopago.com/currencies
"unit_price" => 10.00
)
),
"payer" => array(
array(
"name" => "user-name",
"surname" => "user-surname",
"email" => "[email protected]",
"date_created" => "2015-06-02T12:58:41.425-04:00",
"phone" => array(
"area_code" => "11",
"number" => "4444-4444"
),
"identification" => array(
"type" => "DNI",
"number" => "12345678"
),
"address" => array(
"street_name" => "Street",
"street_number" => 123,
"zip_code" => "5700"
)
)
),
);
Código PHP:
$general = array();
$itemstodos = (object) array( "items" => array() );
$item = (object) array(
"id" => "item-ID-1234",
"title" => "Multicolor kite",
"quantity" => 1,
"currency_id" => "ARS", // Available currencies at: https://api.mercadopago.com/currencies
"picture_url" => "https://www.mercadopago.com/org-img/MP3/home/logomp3.gif",
"description" => "Item description",
"category_id" => "art", // Available categories at https://api.mercadopago.com/item_categories
"unit_price" => 10.00
);
$payertodos = (object) array( "payer" => array() );
$payer = (object) array(
"name" => "user-name",
"surname" => "user-surname",
"email" => "[email protected]",
"date_created" => "2015-06-02T12:58:41.425-04:00",
"phone" => array(
"area_code" => "11",
"number" => "4444-4444"
),
"identification" => array(
"type" => "DNI",
"number" => "12345678"
),
"address" => array(
"street_name" => "Street",
"street_number" => 123,
"zip_code" => "5700"
)
);
array_push($itemstodos->items, $item);
array_push($general, $itemstodos);
array_push($payertodos->payer, $payer);
array_push($general, $payertodos);
print_r($general);
No se si alguien me puede ayudar xD o decirme una forma mas bonita de hacerlo.