-
Notifications
You must be signed in to change notification settings - Fork 198
Quick Start
Joel Ibaceta edited this page Mar 21, 2019
·
2 revisions
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");
- Setup Live Credentials
MercadoPago\SDK::setClientId("YOUR_CLIENT_ID");
MercadoPago\SDK::setClientSecret("YOUR_CLIENT_SECRET");
- 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();
- Use the
$preference->init_point
or$preference->sandbox_init_point
to redirect the user to the payment form. The$payer
is optional.
Developer Experience - MercadoPago