Skip to content

matiascompiano/sdk-dotnet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MercadoPago SDK module for Payments integration

Usage:

  1. Copy bin/mercadopago.dll and bin/Newtonsoft.Json.dll to your project desired folder.
using mercadopago;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

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:

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

Response.Write(preference);

Create a Checkout preference:

JObject 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:

JObject 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
	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"]);
}

More search examples

Receiving IPN notification:

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

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

Cancel (only for pending payments):

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

// Show result
Response.Write(result);

Refund (only for accredited payments):

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

// Show result
Response.Write(result);

About Cancel & Refund

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Classic ASP 89.9%
  • C# 10.1%