Configure 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
Next, create a main file (main) in the backend of your project with the programming language you are using. There, place the following code replacing the value TEST_ACCESS_TOKEN with the test Access Token.
<?php
// Mercado Pago SDK
use MercadoPago\MercadoPagoConfig;
// Add credentials
MercadoPagoConfig::setAccessToken("TEST_ACCESS_TOKEN");
?>
// Mercado Pago SDK
import { MercadoPagoConfig, Preference } from 'mercadopago';
// Add credentials
const client = new MercadoPagoConfig({ accessToken: 'YOUR_ACCESS_TOKEN' });
// Mercado Pago SDK
import com.mercadopago.MercadoPagoConfig;
// Add credentials
MercadoPagoConfig.setAccessToken("TEST_ACCESS_TOKEN");
# Mercado Pago SDK
require 'mercadopago'
# Add credentials
sdk = Mercadopago::SDK.new('TEST_ACCESS_TOKEN')
// Mercado Pago SDK
using MercadoPago.Config;
// Add credentials
MercadoPagoConfig.AccessToken = "TEST_ACCESS_TOKEN";
# Mercado Pago SDK
import mercadopago
# Add credentials
sdk = mercadopago.SDK("TEST_ACCESS_TOKEN")
import (
"github.com/mercadopago/sdk-go/pkg/config"
)
cfg, err := config.New("{{ACCESS_TOKEN}}")
if err != nil {
fmt.Println(err)
}
After completing these configurations, your development environment is 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: