node-paytmpg 6.4.6 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.MD +132 -182
  2. package/app/views/layouts/index.hbs +7 -7
  3. package/app/views/result.hbs +1 -1
  4. package/dist/app/controllers/adapters/open_money.js +400 -0
  5. package/dist/app/controllers/adapters/paytm.js +34 -0
  6. package/{app → dist/app}/controllers/adapters/payu.js +208 -239
  7. package/dist/app/controllers/checksum/PaytmChecksum.js +118 -0
  8. package/dist/app/controllers/checksum/checksum.js +158 -0
  9. package/dist/app/controllers/checksum/crypt.js +117 -0
  10. package/dist/app/controllers/checksum/server.js +130 -0
  11. package/dist/app/controllers/payment.controller.js +985 -0
  12. package/dist/app/controllers/static/loadingsvg.js +54 -0
  13. package/dist/app/controllers/user.controller.js +53 -0
  14. package/dist/app/models/index.js +2 -0
  15. package/dist/app/routes/payment_route.js +46 -0
  16. package/dist/app/utils/buildConfig.js +210 -0
  17. package/dist/app/utils/utils.js +20 -0
  18. package/dist/app/views/home.hbs +22 -0
  19. package/dist/app/views/init.hbs +98 -0
  20. package/dist/app/views/layouts/index.hbs +53 -0
  21. package/dist/app/views/result.hbs +33 -0
  22. package/dist/index.js +119 -0
  23. package/dist/package.json +67 -0
  24. package/dist/public/css/style.css +455 -0
  25. package/dist/public/js/index.js +283 -0
  26. package/dist/public/layer_checkout.js +38 -0
  27. package/dist/public/pay.png +0 -0
  28. package/dist/public/start.png +0 -0
  29. package/dist/public/start2.png +0 -0
  30. package/dist/public/stat.png +0 -0
  31. package/dist/public/test.html +24 -0
  32. package/dist/public/test.html~ +24 -0
  33. package/package.json +29 -6
  34. package/public/test.html~ +24 -0
  35. package/.github/workflows/codeql-analysis.yml +0 -71
  36. package/.github/workflows/nodejs.yml +0 -24
  37. package/.github/workflows/npm-publish.yml +0 -23
  38. package/Dockerfile +0 -9
  39. package/app/controllers/adapters/open_money.js +0 -515
  40. package/app/controllers/checksum/PaytmChecksum.js +0 -94
  41. package/app/controllers/checksum/checksum.js +0 -154
  42. package/app/controllers/checksum/crypt.js +0 -98
  43. package/app/controllers/checksum/server.js +0 -132
  44. package/app/controllers/np_user.controller.js +0 -89
  45. package/app/controllers/payment_controller.js +0 -1204
  46. package/app/models/np_multidbplugin.js +0 -111
  47. package/app/models/np_transaction.model.js +0 -16
  48. package/app/models/np_user.model.js +0 -12
  49. package/app/routes/payment_route.js +0 -73
  50. package/app.yaml +0 -18
  51. package/example.js +0 -34
  52. package/index.js +0 -86
  53. package/lib/config/buildConfig.js +0 -113
  54. package/lib/config/defaults.js +0 -37
  55. package/lib/config/validator.js +0 -103
  56. package/lib/services/database.service.js +0 -153
  57. package/lib/utils/id-generator.js +0 -30
  58. package/lib/utils/sanitizer.js +0 -25
