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.
@@ -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 (expectedTotal < 0n || expectedTotal !== total.value) {
258
- throw new TypeError(`review_and_pay total_amount (${total.value}) must equal subtotal + tax + shipping - discount (${expectedTotal})`);
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
- for (const [accountIndex, entry] of (params.payment_settings ?? []).entries()) {
265
- const account = entry?.payment_account ?? entry?.paymentAccount;
266
- const identifier = account?.identifier_value ?? account?.identifierValue;
267
- if (typeof identifier !== 'string' || !identifier.trim()) {
268
- throw new TypeError(`payment_settings[${accountIndex}] requires payment_account.identifier_value`);
269
- }
270
- if (/^\[[^\]]+\]$/.test(identifier.trim())) {
271
- throw new TypeError(`payment_settings[${accountIndex}] still contains a placeholder identifier (${identifier}); replace it with a valid value or remove that payment account`);
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.15",
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",