Set up development environment
To start integrating Mercado Pago's payment solutions, it is necessary to prepare your development environment with a series of configurations that will allow you to access Mercado Pago's functionalities from the backend.
Next, you will need to install and configure the official Mercado Pago SDK:
Install the Mercado Pago SDK
Server-Side
The backend SDK is designed to handle server-side operations, allowing you to create and manage payment preferences, process transactions, and perform other critical operations securely.
Install the Mercado Pago SDK in the language that best fits your integration using a dependency manager, as shown below.
php composer.phar require "mercadopago/dx-php"
To install the SDK, you must run the following code in your terminal's command line using npm:
npm install mercadopago
To install the SDK in your Maven project, you must add the following dependency to your <code>pom.xml</code> file and run <code>maven install</code> in your terminal's command line:
<dependency>
<groupId>com.mercadopago</groupId>
<artifactId>sdk-java</artifactId>
<version>2.1.7</version>
</dependency>
To install the SDK, you must run the following code in your terminal's command line using Gem:
gem install mercadopago-sdk
To install the SDK, you must run the following code in your terminal's command line using NuGet:
nuget install mercadopago-sdk
To install the SDK, you must run the following code in your terminal's command line using Pip:
pip3 install mercadopago
go get -u github.com/mercadopago/sdk-go
Initialize Mercado Pago library
Server-Side
To initialize the Mercado Pago library, you will need to use your credentials, which are unique keys used to identify and authenticate your integration in your account. These keys are directly linked to the application you created for that integration and will allow you to develop your project with Mercado Pago's best security measures.
First, you will need to activate the production credentials. To do this, you will need to complete some information about your business by following the steps below.
- In Your integrations, select your application. Then, go to the Production section and click on Production Credentials in the menu on the left side of the screen.
- In the Industry field, select from the drop-down menu the industry to which the business you are integrating belongs.
- In the Website (required) field, fill in the URL of your business's website.
- Accept the Privacy Statement and the Terms and conditions. Complete the reCAPTCHA and click on Activate production credentials.
After activating your production credentials, you will be able to use your production access token
, available in the details of your application in Your integrations.
Next, in the backend of your project, create a main file based on the programming language you will use. There, place the following code, replacing the value PROD_ACCESS_TOKEN
with your production access token
.
<?php
// Mercado Pago SDK
use MercadoPago\MercadoPagoConfig;
// Add credentials
MercadoPagoConfig::setAccessToken("PROD_ACCESS_TOKEN");
?>
// Mercado Pago SDK
import { MercadoPagoConfig } from 'mercadopago';
// Add credentials
const client = new MercadoPagoConfig({ accessToken: 'YOUR_ACCESS_TOKEN' });
// Mercado Pago SDK
import com.mercadopago.MercadoPagoConfig;
// Add credentials
MercadoPagoConfig.setAccessToken("PROD_ACCESS_TOKEN");
# Mercado Pago SDK
require 'mercadopago'
# Add credentials
sdk = Mercadopago::SDK.new('PROD_ACCESS_TOKEN')
// Mercado Pago SDK
using MercadoPago.Config;
// Add credentials
MercadoPagoConfig.AccessToken = "PROD_ACCESS_TOKEN";
# Mercado Pago SDK
import mercadopago
# Add credentials
sdk = mercadopago.SDK("PROD_ACCESS_TOKEN")
import (
"github.com/mercadopago/sdk-go/pkg/config"
)
cfg, err := config.New("{{ACCESS_TOKEN}}")
if err != nil {
fmt.Println(err)
}
With these configurations, your development environment is now ready to proceed with setting up a payment preference.
To install the SDK, you must run the following code in your terminal's command line using Composer: