PHP code example of reyesoft / mercadopago

1. Go to this page and download the library: Download reyesoft/mercadopago library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

reyesoft / mercadopago example snippets


MercadoPagoConfig::setAccessToken('YOUR_ACCESS_TOKEN']);

$store = (new StoreClient())->create(
    $params->getUserId(),
    [
        'name' => 'Reyesoft Point',
        'business_hours' => [
            'wednesday' => [
                [
                    'open' => '00:00',
                    'close' => '23:59',
                ],
            ],
        ],
        'external_id' => 'your_store_external_id',
        'location' => [
            'street_number' => '3039',
            'street_name' => 'Caseros',
            'city_name' => 'Belgrano',
            'state_name' => 'Capital Federal',
            'latitude' => -32.8897322,
            'longitude' => -68.8443275,
            'reference' => '3er Piso',
        ],
    ]
);

$pos = new MercadoPagoPos('your_pos_external_id');
$qr_content = $pos->getQrContent();

// just an example, this is Endroid\QrCode library
$qr_code = new QrCode($qr_content);
$qr_code->setText($qr_content);
echo $qr_code->getDataUri();

(new InstoreOrderV2())->create(
    'your_mercadopago_user_id',
    'your_store_external_id',
    'your_pos_external_id',
    [
        'external_reference' => '#' . $your_order_id,
        'title' => 'Order ' . $your_order_id, 
        'description' => 'Your proyects',
        'notification_url' => 'https://yourserver.com/endpoint',
        'total_amount' => 100.10,
        'expiration_date' => today()->addDays(7)->format('Y-m-d\TH:i:s.vP'),
        'items' => [
            [
                'title' => 'Your lovely product',
                'id' => '#' . $your_order_id,
                'external_reference' => '#' . $your_order_id,
                'quantity' => 1,
                'unit_measure' => 'unit',
                'currency_id' => 'ARS',
                'unit_price' => 100.10,
                'total_amount' => 100.10,
                'picture_url' => 'https://yourserver.com/image.jpg',
            ],
        ],
    ]
);