PHPackages                             shulyak/mercadopago - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. shulyak/mercadopago

ActiveLibrary[Payment Processing](/categories/payments)

shulyak/mercadopago
===================

MercadoPago SDK module for Payments integration.

1.0.0(4y ago)056PHP

Since Nov 10Pushed 4y ago1 watchersCompare

[ Source](https://github.com/shulyak/mercadopago)[ Packagist](https://packagist.org/packages/shulyak/mercadopago)[ RSS](/packages/shulyak-mercadopago/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

MercadoPago SDK module for Payments integration
===============================================

[](#mercadopago-sdk-module-for-payments-integration)

- [Install](#install)
- [Basic checkout](#basic-checkout)
- [Customized checkout](#custom-checkout)
- [Generic methods](#generic-methods)

Install
-------

[](#install)

### With Composer

[](#with-composer)

From command line

```
composer require shulyak/mercadopago:1.0.0

```

As a dependency in your project's composer.json

```
{
    "require": {
        "shulyak/mercadopago": "1.0.0"
    }
}
```

### By downloading

[](#by-downloading)

1. Clone/download this repository
2. Copy `lib/mercadopago.php` to your project's desired folder.

Basic checkout
--------------

[](#basic-checkout)

### Configure your credentials

[](#configure-your-credentials)

- Get your **CLIENT\_ID** and **CLIENT\_SECRET** in the following address:
    - Argentina:
    - Brazil:
    - Mexico:
    - Venezuela:
    - Colombia:
    - Chile:

```
require_once ('mercadopago.php');

$mp = new MP ("CLIENT_ID", "CLIENT_SECRET");
```

### Preferences

[](#preferences)

#### Get an existent Checkout preference

[](#get-an-existent-checkout-preference)

```
$preference = $mp->get_preference("PREFERENCE_ID");

print_r ($preference);
```

#### Create a Checkout preference

[](#create-a-checkout-preference)

```
$preference_data = array (
    "items" => array (
        array (
            "title" => "Test",
            "quantity" => 1,
            "currency_id" => "USD",
            "unit_price" => 10.4
        )
    )
);

$preference = $mp->create_preference($preference_data);

print_r ($preference);
```

#### Update an existent Checkout preference

[](#update-an-existent-checkout-preference)

```
$preference_data = array (
    "items" => array (
        array (
            "title" => "Test Modified",
            "quantity" => 1,
            "currency_id" => "USD",
            "unit_price" => 20.4
        )
    )
);

$preference = $mp->update_preference("PREFERENCE_ID", $preference_data);

print_r ($preference);
```

### Payments/Collections

[](#paymentscollections)

#### Search for payments

[](#search-for-payments)

```
$filters = array (
        "id"=>null,
        "site_id"=>null,
        "external_reference"=>null
    );

$searchResult = $mp->search_payment ($filters);

print_r ($searchResult);
```

#### Get payment data

[](#get-payment-data)

```
require_once ('mercadopago.php');

$mp = new MP ("CLIENT_ID", "CLIENT_SECRET");
$paymentInfo = $mp->get_payment ("PAYMENT_ID");

print_r ($paymentInfo);
```

#### Cancel (only for pending payments)

[](#cancel-only-for-pending-payments)

```
$result = $mp->cancel_payment("PAYMENT_ID");

print_r ($result);
```

#### Refund (only for accredited payments)

[](#refund-only-for-accredited-payments)

```
$result = $mp->refund_payment("PAYMENT_ID");

print_r ($result);
```

Customized checkout
-------------------

[](#customized-checkout)

### Configure your credentials

[](#configure-your-credentials-1)

- Get your **ACCESS\_TOKEN** in the following address:
    - Argentina:
    - Brazil:
    - Mexico:
    - Venezuela:
    - Colombia:

```
require_once ('mercadopago.php');

$mp = new MP ("ACCESS_TOKEN");
```

### Create payment

[](#create-payment)

```
$mp->post (
    array(
        "uri" => "/v1/payments",
        "data" => [payment_data]
    )
);
```

### Create customer

[](#create-customer)

```
$mp->post (
    array(
        "uri" => "/v1/customers",
        "data" => array(
            "email" => "email@test.com"
        )
    )
);
```

### Get customer

[](#get-customer)

```
$mp->get (
    array(
        "uri" => "/v1/customers/CUSTOMER_ID"
    )
);
```

- View more Custom checkout related APIs in Developers Site
    - Argentina:
    - Brazil:
    - Mexico:
    - Venezuela:
    - Colombia:

Generic methods
---------------

[](#generic-methods)

You can access any resource from the [MercadoPago API](https://api.mercadopago.com) using the generic methods. The basic structure is:

`$mp->[method]($request)`

where `request` can be:

```
array(
    "uri" => "The resource URI, relative to https://api.mercadopago.com",
    "params" => "Optional. Key=>Value array with parameters to be appended to the URL",
    "data" => "Optional. Object or String to be sent in POST and PUT requests",
    "headers" => "Optional. Key => Value array with custom headers, like content-type: application/x-www-form-urlencoded",
    "authenticate" => "Optional. Boolean to specify if the GET method has to authenticate with credentials before request. Set it to false when accessing public APIs"
)
```

Examples:

```
// Get a resource, with optional URL params. Also you can disable authentication for public APIs
$mp->get (
    array(
        "uri" => "/resource/uri",
        "params" => array(
            "param" => "value"
        ),
        "headers" => array(
            "header" => "value"
        ),
        "authenticate" => true
    )
);

// Create a resource with "data" and optional URL params.
$mp->post (
    array(
        "uri" => "/resource/uri",
        "params" => array(
            "param" => "value"
        ),
        "headers" => array(
            "header" => "value"
        ),
        "data" => [data]
    )
);

// Update a resource with "data" and optional URL params.
$mp->put (
    array(
        "uri" => "/resource/uri",
        "params" => array(
            "param" => "value"
        ),
        "headers" => array(
            "header" => "value"
        ),
        "data" => [data]
    )
);

// Delete a resource with optional URL params.
$mp->delete (
    array(
        "uri" => "/resource/uri",
        "params" => array(
            "param" => "value"
        ),
        "headers" => array(
            "header" => "value"
        )
    )
);
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1644d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b11a45a824825162ff2f9c9c4dc7c489cf2fbc64b36f414f71f52f642a7b9fd3?d=identicon)[shulyak](/maintainers/shulyak)

---

Top Contributors

[![sh00lik](https://avatars.githubusercontent.com/u/64553941?v=4)](https://github.com/sh00lik "sh00lik (2 commits)")

---

Tags

sdkmercadopago

### Embed Badge

![Health badge](/badges/shulyak-mercadopago/health.svg)

```
[![Health](https://phpackages.com/badges/shulyak-mercadopago/health.svg)](https://phpackages.com/packages/shulyak-mercadopago)
```

###  Alternatives

[santigraviano/laravel-mercadopago

Mercado Pago SDK v0.5.2 for Laravel

47145.9k](/packages/santigraviano-laravel-mercadopago)[livepixel/mercado-pago

Mercado Pago API SDK for Laravel

2216.2k](/packages/livepixel-mercado-pago)[cryptonator/merchant-php-sdk

Cryptonator.com Merchant API SDK for PHP

2713.7k](/packages/cryptonator-merchant-php-sdk)[lucassmacedo/omnipay-mercadopago

MercadoPago gateway for OmniPay

154.6k](/packages/lucassmacedo-omnipay-mercadopago)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
