The Flutterwave .NET SDK makes it easy to add our payment features to your .NET web applications.
The Flutterwave .NET Library implements the following payment services:
- Card Payments
- Bank Account Payments.
- Mobile Money Payments.
- Bank Transfer (NGN).
- Subscriptions.
- Virtual Cards.
The Library also implements the following features:
- Tokeniztion
- Subaccounts
- Currencies.
- Pre-Authorisation.
- Refunds.
- .NET 4.5 or later
- Add all relevant modules
using System.Diagnostics;
using System.Collections.Generic;
using Rave.Models.MobileMoney;
using Rave.Models.VirtualCard;
using Rave.Models.Subaccount;
using Rave.Models.Tokens;
using Rave.Models;
using Rave.Models.Charge;
using Rave.Models.Account;
using Rave.Models.Card;
using Rave.Models.Validation;
using NUnit.Framework;
- Pass Public and Secret keys as variables for configuration.
private static string PbKey = "pass your public key here"
private static string ScKey = "pass your secret key here"
var raveConfig = new RaveConfig(PbKey, SCKey, false);
This implements Card payments for Pin, 3D-Secure, VBV and PreAuth transactions.
-
Complete basic configuration following the configuration steps.
-
Configure the card charge
var cardCharge = new ChargeCard(raveConfig);
- Pass Card parameters as payload. The payload should contain:
Public key
First name
Last name
Email address
Amount
Card details.
These card details include:
Card number
CVV
Expiry month
Expiry year
Trans Ref
`var Payload = new CardParams(PbKey, "Anonymous", "Customer", "[email protected]", 2100){ cardNo = "5438898014560229", Cvv = "789", Expirymonth = "09", Expiryyear = "19", TxRef = tranxRef}
- Charge card.
var cha = cardCharge.Charge(Payload).Result;
- Pass Pin and OTP to complete the Transaction
if (cha.Message == "AUTH_SUGGESTION" && cha.Data.SuggestedAuth == "PIN")
{
cardParams.Pin = "3310";
cardParams.Otp = "12345";
cardParams.SuggestedAuth = "PIN";
cha = cardCharge.Charge(Payload).Result;
}
The complete card charge and validation flow:
class Program
{
private static string tranxRef = "454839";
private static string PbKey = "";
private static string ScKey = "";
static void Main(string[] args)
{
var raveConfig = new RaveConfig(PbKey, ScKey, false);
var cardCharge = new CardCharge(raveConfig);
var Payload = new CardChargeParams(PbKey, "Anonymous", "Customer", "[email protected]", 2100)
{ CardNo = "5438898014560229", Cvv = "789", Expirymonth = "09", Expiryyear = "19", TxRef = tranxRef }
;
var cha = cardCharge.Charge(cardParams).Result;
if (cha.Message == "AUTH_SUGGESTION" && cha.Data.SuggestedAuth == "PIN")
{
cardParams.Pin = "3310";
cardParams.Otp = "12345";
cardParams.SuggestedAuth = "PIN";
cha = cardCharge.Charge(Payload).Result;
}
}
}
This implements direct debit transactions from Bank accounts.
-
Complete basic configuration following the configuration steps.
-
Configure the Account charge
var accountCharge = new ChargeAccount(raveConfig);
- Pass Account parameters as payload. The payload should contain:
Public key
First name
Last name
Email address
Account number
Amount
Bank code.
Currency (NGN)
Trans Ref
var Payload = new AccountParams(PbKey, "Anonymous", "customer", "[email protected]", "0690000031", 1000.00m, "044", "NGN", "MC-0292920");
- Charge Account.
var chargeResponse = await accountCharge.Charge(accountParams);
if (chargeResponse.Data.Status == "success-pending-validation")
{
// This usually means the user needs to validate the transaction with an OTP
accountParams.Otp = "12345";
chargeResponse = accountCharge.Charge(accountParams).Result;
}
Trace.WriteLine(chargeResponse.Data.ValidateInstructions.Instruction);
Trace.WriteLine(chargeResponse.Data.ValidateInstructions.Valparams);
Trace.WriteLine(chargeResponse.Data.ValidateInstruction);
The complete card charge and validation flow:
class Program
{
private static string tranxRef = "454839";
private static string PbKey = "";
private static string ScKey = "";
static void Main(string[] args)
{
var raveConfig = new RaveConfig(recurringPbKey, recurringScKey, false);
var accountCharge = new ChargeAccount(raveConfig);
var Payload = new AccountParams(PbKey, "Anonymous", "customer", "[email protected]", "0690000031", 1000.00m, "044", "MC-0292920");
var chargeResponse = await accountCharge.Charge(accountParams);
if (chargeResponse.Data.Status == "success-pending-validation")
{
// This usually means the user needs to validate the transaction with an OTP
accountParams.Otp = "12345";
chargeResponse = accountCharge.Charge(accountParams).Result;
}
Trace.WriteLine(chargeResponse.Data.ValidateInstructions.Instruction);
Trace.WriteLine(chargeResponse.Data.ValidateInstructions.Valparams);
Trace.WriteLine(chargeResponse.Data.ValidateInstruction);
ValidateAccountCharge(chargeResponse.Data.FlwRef);
}
}
This implements Mpesa, Ghana, Uganda, Zambia and Rwanda Mobile money transactions for customers.
-
Complete basic configuration following the configuration steps.
-
Configure the Mobile money charge
var mobilemoney = new ChargeMobileMoney(raveConfig);
- Pass mobile money parameters as payload. The payload should contain:
Public key
Secret key
First name
Last name
Email address
Amount
Currency
Mobile number
Network
Country
Payment Type
Trans Ref
var Payload = new MobileMoneyParams(PbKey, ScKey, "Anonymous", "customer", "[email protected]", 1055, "GHS", "054709929220", "network", "country", "paymentType", "MC-0292920");
The payload parameters differ for different countries, currencies and payment types.
Country | Payment Type | Country code | Currency | Network |
---|---|---|---|---|
Ghana | mobilemoneygh |
GH |
GHS | MTN, VODAFONE, TIGO |
Kenya | mpesa |
KE |
KES | |
Rwanda | mobilemoneygh |
NG |
RWF | RWF |
Zambia | mobilemoneyzambia |
NG |
ZMW | MTN |
Uganda | mobilemoneyuganda |
UG |
UGX | UGX |
- Carry out mobile money charge
var cha = mobilemoney.Charge(Payload).Result;
The Complete flow for mobile money charge:
class Program
{
private static string tranxRef = "454839";
private static string PbKey = "";
private static string ScKey = "";
static void Main(string[] args)
{
var raveConfig = new RaveConfig(recurringPbKey, recurringScKey, false);
var mobilemoney = new ChargeMobileMoney(raveConfig);
var Payload = new MobileMoneyParams(PbKey, ScKey, "Anonymous", "customer", "[email protected]", 1055, "GHS", "054709929220", "MTN", "GH", "mobilemoneygh", tranxRef);
var cha = mobilemoney.Charge(Payload).Result;
}
This shows how to create an account number for customers to pay you with using the pay with bank transfer feature.
Static Accounts:
var virtualacct = new VirtualAccount();
var virtualaccountparams = new VirtualAccountParams(narration, ScKey, email, reference);
var chargeResponse = virtuala.CreateStaticVirtualAccount(virtualaccountparams);
Transaction Accounts:
var virtuala = new VirtualAccount();
var virtualaccountparams = new VirtualAccountParams(narration, ScKey, email, reference, amount);
var chargeResponse = virtuala.CreateTransactionVirtualAccount(virtualaccountparams);
Duration Accounts:
var virtuala = new VirtualAccount();
var virtualaccountparams = new VirtualAccountParams(frequency, durtion, narration, ScKey, email, ref, amount);
var chargeResponse = virtuala.CreateTransactionVirtualAccount(virtualaccountparams);
This API allows you to create and update a new Ebills order.
Create Ebills:
var ebillscreate = new CreateOrder();
var ebillscreateparams = new EbillsCreateRequestParams(currency, numberofunits, narraction, ScKey, email, amount, phonenumber, txRef, IP);
var chargeResponse = ebillscreate.doCreateOrder(ebillscreateparams);
Update Ebills:
var ebillsupdate = new UpdateOrder();
var ebillsupdateparams = new EbillsUpdateRequestParams(currency, ScKey, amount, flwref");
var chargeResponse = ebillsupdate.doUpdateOrder(ebillsupdateparams);
This implements Card tokenization for Pin, 3D-Secure, VBV and NoAuth cards.
-
Complete basic configuration following the configuration steps.
-
Charge the card using instructions from the Card charge section of the documentation.
-
Configure the tokenized card
var tokenCard = new Tokenize(raveConfig);
- Pass tokenized card parameters as payload. The payload should contain:
Secret key
First name
Last name
Email address
Transaction ref
Amount
currency
embed token
Narration
var Payload = new TokensParams(ScKey, "Anonymous", "Customer", "[email protected]", tranxref, 2100, "NGN", "NG"){ Token = "flw-t1nf-139d69763063262928b77bc1f4fba199-m03k", Narration = "Test"};
- Make tokenized charge.
var tokenResponse = tokenCard.Charge(tokenparam).Result;
The complete tokenized card charge:
class Program
{
private static string tranxRef = "454839";
private static string PbKey = "";
private static string ScKey = "";
static void Main(string[] args)
{
var raveConfig = new RaveConfig(PbKey, ScKey, false);
var cardCharge = new CardCharge(raveConfig);
var Payload = new TokensParams(ScKey, "Anonymous", "Customer", "[email protected]", tranxref, 2100, "NGN", "NG"){ Token = "flw-t1nf-139d69763063262928b77bc1f4fba199-m03k", Narration = "Test"};
var tokenResponse = tokenCard.Charge(tokenparam).Result;
}
}
This implements subaccount creation for split payments.
-
Complete basic configuration following the configuration steps.
-
Configure the SubAccount
var subacc = new CreateSubAccount(raveConfig);
- Pass tokenized card parameters as payload. The payload should contain:
Secret key
Account Bank
Account number
Business Name
Business Email
Business contact
Business contact mobile
var payload = new SubAccountParams(ScKey, "0690000031", "0690000031", "TEST BUSINESS", "[email protected]", "0900000000", "0900000000");
please note that the same value can be passed as business contact and business contact number.
- Create the Subaccount.
var chargeResponse = subacc.Charge(payload).Result;
The complete subaccount creation flow:
class Program
{
private static string tranxRef = "454839";
private static string PbKey = "";
private static string ScKey = "";
static void Main(string[] args)
{
var raveConfig = new RaveConfig(PbKey, ScKey, false);
var subacc = new CreateSubAccount(raveConfig);
var payload = new SubAccountParams(ScKey, "0690000031", "0690000031", "TEST BUSINESS", "[email protected]", "0900000000", "0900000000");
var chargeResponse = subacc.Charge(payload).Result;
}
}
For further assistance in using the SDK, you can contact the Developers on Slack and Email. You can also check out some awesome Beta features here.