Skip to content

Latest commit

 

History

History
158 lines (107 loc) · 5.02 KB

index.md

File metadata and controls

158 lines (107 loc) · 5.02 KB

Mercado Pago .Net

Portuguese / Spanish

CI NuGet Download count APM

The official Mercado Pago .NET SDK.

💡 Requirements

.NET Standard 2.1+, .NET Core 2.0+, and .NET Framework 6.0+.

If you are using previous versions of .NET Framework in your project, please refer to the older versions of the SDK.

📲 Installation

dotnet add package mercadopago-sdk
nuget install mercadopago-sdk

Using the Package Manager

Install-Package mercadopago-sdk

From Visual Studio

  1. Open the Solution Explorer.
  2. Right-click on a project within your solution.
  3. Click on Manage NuGet Packages....
  4. Click on the Browse tab and search for "mercadopago-sdk".
  5. Click on the mercadopago-sdk package, select the appropriate version and click Install.

🌟 Getting Started

First time using Mercado Pago? Create your Mercado Pago account.

Copy your Access Token in the credentials panel and replace the text YOUR_ACCESS_TOKEN with it.

Simple usage

To generate a card token read the Checkout API documentation.

using System;
using System.Threading.Tasks;
using MercadoPago.Client.Payment;
using MercadoPago.Config;
using MercadoPago.Resource.Payment;

MercadoPagoConfig.AccessToken = "YOUR_ACCESS_TOKEN";

var request = new PaymentCreateRequest
{
    TransactionAmount = 10,
    Token = "CARD_TOKEN",
    Description = "Payment description",
    Installments = 1,
    PaymentMethodId = "visa",
    Payer = new PaymentPayerRequest
    {
        Email = "[email protected]",
    }
};

var client = new PaymentClient();
Payment payment = await client.CreateAsync(request);

Console.WriteLine($"Payment ID: {payment.Id}");

Per-request configuration

All methods that make API calls accept an optional RequestOptions object. This can be used to configure some special options of the request, such as changing credentials or custom headers.

using MercadoPago.Client;

var requestOptions = new RequestOptions();
requestOptions.AccessToken = "YOUR_ACCESS_TOKEN";
// ...

var client = new PaymentClient();
Payment payment = await client.CreateAsync(request, requestOptions);

Advanced usage

Using a proxy server

using System.Net;
using System.Net.Http;
using MercadoPago.Config;
using MercadoPago.Http;

var handler = new HttpClientHandler
{
    Proxy = new WebProxy(proxyUrl),
    UseProxy = true,
};
var httpClient = new HttpClient(handler);
MercadoPagoConfig.HttpClient = new DefaultHttpClient(httpClient);

Configuring automatic retries

The SDK automatically retries requests on intermittent failures. The default max number of attempts is 2.

using MercadoPago.Config;
using MercadoPago.Http;

var retryStrategy = new DefaultRetryStrategy(5);
MercadoPagoConfig.RetryStrategy = retryStrategy;

📚 Documentation

Visit our Developer Site for further information regarding:

Check our SDK docs to explore all available functionalities.

🤝 Contributing

All contributions are welcome, ranging from people wanting to triage issues, others wanting to write documentation, to people wanting to contribute code.

Please read and follow our contribution guidelines. Contributions not following this guidelines will be disregarded. The guidelines are in place to make all of our lives easier and make contribution a consistent process for everyone.

❤️ Support

If you require technical support, please contact our support team at developers.mercadopago.com.

🏻 License

MIT license. Copyright (c) 2021 - Mercado Pago / Mercado Libre
For more information, see the LICENSE file.