Foloosi
Search…
React JS
The Foloosi Payments plugin allows you to accept credit card and debit card payments via Foloosi payment gateway in your React JS.

react-foloosi-widget

Foloosi Payment Gateway for your Online Business.

Install

with npm
1
npm install --save react-foloosi-widget
Copied!

Usage

Foloosi Payment Gateway uses sensible defaults, so only minimal configuration via props is necessary.

Basic configuration

How to do configuration in your React Project?

Step 1

Initialize the Foloosi Payment like below.
1
import {Foloosi} from 'react-foloosi-widget';
2
3
class App extends Component {
4
state = {
5
foloosiOpen: false,
6
reference_token:'YOUR_REFERENCE_TOKEN',
7
merchant_key:'YOUR_MERCHANT_KEY'
8
};
9
foloosiHandler(e){
10
if(e.data.status == 'success'){
11
console.log(e.data);
12
console.log(e.data.data.transaction_no);
13
}
14
if(e.data.status == 'error'){
15
console.log(e.data);
16
console.log(e.data.data.payment_status);
17
}
18
}
19
componentDidUpdate(){
20
window.addEventListener('message', this.foloosiHandler);
21
}
22
foloosiOpen(){
23
this.setState({foloosiOpen: true});
24
}
25
render() {
26
return (
27
<div>
28
<span onClick={e => this.foloosiOpen(e)}>Foloosi</span>
29
<Foloosi foloosiOpen={this.state.foloosiOpen} foloosiClose={true} reference_token={this.state.reference_token} merchant_key={this.state.merchant_key}
30
/>
31
</div>
32
);
33
}
34
}
Copied!

Step 2

Post the following data's in below API link to requesting reference token for accessing the payment gateway.
1
POST API LINK :
2
https://foloosi.com/api/v1/api/initialize-setup
3
4
HEADERS:
5
merchant_key : YOUR_MERCHANT_KEY
6
7
BODY:
8
redirect_url : YOUR_REDIRECT_URL
9
transaction_amount : YOUR_TRANSACTION_AMOUNT
10
currency : YOUR_CURRENCY_CODE
11
customer_name : OPTIONAL /*note : auto render in payment popup*/
12
customer_email : OPTIONAL /*note : auto render in payment popup*/
13
customer_mobile : OPTIONAL /*note : auto render in payment popup*/
14
customer_address : OPTIONAL /*note : minimize form fields in card detail page*/
15
customer_city : OPTIONAL /*note : minimize form fields in card detail page*/
Copied!
Supported Currencies areas follows : AED, USD, EUR, INR If you need optional parameters, you can add it your own data option name and values in Body. The above POST request returns the Response like below. In that response, you will get Reference Token. After that you need to assign this Reference token variable globally as mentioned in Step 1.
1
Response
2
{
3
"message": "Application setup successfully",
4
"data": {
5
"reference_token" : "YOUR_REFERENCE_TOKEN",
6
"payment_qr_data" : "YOUR_PAYMENT_QR_DATA",
7
"payment_qr_url" : "YOUR_PAYMENT_QR_URL"
8
}
9
}
Copied!

Step 3

When you click place order button our popup will be loaded so you can use below test card credentials to complete the order.
1
Card Number 4111 1111 1111 1111
2
Expiry 05/23
3
CVV 123
4
5
Card Number 4000 0000 0000 0002
6
Expiry 05/23
7
CVV 123
Copied!

Step 4 (Optional)

For Transaction List details, you can use the below Get request to get the transaction based on your merchant key.
1
GET API LINK:
2
https://foloosi.com/api/v1/api/transaction-list
3
4
HEADERS:
5
secret_key : YOUR_SECRET_KEY
Copied!
For Transaction Details, you can use the below Get request to get the transaction detail.
1
GET API LINK:
2
http://foloosi.com/api/v1/api/transaction-detail/YOUR_TRANSACTION_ID
3
4
HEADERS:
5
secret_key : YOUR_SECRET_KEY
Copied!

Props

React Foloosi default props to provide a dynamic experience to open a payment widget and allow user to make a payment via Credit/Debit Card.
  • foloosiOpen - Boolean - toggles the popup open state (see above example)
  • foloosiClose - Boolean - Enables the popup close option state (see above example)
  • reference_token - String - sets the Reference Token as reference_token state (Check our Foloosi API in your Merchant Panel)
  • merchant_key - String - sets your Merchant Key as merchant_key state (Check your Profile in Foloosi Merchant Panel to know the Merchant Key)

Success and Error Handlers

React Foloosi gives you the handlers for Payment status and details.
After Payment done, the below line sends the Payment details and status to foloosiHandler function.
1
window.addEventListener('message', this.foloosiHandler);
Copied!
You can get the Payment status in the below function, it may be success or error.
1
foloosiHandler(e){
2
if(e.data.status == 'success'){
3
console.log(e.data);
4
console.log(e.data.data.transaction_no);
5
}
6
if(e.data.status == 'error'){
7
console.log(e.data);
8
console.log(e.data.data.payment_status);
9
}
10
}
Copied!
Last modified 10mo ago