- Copy bin/mercadopago.dll and bin/Newtonsoft.Json.dll to your project desired folder.
- Get your CLIENT_ID and CLIENT_SECRET in the following address:
using mercadopago;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
MP mp = new MP ("CLIENT_ID", "CLIENT_SECRET");
JObject preference = mp.getPreference("PREFERENCE_ID");
Response.Write(preference);
JObject preference = mp.createPreference("{'items':[{'title':'sdk-dotnet','quantity':1,'currency_id':'ARS','unit_price':10.5}]}");
Response.Write(preference);
JObject preference = mp.updatePreference("PREFERENCE_ID", "{'items':[{'title':'sdk-dotnet','quantity':1,'currency_id':'USD','unit_price':2}]}");
Response.Write(preference);
// Sets the filters you want
Dictionary<String, String> filters = new Dictionary<String, String> ();
filters.Add("site_id", "MLA"); // Argentina: MLA; Brasil: MLB
filters.Add("external_reference", "Bill001");
// Search payment data according to filters
JObject searchResult = mp.searchPayment (filters);
foreach (JObject payment in searchResult.SelectToken ("response.results")) {
Response.Write(payment["collection"]["id"]);
Response.Write(payment["collection"]["status"]);
}
- Go to Mercadopago IPN configuration:
JObject payment_info = mp.getPaymentInfo("ID");
Response.Write(payment_info["response"]);
JObject result = mp.cancelPayment("ID");
// Show result
Response.Write(result);
JObject result = mp.refundPayment("ID");
// Show result
Response.Write(result);