Skip to content

A library for integrating with Monnify APIs for payment solutions on dotnet projects.

License

Notifications You must be signed in to change notification settings

WilliamsEnabulele/MonnifyDotnetSDK

Repository files navigation

Monnify .NET SDK

NuGet version

Monnify .NET SDK simplifies integration with the Monnify API for developers using .NET.

Features

  • Easy-to-use SDK for Monnify payments.
  • Supports:
    • CustomerReservedAccount
    • DirectDebit
    • Invoice
    • LimitProfile
    • Paycode
    • RecurringPayment
    • Refund
    • Settlement
    • SubAccount
    • Transaction
    • Transfer
    • Verification
    • Wallet
    • Other

Installation

Install the package via NuGet:

dotnet add package MonnifyDotnetSDK

Configuration

Add your Monnify credentials in appsettings.json:

{
  "MonnifyOptions": {
    "ApiKey": "YOUR_API_KEY",
    "ApiSecret": "YOUR_SECRET_KEY",
    "BaseUrl": "https://sandbox.monnify.com/api/v1",
    "ContractCode": "YOUR_CONTRACT_CODE"
  }
}

Usage

You can use in two ways, either register the SDK in your application:

1. Via Dependency Injection

builder.Services.AddMonnify(options => 
{
    options.ApiKey = builder.Configuration["MonnifyOptions:ApiKey"];
    options.SecretKey = builder.Configuration["MonnifyOptions:SecretKey"];
    options.BaseUrl = builder.Configuration["MonnifyOptions:BaseUrl"];
});


public class PaymentService {
    private readonly IMonnifyClient _monnifyClient;

    PaymentService(IMonnifyClient monnifyClient) {
        _monnifyClient = monnifyClient;
    }

    public YourResponse InitiatePayment(Request request) {
        var response = _monnifyClient.Transaction.InitiateTransaction(request);
        ...
    }
}

2. or simply create a new instance of MonnifyClient

var monnifyClient = new MonnifyClient(new MonnifyOptions
{
    ApiKey = "{{API_KEY}}",
    ApiSecret = "{{API_SECRET}}",
    BaseUrl = "{{BASE_URL}}"
})

var paymentRequest = new InitiatizeTransaction
{
    Amount = 5000.00m,
    CurrencyCode = "NGN",
    CustomerEmail = "[email protected]",
    CustomerName = "John Doe",
    PaymentReference = Guid.New().ToString(),
    PaymentDescription = "Test Payment",
    ContractCode = "1438045810",
    RedirectUrl = "https://your-site.com/payment-callback"
};


var response = await monnifyClient.Transaction.InitiateTransaction(paymentRequest);
...

API Documentation

For detailed information about the Monnify API, refer to the official documentation.

License

This SDK is licensed under the MIT License. See the LICENSE file for details.

About

A library for integrating with Monnify APIs for payment solutions on dotnet projects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages