Skip to content

yousseefs/dx-dotnet

 
 

Repository files navigation

Mercado Pago SDK for .Net

Build Status

This library provides developers with a simple set of bindings to the Mercado Pago API.

.Net versions supported:

3.5 .Net Framework or Major

Installation

Using our nuget package

Using Package Manager

PM> Install-Package mercadopago-sdk -Version 1.1.0

Using .Net CLI

> dotnet add package mercadopago-sdk --version 1.1.0

Using Packet CLI

> paket add mercadopago-sdk --version 1.1.0

Quick Start

1. You have to import the Mercado Pago SDK.

using MercadoPago;

2. Setup your credentials

For Web-checkout:

MercadoPago.SDK.ClientId = "YOUR_CLIENT_ID";
MercadoPago.SDK.ClientSecret = "YOUR_CLIENT_SECRET";

For API or custom checkout:

MercadoPago.SDK.AccessToken = "YOUR_ACCESS_TOKEN";

3. Using resource objects

You can interact with all the resources available in the public API, to this each resource is represented by classes according to the following diagram:

sdk resource structure

Sample (Creating a Payment)

using MercadoPago;
using MercadoPago.Resources;
using MercadoPago.DataStructures.Payment;
using MercadoPago.Common;

MercadoPago.SDK.ClientSecret = "YOUR_ACCESS_TOKEN";

Payment payment = new Payment
{
    TransactionAmount = (float)100.0,
    Token = "YOUR_CARD_TOKEN"
    Description = "Ergonomic Silk Shirt",
    PaymentMethodId = "visa", 
    Installments = 1,
    Payer = new Payer {
        Email = "larue.nienow@hotmail.com"
    }
};

payment.Save();

Console.Out.WriteLine(payment.Status);

4. Handling Errors

Error response structure

errorstructure

You can check the errors and causes returned by the API using the errors attribute.

Console.Out.WriteLine(payment.Errors.Message) // Print the error Message 

Support

Write us at developers.mercadopago.com

About

Mercado Pago's Official .Net SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%