diff --git a/netlify.toml b/netlify.toml index 0e98eef..226f47f 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,4 +3,4 @@ to = "/index.html" status = 200 [functions] - included_files = ["./src/assets/serviceList.txt", "/src/assets/serviceList.txt" ] \ No newline at end of file + included_files = ["./src/assets/serviceList.txt", "/src/assets/serviceList.txt", "./src/assets/serviceList.json", "/src/assets/serviceList.json"] \ No newline at end of file diff --git a/netlify/functions/get1ServiceStock.js b/netlify/functions/get1ServiceStock.js new file mode 100644 index 0000000..537c5f8 --- /dev/null +++ b/netlify/functions/get1ServiceStock.js @@ -0,0 +1,37 @@ +const mongoDBPassword = process.env.mongoDBPassword +const mongoServerLocation = process.env.mongoServerLocation +const { MongoClient, ServerApiVersion } = require('mongodb') +const Joi = require("joi") +const uri = "mongodb+srv://main:" + mongoDBPassword + "@"+ mongoServerLocation + "/?retryWrites=true&w=majority" +const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 }) +const phoneInfoCollection = client.db("real").collection("phonesInfo") +exports.handler = async (event) => { + const phoneMap = [] + try { + const phoneInfo = await phoneInfoCollection.find().toArray() + for (const phone of phoneInfo) { + const tempObject = { + sim1: ['all'], + sim2: ['all'] + } + if (phone.sim1.phoneNumber.length > 5) { + tempObject.sim1 = phone.sim1.usedServices + } + if (phone.sim2.phoneNumber.length > 5) { + tempObject.sim2 = phone.sim2.usedServices + } + phoneMap.push(tempObject) + } + return { + statusCode: 200, + body: JSON.stringify(phoneMap) + } + } + catch (error) { + console.log(error) + return { + statusCode: 500, + body: '' + } + } +} \ No newline at end of file diff --git a/netlify/functions/submitOrder.js b/netlify/functions/submitOrder.js index f166dc1..2610bbc 100644 --- a/netlify/functions/submitOrder.js +++ b/netlify/functions/submitOrder.js @@ -4,9 +4,8 @@ const axios = require("axios") const Joi = require("joi") const fs = require('fs') const path = require("path") -const pathWordlist = path.resolve("./src/assets/serviceList.txt") -const serviceList = fs.readFileSync(pathWordlist, 'utf8').toString().split("\n") - +const pathServiceList = path.resolve("./src/assets/serviceList.json") +const serviceList = JSON.parse(fs.readFileSync(pathServiceList, 'utf8')) exports.handler = async (event, context) => { try { const params = event.body @@ -129,8 +128,8 @@ async function process1Service(parsed) { await serviceSchema.validateAsync(parsed.purchaseInfo.service) let serviceCorrect = false - for (let element of serviceList) { - if (element.replace(/[^a-zA-Z ]/g, "") === parsed.purchaseInfo.service.replace(/[^a-zA-Z ]/g, "")) { + for (let element of Object.keys(serviceList)) { + if (element === parsed.purchaseInfo.service) { serviceCorrect = true break } @@ -142,7 +141,7 @@ async function process1Service(parsed) { const response = await axios.post( storeAddress, { - 'amount': '2', + 'amount': serviceList[parsed.purchaseInfo.service].price, 'speedPolicy': 'MediumSpeed', 'checkout': { 'paymentMethods': [ @@ -155,7 +154,7 @@ async function process1Service(parsed) { numberArray: numberArray, purchase: { serviceType: '1service', - service: parsed.purchaseInfo.service.replace(/[^a-zA-Z ]/g, "") + service: parsed.purchaseInfo.service }, timestamp: Date.now() } diff --git a/src/assets/serviceList.json b/src/assets/serviceList.json new file mode 100644 index 0000000..efe86c0 --- /dev/null +++ b/src/assets/serviceList.json @@ -0,0 +1,47 @@ +{ + "Twitter": { + "price": 1.50 + }, + "Google Voice": { + "price": 1.50 + }, + "Signal": { + "price": 1.50 + }, + "Apple": { + "price": 1.50 + }, + "Telegram": { + "price": 3.00 + }, + "Instagram": { + "price": 1.50 + }, + "Paypal": { + "price": 1.50 + }, + "Tinder": { + "price": 1.50 + }, + "Bumble": { + "price": 1.50 + }, + "Hinge": { + "price": 1.50 + }, + "Uber": { + "price": 1.50 + }, + "Tik Tok": { + "price": 1.50 + }, + "Uber Eats": { + "price": 1.50 + }, + "Grubhub": { + "price": 1.50 + }, + "DoorDash": { + "price": 1.50 + } +} \ No newline at end of file diff --git a/src/assets/serviceList.txt b/src/assets/serviceList.txt deleted file mode 100644 index 7a116c9..0000000 --- a/src/assets/serviceList.txt +++ /dev/null @@ -1,15 +0,0 @@ -Twitter -Google Voice -Signal -Apple -Facebook -Instagram -Paypal -Tinder -Bumble -Hinge -Uber -TikTok -Uber Eats -Grubhub -DoorDash \ No newline at end of file diff --git a/src/views/checkout1service.vue b/src/views/checkout1service.vue index c2538b3..d8ed2ef 100644 --- a/src/views/checkout1service.vue +++ b/src/views/checkout1service.vue @@ -1,10 +1,10 @@