elpaypg 2.0.8 → 2.1.0
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.
- package/package.json +3 -1
- package/src/index.js +22 -1
- package/src/services/whatsapp-berry.service.js +3 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elpaypg",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "ELPAY PG - single-backend payment gateway module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
".env.example"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
+
"@berrysdk/core": "^0.1.10",
|
|
18
|
+
"berryprotocol": "^0.1.10",
|
|
17
19
|
"express": "^4.19.0",
|
|
18
20
|
"qrcode": "^1.5.4"
|
|
19
21
|
},
|
package/src/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
PaymentVerificationPipeline
|
|
26
26
|
} from './vendor/core/index.js';
|
|
27
27
|
import { createRouter } from './router.js';
|
|
28
|
+
import { getWhatsAppBerryService, WhatsAppBerryService } from './services/whatsapp-berry.service.js';
|
|
28
29
|
|
|
29
30
|
const __filename = fileURLToPath(import.meta.url);
|
|
30
31
|
const __dirname = path.dirname(__filename);
|
|
@@ -110,10 +111,22 @@ export async function elpay(options = {}) {
|
|
|
110
111
|
server: null, eventEmitter
|
|
111
112
|
});
|
|
112
113
|
|
|
114
|
+
const whatsappDataDir = options.whatsappDataDir || path.resolve(process.cwd(), 'data', 'whatsapp');
|
|
115
|
+
const whatsappEnabled = options.whatsapp !== false;
|
|
116
|
+
const whatsappBerryService = !whatsappEnabled
|
|
117
|
+
? null
|
|
118
|
+
: (options.whatsappBerryService || getWhatsAppBerryService({
|
|
119
|
+
sessionId: options.whatsappSessionId || 'elpay_berry_session',
|
|
120
|
+
sessionPath: path.join(whatsappDataDir, 'auth'),
|
|
121
|
+
databasePath: path.join(whatsappDataDir, 'store.db'),
|
|
122
|
+
metaFile: path.join(whatsappDataDir, 'session.json')
|
|
123
|
+
}));
|
|
124
|
+
|
|
113
125
|
const ctx = {
|
|
114
126
|
db, merchantRepo, accountRepo, customerRepo, customerSessionRepo, sessionRepo, deviceRepo,
|
|
115
127
|
obsRepo, ticketRepo, auditRepo, queueEngine, timingEngine, attributionEngine, pipeline,
|
|
116
128
|
recoveryEngine, eventEmitter, defaultMerchant, checkoutBaseUrl, webhookEngine,
|
|
129
|
+
whatsappBerryService,
|
|
117
130
|
baseUrl: options.baseUrl || process.env.BASE_URL || 'http://localhost:5000',
|
|
118
131
|
otpCooldownMs: options.otpCooldownMs,
|
|
119
132
|
theme: options.theme || {}
|
|
@@ -124,12 +137,20 @@ export async function elpay(options = {}) {
|
|
|
124
137
|
const destroy = () => {
|
|
125
138
|
timingEngine.destroy?.();
|
|
126
139
|
attributionEngine.destroy?.();
|
|
140
|
+
if (whatsappBerryService && typeof whatsappBerryService.disconnect === 'function') {
|
|
141
|
+
whatsappBerryService.disconnect({ cleanSession: false }).catch(() => {});
|
|
142
|
+
}
|
|
127
143
|
};
|
|
128
144
|
|
|
129
145
|
return {
|
|
130
146
|
router,
|
|
147
|
+
whatsappBerryService,
|
|
131
148
|
on: (event, cb) => eventEmitter.on(event, cb),
|
|
132
|
-
init: async () => {
|
|
149
|
+
init: async () => {
|
|
150
|
+
if (whatsappBerryService && typeof whatsappBerryService.initialize === 'function') {
|
|
151
|
+
whatsappBerryService.initialize().catch(() => {});
|
|
152
|
+
}
|
|
153
|
+
},
|
|
133
154
|
destroy,
|
|
134
155
|
};
|
|
135
156
|
}
|
|
@@ -16,11 +16,8 @@ async function loadDependencies() {
|
|
|
16
16
|
const candidates = [
|
|
17
17
|
'berryprotocol',
|
|
18
18
|
pathToFileURL(path.resolve(rootDir, 'node_modules/berryprotocol/dist/index.js')).href,
|
|
19
|
-
pathToFileURL(path.resolve(
|
|
20
|
-
'
|
|
21
|
-
'file:///D:/E-Commerce PKG/services/whatsapp-worker/node_modules/berryprotocol/dist/index.js',
|
|
22
|
-
'file:///D:/ECOM AND ELPAY PG INTEGRATION/E-Commerce PACKAGE/services/whatsapp-worker/node_modules/berryprotocol/dist/index.js',
|
|
23
|
-
'file:///D:/distribution/services/whatsapp-worker/node_modules/berryprotocol/dist/index.js'
|
|
19
|
+
pathToFileURL(path.resolve(process.cwd(), 'node_modules/berryprotocol/dist/index.js')).href,
|
|
20
|
+
pathToFileURL(path.resolve(process.cwd(), 'node_modules/elpaypg/node_modules/berryprotocol/dist/index.js')).href
|
|
24
21
|
];
|
|
25
22
|
for (const p of candidates) {
|
|
26
23
|
try {
|
|
@@ -37,11 +34,7 @@ async function loadDependencies() {
|
|
|
37
34
|
const qrCandidates = [
|
|
38
35
|
'qrcode',
|
|
39
36
|
pathToFileURL(path.resolve(rootDir, 'node_modules/qrcode/lib/index.js')).href,
|
|
40
|
-
pathToFileURL(path.resolve(
|
|
41
|
-
'file:///D:/WA-USERAUTH DEV/node_modules/qrcode/lib/index.js',
|
|
42
|
-
'file:///D:/E-Commerce PKG/services/whatsapp-worker/node_modules/qrcode/lib/index.js',
|
|
43
|
-
'file:///D:/ECOM AND ELPAY PG INTEGRATION/E-Commerce PACKAGE/services/whatsapp-worker/node_modules/qrcode/lib/index.js',
|
|
44
|
-
'file:///D:/distribution/services/whatsapp-worker/node_modules/qrcode/lib/index.js'
|
|
37
|
+
pathToFileURL(path.resolve(process.cwd(), 'node_modules/qrcode/lib/index.js')).href
|
|
45
38
|
];
|
|
46
39
|
for (const p of qrCandidates) {
|
|
47
40
|
try {
|