Skip to content

prmces/sdk-dotnet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MercadoPago SDK module for Payments integration

Install

Copy bin/mercadopago.dll to your project desired folder.

Basic checkout

Configure your credentials

using mercadopago;

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

Preferences

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);

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);

Payments/Collections

Search for payments

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

Get payment data

Hashtable payment_info = mp.getPayment("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);

Customized checkout

Configure your credentials

using mercadopago;

MP mp = new MP ("ACCESS_TOKEN");

Create payment

mp.post ("/v1/payments", paymentData);

Create customer

mp.post ("/v1/customers", "{'email': 'email@test.com'}");

Get customer

mp.get ("/v1/customers/CUSTOMER_ID");

Generic methods

You can access any other resource from the MercadoPago API using the generic methods:

// Get a resource, with optional URL params. Also you can disable authentication for public APIs
mp.get ("/resource/uri", [params], [authenticate=true]);

// Create a resource with "data" and optional URL params.
mp.post ("/resource/uri", data, [params]);

// Update a resource with "data" and optional URL params.
mp.put ("/resource/uri", data, [params]);

// Delete a resource with optional URL params.
mp.delete ("/resource/uri", [params]);

For example, if you want to get the Sites list (no params and no authentication):

Hashtable result = mp.get ("/sites", null, false);

Response.Write(result);

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.7%
  • Makefile 0.3%