Rave-Javascript-SDK
Implement Rave by Flutterwave easily with Javascript frameworks and Libraries
- Go to Flutterwave Rave Live to get your
LIVE
public and private key - Go to Flutterwave Rave Test to get your
TEST
public and private key
Tested on
- VueJS
- NuxtJS
- ReactJS
Installation
npm install rave-javascript-sdk --save
ReactJS and VueJS
Add this Rave Inline Script to your index.html
for a test account
Add this Rave Inline Script to your index.html
for a live account
Nuxt
Add this to your nuxt.config.js
or in Vue Page
head for a test account
head: script: --- src: 'https://rave-api-v2.herokuapp.com/flwv3-pug/getpaidx/api/flwpbf-inline.js' body: true ---
Add this to your nuxt.config.js
or in Vue Page
head for a live account
head: script: --- src: 'https://api.ravepay.co/flwv3-pug/getpaidx/api/flwpbf-inline.js' body: true ---
Basic Usage
VueJS Sample
Buy
ReactJS Sample
;; { superprops; thisbuy = thisbuy; } { var rave = ; rave } { return <div> <button onClick=thisbuy>Buy</button> </div> }
Available Rave methods
Name | Type | Default | Required | Description |
---|---|---|---|---|
setPublicKey | String | Yes | Your merchant public key provided when you sign up for rave. | |
setEmail | String | Yes | Email of the customer. | |
setAmount | String | Yes | Amount to charge. | |
setPhone | String | No | Phone number of the customer. | |
setPaymentMethod | String | both |
No | This allows you select the payment option you want for your users, this can be both , card , ussd or account . |
setMeta | Object Array | [] |
No | These are additional information you want to pass through the payment gateway . |
setCurrency | String | NGN |
No | The currency you want to charge the customer. |
setRedirectURL | String | No | URL to redirect to when transaction is completed. | |
setCountry | String | NG |
No | The country of operation. |
setFirstname | String | No | First name of the customer. | |
setLastName | String | No | Last name of the customer. | |
setModalTitle | String | No | Text to be displayed as the title of the payment modal. | |
setDescription | String | No | Text to be displayed as a short modal description. | |
setLogo | String | No | Link to the Logo image. | |
setTransactionReference | String | It will be generated automatically when left blank | No | Unique transaction reference provided by the merchant. |
setCallback | Function | No | A function to be called on successful card charge. User’s can always be redirected to a successful or failed page supplied by the merchant here based on response. | |
setCancel | Function | No | A function to be called when the pay modal is closed. |
Available Functions
RequeryTransaction({ live, txref, SECKEY })
This requeries a transaction, useful to check if a failed transaction is successful
live
:false
ortrue
Set to true if you are using a live account and vice versatxref
: The transaction referenceSECKEY
: Your API secret key
;
VerifyTransaction({ live, txref, SECKEY })
This validates a transaction, you can get your metas passed through this
live
:false
ortrue
Set to true if you are using a live account and vice versatxref
: The transaction referenceSECKEY
: Your API secret key
var currency = "NGN"; //Gotten from server or hardcodedvar amount = "3000"; //Gotten from server or hardcoded ;
More Samples
VueJS with Transaction Verification
Buy
ReactJS with Transaction Verification
;; { superprops; thisbuy = thisbuy; } { var rave = ; rave } { return ; } { console; } { return <div> <button onClick=thisbuy>Buy</button> </div> }
Contributing
Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.
Kindly star the GitHub repo and share ❤️. I ❤️ Flutterwave
Kindly follow me on twitter!
Credits
License
The MIT License (MIT). Please see License File for more information.