Skip to content
Mercado Pago's Official PHP SDK
PHP
Branch: master
Clone or download
This branch is 31 commits ahead, 4 commits behind mercadopago:master.

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE
img
samples
src/MercadoPago
tests
.gitignore
.travis.yml
LICENSE
README.md
composer.json
phpunit.phar
phpunit.xml

README.md

Unoficial Mercado Pago SDK for PHP

Build Status

This library provides developers with a simple set of bindings to the Mercado Pago API.

PHP Versions Supported:

The SDK supports PHP 7.1 or major

Installation

Using Composer

  1. Download Composer if not already installed
  2. Go to your project directory and run composer require "liveecommerce/dx-php:1.9.0" on the command line.
  3. This how your directory structure would look like.
  4. Thats all, you have Mercado Pago SDK installed.

installation-demo

Quick Start

  1. You have to require the library from your Composer vendor folder.
require __DIR__  . '/vendor/autoload.php';
  1. Setup your credentials

You have two types of credentials:

  • For API or custom checkout:
    MercadoPago\SDK::setAccessToken("YOUR_ACCESS_TOKEN");      // On Production
    MercadoPago\SDK::setAccessToken("YOUR_TEST_ACCESS_TOKEN"); // On Sandbox
  • For Web-checkout:
    MercadoPago\SDK::setClientId("YOUR_CLIENT_ID");
    MercadoPago\SDK::setClientSecret("YOUR_CLIENT_SECRET");
  1. Using resource objects.

You can interact with all the resources available in the public API, to this each resource is represented by classes according to the following diagram:

sdk resource structure

Sample

  <?php
  
    require __DIR__  . '/vendor/autoload.php';

    MercadoPago\SDK::setAccessToken("YOUR_ACCESS_TOKEN");

    $payment = new MercadoPago\Payment();

    $payment->transaction_amount = 141;
    $payment->token = "YOUR_CARD_TOKEN";
    $payment->description = "Ergonomic Silk Shirt";
    $payment->installments = 1;
    $payment->payment_method_id = "visa";
    $payment->payer = array(
      "email" => "larue.nienow@hotmail.com"
    );
 
    echo $payment->status;
    
  ?>

Support

Write us at developers.mercadopago.com

You can’t perform that action at this time.