Foloosi
Search…
Javascript Integration
The Foloosi Payments plugin allows you to accept credit card and debit card payments via Foloosi payment gateway.
Step 1
Just copy these HTML snippets and paste it before closing of <body> tag.
1
<script type="text/javascript">
2
var options = {
3
"reference_token" : "REFERENCE_TOKEN", //which is get from step2
4
"merchant_key" : "YOUR_MERCHANT_KEY",
5
"redirect" : true | false // If you need redirection method, this parameter is must
6
}
7
var fp1 = new Foloosipay(options);
8
</script>
9
<script type="text/javascript" src="https://www.foloosi.com/js/foloosipay.v2.js"></script>
Copied!
Note : Apple Pay option available for Redirection Method
Step 2 - Initialize Payment Setup
Post the following data's in below API link to requesting 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
transaction_amount : YOUR_TRANSACTION_AMOUNT
9
currency : YOUR_CURRENCY_CODE
10
customer_name : OPTIONAL /*note : auto render in payment popup*/
11
customer_email : OPTIONAL /*note : auto render in payment popup*/
12
customer_mobile : OPTIONAL /*note : auto render in payment popup*/
13
customer_address : OPTIONAL /*note : minimize form fields in card detail page*/
14
customer_city : OPTIONAL /*note : minimize form fields in card detail page*/
15
site_return_url: OPTIONAL /*note : if you pass redirect as true in step 1, need to pass this params. */
Copied!
Note : This params site_return_url used for redirecting to your website after payment done. This redirection comes with Post data like Transaction Status and Transaction ID.
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.Response
1
{
2
"message": "Application setup successfully",
3
"data": {
4
"reference_token":
5
"U0sjdGVzdF8kMnkkMTAkM21LRi0xZGliVDhldTV4NHlZSm9tZXZobnZxWTNEVnZmay1MdHNndTNFenNBTDU0clhWYkccVE4jRkxTQVBJNWM3Njk2ZDkwOWIzNxxSVCMkMnkkMTAkQXZ4ay9wdjlpTFlYLzRSZ2FjSkxpZWhHb2o0U0wvTFpZNXAyVjRGOVFycWNQZ2lHQ3VEZ08="
6
}
7
}
Copied!
Step 3
Just paste the following code to Open and Close the Payment Widget.
For Open a Widget, refer the code below. fp1.open();
For Close a Widget, refer the code below. fp1.close();
Step 4
When you click place order button our popup will be loaded so you can use test card credentials from test card section to complete the order.
note: Test card is valid only for test mode
Step 5 (For Success and Error Handlers)
For Success and Error Handlers, you can use the below handler function to get the payment response.
1
foloosiHandler(response, function (e) {
2
if(e.data.status == 'success'){
3
//responde success code
4
//console.log(e.data.status);
5
//console.log(e.data.data.transaction_no);
6
}
7
if(e.data.status == 'error'){
8
//responde success code
9
//console.log(e.data.status);
10
//console.log(e.data.data.payment_status);
11
}
12
if(e.data.status == 'closed'){
13
//Payment Popup Closed
14
//console.log(e.data);
15
}
16
});
Copied!
Note: Site must be https with proper SSL certificate.
To get the Transaction Details
For Transaction Details, you can use the below Get request to get the transaction details.
1
GET API LINK: http://foloosi.com/api/v1/api/transaction-detail/YOUR_TRANSACTION_ID
2
3
HEADERS:
4
secret_key : YOUR_SECRET_KEY
Copied!
To get the Transaction List
For Transaction List details, you can use the below Get request to get the transaction based on your merchant key.
1
GET API LINK: https://foloosi.com/api/v1/api/transaction-list
2
3
HEADERS:
4
secret_key : YOUR_SECRET_KEY
Copied!
Copy link