Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -74,12 +74,13 @@ app.get('/check-status', (req, res) => {
|
|
| 74 |
return res.json({ status: "NOT_FOUND" });
|
| 75 |
});
|
| 76 |
|
| 77 |
-
//
|
| 78 |
app.post('/notifdana', (req, res) => {
|
| 79 |
const { message } = req.body;
|
| 80 |
console.log(`[Notifikasi Masuk]: ${message}`);
|
| 81 |
|
| 82 |
-
|
|
|
|
| 83 |
try {
|
| 84 |
const regexUang = /Rp([\d.]+)/;
|
| 85 |
const matchUang = message.match(regexUang);
|
|
@@ -87,10 +88,11 @@ app.post('/notifdana', (req, res) => {
|
|
| 87 |
if (matchUang) {
|
| 88 |
const nominalBersih = matchUang[1].replace(/\./g, '');
|
| 89 |
|
| 90 |
-
// Jika nominal terdaftar di server, ubah statusnya menjadi SUCCESS
|
| 91 |
if (databaseTransaksi[nominalBersih]) {
|
| 92 |
databaseTransaksi[nominalBersih].status = "SUCCESS";
|
| 93 |
console.log(`[REAL-TIME] Transaksi nominal Rp ${nominalBersih} BERHASIL DIKONFIRMASI!`);
|
|
|
|
|
|
|
| 94 |
}
|
| 95 |
}
|
| 96 |
} catch (error) {
|
|
|
|
| 74 |
return res.json({ status: "NOT_FOUND" });
|
| 75 |
});
|
| 76 |
|
| 77 |
+
// Ganti bagian app.post('/notifdana') di index.js Anda dengan ini:
|
| 78 |
app.post('/notifdana', (req, res) => {
|
| 79 |
const { message } = req.body;
|
| 80 |
console.log(`[Notifikasi Masuk]: ${message}`);
|
| 81 |
|
| 82 |
+
// Kita buat pendeteksian lebih fleksibel: Cukup pastikan teks mengandung kata "Rp" dan kata "berhasil"
|
| 83 |
+
if (message && message.toLowerCase().includes('berhasil') && message.includes('Rp')) {
|
| 84 |
try {
|
| 85 |
const regexUang = /Rp([\d.]+)/;
|
| 86 |
const matchUang = message.match(regexUang);
|
|
|
|
| 88 |
if (matchUang) {
|
| 89 |
const nominalBersih = matchUang[1].replace(/\./g, '');
|
| 90 |
|
|
|
|
| 91 |
if (databaseTransaksi[nominalBersih]) {
|
| 92 |
databaseTransaksi[nominalBersih].status = "SUCCESS";
|
| 93 |
console.log(`[REAL-TIME] Transaksi nominal Rp ${nominalBersih} BERHASIL DIKONFIRMASI!`);
|
| 94 |
+
} else {
|
| 95 |
+
console.log(`[PERINGATAN] Nominal Rp ${nominalBersih} diterima tapi tidak dicari oleh frontend.`);
|
| 96 |
}
|
| 97 |
}
|
| 98 |
} catch (error) {
|