Skip to content
This repository was archived by the owner on Jul 4, 2024. It is now read-only.

Commit 28e5d6b

Browse files
committed
Will be writing documentation today
1 parent 7c48958 commit 28e5d6b

File tree

3 files changed

+15
-85
lines changed

3 files changed

+15
-85
lines changed

src/cred/authKey.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
const { PRIVATE_KEY } = process.env;
2-
const { PRIVATE_KEY_ID } = process.env;
3-
const { CERT_URL } = process.env;
41
module.exports = {
52
authKey: {
63
type: "service_account",
7-
project_id: "ecom-test-53555",
8-
private_key_id: PRIVATE_KEY_ID,
9-
private_key: PRIVATE_KEY.replace(/\\n/g, "\n"),
10-
client_email:
11-
"firebase-adminsdk-ijb5q@ecom-test-53555.iam.gserviceaccount.com",
12-
client_id: "101621889260973490183",
13-
auth_uri: "https://accounts.google.com/o/oauth2/auth",
14-
token_uri: "https://oauth2.googleapis.com/token",
15-
auth_provider_x509_cert_url: "https://www.googleapis.com/oauth2/v1/certs",
16-
client_x509_cert_url: CERT_URL,
4+
project_id: "Your Project id",
5+
private_key_id: " Your PRIVATE_KEY_ID",
6+
private_key: "Your PRIVATE_KEY",
7+
client_email: "Your client email",
8+
client_id: "Your client id",
9+
auth_uri: "your auth uri",
10+
token_uri: "auth token uri",
11+
auth_provider_x509_cert_url: "cert url provider",
12+
client_x509_cert_url: " your CERT_URL",
1713
},
1814
};

src/payConf.js

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ const serviceAccount = require("./cred/authKey").authKey;
2424
if (!admin.apps.length) {
2525
admin.initializeApp({
2626
credential: admin.credential.cert(serviceAccount),
27-
databaseURL: "https://ecom-test-53555.firebaseio.com",
28-
databaseAuthVariableOverride: {
29-
uid: "lSC134A31NZqjxaEtGvaKfG0PTA3",
30-
},
27+
databaseURL: "Your database url",
3128
});
3229
}
3330
//firebase
@@ -37,7 +34,6 @@ router.post("/", cors(corsOptions), (req, res) => {
3734
if (
3835
paytm_checksum.verifychecksum(req.body, paytm_config.MERCHANT_KEY, checksum)
3936
) {
40-
console.log("checksum verified local");
4137
var paytmParams = {};
4238

4339
paytmParams.body = {
@@ -53,7 +49,6 @@ router.post("/", cors(corsOptions), (req, res) => {
5349
paytmParams.head = {
5450
signature: checksum,
5551
};
56-
console.log("generated signature");
5752
var post_data = JSON.stringify(paytmParams);
5853

5954
var options = {
@@ -70,45 +65,35 @@ router.post("/", cors(corsOptions), (req, res) => {
7065
"Content-Length": post_data.length,
7166
},
7267
};
73-
console.log("this is before request");
7468
var response = "";
7569
var post_req = https.request(options, function (post_res) {
7670
post_res.on("data", function (chunk) {
7771
response += chunk;
7872
});
7973
post_res.on("end", async () => {
80-
console.log("from paytm");
8174
const resBody = JSON.parse(response);
82-
console.log(resBody);
8375
const paytm_response = resBody.body.resultInfo;
8476
if (paytm_response.resultStatus === "TXN_SUCCESS") {
85-
console.log("isSuccess");
8677
const date = `${Date().slice(11, 15)}_${Date().slice(
8778
4,
8879
7
8980
)}_${Date().slice(8, 10)}`;
90-
console.log(date);
9181
await admin
9282
.database()
9383
.ref(`/Orders/${date}/${req.body.ORDERID}`)
9484
.set({
9585
orderId: req.body.ORDERID,
9686
})
9787
.then(() => {
98-
console.log("sending data");
9988
res.send(
100-
`<script>window.location ='https://tiaamo.com/order/?paytm_response=${paytm_response.resultStatus}' </script>`
89+
`<script>window.location ='https://your_site_order_confirmation_url/?paytm_response=${paytm_response.resultStatus}' </script>`
10190
);
10291
})
103-
.catch((err) => {
104-
console.log(err);
105-
("<script>window.location ='https://tiaamo.com/cart' </script>");
92+
.catch(() => {
93+
("<script>window.location ='fallback_url' </script>");
10694
});
10795
} else if (paytm_response.resultStatus === "TXN_FAILURE") {
108-
console.log("isFailure");
109-
res.send(
110-
"<script>window.location ='https://tiaamo.com/cart'</script>"
111-
);
96+
res.send("<script>window.location ='fallback_url'</script>");
11297
}
11398
});
11499
});
@@ -117,7 +102,7 @@ router.post("/", cors(corsOptions), (req, res) => {
117102
post_req.end();
118103
});
119104
} else {
120-
res.send("<script>window.location ='http://tiaamo.com/cart' </script>");
105+
res.send("<script>window.location ='fallback_url' </script>");
121106
}
122107
});
123108
app.use("/.netlify/functions/payConf", router);

src/syncOrder.js

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)