Giter VIP home page Giter VIP logo

rave-dot-net's Introduction

RAVE .NET SDK

Use this library to integrate your dotnet app to use the Flutterwave Rave Payment Service

Specs

This library targets the dotnet standard 2.0

How to install

To add the package to your .NET standard or core app via nuget, use the following terminal command:

dotnet add package RaveDotNet

To install in a .NET framework application via the Package Management Console in Visual Studio:

Install-Package RaveDotNet

How to use

To initialize,

private ConfigModel config = new ConfigModel()
{
    Meta = new List<string>(),
    RedirectUrl = "https://your-app.com/rave", //callback to retrieve payment status
    Env = ConfigModel.STAGING, //or ConfigModel.LIVE (for production)
    PublicKey = "<YOUR-PUBLIC-KEY>",
    SecretKey = "<YOUR-SECRET-KEY>"
};

private PaymentRequestModel request = new PaymentRequestModel() {
    CustomerEmail = "[email protected]",
    CustomerPhone = "08021123345",
    Amount = 1000,
    Country = "Nigeria",
    Currency = "NGN",
    CustomDescription = "xyz",
    CustomerFirstname = "Abc",
    CustomerLastname = "Def",
    CustomLogo = "none",
    CustomTitle = "Mr.",
    PayButtonText = "Pay Me"
};

RaveService raveService = new RaveService(config, request);

To specify a custom Transaction reference, while configuring your PaymentRequestModel, you can configure a transaction reference like so:

private PaymentRequestModel request = new PaymentRequestModel() {
// other configurations here...

    new PaymentRequestModel() {
        GetTransactionReference = () => "my-tx-ref-01"
    };
}

To render the payment page,

raveService.RenderHtml(); //will generate an html string to be loaded on the client browser

When the payment is done (success or failure), the user will be redirected to the Redirect URL you specified. You can retrieve the transaction reference from the URL as a query string.

To verify transaction,

var result = await raveService.RequeryTransaction("<THE-TRANSACTION-REFERENCE-YOU-RECEIVED>");

if (result.IsSuccessful()) {
    //do something
}
else if (result.IsFailed()) {
    //handle failure
}
else {
    //indecisive
}

You can also listen for events for tasks like logging transactions:

using Rave.Models.Events;
raveService.SuccessEvent += ((object sender, SuccessEventArgs e) => {
 //triggered on a successful payment
});

raveService.FailedEvent += ((object sender, CancelledEventArgs e) => {
 //triggered on a failed payment
});

raveService.InitEvent += ((object sender, InitEventArgs e) => {
 //triggered when you render html
});

raveService.RequeryEvent += ((object sender, RequeryEventArgs e) => {
 //triggered when a verification (requery) request is created
});

raveService.RequeryErrorEvent += ((object sender, RequeryErrorEventArgs e) => {
 //triggered when verification fails
});

raveService.TimeoutEvent += ((object sender, TimeoutEventArgs e) => {
 //triggered during verification request timeout
});

It's that easy to use!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.