This library provides developers with a simple set of bindings to the Mercado Pago API.
The SDK supports PHP 5.6, 7.1 or major
Download Composer if not already installed
Go to your project directory and run on the command line
composer require "mercadopago/dx-php:2.0.0"for PHP7 orcomposer require "mercadopago/dx-php:1.8.1"for PHP5.6. See the latest version (here)[https://github.com/mercadopago/dx-php/releases].This how your directory structure would look like.
Thats all, you have Mercado Pago SDK installed.
- You have to require the library from your Composer vendor folder.
require__DIR__ . '/vendor/autoload.php';Setup your credentials
MercadoPago\SDK::setAccessToken("YOUR_ACCESS_TOKEN"); // On ProductionMercadoPago\SDK::setAccessToken("YOUR_TEST_ACCESS_TOKEN"); // On Sandbox
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:
Sample
<?phprequire__DIR__ . '/vendor/autoload.php';
MercadoPago\SDK::setAccessToken("YOUR_ACCESS_TOKEN");
$payment = newMercadoPago\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;
?>Write us at developers.mercadopago.com


