Skip to content

Commit

Permalink
Create main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Junaid433 authored Apr 12, 2023
1 parent 4872e8a commit bb32be1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const express = require('express');
const stripefuncs = require('./index');
const app = express()
const port = 3000

app.get('/', async (req, res) => {
url = req.query.url
if (!url){
res.send({error : 'url not found'})
return
}
[pk, urlx] = await stripefuncs.getStripePK(url)
if (!pk){
res.send({error : 'unknown error'})
return
}
amount = await stripefuncs.getAmountDue(urlx, pk)
email = await stripefuncs.getCustomerEmail(urlx, pk)
cs = await stripefuncs.getCheckoutSession(urlx, pk)
curr = await stripefuncs.getCheckoutCurrency(urlx, pk)
res.send({
pk : pk,
amount : amount,
email : email,
checkout : cs,
currency : curr
})
return
})

app.listen(port, () => {
console.log(`app listening on port ${port}`)
})

0 comments on commit bb32be1

Please sign in to comment.