npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ravenodejs

v1.0.0

Published

Node library for Rave by Flutterwave

Downloads

12

Readme

Ravepay Nodejs Library v1.0.0

Ravepay Services exposed by the library

  • Account Charge
  • Card Charge
  • USSD Charge
  • Fees
  • Banks
  • TokenCharge
  • Card PreAuthorization
  • Transfers
  • Subaccount
  • Subscription
  • Payment Plan

For more information on the services listed above, visit the Ravepay website

How to use

npm install ravepay

You can get your PUBLICK_KEY and SECRET_KEY from the Rave dashboard.

Go here to get your live keys. Go here to get your live keys.

var Ravepay = require('ravepay');

var rave = new Ravepay(PUBLICK_KEY, SECRET_KEY, PRODUCTION_FLAG);

If you pass true as the value for PRODUCTION_FLAG, the library will use the production url as the base for all calls. Otherwise it will use the staging base url;

var rave = new Ravepay(PUBLICK_KEY, SECRET_KEY, PRODUCTION_FLAG); //Base url is 'https://ravesandboxapi.flutterwave.com'

var rave = new Ravepay(PUBLICK_KEY, SECRET_KEY, true); //Base url is 'http://api.ravepay.co'

Card Charge

var Ravepay = require('ravepay');

var rave = new Ravepay(PUBLICK_KEY, SECRET_KEY, false);

rave.Card.charge(
    {
        "cardno": "5438898014560229",
        "cvv": "890",
        "expirymonth": "09",
        "expiryyear": "19",
        "currency": "NGN",
        "country": "NG",
        "amount": "10",
        "pin": "3310",
        "suggested_auth": "pin",
        "email": "[email protected]",
        "phonenumber": "0902620185",
        "firstname": "temi",
        "lastname": "desola",
        "IP": "355426087298442",
        "txRef": "MC-" + Date.now(),// your unique merchant reference
        "meta": [{metaname: "flightID", metavalue: "123949494DC"}],
        "redirect_url": "https://rave-webhook.herokuapp.com/receivepayment",
        "device_fingerprint": "69e6b7f0b72037aa8428b70fbe03986c"
      }
).then(resp => {
    // console.log(resp.body);

    rave.Card.validate({
        "transaction_reference":resp.body.data.flwRef,
        "otp":12345
    }).then(response => {
        console.log(response.body.data.tx);
        
    })
    
}).catch(err => {
    console.log(err);
    
})

Tokenized Charge

var Ravepay = require('ravepay');

var rave = new Ravepay(PUBLICK_KEY, SECRET_KEY, false);


rave.TokenCharge.card({
    "token": "flw-t0-341d0303583cfbfdf4be74bb52d63ce1-m03k",
    "currency": "NGN",
    "country": "NG",
    "amount": "10",
    "pin": "3310",
    "suggested_auth": "pin",
    "email": "[email protected]",
    "phonenumber": "0902620185",
    "firstname": "temi",
    "lastname": "desola",
    "IP": "355426087298442",
    "txRef": "MC-" + Date.now(),// your unique merchant reference
    "meta": [{metaname: "flightID", metavalue: "123949494DC"}],
    "redirect_url": "https://rave-webhook.herokuapp.com/receivepayment",
    "device_fingerprint": "69e6b7f0b72037aa8428b70fbe03986c"

}).then(resp => {
    console.log(resp.body);
    
}).catch(err => {
    console.log(err);
    
})

Tranfers

When a transfer is initiated, it comes with a status NEW this means the transfer has been queued for processing, and you would need to use the reference you passed to call the Fetch a Transfer endpoint to retrieve the updated status of the transfer.

Available countries you can transfer to

Country Currency

NG (Nigeria)            NGN

GH (Ghana)              GHS

KE (Kenya)              KES

UG (Ugandan)            UGX

US (United States)      USD

OT (Other countries)    GBP, EUR, AUD etc.

Functions included:

  • .initiate

  • .bulk

  • .fetch

  • .list

  • .getApplicableFee

  • .getBalance

.initiate()

This is called to start a transfer. The payload should contain the following card information:

  • 'account_bank', 'required:true, eg:044',

  • 'account_number 'required:true,validators:isNumeric, eg:06900021',

  • 'amount', 'required:true, eg:10',

  • 'secKey', 'required:true,eg:FLWSECK-e6db11d1f8a6208de8cb2f94e293450e-X',

  • 'narration', 'required:false,eg:New transfer',

  • 'currency', 'required:required,eg:NGN',

  • 'reference', 'required:required,eg:mk-902837-jk',

var Ravepay = require('ravepay');

var rave = new Ravepay(PUBLICK_KEY, SECRET_KEY, false);

rave.Transfer.initiate(
    {
        "account_bank": "044",
        "account_number": "0690000044",
        "amount": 500,
        "seckey": "FLWSECK-e6db11d1f8a6208de8cb2f94e293450e-X",
        "narration": "New transfer",
        "currency": "NGN",
        "reference": "mk-902837-jk"
    }
).then(resp => {
    console.log(resp.body);
    
}).catch(err => {
    console.log(err);
    
})

