FlutterWave.RavePay.Net
A .NET library for Flutterwave Ravepay payment gateway
Install / Use
/learn @okezieokpara/FlutterWave.RavePay.NetREADME
FlutterWave.RavePay.Net
A .NET library for Flutterwave Ravepay payment gateway. This library provides a wrapper to the Flutterwave RavePay API
Get the package from Nuget.
Install-Package Flutterwave.Ravepay.Net -IncludePrerelease
Breaking changes
The charge validation feature has been moved their different specialised classes
RaveAccountChargeValidationand RaveCardChargeValidation
And to they are used like so:
var raveConfig = new RavePayConfig(TestConsts.recurringPbKey, TestConsts.recurringScKey, false);
var cardValidation = new RaveCardChargeValidation(raveConfig);
var val = cardValidation.ValidateCharge(new CardValidateChargeParams(TestConsts.recurringPbKey, txRef, "12345")).Result;
// You can query their results now
Trace.WriteLine($"Status: {val.Status}"); // Should be "success"
Trace.WriteLine($"Message: {val.Message}");
Also every card charge validation request now returns a token. This token can be used to charge the card subsequently without using the full card details.
Trace.WriteLine(val.Data.TX.CardChargeToken.EmbedToken));
Trace.WriteLine(val.Data.TX.CardChargeToken.UserToken));
The following services can be carried out with this library:
-
Tokenized charge
Card Charge
To successfully charge a user credit card, first make sure you have the
PBFPubKeythat you got from the checkout button on your RavePay dashboard. Then
you use the RaveCardChargeclass like so:
var raveConfig = new RavePayConfig(<your-PBFPubKey>, false);
// The second(boolean) paramater toggles between live and test mode. The default value is false
var cardCharge = new RaveCardCharge(raveConfig);
var cardParams = new CardChargeParams(recurringPbKey, "Okezie", "Okpara", "rave-test-card@mailinator.com",
4556)
{
CardNo = "5438898014560229",
Cvv = "789",
Expirymonth = "09",
Expiryyear = "19",
TxRef = tranxRef
};
// Alternatively you can create an instance of a card object.
var debitCard = new Card("5438898014560229", "09", "19", "780");
//And use it like so:
var cardParams = new CardChargeParams(recurringPbKey, "Okezie", "Okpara", "test-card@mailinator.com",
4556, debitCard)
{
TxRef = tranxRef
};
// And to make a charge request.
var chargeResponse = await cardCharge.Charge(cardParams);
// Then you can query the charge response. Especially to find the 'Suggested Auth' Property:
if (chargeResponse .Message == "AUTH_SUGGESTION" && cha.Data.SuggestedAuth == "PIN")
{
cardParams.Pin = "3310";
cardParams.Otp = "12345";
cardParams.SuggestedAuth = "PIN";
// Since the suggested auth was 'pin' we make a second request. Sending the pin and otp.
chargeResponse = cardCharge.Charge(cardParams).Result;
}
After each transaction it is a nice idea to validate the status of the
transaction. For this purpose we will validate our last transaction. To validate
a transaction, you need the txRef value and otpof that transaction. Here is
an example:
var raveConfig = new RavePayConfig(recurringPbKey, false);
var cardCharge = new RaveCardCharge(raveConfig);
var verifyResponse = await cardCharge.ValidateCharge(new CardValidateChargeParams(recurringPbKey, txRef, "12345"));
// You can now query the response message and status of the transaction
Trace.WriteLine($"Status: {verifyResponse.Status}");
Trace.WriteLine($"Message: {verifyResponse.Message}");
Account Charge
To successfully charge an account, first you need the account details.
//Setup the RavePay Config
var raveConfig = new RavePayConfig(publicKey, false);
var accountCharge = new RaveAccountCharge(raveConfig);
var accountParams = new AccountChargeParams(publicKey, "Anonymous", "customer", "user@example.com", 0690000031, 509,
acessBank.BankCode, <sample-txRef>);
var chargeResponse = await accountCharge.Charge(accountParams);
// Now check the response recieved from the API. Especially the validation status
if (chargeResponse.Data.Status == "success-pending-validation")
{
// This usually means the user needs to validate the transaction with an OTP
}
Requests to the account charge endpoint usually instructs the user on the next
steps to take to complete the transaction. You can find the instructions by
check the chargeResponse.Data.ValidateInstructions property and displaying it
to the user. The AccountValidateInstructionsobject holds the instructions you
must display to the user. Here is an example response you will typically get:
Trace.WriteLine(chargeResponse.Data.ValidateInstructions.Instruction);
//"Please validate with the OTP sent to your mobile or email"
Trace.WriteLine(chargeResponse.Data.ValidateInstructions.Valparams);
// This is usually : ["OTP"]
Trace.WriteLine(chargeResponse.Data.ValidateInstruction);
//"Please dial *901*4*1# to get your OTP. Enter the OTP gotten in the field below"
You can also validate an an account charge. You need the flwRef value that you
recieved from the transaction you want to validate, you also need an OTP. Here
is a sample:
var raveConfig = new RavePayConfig(publicKey, secretKey, false);
var cardCharge = new RaveAccountCharge(raveConfig);
var val = await cardCharge.ValidateCharge(new AccountValidateChargeParams(publicKey, flwRef, sampleOtp));
// You can now check the response status
Trace.WriteLine($"Status: {val.Status}");
Trace.WriteLine($"Message: {val.Message}");
Banks
With the Flutterwave RavePay API, you can query the list of supported banks by
using the BankServiceclass:
var banks = await BankService.GetBankList();
foreach (var bank in banks)
{
Trace.WriteLine(bank.ToString());
//Returns
//Bank name: ACCESS BANK NIGERIA Bank Code: 044 InternetBanking: False
//Bank name: ECOBANK NIGERIA PLC Bank Code: 050 InternetBanking: False
//Bank name: STERLING BANK PLC Bank Code: 232 InternetBanking: False
// Bank name: ZENITH BANK PLC Bank Code: 057 InternetBanking: False
// Bank name: FIRST CITY MONUMENT BANK PLC Bank Code: 214 InternetBanking: False
// Bank name: SKYE BANK PLC Bank Code: 076 InternetBanking: False
// Bank name: FSDH Merchant Bank Limited Bank Code: 601 InternetBanking: False
}
Fees(See doc)
The RavePay API allows you to get the fees associated with each payments. To get
the fees, you use the RaveFeeServicestatic class:
var fees = await RaveFeeService.GetFees(new GetFeesParams(publicKey, 5938, CurrencyType.Naira));
Trace.WriteLine(fees.Data.ChargeAmount); // The charge amount
Trace.WriteLine(fees.Status) // Should be "success"
Currency
The Flutterwave currently supports multiple currencies including: Dollar, Naira, Euro, Pounds, Cedi, KenyanShilling.
This API has a Currencyclass which represents a currency object and has two
properties: Namei.e the name of the currency e.g Dollar and codei.e the
three-letter currency code e.g NGN.
You can either instantiate the directly or use a value from the
CurrencyTypeenum like so:
var naira = new Currency("Naira", "NGN"); // Instatiates a currency object to naira
var pounds = CurrencyType.Pounds // sets the currency using the CurrencyType enum
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
