I'm making a cart system here to test the MercadoPago API. Everything is working except for the part of creating the payment that I have no idea how to start.
I'm not very good at messing with arrays, and I'm here to ask for help. As it turns out there on the API site, it uses array.
$preference_data = array(
"items" => array(
array(
"title" => "API do Mercado Pago",
"quantity" => 1,
"currency_id" => "BRL", "unit_price" => 10.00
)
)
);
So I have an array (of the cart) that I want to pass to the MP's payment request.
Cart, so doing by SESSION:
$_SESSION['carrinho'][$produto] = $preco; //Produto:Teste;Preço:20
$_SESSION['carrinho'][$produto2] = $preco2; //Produto:Teste2;Preço:15
(I used the PayPal API on it and got it to work)
Now I want to build that MercadoPago array with these Cart products that I get like this:
foreach($_SESSION['carrinho'] as $produto => $preco){
Finally, how do I convert the cart array to the marketplace array?