Returns

A sample response is:

{
  "status": "success",
  "message": "TRANSFER-CREATED",
  "data": {
    "id": 542,
    "account_number": "0690000044",
    "bank_code": "044",
    "fullname": "Mercedes Daniel",
    "date_created": "2018-06-06T10:56:12.000Z",
    "currency": "NGN",
    "amount": 500,
    "fee": 45,
    "status": "NEW",
    "reference": "rave-transfer-1528159847480966",
    "narration": "New transfer",
    "complete_message": "",
    "requires_approval": 0,
    "is_approved": 1,
    "bank_name": "ACCESS BANK NIGERIA"
  }
}

.bulk()

This allows you send bulk transfers.

The payload should contain the following parameters

  • 'bulk_data', 'required:true, eg:{ "Bank":"044","Account Number":"0690000032"},{"Bank":"044","Account Number":"0690000032"}',
rave.Transfer.bulk(
    {
  "seckey":"FLWSECK-0b1d6669cf375a6208db541a1d59adbb-X",
  "title":"May Staff Salary",
  "bulk_data":[
  	{
        "Bank":"044",
        "Account Number": "0690000032",
        "Amount":500,
        "Currency":"NGN",
        "Narration":"Bulk transfer 1",
        "reference": "mk-82973029"
    },
    {
        "Bank":"044",
        "Account Number": "0690000034",
        "Amount":500,
        "Currency":"NGN",
        "Narration":"Bulk transfer 2",
        "reference": "mk-283874750"
    }
  ]
}
).then(resp => {
    console.log(resp.body);
    
}).catch(err => {
    console.log(err);
    
})

Returns

A sample response is:

{
    "status": "success",
    "message": "BULK-TRANSFER-CREATED",
    "data": {
        "id": 21,
        "uuid": 21,
        "date_created": "2018-05-17T08:39:54.000Z",
        "approver": "N/A"
    }
}

.fetch()

This allows you retrieve a single transfer. It uses a GET method.

rave.Transfer.fetch('<id="transfer ID" e.g mk-902837-jk>') 
    .then(resp => {
        console.log(resp.body);
        
    }).catch(err => {
        console.log(err);
        
    })

Returns

A sample response is:

{
    "status": "success",
    "message": "QUERIED-TRANSFERS",
    "data": {
        "page_info": {
            "total": 1,
            "current_page": 1,
            "total_pages": 1
        },
        "payouts": [
            {
                "id": 247,
                "account_number": "0690000032",
                "bank_code": "044",
                "fullname": "Pastor Bright",
                "date_created": "2018-05-17T08:39:55.000Z",
                "currency": "NGN",
                "amount": 500,
                "fee": 45,
                "status": "FAILED",
                "narration": "Bulk transfer 1",
                "approver": null,
                "complete_message": "NO AUTH CONTEXT FOUND",
                "requires_approval": 0,
                "is_approved": 1,
                "bank_name": "ACCESS BANK NIGERIA"
            }
        ]
    }
}

.list()

This allows you fetch all transfers using a GET method

rave.Transfer.list() 
    .then(resp => {
        console.log(resp.body);
        
    }).catch(err => {
        console.log(err);
        
    })

.getApplicableFee()

This retrieves the fee for a transfer

rave.Transfer.getApplicableFee()
    .then(resp => {
        console.log(resp.body);
        
    }).catch(err => {
        console.log(err);
        
    })

.getBalance()

This helps you get your balance for transfers.

  • 'currency', 'required:required,eg:NGN',

Returns

A sample response is:

{
    "status": "success",
    "message": "WALLET-BALANCE",
    "data": {
        "Id": 3570,
        "ShortName": "NGN",
        "WalletNumber": "5070000106866",
        "AvailableBalance": 177337.24,
        "LedgerBalance": 177337.24
    }
}

Subaccounts

This is used to create and manage subaccounts

Functions included:

  • .create

  • .list

  • .fetch

.create()

This function helps you to create a subaccount on rave.

var Ravepay = require('ravepay');

var rave = new Ravepay(PUBLICK_KEY, SECRET_KEY, false);

rave.Subaccount.create(
    {
	"account_bank": "044",
	"account_number": "0690000035",
	"business_name": "JK Services",
	"business_email": "[email protected]",
	"business_contact": "Seun Alade",
	"business_contact_mobile": "090890382",
	"business_mobile": "09087930450",
	"meta": [{"metaname": "MarketplaceID", "metavalue": "ggs-920900"}],
	"seckey": "FLWSECK-e6db11d1f8a6208de8cb2f94e293450e-X"
}
).then(resp => {
    console.log(resp.body);
    
}).catch(err => {
    console.log(err);
    
})

Returns

This call returns:

