MaxiPago SDK (.NET)

Logo

The MaxiPago SDK for .NET projects

View the Project on GitHub guibranco/MaxiPago-SDK-dotnet

MaxiPago SDK client

The MaxiPago gateway SDK for .NET projects

GitHub license Time tracker

MaxiPago


CI/CD

Build status Last commit Tests Coverage Code Smells LoC
Build status GitHub last commit AppVeyor tests (branch) Coverage Code Smells Lines of Code

Code Quality

Codacy Badge Codacy Badge

codecov CodeFactor

Maintainability Test Coverage

Quality Gate Status Maintainability Rating

Technical Debt Duplicated Lines (%)

Reliability Rating Security Rating

Bugs Vulnerabilities


Installation

Github Releases

GitHub last release Github All Releases

Download the latest zip file from the Release page.

Nuget package manager

Package Version Downloads
MaxiPago MaxiPago NuGet Version MaxiPago NuGet Downloads

Features

Implements all features of MaxiPago API available at Integration Documentation


Usage

Adding a customer


//For each environment (TEST and LIVE) this information is different!
var merchantId = "your-merchant-id"; //get this information with MaxiPago
var merchantKey = "your-merchant-key"; //get this information with MaxiPago

var api = new Api { Environment = "TEST" }; //TEST or LIVE
var response = api.AddConsumer(
    MerchantId,
    MerchantKey,
    userIdInYourSystem,
    firstName,
    lastName,
    addressLineOne, //if you don't have this information, use null instead
    addressLineTwo, //if you don't have this information, use null instead
    city, //if you don't have this information, use null instead
    state, //if you don't have this information, use null instead
    zipCode, //if you don't have this information, use null instead
    phone, //if you don't have this information, use null instead
    email,
    dateOfBirth, //if you don't have this information, use null instead
    document,
    gender); //M for Male and F for Female

if(!string.IsNullOrWhiteSpace(response.ErrorMessage))
    //handle the error message.
return response.Result.CustomerId; //store this customer ID value for updating or deleting the customer in future.

Delete customer


//For each environment (TEST and LIVE) this information is different!
var merchantId = "your-merchant-id"; //get this information with MaxiPago
var merchantKey = "your-merchant-key"; //get this information with MaxiPago

var api = new Api { Environment = "TEST" }; //TEST or LIVE

var response = api.DeleteCustomer(merchantId, merchantKey, customerId); //this information was returned by the AddCustomer method.
if(!string.IsNullOrWhiteSpace(response.ErrorMessage))
    //handle the error message.

Update customer


//For each environment (TEST and LIVE) this information is different!
var merchantId = "your-merchant-id"; //get this information with MaxiPago
var merchantKey = "your-merchant-key"; //get this information with MaxiPago

var api = new Api { Environment = "TEST" }; //TEST or LIVE

var response = api.UpdatedCustomer(
    merchantId,
    merchantKey,
    customerId,
    userIdOnYourSystem,
    firstName,
    lastName,
    null,
    null,
    null,
    null,
    null,
    "+5511123456789", //updates the telephone
    email,
    null,
    null,
    "M");

if(!string.IsNullOrWhiteSpace(response.ErrorMessage))
    //handle the error message.

Save card


//For each environment (TEST and LIVE) this information is different!
var merchantId = "your-merchant-id"; //get this information with MaxiPago
var merchantKey = "your-merchant-key"; //get this information with MaxiPago

var api = new Api { Environment = "TEST" }; //TEST or LIVE

var response = api.AddCardOnFile(
    merchantId,
    merchantKey,
    customerId,
    creditCardNumber,
    expirationMonth,
    expirationYear,
    billingName,
    billingAddressLineOne,
    billingAddressLineTwo,
    billingCity,
    billingState,
    billingZip,
    billingCountry,
    billingPhone,
    billingEmail,
    onFileEndDate, //Deadline to keep the card in the base
    onFilePermission, //Limit duration for the use of the saved card. "ongoing" = indefinitely / "use_once" = only once after the 1st payment
    onFileComment,
    onFileMaxChargeAmount); //Maximum amount that this card is authorized to be charged.

if(!string.IsNullOrWhiteSpace(response.ErrorMessage))
    //handle the error message.
return response.Result.Token; //store this token for future use (remove card, sale, auth...)

Create a recurring payment


//For each environment (TEST and LIVE) this information is different!
var merchantId = "your-merchant-id"; //get this information with MaxiPago
var merchantKey = "your-merchant-key"; //get this information with MaxiPago

var transaction = new Transaction { Environment = "TEST" }; //TEST or LIVE

var response = transaction.Recurring(
        merchantId,
        merchantKey,
        transactionId,
        value,
        creditCardNumber,
        expirationMonth,
        expirationYear,
        null,
        creditCardSecureCode,
        processorId, //TEST SIMULATOR = 1 | Rede = 2 | GetNet = 3 | Cielo = 4 | TEF = 5 | Elavon = 6 | ChasePaymentech = 8 
        6, //installments
        "N", //charge interest
        ipAddress,
        "new",
        startDate, //the date of first charge
        frequency, //combined with period, so if the frequency is 1, every "period" will be charged. So if the period is "weekly" and the frequency is "2", every two weeks will be charged.
        period, //The charge recurring period: daily, weekly, monthly
        numberOfTimes, //The number of times to repeat the charge (use 999 as max value for "indefinitely" time, after 999 times, this recurring will need to be created again).
        failureThreshold, //Number of failed attempts needed to trigger an email notification to the merchant.
        "BRL"); //currency of the charge.

if(response.IsErrorResponse){
    if(response is ErrorResponse errorResult)
        Console.WriteLine(errorResult.ErrorMsg); //handle the error message.
}
if(!(response is TransactionResponse result))
    //some other error, handle it

var orderId = result.OrderId;
var responseCode = result.ResponseCode;
if(responseCode != 0) {
    Console.WriteLine(result.ErrorMessage); //handle it