Mercado Pago SDK for PHP
This library provides developers with a simple set of bindings to the Mercado Pago API.
Supported PHP Versions:
This SDK supports PHP version 5.6 or newer.
- Download Composer if not already installed
- Go to your project directory and run
composer require "mercadopago/dx-php:dev-master"on the command line.
- 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
You have two types of credentials:
For Checkout Mercado Pago:
For API or custom checkout:
MercadoPago\SDK::setAccessToken("ACCESS_TOKEN"); // On Production MercadoPago\SDK::setAccessToken("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:
<?php require_once 'vendor/autoload.php'; MercadoPago\SDK::setAccessToken("ENV_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" => "email@example.com" ); $payment->save(); echo $payment->status; ?>
Was this information helpful?
Thank you for helping us improve. We’re sorry you didn’t find what you were looking for. Could you give us more details? It will only take a few minutes. Go to the form.
Thank you for helping us improve! Can you tell us about your experience?
It will only take a few minutes. Go to the form.