Skip to content

gitanshwadhwa28/POS-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Decentralhacks 2021 💻

Team Pegasas

Github Repo for Smart Contracts :octocat:

Table of Contents
  1. About The Project
  2. Getting Started
  3. Payment Gateway
  4. Application Screenshots

About The Project

Nowadays many business small or big has started accepting UPI Payments , in future as crypto starts to be more accepted we might see businesses & e-commerce websites start accepting Crypto as a form of payment on any purchase.

Created an application which is more accessible for a beginner to integrate Crypto payments with a few lines of code and grow their business. For any online marketplace like E-commerce websites can take different forms of payments to make it much more accessible to their customers. Even with zero knowledge of blockchain or cryptocurrency, one can start accepting payments simply by creating an account on Pegasas web application without any KYC.

Technologies Used

Here are the major framworks which were used in the project

Getting Started

The following section helps in installing the project to run the application locally and the prerequisties required for the same. The prerequisites and the installation guide are as follow:-

Prerequisites

The local machine should have Node js and MongoDB installed

  • npm
    npm install npm@latest -g
  • mongodb

Make sure you are using Chrome browser with Metamask installed.

Installation

  1. Clone the repo
    git clone https://github.com/gitanshwadhwa28/POS-API.git
  2. Install NPM packages
    npm install
  3. Make a .env file and inside the file enter your

    Mongoose cluster path DB_CONNECT = "YOUR PATH".
    Port number for your localhost PORT = "Port Number".
    Infura endpoint for your project ENDPOINT = "Infura endpoint".
    Verification string for JSON web tokens VERIFY_TOKEN = "-".
    Secret session string SESSION_SECRET = "-".

Payment Gateway

app.post("/pay", (req, res) => {

    const data = {
        address: 'SMART CONTRACT ADDRESS',
        amount: AMOUNT
    };
    const url = "https://pos-api-dh.herokuapp.com/pay";
    request.post({
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json'
        },
        uri: url,
        form: data,
    }, function (error, httpRes, body) {
        if (error) {
            console.log("Error", error);
            res.status(400).json(
                {
                    status: false,
                    message: error
                }
            );
        }
        if (httpRes.statusCode === 200) {
            res.send(body);
        } else if (httpRes.statusCode >= 300 && httpRes.statusCode <= 400) {
            res.redirect(httpRes.headers.location.toString());
            console.log("error 300 and 400");
        }
    })
})

Application Screenshots

s1 s2 s3 s4 s5

About

Accept Payments via cryptocurrency with Pegasas Payment Gateway

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •