SDK for interacting with different payment gateways supported on our services.
- Remita
- Monnify
- Invoice generation
- Cancel invoice
- Check invoice status
If this NG Payments helps you - please star this project, every star makes us very happy!
You can generation a remita invoice from the remita payment gateway provider by create our remita payment service instance using our payment factory
using NGPayments.Entities;
using NGPayments.Gateways.Remita.Models;
using NGPayments.Services;
public class RemitaPayments
{
// Defining the remita configuration properties using our `RemitaConfiguration` class
private readonly RemitaConfiguration configuration = new RemitaConfiguration()
{
MerchantId = "2547916", // Demo Merchant ID
ServiceTypeId = "4430731", // Demo Service Type ID
ApiKey = "1946", // Demo Api Key
};
RemitaRequestBody payload = new RemitaRequestBody
{
configuration = this.configuration,
serviceTypeId = configuration.ServiceTypeId,
amount = "2000",
orderId = Guid.NewGuid().ToString().Replace("-",""),
payerName = "john doe",
payerEmail = "doe@gmail.com",
payerPhone = "09062067384",
description = "payment for septmeber fees"
};
GatewayRequest gatewayRequest = new GatewayRequest()
{
RemitaRequest = payload,
};
// Get the remita payment service instance
var paymentService = PaymentFactory.GetGatewayInstance(PaymentGateway.REMITA);
// Generate remita payment invoice
var response = await paymentService.GenerateInvoice(gatewayRequest);
}
You can cancel an already generated invoice on remita with RRR
using NGPayments.Entities;
using NGPayments.Gateways.Remita.Models;
using NGPayments.Services;
public class RemitaPayments
{
// Defining the remita configuration properties using our `RemitaConfiguration` class
private readonly RemitaConfiguration configuration = new RemitaConfiguration()
{
MerchantId = "2547916", // Demo Merchant ID
ServiceTypeId = "4430731", // Demo Service Type ID
ApiKey = "1946", // Demo Api Key
};
// Defining the invoice cancellation payload
RemitaRequestBody payload = new RemitaRequestBody
{
configuration = this.configuration,
rrr = "190010144722", // generated RRR
};
// Get the remita payment service instance
var paymentService = PaymentFactory.GetGatewayInstance(PaymentGateway.REMITA);
// Cancel remita payment invoice
var response = await paymentService.CancelInvoice(gatewayRequest);
}
You can check the status of an already generated invoice using the orderId
or RRR
using NGPayments.Entities;
using NGPayments.Gateways.Remita.Models;
using NGPayments.Services;
public class RemitaPayments
{
// Defining the remita configuration properties using our `RemitaConfiguration` class
private readonly RemitaConfiguration configuration = new RemitaConfiguration()
{
MerchantId = "2547916", // Demo Merchant ID
ServiceTypeId = "4430731", // Demo Service Type ID
ApiKey = "1946", // Demo Api Key
};
// Defining the invoice status checker payload
RemitaRequestBody payload = new RemitaRequestBody
{
configuration = this.configuration,
orderId = "3b53f4f3dc824658aa8a827d4bd3ddae", // generated order Id
};
// Get the remita payment service instance
var paymentService = PaymentFactory.GetGatewayInstance(PaymentGateway.REMITA);
// Check remita payment invoice status
var response = await paymentService.CheckInvoiceStatus(gatewayRequest);
}
using NGPayments.Entities;
using NGPayments.Gateways.Remita.Models;
using NGPayments.Services;
public class RemitaPayments
{
// Defining the remita configuration properties using our `RemitaConfiguration` class
private readonly RemitaConfiguration configuration = new RemitaConfiguration()
{
MerchantId = "2547916", // Demo Merchant ID
ServiceTypeId = "4430731", // Demo Service Type ID
ApiKey = "1946", // Demo Api Key
};
// Defining the invoice status checker payload
RemitaRequestBody payload = new RemitaRequestBody
{
configuration = this.configuration,
rrr = "190010144722", // generated RRR
};
// Get the remita payment service instance
var paymentService = PaymentFactory.GetGatewayInstance(PaymentGateway.REMITA);
// Check remita payment invoice status
var response = await paymentService.CheckInvoiceStatus(gatewayRequest);
}
You can generation a monnify invoice from the monnify payment gateway provider by create our monnify payment service instance using our payment factory
using NGPayments.Entities;
using NGPayments.Gateways.Monnify.Models;
using NGPayments.Services;
public class MonnifyPayments
{
// Defining the monnify configuration properties using our `MonnifyConfiguration` class
private readonly MonnifyConfiguration configuration = new MonnifyConfiguration
{
ApiKey = "MK_TEST_MT3NUVU3KR",
ClientSecret = "DFD6CQLLX8TD9U4YACCSJSWQ9CRU4B7Y",
ContractCode = "6424247297"
};
MonnifyRequestBody payload = new MonnifyRequestBody
{
configuration = this.configuration,
amount = "2000",
invoiceReference = Guid.NewGuid().ToString().Replace("-", ""),
contractCode = configuration.ContractCode,
currencyCode = "NGN",
paymentMethods = new string[] { "ACCOUNT_TRANSFER","CARD" },
customerName = "john doe",
customerEmail = "doe@gmail.com",
customerUniqueId = "09062067384",
description = "payment for septmeber fees",
expiryDate = DateTime.Now.AddDays(1).ToString("yyy-MM-dd HH:mm:ss"),
redirectUrl = "http:localhost:2000"
};
GatewayRequest gatewayRequest = new GatewayRequest()
{
MonnifyRequest = payload,
};
// Get the monnify payment service instance
var paymentService = PaymentFactory.GetGatewayInstance(PaymentGateway.MONNIFY);
// Generate monnify payment invoice
var response = await paymentService.GenerateInvoice(gatewayRequest);
}
You can cancel an already generated invoice on monnify with the transactionReference
using NGPayments.Entities;
using NGPayments.Gateways.Monnify.Models;
using NGPayments.Services;
public class MonnifyPayments
{
// Defining the monnify configuration properties using our `MonnifyConfiguration` class
private readonly MonnifyConfiguration configuration = new MonnifyConfiguration
{
ApiKey = "MK_TEST_MT3NUVU3KR",
ClientSecret = "DFD6CQLLX8TD9U4YACCSJSWQ9CRU4B7Y",
ContractCode = "6424247297"
};
// Defining the invoice cancellation payload
MonnifyRequestBody payload = new MonnifyRequestBody
{
configuration = this.configuration,
transactionReference = "MNFY|61|20230203144234|000011"
};
GatewayRequest gatewayRequest = new GatewayRequest()
{
MonnifyRequest = payload,
};
// Get the monnify payment service instance
var paymentService = PaymentFactory.GetGatewayInstance(PaymentGateway.MONNIFY);
// Cancel monnify payment invoice
var response = await paymentService.CancelInvoice(gatewayRequest);
}
You can check the status of an already generated invoice using the transactionReference
using NGPayments.Entities;
using NGPayments.Gateways.Monnify.Models;
using NGPayments.Services;
public class MonnifyPayments
{
// Defining the monnify configuration properties using our `MonnifyConfiguration` class
private readonly MonnifyConfiguration configuration = new MonnifyConfiguration
{
ApiKey = "MK_TEST_MT3NUVU3KR",
ClientSecret = "DFD6CQLLX8TD9U4YACCSJSWQ9CRU4B7Y",
ContractCode = "6424247297"
};
// Defining the invoice cancellation payload
MonnifyRequestBody payload = new MonnifyRequestBody
{
configuration = this.configuration,
transactionReference = "MNFY|61|20230203144234|000011"
};
GatewayRequest gatewayRequest = new GatewayRequest()
{
MonnifyRequest = payload,
};
// Get the monnify payment service instance
var paymentService = PaymentFactory.GetGatewayInstance(PaymentGateway.MONNIFY);
// Check monnify payment invoice status
var response = await paymentService.CheckInvoiceStatus(gatewayRequest);
}