This library makes it easy to consume Flutterwave API (v3) in .Net projects.
This library implements the following services:
- Banks
- Get bank branches
- Get banks
- Miscellaneous
- Verify a bank account number
- Payments
- Cancel a payment plan
- Create a payment plan
- Get a payment plan
- Get payment plans
- Initiate payment
- Update a payment plan
- Sub accounts
- Create a sub account
- Delete a sub account
- Fetch a sub account
- Fetch all sub accounts
- Update a sub account
- Transactions
- Get transaction fees
- Get all transactions
- Verify a transaction
- From Nuget
Install-Package Flutterwave.Net -Version 1.0.0
- From .NET CLI
dotnet add package Flutterwave.Net --version 1.0.0
- As a package reference
<PackageReference Include="Flutterwave.Net" Version="1.0.0" />
- Include the Flutterwave.Net namespace to expose all types
... using Flutterwave.Net; ...
- Declare and initialise the FlutterwaveAPI class with your secret key
string flutterwaveSecretKey = ConfigurationManager.AppSettings["FlutterwaveSecretKey"]; var api = new FlutterwaveApi(flutterwaveSecretKey);
-
Get bank branches
int bankId = 280; GetBankBranchesResponse response = api.GetBankBranches(bankId); // success if (response.Status == "success") { // Get bank branches List<BankBranch> bankBranches = response.Data; } // error else { // Get error message string errorMessage = response.Message; }
-
Get banks
GetBanksResponse response = api.GetBanks(Country.Nigeria); // success if (response.Status == "success") { // Get all banks List<Bank> banks = response.Data; } // error else { // Get error message string errorMessage = response.Message; }
- Verify a bank account number
string accountNumber = "0690000032"; string bankCode = "044"; VerifyBankAccountResponse response = api.Miscellaneous.VerifyBankAccount(accountNumber, bankCode); // success if (response.Status == "success") { // Get the bank account BankAccount bankAccount = response.Data; } // error else { // Get error message string errorMessage = response.Message; }
- Cancel a payment plan
int paymentPlanId = 123; PaymentPlanResponse response = api.CancelPaymentPlan(paymentPlanId); // success if (response.Status == "success") { // Get payment plan PaymentPlan paymentPlan = response.Data; // Verify payment plan status bool isCancelled = paymentPlan.Status == "cancelled"; } // error else { // Get error message string errorMessage = response.Message; }
- Create a payment plan
decimal amount = 5000; string name = "Monthly Nepa Bill Collection"; int duration = 24; PaymentPlanResponse response = api.CreatePaymentPlan(amount, name, Interval.Monthly, duration); // success if (response.Status == "success") { // Get payment plan PaymentPlan paymentPlan = response.Data; } // error else { // Get error message string errorMessage = response.Message; }
- Get a payment plan
int paymentPlanId = 123; PaymentPlanResponse response = api.GetPaymentPlan(paymentPlanId); // success if (response.Status == "success") { // Get payment plan PaymentPlan paymentPlan = response.Data; } // error else { // Get error message string errorMessage = response.Message; }
- Get payment plans
GetPaymentPlansResponse response = api.GetPaymentPlans(); // success if (response.Status == "success") { // Get payment plans List<PaymentPlan> paymentPlans = response.Data; } // error else { // Get error message string errorMessage = response.Message; }
- Initiate payment
string txRef = "hooli-tx-1920bbtytty"; decimal amount = 100; string redirectUrl = "https://webhook.site/9d0b00ba-9a69-44fa-a43d-a82c33c36fdc"; string customerEmail = "[email protected]"; string customerPhonenumber = "08012345678"; string customerName = "Yemi Desola"; string paymentTitle = "Pied Piper Payments"; string paymentDescription = "Middleout isn't free. Pay the price"; string brandLogoUrl = "https://assets.piedpiper.com/logo.png"; InitiatePaymentResponse response = api.Payments.InitiatePayment(txRef, amount, redirectUrl, customerName, customerEmail, customerPhonenumber, paymentTitle, paymentDescription, brandLogoUrl); // success if (response.Status == "success") { // Get payment hosted link string hostedLink = response.Data.Link; } // error else { // Get error message string errorMessage = response.Message; }
- Update a payment plan
int paymentPlanId = 123; string name = "January neighbourhood"; PaymentPlanResponse response = api.UpdatePaymentPlan(paymentPlanId, name, PaymentPlanStatus.Active); // success if (response.Status == "success") { // Get payment plan PaymentPlan paymentPlan = response.Data; } // error else { // Get error message string errorMessage = response.Message; }
- Create a sub account
string bankCode = "044"; string accountNumber = "0690000032"; string businessName = "Eternal Blue"; string businessEmail = "[email protected]"; double splitValue = 0.5; string businessContact = "Yemi Desola"; string businessContactMobile = "08012345678"; string businessMobile = "08012345678"; SubAccountResponse response = api.CreateSubAccount(bankCode, accountNumber, businessName, businessEmail, Country.Nigeria, SplitType.Percentage, splitValue, businessContact, businessContactMobile, businessMobile); // success if (response.Status == "success") { // Get sub account SubAccount subAccount = response.Data; } // error else { // Get error message string errorMessage = response.Message; }
- Delete a sub account
int subAccountId = 12345 SubAccountResponse response = api.DeleteSubAccount(subAccountId); // success if (response.Status == "success") { // Get success message string successMessage = response.Message; } // error else { // Get error message string errorMessage = response.Message; }
- Fetch a sub account
int subAccountId = 12345; SubAccountResponse response = api.GetSubAccount(subAccountId); // success if (response.Status == "success") { // Get the sub account SubAccount subAccounts = response.Data; } // error else { // Get error message string errorMessage = response.Message; }
- Fetch all sub accounts
GetSubAccountsResponse response = api.GetSubAccounts(); // success if (response.Status == "success") { // Get all sub accounts List<SubAccount> subAccounts = response.Data; } // error else { // Get error message string errorMessage = response.Message; }
- Update a sub account
int subAccountId = 12345; string businessName = "Eternal Blue"; string businessEmail = "[email protected]"; string bankCode = "044"; string accountNumber = "0690000032"; double splitValue = 0.5; SubAccountResponse response = api.UpdateSubAccountRequest(subAccountId, businessName, businessEmail, bankCode, accountNumber, SplitType.Percentage, splitValue); // success if (response.Status == "success") { // Get updated sub account SubAccount subAccount = response.Data; } // error else { // Get error message string errorMessage = response.Message; }
- Get transaction fees
decimal amount = 5000; GetTransactionFeeResponse response = api.Transactions.GetTransactionFee(amount); // success if (response.Status == "success") { // Get transaction fees TransactionFee transactionFees = response.Data; } // error else { // Get error message string errorMessage = response.Message; }
- Get all transactions
GetTransactionsResponse response = api.Transactions.GetTransactions(); // success if (response.Status == "success") { // Get all transactions List<Transaction> transactions = response.Data; } // error else { // Get error message string errorMessage = response.Message; }
- Verify a transaction
int transactionId = 1234567; VerifyTransactionResponse response = api.Transactions.VerifyTransaction(id); // success if (response.Status == "success") { // Get the transaction Transaction transaction = response.Data; // Verify transaction status bool isSuccess = transaction.Status == "successful"; // Verify that the transaction reference, currency and charged amount i.e // transaction.TxRef, transaction.Currency and transaction.ChargedAmount // are what you expect them to be } // error else { // Get error message string errorMessage = response.Message; }
Create a new issue or add a comment to an open issue to request for new features and/or report bugs
Send a mail for further assistance using this library