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.
1) Download Composer if not already installed.
2) Go to your project directory and run
php composer.phar require "mercadopago/dx-php" on the command line.
3) This how your directory structure would look like.
4) Thats all, you have Mercado Pago SDK installed.
1) You have to require the library from your Composer vendor folder.
require __DIR__ . '/vendor/autoload.php';
2) Setup your credentials
```php MercadoPago\SDK::setAccessToken("ACCESS_TOKEN"); // On Production MercadoPago\SDK::setAccessToken("TEST_ACCESS_TOKEN"); // On Sandbox ```
Find all the information about your credentials in our FAQs.
3) 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" => "firstname.lastname@example.org" ); $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.