React-Flutterwave-Rave
Implement Rave by Flutterwave easily with ReactJS
- 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
Installation
npm install react-flutterwave-rave --save
Add this Rave Inline Script to your index.html
for a testing account
Add this Rave Inline Script to your index.html
for a live account
Available Props
Name | Type | Default | Required | Description |
---|---|---|---|---|
pay_button_text | String | False |
No | The text that displays on your button. |
class | String | No | The css style class of the button. | |
payment_method | String | both |
No | This allows you select the payment option you want for your users, this can be both , card , ussd or account . |
metadata | Object Array | {} |
No | These are additional information you want to pass through the payment gateway . |
currency | String | NGN |
No | The currency you want to charge the customer. |
redirect_url | String | No | URL to redirect to when transaction is completed. | |
country | String | NG |
No | The country of operation. |
customer_firstname | String | No | First name of the customer. | |
customer_lastname | String | No | Last name of the customer. | |
custom_title | String | No | Text to be displayed as the title of the payment modal. | |
custom_description | String | No | Text to be displayed as a short modal description. | |
custom_logo | String | No | Link to the Logo image. | |
txref | String | It will be generated automatically when left blank | No | Unique transaction reference provided by the merchant. |
customer_email | String | No | Email of the customer. | |
customer_phone | String | No | Phone number of the customer. | |
amount | String | No | Amount to charge. | |
ravePubKey | String | No | Your merchant public key provided when you sign up for rave. | |
callback | Function | Yes | 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. | |
onclose | Function | Yes | 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 ;
Usage
Sample 1
This is a basic sample of using Rave
;;// Import the Library { superprops; thisstate = key: "FLWPUBK-XXXXXXXXXXXXXXXXXXXXXXXXXXXX-X" // RavePay PUBLIC KEY phone: "0000000000000" amount: 2000 firstname: "Oluwole" lastname: "Adebiyi" email: "test@test.com" room_number: "23A" hostel: "Silver 1" ticket_number: 3 thiscallback = thiscallback; thisclose = thisclose; } { console; } { console; } { return <div className="App"> <Rave pay_button_text="Pay With Rave" class="button" metadata= metaname: 'Tickets' metavalue: thisstateticket_number metaname: 'Hostel' metavalue: thisstatehostel metaname: 'Room' metavalue: thisstateroom_number payment_method="card" customer_email=thisstateemail customer_phone=thisstatephone amount="" + thisstateamount * thisstateticket_number + "" ravePubKey=thisstatekey callback=thiscallback onclose=thisclose /> </div> ; } ;
Sample 2
This Sample shows how to use Rave and how to verify transaction
;;// Import the Library { superprops; thisstate = key: "FLWPUBK-XXXXXXXXXXXXXXXXXXXXXXXXXXXX-X" // RavePay PUBLIC KEY phone: "000000000000" amount: 2000 firstname: "Oluwole" lastname: "Adebiyi" email: "test@test.com" room_number: "23A" hostel: "Silver 1" ticket_number: 3 thiscallback = thiscallback; thisclose = thisclose; } { return ; } { console; } { return <div className="App"> <Rave pay_button_text="Pay With Rave" class="button" metadata= metaname: 'Tickets' metavalue: thisstateticket_number metaname: 'Hostel' metavalue: thisstatehostel metaname: 'Room' metavalue: thisstateroom_number payment_method="card" customer_email=thisstateemail customer_phone=thisstatephone amount="" + thisstateamount * thisstateticket_number + "" ravePubKey=thisstatekey callback=thiscallback onclose=thisclose /> </div> ; } ;
Sample 3
This Sample shows how to use Rave and requery a transaction
;;// Import the Library { superprops; thisstate = key: "FLWPUBK-XXXXXXXXXXXXXXXXXXXXXXXXXXXX-X" // RavePay PUBLIC KEY phone: "000000000000" amount: 2000 firstname: "Oluwole" lastname: "Adebiyi" email: "test@test.com" room_number: "23A" hostel: "Silver 1" ticket_number: 3 thiscallback = thiscallback; thisclose = thisclose; } { return ; } { console; } { return <div className="App"> <Rave pay_button_text="Pay With Rave" class="button" metadata= metaname: 'Tickets' metavalue: thisstateticket_number metaname: 'Hostel' metavalue: thisstatehostel metaname: 'Room' metavalue: thisstateroom_number payment_method="card" customer_email=thisstateemail customer_phone=thisstatephone amount="" + thisstateamount * thisstateticket_number + "" ravePubKey=thisstatekey callback=thiscallback onclose=thisclose /> </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.