Skip to content

Latest commit

 

History

History
116 lines (80 loc) · 3.87 KB

README.md

File metadata and controls

116 lines (80 loc) · 3.87 KB

MercadoPago SDK module for Payments integration

Usage:

  1. Copy bin/mercadopago.dll to your project desired folder.
using mercadopago;

MP mp = new MP ("CLIENT_ID", "CLIENT_SECRET");

Get your Access Token:

String accessToken = mp.getAccessToken();

Response.Write(accessToken);

Using MercadoPago Checkout

Get an existent Checkout preference:

Hashtable preference = mp.getPreference("PREFERENCE_ID");

Response.Write(preference);

Create a Checkout preference:

Hashtable preference = mp.createPreference("{\"items\":[{\"title\":\"sdk-dotnet\",\"quantity\":1,\"currency_id\":\"ARS\",\"unit_price\":10.5}]}");

Response.Write(preference);

Others items to use

Update an existent Checkout preference:

Hashtable preference = mp.updatePreference("PREFERENCE_ID", "{\"items\":[{\"title\":\"sdk-dotnet\",\"quantity\":1,\"currency_id\":\"USD\",\"unit_price\":2}]}");

Response.Write(preference);

Using MercadoPago Payment

Searching:

// Sets the filters you want
Dictionary<String, String> filters = new Dictionary<String, String> ();
    filters.Add("site_id", "MLA"); // Argentina: MLA; Brasil: MLB; Mexico: MLM; Venezuela: MLV; Colombia: MCO
    filters.Add("external_reference", "Bill001");
      
// Search payment data according to filters
Hashtable searchResult = mp.searchPayment (filters);

foreach (Hashtable payment in searchResult.SelectToken ("response.results")) {
    Response.Write(payment["collection"]["id"]);
    Response.Write(payment["collection"]["status"]);
}

More search examples

Receiving IPN notification:

Hashtable payment_info = mp.getPaymentInfo("ID");

Response.Write(payment_info["response"]);

Cancel (only for pending payments):

Hashtable result = mp.cancelPayment("ID");

// Show result
Response.Write(result);

Refund (only for accredited payments):

Hashtable result = mp.refundPayment("ID");

// Show result
Response.Write(result);

About Cancel & Refund