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

react-foloosi-widget

v1.0.8

Published

Foloosi Payment - React

Downloads

55

Readme

react-foloosi-widget

Foloosi Payment Gateway for your Online Business.

Install

with npm

npm install --save react-foloosi-widget

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.

import {Foloosi} from 'react-foloosi-widget';

class App extends Component {
  state = {
    foloosiOpen: false,
    reference_token:'YOUR_REFERENCE_TOKEN',
    merchant_key:'YOUR_MERCHANT_KEY',
    redirect: true | false // If you need redirection method with value as true, this parameter is must for both redirection and ApplePay
  };
  foloosiHandler(e){
    if(e.data.status == 'success'){
        console.log(e.data);
        console.log(e.data.data.transaction_no);
    }
    if(e.data.status == 'error'){
        console.log(e.data);
        console.log(e.data.data.payment_status);
    }
  }
  componentDidUpdate(){
    window.addEventListener('message', this.foloosiHandler);
  }
  foloosiOpen(){
    this.setState({foloosiOpen: true});
  }
  render() {
    return (
      <div>
        <span onClick={e => this.foloosiOpen(e)}>Foloosi</span>
        <Foloosi foloosiOpen={this.state.foloosiOpen} foloosiClose={true} reference_token={this.state.reference_token} merchant_key={this.state.merchant_key} redirect={this.state.redirect}
          />
      </div> 
    );
  }
}

Step 2

Post the following data's in below API link to requesting reference token for accessing the payment gateway.

  POST API LINK :
  https://foloosi.com/api/v1/api/initialize-setup

  HEADERS:
  merchant_key : YOUR_MERCHANT_KEY

  BODY:
  redirect_url : YOUR_REDIRECT_URL
  transaction_amount : YOUR_TRANSACTION_AMOUNT
  currency : YOUR_CURRENCY_CODE
  customer_name : OPTIONAL /*note : auto render in payment popup*/
  customer_email : OPTIONAL /*note : auto render in payment popup*/
  customer_mobile : OPTIONAL /*note : auto render in payment popup*/
  customer_address : OPTIONAL /*note : minimize form fields in card detail page*/
  customer_city : OPTIONAL /*note : minimize form fields in card detail page*/
  site_return_url : YOUR_RETURN_URL /*note : Needed for Redirection method and also for ApplePay.*/

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
  {
  "message": "Application setup successfully",
  "data": {
      "reference_token" : "YOUR_REFERENCE_TOKEN",
      "payment_qr_data" : "YOUR_PAYMENT_QR_DATA",
      "payment_qr_url" : "YOUR_PAYMENT_QR_URL"
    }
  } 

Here, we are given QR code for your transaction amount. A we mentioned in above For example: In above the response, just take payment_qr_url and show in image tag


<img src ="payment_qr_url" width ="400px" height="400px">

width and height is depending on your requirement.

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.

  Card Number 4111 1111 1111 1111
  Expiry 05/20
  CVV 123

  Card Number 4242 4242 4242 4242
  Expiry 05/23
  CVV 123

Step 4 (Optional)

For Transaction List details, you can use the below Get request to get the transaction based on your merchant key.

  GET API LINK:
  https://foloosi.com/api/v1/api/transaction-list

  HEADERS:
  secret_key : YOUR_SECRET_KEY

For Transaction Details, you can use the below Get request to get the transaction detail.

  GET API LINK:
  http://foloosi.com/api/v1/api/transaction-detail/YOUR_TRANSACTION_ID

  HEADERS:
  secret_key : YOUR_SECRET_KEY

Generate QR Code

Post the following data's in below API link to requesting QR code.This option for foloosi customer can do scan and pay transaction.

  POST API LINK :
  https://foloosi.com/api/v1/api/generate-qr-api

  HEADERS:
  secret_key : YOUR_SECRET_KEY

  BODY:
  amount : YOUR_TRANSACTION_AMOUNT
  description : DESCRIPTION 
Response
  {
  "message": "QR created successfully",
  "data": {
      "payment_qr_data" : "YOUR_PAYMENT_QR_DATA",
      "payment_qr_url" : "YOUR_PAYMENT_QR_URL"
    }
  }   

Here, we are given QR code for your transaction amount. A we mentioned in above For example: In above the response, just take payment_qr_url and show in image tag

<img src ="payment_qr_url" width ="400px" height="400px">

width and height is depending on your requirement.

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.

window.addEventListener('message', this.foloosiHandler);

You can get the Payment status in the below function, it may be success or error.

  foloosiHandler(e){
    if(e.data.status == 'success'){
        console.log(e.data);
        console.log(e.data.data.transaction_no);
    }
    if(e.data.status == 'error'){
        console.log(e.data);
        console.log(e.data.data.payment_status);
    }
  }

Author

This component is written by Muthukumar D.

License

Foloosi 2019 © All Rights Reserved. foloosi