wahdx-api 2.0.0 → 2.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 wahdalo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # wahdx-api
2
2
 
3
- Package untuk generate QRIS dan cek payment status secara realtime dengan API OrderKuota dari [https://api.wahdx.co](https://api.wahdx.co).
3
+ Package untuk generate QRIS dan cek payment status secara realtime dengan API OrderKuota dari [https://eqris.com](https://eqris.com).
4
4
 
5
- > **⚠️ PENTING: Perubahan di Versi 2.0.0**
5
+ > **PENTING: Perubahan di Versi 2.0.2**
6
+ >
7
+ > Endpoint mutasi OrderKuota terbaru membutuhkan `captcha_key`. Nilai ini adalah API key dari 2Captcha yang diperlukan untuk auto resolve captcha. Tambahkan `ORKUT_CAPTCHA_KEY` di `.env` dan kirim sebagai `captcha_key` pada konfigurasi package.
8
+
9
+ > **PENTING: Perubahan di Versi 2.0.0**
6
10
  >
7
11
  > Pada versi 2.0.0, kami melakukan perubahan besar pada package ini:
8
12
  > - Fitur `generateQRFromImage` telah **DIHAPUS** sepenuhnya
@@ -32,9 +36,10 @@ Buat file `.env` di root project Anda:
32
36
  WAHDX_TOKENKEY=your_wahdx_token_key
33
37
  ORKUT_TOKEN_AUTH=your_orkut_token_auth
34
38
  ORKUT_USERNAME=your_orkut_username
39
+ ORKUT_CAPTCHA_KEY=your_2captcha_api_key
35
40
  ```
36
41
 
37
- > **Catatan:** Untuk mendapatkan tokenKey, Anda bisa membelinya di halaman [https://api.wahdx.co](https://api.wahdx.co)
42
+ > **Catatan:** Untuk mendapatkan tokenKey, Anda bisa membelinya di halaman [https://eqris.com](https://eqris.com)
38
43
 
39
44
  ### Opsi Konfigurasi
40
45
 
@@ -45,6 +50,7 @@ ORKUT_USERNAME=your_orkut_username
45
50
  | tokenKey | Token key dari WAHDX | - |
46
51
  | auth_token | Token autentikasi OrderKuota | - |
47
52
  | auth_username | Username OrderKuota | - |
53
+ | captcha_key | API key 2Captcha untuk auto resolve captcha pada endpoint mutasi OrderKuota | - |
48
54
  | autoGenerateReceipt | Mengaktifkan/menonaktifkan pembuatan receipt otomatis | true |
49
55
 
50
56
  ## Penggunaan
@@ -61,8 +67,9 @@ const config = {
61
67
  storeName: 'AHDX STORE',
62
68
  baseQrString: 'base-qr-string-anda', // Diperlukan untuk generateQR secara lokal
63
69
  tokenKey: process.env.WAHDX_TOKENKEY, // Diperlukan untuk generateQRFromAPI
64
- auth_token: process.env.ORKUT_TOKEN_AUTH, // Diperlukan untuk generateQRFromAPI
65
- auth_username: process.env.ORKUT_USERNAME, // Diperlukan untuk generateQRFromAPI
70
+ auth_token: process.env.ORKUT_TOKEN_AUTH, // Diperlukan untuk generateQRFromAPI dan checkPayment
71
+ auth_username: process.env.ORKUT_USERNAME, // Diperlukan untuk generateQRFromAPI dan checkPayment
72
+ captcha_key: process.env.ORKUT_CAPTCHA_KEY, // API key 2Captcha untuk auto resolve captcha endpoint mutasi
66
73
  autoGenerateReceipt: true // Atur false jika tidak ingin otomatis membuat receipt
67
74
  };
68
75
 
@@ -129,8 +136,9 @@ const config = {
129
136
  storeName: 'NAMA TOKO',
130
137
  baseQrString: 'base-qr-string-anda', // Diperlukan untuk generateQR secara lokal
131
138
  tokenKey: 'your_wahdx_token_key', // Diperlukan untuk generateQRFromAPI
132
- auth_token: 'your_orkut_token_auth', // Diperlukan untuk generateQRFromAPI
133
- auth_username: 'your_orkut_username', // Diperlukan untuk generateQRFromAPI
139
+ auth_token: 'your_orkut_token_auth', // Diperlukan untuk generateQRFromAPI dan checkPayment
140
+ auth_username: 'your_orkut_username', // Diperlukan untuk generateQRFromAPI dan checkPayment
141
+ captcha_key: 'your_2captcha_api_key', // API key 2Captcha untuk auto resolve captcha endpoint mutasi
134
142
  autoGenerateReceipt: true // Atur false jika tidak ingin otomatis membuat receipt
135
143
  };
136
144
 
@@ -209,10 +217,10 @@ if (result.success && result.data.status === 'PAID') {
209
217
  ## FAQ
210
218
 
211
219
  ### Q: Bagaimana cara mendapatkan tokenKey agar bisa menggunakan module ini?
212
- A: Anda bisa membeli tokenKey di halaman utama [https://api.wahdx.co](https://api.wahdx.co)
220
+ A: Anda bisa membeli tokenKey di halaman utama [https://eqris.com](https://eqris.com)
213
221
 
214
222
  ### Q: Bagaimana cara mendapatkan kredensial API OrderKuota?
215
- A: Silahkan kunjungi dokumentasi api [https://api.wahdx.co/api-docs](https://api.wahdx.co/api-docs) untuk mendapatkan token pada akun orderkuota anda.
223
+ A: Silahkan kunjungi dokumentasi api [https://eqris.com/api-docs](https://eqris.com/api-docs) untuk mendapatkan token pada akun orderkuota anda.
216
224
 
217
225
  ### Q: Apakah module ini bisa digunakan di project CommonJS?
218
226
  A: Ya! Package ini mendukung dual module system (ESM dan CommonJS). Anda bisa menggunakan dengan dua cara:
@@ -237,4 +245,4 @@ Package secara otomatis mendeteksi format yang digunakan dan menyediakan versi y
237
245
 
238
246
  ## Lisensi
239
247
 
240
- MIT
248
+ MIT
@@ -3,27 +3,29 @@ const moment = require("moment-timezone");
3
3
 
4
4
  class PaymentChecker {
5
5
  constructor(config) {
6
- if (!config.tokenKey || !config.auth_username || !config.auth_token) {
7
- throw new Error('tokenKey, auth_username, dan auth_token harus diisi');
6
+ if (!config.tokenKey || !config.auth_username || !config.auth_token || !config.captcha_key) {
7
+ throw new Error('tokenKey, auth_username, auth_token, dan captcha_key harus diisi');
8
8
  }
9
9
  this.config = {
10
10
  tokenKey: config.tokenKey,
11
11
  auth_username: config.auth_username,
12
- auth_token: config.auth_token
12
+ auth_token: config.auth_token,
13
+ captcha_key: config.captcha_key
13
14
  };
14
15
  }
15
-
16
+
16
17
  async checkPaymentStatus(reference, amount) {
17
18
  try {
18
19
  if (!reference || !amount || amount <= 0) {
19
20
  throw new Error('Reference dan amount harus diisi dengan benar');
20
21
  }
21
-
22
+
22
23
  const response = await axios.post(
23
- 'https://api.wahdx.co/api/mutasi-orkut-v2',
24
+ 'https://eqris.com/api/mutasi-orkut-v2',
24
25
  {
25
26
  username_orkut: this.config.auth_username,
26
- token_orkut: this.config.auth_token
27
+ token_orkut: this.config.auth_token,
28
+ captcha_key: this.config.captcha_key
27
29
  },
28
30
  {
29
31
  headers: {
@@ -32,24 +34,24 @@ class PaymentChecker {
32
34
  }
33
35
  }
34
36
  );
35
-
37
+
36
38
  if (!response.data || !response.data.status || !response.data.data) {
37
39
  throw new Error('Response tidak valid dari server');
38
40
  }
39
-
41
+
40
42
  const transactions = response.data.data;
41
-
43
+
42
44
  const matchingTransactions = transactions.filter(tx => {
43
45
  const txAmount = parseInt(tx.amount);
44
46
  // Parse tanggal dengan timezone Jakarta
45
47
  const txDate = moment.tz(tx.date, 'YYYY-MM-DD HH:mm', 'Asia/Jakarta');
46
48
  const now = moment().tz("Asia/Jakarta");
47
49
  const timeDiff = now.diff(txDate, 'milliseconds');
48
-
50
+
49
51
  return txAmount === amount &&
50
- tx.qris === "static" &&
51
- tx.type === "CR" &&
52
- timeDiff <= 5 * 60 * 1000;
52
+ tx.qris === "static" &&
53
+ tx.type === "CR" &&
54
+ timeDiff <= 5 * 60 * 1000;
53
55
  });
54
56
 
55
57
  if (matchingTransactions.length > 0) {
@@ -58,7 +60,7 @@ class PaymentChecker {
58
60
  const latestDate = moment.tz(latest.date, 'YYYY-MM-DD HH:mm', 'Asia/Jakarta');
59
61
  return currentDate.isAfter(latestDate) ? current : latest;
60
62
  });
61
-
63
+
62
64
  return {
63
65
  success: true,
64
66
  data: {
@@ -71,7 +73,7 @@ class PaymentChecker {
71
73
  }
72
74
  };
73
75
  }
74
-
76
+
75
77
  return {
76
78
  success: true,
77
79
  data: {
@@ -89,4 +91,4 @@ class PaymentChecker {
89
91
  }
90
92
  }
91
93
 
92
- module.exports = PaymentChecker;
94
+ module.exports = PaymentChecker;
@@ -3,27 +3,29 @@ import moment from 'moment-timezone';
3
3
 
4
4
  class PaymentChecker {
5
5
  constructor(config) {
6
- if (!config.tokenKey || !config.auth_username || !config.auth_token) {
7
- throw new Error('tokenKey, auth_username, dan auth_token harus diisi');
6
+ if (!config.tokenKey || !config.auth_username || !config.auth_token || !config.captcha_key) {
7
+ throw new Error('tokenKey, auth_username, auth_token, dan captcha_key harus diisi');
8
8
  }
9
9
  this.config = {
10
10
  tokenKey: config.tokenKey,
11
11
  auth_username: config.auth_username,
12
- auth_token: config.auth_token
12
+ auth_token: config.auth_token,
13
+ captcha_key: config.captcha_key
13
14
  };
14
15
  }
15
-
16
+
16
17
  async checkPaymentStatus(reference, amount) {
17
18
  try {
18
19
  if (!reference || !amount || amount <= 0) {
19
20
  throw new Error('Reference dan amount harus diisi dengan benar');
20
21
  }
21
-
22
+
22
23
  const response = await axios.post(
23
- 'https://api.wahdx.co/api/mutasi-orkut-v2',
24
+ 'https://eqris.com/api/mutasi-orkut-v2',
24
25
  {
25
26
  username_orkut: this.config.auth_username,
26
- token_orkut: this.config.auth_token
27
+ token_orkut: this.config.auth_token,
28
+ captcha_key: this.config.captcha_key
27
29
  },
28
30
  {
29
31
  headers: {
@@ -32,24 +34,24 @@ class PaymentChecker {
32
34
  }
33
35
  }
34
36
  );
35
-
37
+
36
38
  if (!response.data || !response.data.status || !response.data.data) {
37
39
  throw new Error('Response tidak valid dari server');
38
40
  }
39
-
41
+
40
42
  const transactions = response.data.data;
41
-
43
+
42
44
  const matchingTransactions = transactions.filter(tx => {
43
45
  const txAmount = parseInt(tx.amount);
44
46
  // Parse tanggal dengan timezone Jakarta
45
47
  const txDate = moment.tz(tx.date, 'YYYY-MM-DD HH:mm', 'Asia/Jakarta');
46
48
  const now = moment().tz("Asia/Jakarta");
47
49
  const timeDiff = now.diff(txDate, 'milliseconds');
48
-
50
+
49
51
  return txAmount === amount &&
50
- tx.qris === "static" &&
51
- tx.type === "CR" &&
52
- timeDiff <= 5 * 60 * 1000;
52
+ tx.qris === "static" &&
53
+ tx.type === "CR" &&
54
+ timeDiff <= 5 * 60 * 1000;
53
55
  });
54
56
 
55
57
  if (matchingTransactions.length > 0) {
@@ -58,7 +60,7 @@ class PaymentChecker {
58
60
  const latestDate = moment.tz(latest.date, 'YYYY-MM-DD HH:mm', 'Asia/Jakarta');
59
61
  return currentDate.isAfter(latestDate) ? current : latest;
60
62
  });
61
-
63
+
62
64
  return {
63
65
  success: true,
64
66
  data: {
@@ -71,7 +73,7 @@ class PaymentChecker {
71
73
  }
72
74
  };
73
75
  }
74
-
76
+
75
77
  return {
76
78
  success: true,
77
79
  data: {
@@ -89,4 +91,4 @@ class PaymentChecker {
89
91
  }
90
92
  }
91
93
 
92
- export default PaymentChecker;
94
+ export default PaymentChecker;
@@ -21,7 +21,7 @@ class QRISGenerator {
21
21
  if (!qrString) {
22
22
  throw new Error('qrString tidak boleh kosong');
23
23
  }
24
-
24
+
25
25
  // Gunakan QRCode.toBuffer langsung tanpa canvas
26
26
  const qrBuffer = await QRCode.toBuffer(qrString, {
27
27
  errorCorrectionLevel: 'H',
@@ -32,7 +32,7 @@ class QRISGenerator {
32
32
  light: '#ffffff'
33
33
  }
34
34
  });
35
-
35
+
36
36
  return qrBuffer;
37
37
  } catch (error) {
38
38
  throw new Error('Gagal generate QR: ' + error.message);
@@ -69,7 +69,7 @@ class QRISGenerator {
69
69
  }
70
70
 
71
71
  const response = await axios.post(
72
- 'https://api.wahdx.co/api/qr-orkut-v2',
72
+ 'https://eqris.com/api/qr-orkut-v2',
73
73
  {
74
74
  username_orkut: this.config.auth_username,
75
75
  token_orkut: this.config.auth_token,
@@ -88,10 +88,10 @@ class QRISGenerator {
88
88
  }
89
89
 
90
90
  const qrString = response.data.qrString;
91
-
91
+
92
92
  // Generate QR image dari qrString yang didapat dari API
93
93
  const qrBuffer = await this.generateQRImage(qrString);
94
-
94
+
95
95
  return {
96
96
  qrString,
97
97
  qrBuffer
@@ -106,15 +106,15 @@ class QRISGenerator {
106
106
  if (!amount || amount <= 0) {
107
107
  throw new Error('Nominal harus lebih besar dari 0');
108
108
  }
109
-
109
+
110
110
  if (!this.config.baseQrString) {
111
111
  throw new Error('BaseQrString tidak tersedia. Gunakan readQRFromImage terlebih dahulu atau berikan baseQrString pada config.');
112
112
  }
113
-
113
+
114
114
  if (!this.config.baseQrString.includes("5802ID")) {
115
115
  throw new Error("Format QRIS tidak valid");
116
116
  }
117
-
117
+
118
118
  const finalAmount = Math.floor(amount);
119
119
  const qrisBase = this.config.baseQrString.slice(0, -4).replace("010211", "010212");
120
120
  const nominalStr = finalAmount.toString();
@@ -122,7 +122,7 @@ class QRISGenerator {
122
122
  const insertPosition = qrisBase.indexOf("5802ID");
123
123
  const qrisWithNominal = qrisBase.slice(0, insertPosition) + nominalTag + qrisBase.slice(insertPosition);
124
124
  const checksum = this.calculateCRC16(qrisWithNominal);
125
-
125
+
126
126
  return qrisWithNominal + checksum;
127
127
  } catch (error) {
128
128
  throw new Error('Gagal generate string QRIS: ' + error.message);
@@ -21,7 +21,7 @@ class QRISGenerator {
21
21
  if (!qrString) {
22
22
  throw new Error('qrString tidak boleh kosong');
23
23
  }
24
-
24
+
25
25
  // Gunakan QRCode.toBuffer langsung tanpa canvas
26
26
  const qrBuffer = await QRCode.toBuffer(qrString, {
27
27
  errorCorrectionLevel: 'H',
@@ -32,7 +32,7 @@ class QRISGenerator {
32
32
  light: '#ffffff'
33
33
  }
34
34
  });
35
-
35
+
36
36
  return qrBuffer;
37
37
  } catch (error) {
38
38
  throw new Error('Gagal generate QR: ' + error.message);
@@ -69,7 +69,7 @@ class QRISGenerator {
69
69
  }
70
70
 
71
71
  const response = await axios.post(
72
- 'https://api.wahdx.co/api/qr-orkut-v2',
72
+ 'https://eqris.com/api/qr-orkut-v2',
73
73
  {
74
74
  username_orkut: this.config.auth_username,
75
75
  token_orkut: this.config.auth_token,
@@ -88,10 +88,10 @@ class QRISGenerator {
88
88
  }
89
89
 
90
90
  const qrString = response.data.qrString;
91
-
91
+
92
92
  // Generate QR image dari qrString yang didapat dari API
93
93
  const qrBuffer = await this.generateQRImage(qrString);
94
-
94
+
95
95
  return {
96
96
  qrString,
97
97
  qrBuffer
@@ -106,15 +106,15 @@ class QRISGenerator {
106
106
  if (!amount || amount <= 0) {
107
107
  throw new Error('Nominal harus lebih besar dari 0');
108
108
  }
109
-
109
+
110
110
  if (!this.config.baseQrString) {
111
111
  throw new Error('BaseQrString tidak tersedia. Gunakan readQRFromImage terlebih dahulu atau berikan baseQrString pada config.');
112
112
  }
113
-
113
+
114
114
  if (!this.config.baseQrString.includes("5802ID")) {
115
115
  throw new Error("Format QRIS tidak valid");
116
116
  }
117
-
117
+
118
118
  const finalAmount = Math.floor(amount);
119
119
  const qrisBase = this.config.baseQrString.slice(0, -4).replace("010211", "010212");
120
120
  const nominalStr = finalAmount.toString();
@@ -122,7 +122,7 @@ class QRISGenerator {
122
122
  const insertPosition = qrisBase.indexOf("5802ID");
123
123
  const qrisWithNominal = qrisBase.slice(0, insertPosition) + nominalTag + qrisBase.slice(insertPosition);
124
124
  const checksum = this.calculateCRC16(qrisWithNominal);
125
-
125
+
126
126
  return qrisWithNominal + checksum;
127
127
  } catch (error) {
128
128
  throw new Error('Gagal generate string QRIS: ' + error.message);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wahdx-api",
3
- "version": "2.0.0",
4
- "description": "Package untuk generate QRIS dan cek payment status secara realtime dengan API OrderKuota dari https://api.wahdx.co",
3
+ "version": "2.0.2",
4
+ "description": "Package untuk generate QRIS dan cek payment status secara realtime dengan API OrderKuota dari https://eqris.com",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
7
7
  "exports": {