Github Repo for Smart Contracts
Table of Contents
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.
Here are the major framworks which were used in the project
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:-
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.
- Clone the repo
git clone https://github.com/gitanshwadhwa28/POS-API.git
- Install NPM packages
npm install
- Make a
.env
file and inside the file enter your
Mongoose cluster pathDB_CONNECT = "YOUR PATH"
.
Port number for your localhostPORT = "Port Number"
.
Infura endpoint for your projectENDPOINT = "Infura endpoint"
.
Verification string for JSON web tokensVERIFY_TOKEN = "-"
.
Secret session stringSESSION_SECRET = "-"
.
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");
}
})
})