Skip to content

Quick Start

Joel Ibaceta edited this page Mar 21, 2019 · 2 revisions

To start you have to setup your account credentials

We have two kind of credentials, Live Credentials and API Credentials.

  • Live Credentials: (ClientId + ClientSecret) One shot credentials used to setup an isolated product as Web Checkout (Preference, Payment Button)
  • API Credentials: (AccessToken) These credentials should be used to interact with our APIs (Payments, MerchantOrders, Users, Customers & Cards, etc)

Setting up live credentials:

MercadoPago\SDK::setClientId("YOUR_CLIENT_ID");
MercadoPago\SDK::setClientSecret("YOUR_CLIENT_SECRET"); 

Setting up API Credentials

MercadoPago\SDK::setAccessToken("YOUR_ACCESS_TOKEN");

Building a Web Checkout

  1. Setup Live Credentials
MercadoPago\SDK::setClientId("YOUR_CLIENT_ID");
MercadoPago\SDK::setClientSecret("YOUR_CLIENT_SECRET"); 
  1. Create a Preference
$preference = new \MercadoPago\Preference();

# Building an item
$item = new \MercadoPago\Item();
$item->id = 'ITEM_ID';
$item->title = 'ITEM DESCRIPTION';
$item->quantity = 1;
$item->unit_price = 112.00

$preference->items = array($item);
$preference->save();
  1. Use the $preference->init_point or $preference->sandbox_init_point to redirect the user to the payment form. The $payer is optional.
Clone this wiki locally