dnetix/mercadopago

An easy to use library for MercadoPago API communication

v0.8.2 2015-09-23 02:22 UTC

This package is not auto-updated.

Last update: 2024-11-09 18:22:13 UTC


README

Installation

With Composer

From command line

composer require dnetix/mercadopago

As a dependency in your project's composer.json

{
    "require": {
        "dnetix/mercadopago": "0.8.*"
    }
}

Basic checkout

  • Create your application in https://applications.mercadopago.com
  • Set the values for the configuration array (Structure in examples/config.php)
  • Instanciate a MercadoPago object to create a preference. It can be binded to an IoC and create the preference
$mercadopago = Dnetix\MercadoPago\MercadoPago::load($config);

$preference = $mercadoPago->addItem([
        'id' => 'PRODUCT_ID',
        'title' => 'PRODUCT_TITLE',
        'description' => 'PRODUCT_DESCRIPTION',
        'quantity' => 1,
        'unit_price' => 10000,
        'picture_url' => 'OPTIONAL_URL_IMAGE_OF_PRODUCT',
    ])
    ->addExternalReference('OPTIONAL_EXTERNAL_REFERENCE')
    ->createPreference();
  • In your html
    <a href="<?= $preference->initPoint() ?>" name="MP-Checkout" class="">Payment Link</a>
  • And that's all. This process is explained in detail on examples/payment-creation/payment-simple.php

Examples

The examples for the different usage methods such as marketplace charges, payment search, notification handling and others are explained in the examples folder.