5
I’m making a trolley system here to test the API of the marketplace. Everything is working, except the part about creating the payment that I have no idea how to get started.
I’m not very good at messing with arrays, and I’m here for help. As seen on the API website, it uses array.
$preference_data = array(
"items" => array(
array(
"title" => "API do Mercado Pago",
"quantity" => 1,
"currency_id" => "BRL", "unit_price" => 10.00
)
)
);
Then I have an array (from the cart) that I want to pass to that of the MP payment request.
Cart, I’m doing by SESSION:
$_SESSION['carrinho'][$produto] = $preco; //Produto:Teste;Preço:20
$_SESSION['carrinho'][$produto2] = $preco2; //Produto:Teste2;Preço:15
(I used the Pagseguro API on it and managed to make it work)
Now I want to build that Mercadopago array with those Stand products that I can so:
foreach($_SESSION['carrinho'] as $produto => $preco){
Anyway, how do I convert the cart array to the mercadopago array?
What is stored in your cart array? The quantity is also stored?
– LocalHost
Quantity and always 1
– DaviDEV