kage-baileys 25.4.15 → 25.4.16
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/lib/Utils/native-flow.js +20 -14
- package/package.json +1 -1
package/lib/Utils/native-flow.js
CHANGED
|
@@ -254,25 +254,31 @@ export function prepareNativeFlowMessageForRelay(input) {
|
|
|
254
254
|
return readAmount(params.order[key], `order.${key}`, offset, true).value;
|
|
255
255
|
};
|
|
256
256
|
const expectedTotal = itemSum + optionalOrderAmount('tax') + optionalOrderAmount('shipping') - optionalOrderAmount('discount');
|
|
257
|
-
if
|
|
258
|
-
|
|
257
|
+
// Auto-fix like kage-antigua: if total_amount does not match the order math,
|
|
258
|
+
// correct it instead of throwing so existing payloads keep working.
|
|
259
|
+
if (expectedTotal < 0n) {
|
|
260
|
+
throw new TypeError(`review_and_pay computed total is negative (${expectedTotal})`);
|
|
261
|
+
}
|
|
262
|
+
if (expectedTotal !== total.value) {
|
|
263
|
+
params.total_amount = { value: Number(expectedTotal), offset };
|
|
264
|
+
// also keep order.subtotal in sync when it was missing or wrong
|
|
265
|
+
if (params.order.subtotal == null || Number(params.order.subtotal?.value) !== Number(itemSum)) {
|
|
266
|
+
params.order.subtotal = { value: Number(itemSum), offset };
|
|
267
|
+
}
|
|
259
268
|
}
|
|
260
269
|
|
|
261
270
|
if (params.payment_settings != null && !Array.isArray(params.payment_settings)) {
|
|
262
271
|
throw new TypeError('review_and_pay payment_settings must be an array');
|
|
263
272
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
if (/^\[[^\]]+\]$/.test(identifier.trim())) {
|
|
274
|
-
throw new TypeError(`payment_settings[${accountIndex}] still contains a placeholder identifier; remove it or replace it with a valid provider value`);
|
|
275
|
-
}
|
|
273
|
+
// Drop placeholder accounts instead of throwing (kage-antigua style tolerance)
|
|
274
|
+
if (Array.isArray(params.payment_settings)) {
|
|
275
|
+
params.payment_settings = params.payment_settings.filter((entry, accountIndex) => {
|
|
276
|
+
const account = entry?.payment_account ?? entry?.paymentAccount;
|
|
277
|
+
const identifier = account?.identifier_value ?? account?.identifierValue;
|
|
278
|
+
if (typeof identifier !== 'string' || !identifier.trim()) return false;
|
|
279
|
+
if (/^\[[^\]]+\]$/.test(identifier.trim())) return false;
|
|
280
|
+
return true;
|
|
281
|
+
});
|
|
276
282
|
}
|
|
277
283
|
|
|
278
284
|
const normalized = JSON.stringify(params);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kage-baileys",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "25.4.
|
|
4
|
+
"version": "25.4.16",
|
|
5
5
|
"description": "Kage Baileys with confirmed pairing registration state, resilient reconnect classification, hardened Native Flow review_and_pay, expanded WAProto schema and compatibility helpers",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"whatsapp",
|