PHPackages                             extlib-mercadopago/sdk - 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. extlib-mercadopago/sdk

ActiveLibrary

extlib-mercadopago/sdk
======================

MercadoPago SDK module for Payments integration.

01.3kPHP

Since Oct 4Pushed 1y agoCompare

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

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

**Warning:** We recommend try to use our new SDK [dx-php](https://github.com/mercadopago/dx-php)

MercadoPago SDK
===============

[](#mercadopago-sdk)

- [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 extlib-mercadopago/sdk:0.5.3

```

As a dependency in your project's composer.json

```
{
    "require": {
        "extlib-mercadopago/sdk": "0.5.3"
    }
}
```

### 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,
        "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

18

—

LowBetter than 8% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 50% 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.

### Community

Maintainers

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

---

Top Contributors

[![CherkashinYaroslav](https://avatars.githubusercontent.com/u/159754953?v=4)](https://github.com/CherkashinYaroslav "CherkashinYaroslav (2 commits)")[![Gorchel567](https://avatars.githubusercontent.com/u/75777865?v=4)](https://github.com/Gorchel567 "Gorchel567 (2 commits)")

### Embed Badge

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

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

PHPackages © 2026

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