{
    "status": "success",
    "message": "SUBACCOUNT-CREATED",
    "data": {
        "id": 10,
        "account_number": "0690000047",
        "account_bank": "044",
        "fullname": "Ben Fowler",
        "date_created": "2018-05-22T23:08:07.000Z",
        "meta": [
            {
                "metaname": "MarketplaceID",
                "metavalue": "ggs-920800"
            }
        ],
        "subaccount_id": "RS_D87A9EE339AE28BFA2AE86041C6DE70E",
        "bank_name": "ACCESS BANK NIGERIA"
    }
}

A sample .err contains

{
    "status": "error",
    "message": "Sorry we couldn't verify your account number kindly pass a valid account number.",
    "data": null
}

.list()

This allows you to list all or specific subaccounts.

rave.Subaccount.list() 
    .then(resp => {
        console.log(resp.body);

    }).catch(err => {
        console.log(err);
        
    })

.fetch()

This allows you fetch a single subaccount using the subaccount ID

rave.Subaccount.fetch(subaccount_id) 
    .then(resp => {
        console.log(resp.body);
        
    }).catch(err => {
        console.log(err);
        
    })

Payment Plans

Rave helps you collect payments recurrently from your customers using a payment plan. Payment plans allow you create a subscription for your customers.

When you have created a payment plan you can subscribe a customer to it by simply passing the plan ID in your request to charge the customers card.

Functions included:

  • .create

  • .list

  • .fetch

  • .cancel

  • .edit

.create()

This function allows you to create payment plans on rave.

var Ravepay = require('ravepay');

var rave = new Ravepay(PUBLICK_KEY, SECRET_KEY, false);

rave.Paymentplan.create(
    { 
        amount: '10',
        name: 'fosm',
        interval: 'daily',
        duration: 5,
        seckey: 'FLWSECK-e6db11d1f8a6208de8cb2f94e293450e-X' },
        json: true 
    }
    
    
).then(resp => {
    console.log(resp.body);
    
}).catch(err => {
    console.log(err);
    
})

Returns

A sample response is seen below:

{
  "status": "success",
  "message": "CREATED-PAYMENTPLAN",
  "data": {
    "id": 933,
    "name": "fosm",
    "amount": "10",
    "interval": "daily",
    "duration": 5,
    "status": "active",
    "currency": "NGN",
    "plan_token": "rpp_8b87056c262128afbe56",
    "date_created": "2018-10-15T16:35:10.000Z"
  }
}

.list()

This function allows you to list all the payment plans on an account.

var Ravepay = require('ravepay');

var rave = new Ravepay(PUBLICK_KEY, SECRET_KEY, false);

rave.Paymentplan.list() 
    .then(resp => {
        console.log(resp.body);
        
    }).catch(err => {
        console.log(err);
        
    })

.fetch()

This function allows you to fetch a single payment plan

rave.Paymentplan.fetch(plan_id) 
    .then(resp => {
        console.log(resp.body);
        
    }).catch(err => {
        console.log(err);
        
    })

.cancel()

This function allows you to cancel an exisiting payment plan


rave.Paymentplan.cancel(
    {
	"id": 912,
	"seckey": "FLWSECK-e6db11d1f8a6208de8cb2f94e293450e-X"
}
).then(resp => {
    console.log(resp.body);
    
}).catch(err => {
    console.log(err);
    
})

.edit()

This function allows you to edit a payment plan


rave.Paymentplan.edit(
    {
	"id": 912,
	"seckey": "FLWSECK-e6db11d1f8a6208de8cb2f94e293450e-X"
}
).then(resp => {
    console.log(resp.body);
    
}).catch(err => {
    console.log(err);
    
})

Subscriptions

Functions included:

  • .list

  • .fetch

  • .cancel

  • .activate

.list()

This function allows you to list all subscriptions on a merchant account.

var Ravepay = require('ravepay');

var rave = new Ravepay(PUBLICK_KEY, SECRET_KEY, false);

rave.Subscription.list() 
    .then(resp => {
        console.log(resp.body);

    }).catch(err => {
        console.log(err);
        
    })

.fetch()

This function allows you to get a particular subscription on a merchant account.

rave.Subscription.fetch(subscription_id) 
    .then(resp => {
        console.log(resp.body);
        
    }).catch(err => {
        console.log(err);
        
    })

.cancel()

This function allows you to cancel an exisiting subscription


rave.Subscription.cancel(
    {
	"id": 912,
	"seckey": "FLWSECK-e6db11d1f8a6208de8cb2f94e293450e-X"
}
).then(resp => {
    console.log(resp.body);
    
}).catch(err => {
    console.log(err);
    
})

.activate()

This page describes how to activate a subscription


rave.Subscription.activate(
    {
	"id": 912,
	"seckey": "FLWSECK-e6db11d1f8a6208de8cb2f94e293450e-X"
}
).then(resp => {
    console.log(resp.body);
    
}).catch(err => {
    console.log(err);
    
})