- Copy lib/mercadopago.php to your project desired folder.
- Copy lib/cacert.pem to the same folder (for SSL access to MercadoPago APIs).
- Get your CLIENT_ID and CLIENT_SECRET in the following address:
require_once "mercadopago.php";
$mp = new MP ("CLIENT_ID", "CLIENT_SECRET");
$accessToken = $mp->get_access_token();
print_r ($accessToken);
$preferenceResult = $mp->get_preference("PREFERENCE_ID");
print_r ($preferenceResult);
$preference = array (
"items" => array (
array (
"title" => "Test",
"quantity" => 1,
"currency_id" => "USD",
"unit_price" => 10.4
)
)
);
$preferenceResult = $mp->create_preference($preference);
print_r ($preferenceResult);
$preference = array (
"items" => array (
array (
"title" => "Test Modified",
"quantity" => 1,
"currency_id" => "USD",
"unit_price" => 20.4
)
)
);
$preferenceResult = $mp->update_preference("PREFERENCE_ID", $preference);
print_r ($preferenceResult);
###Searching:
$filters = array (
"id": null,
"site_id": null,
"external_reference": null
};
$searchResult = $mp->search_payment ($filters);
print_r ($searchResult);
- Go to Mercadopago IPN configuration:
require_once "mercadopago.php";
header("Content-type: text/plain");
$mp = new MP ("CLIENT_ID", "CLIENT_SECRET");
$paymentInfo = $mp->get_payment_info ($_GET["id"]);
header ("", true, $paymentInfo["status"]);
print_r ($paymentInfo);
$result = $mp->cancel_payment($_GET["ID"]);
// Show result
print_r ($result);
$result = $mp->refund_payment($_GET["ID"]);
// Show result
print_r ($result);