Monnify .NET SDK simplifies integration with the Monnify API for developers using .NET.
- Easy-to-use SDK for Monnify payments.
- Supports:
- CustomerReservedAccount
- DirectDebit
- Invoice
- LimitProfile
- Paycode
- RecurringPayment
- Refund
- Settlement
- SubAccount
- Transaction
- Transfer
- Verification
- Wallet
- Other
Install the package via NuGet:
dotnet add package MonnifyDotnetSDK
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"
}
}
You can use in two ways, either register the SDK in your application:
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);
...
}
}
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);
...
For detailed information about the Monnify API, refer to the official documentation.
This SDK is licensed under the MIT License. See the LICENSE file for details.