@@ -1,153 +0,0 @@
1
- /**
2
- * Database Service
3
- * Abstracts database operations to support both MongoDB (legacy) and MultiDB ORM
4
- */
5
- class DatabaseService {
6
- constructor(db, config) {
7
- this.db = db;
8
- this.config = config;
9
- this.usingMultiDbOrm = this.detectDbType();
10
-
11
- // Will be initialized later
12
- this.Transaction = null;
13
- this.User = null;
14
- }
15
-
16
- /**
17
- * Detects whether we're using MultiDB ORM or MongoDB
18
- */
19
- detectDbType() {
20
- // Using MultiDB ORM if db instance provided and no db_url in config
21
- return !!this.db && !this.config.db_url;
22
- }
23
-
24
- /**
25
- * Initializes transaction model
26
- */
27
- initTransactionModel() {
28
- if (this.config.db_url) {
29
- // Legacy MongoDB mode
30
- this.Transaction = require('../models/transaction.model');
31
- } else if (this.db) {
32
- // MultiDB ORM mode
33
- const sample = {
34
- orderId: "string",
35
- cusId: "string",
36
- time: 1770051201752,
37
- timeStamp: 1770051201752,
38
- status: "string",
39
- name: "string",
40
- email: "string",
41
- phone: "string",
42
- amount: 1,
43
- pname: "string",
44
- extra: "stringlarge",
45
- TXNID: "27118670199",
46
- returnUrl: "string"
47
- };
48
-
49
- const multiDbPlugin = require('../models/np_multidbplugin');
50
- this.Transaction = multiDbPlugin('nptransactions', this.db, sample);
51
- this.Transaction.db = this.db;
52
- this.Transaction.modelname = 'nptransactions';
53
- this.Transaction.idFieldName = 'orderId';
54
- }
55
-
56
- return this.Transaction;
57
- }
58
-
59
- /**
60
- * Initializes user model
61
- */
62
- initUserModel() {
63
- if (this.config.db_url) {
64
- // Legacy MongoDB mode
65
- this.User = require('../models/user.model');
66
- } else if (this.db) {
67
- // MultiDB ORM mode
68
- const sample = {
69
- id: "string",
70
- name: "string",
71
- email: "string",
72
- phone: "string"
73
- };
74
-
75
- const multiDbPlugin = require('../models/np_multidbplugin');
76
- this.User = multiDbPlugin('npusers', this.db, sample);
77
- this.User.db = this.db;
78
- this.User.modelname = 'npusers';
79
- this.User.idFieldName = 'id';
80
- }
81
-
82
- return this.User;
83
- }
84
-
85
- /**
86
- * Finds one document
87
- * @param {Object} model - Mongoose model or MultiDB model
88
- * @param {Object} query - Query object
89
- * @param {Function} callback - Callback function (err, doc)
90
- */
91
- findOne(model, query, callback) {
92
- if (this.usingMultiDbOrm) {
93
- model.findOne(query, callback, model);
94
- } else {
95
- model.findOne(query, callback);
96
- }
97
- }
98
-
99
- /**
100
- * Creates and saves a new document
101
- * @param {Object} modelClass - Model constructor
102
- * @param {Object} data - Data to save
103
- * @returns {Promise} Promise that resolves with saved document
104
- */
105
- create(modelClass, data) {
106
- const doc = new modelClass(data);
107
- return doc.save();
108
- }
109
-
110
- /**
111
- * Updates one document
112
- * @param {Object} model - Mongoose model or MultiDB model
113
- * @param {Object} query - Query object
114
- * @param {Object} update - Update object
115
- * @param {Function} callback - Callback function (err, result)
116
- */
117
- updateOne(model, query, update, callback) {
118
- if (this.usingMultiDbOrm) {
119
- model.updateOne(query, update, callback);
120
- } else {
121
- model.updateOne(query, update, callback);
122
- }
123
- }
124
-
125
- /**
126
- * Gets the Transaction model
127
- */
128
- getTransactionModel() {
129
- if (!this.Transaction) {
130
- this.initTransactionModel();
131
- }
132
- return this.Transaction;
133
- }
134
-
135
- /**
136
- * Gets the User model
137
- */
138
- getUserModel() {
139
- if (!this.User) {
140
- this.initUserModel();
141
- }
142
- return this.User;
143
- }
144
-
145
- /**
146
- * Returns whether using MultiDB ORM
147
- */
148
- isUsingMultiDbOrm() {
149
- return this.usingMultiDbOrm;
150
- }
151
- }
152
-
153
- module.exports = DatabaseService;
@@ -1,30 +0,0 @@
1
- /**
2
- * Generates a random alphanumeric ID
3
- * @param {number} length - Length of the ID to generate
4
- * @returns {string} Random ID
5
- */
6
- function generateId(length = 10) {
7
- const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
8
- let text = "";
9
-
10
- for (let i = 0; i < length; i++) {
11
- text += possible.charAt(Math.floor(Math.random() * possible.length));
12
- }
13
-
14
- return text;
15
- }
16
-
17
- /**
18
- * Generates an order ID with a prefix
19
- * @param {string} prefix - Prefix for the order ID (e.g., 'pay_', 'payu_')
20
- * @param {number} length - Length of the random part
21
- * @returns {string} Order ID
22
- */
23
- function generateOrderId(prefix = '', length = 10) {
24
- return prefix + generateId(length);
25
- }
26
-
27
- module.exports = {
28
- generateId,
29
- generateOrderId
30
- };
@@ -1,25 +0,0 @@
1
- /**
2
- * Sanitizes request body by parsing amount fields to floats
3
- * @param {Object} body - Request body to sanitize
4
- * @returns {Object} Sanitized request body
5
- */
6
- function sanitizeRequest(body) {
7
- if (!body || typeof body !== 'object') {
8
- return body;
9
- }
10
-
11
- // Parse amount to float if present
12
- if (body.amount) {
13
- body.amount = parseFloat(body.amount);
14
- }
15
-
16
- if (body.TXN_AMOUNT) {
17
- body.TXN_AMOUNT = parseFloat(body.TXN_AMOUNT);
18
- }
19
-
20
- return body;
21
- }
22
-
23
- module.exports = {
24
- sanitizeRequest
25
- };