backend-manager 5.0.167 → 5.0.168

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/CHANGELOG.md CHANGED
@@ -14,6 +14,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
14
14
  - `Fixed` for any bug fixes.
15
15
  - `Security` in case of vulnerabilities.
16
16
 
17
+ # [5.0.168] - 2026-03-21
18
+ ### Fixed
19
+ - Immediately suspend subscription on payment denial (PAYMENT.SALE.DENIED, invoice.payment_failed) instead of waiting for the processor to give up retrying — recovery via PAYMENT.SALE.COMPLETED restores active status
20
+
17
21
  # [5.0.167] - 2026-03-20
18
22
  ### Changed
19
23
  - Extracted `resolveTemperature()` helper for consistency with `resolveFormatting()` and `resolveReasoning()`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "5.0.167",
3
+ "version": "5.0.168",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -218,6 +218,16 @@ async function processPaymentEvent({ category, library, resource, resourceType,
218
218
  ? library.toUnifiedSubscription(resource, transformOptions)
219
219
  : library.toUnifiedOneTime(resource, transformOptions);
220
220
 
221
+ // Override: immediately suspend on payment denial
222
+ // Processors keep the sub active while retrying, but we revoke access right away.
223
+ // If the retry succeeds (e.g. PAYMENT.SALE.COMPLETED), it will restore active status.
224
+ // PayPal: PAYMENT.SALE.DENIED, Stripe: invoice.payment_failed, Chargebee: payment_failed
225
+ const PAYMENT_DENIED_EVENTS = ['PAYMENT.SALE.DENIED', 'invoice.payment_failed', 'payment_failed'];
226
+ if (isSubscription && PAYMENT_DENIED_EVENTS.includes(eventType) && unified.status === 'active') {
227
+ assistant.log(`Overriding status to suspended: ${eventType} received but provider still says active`);
228
+ unified.status = 'suspended';
229
+ }
230
+
221
231
  assistant.log(`Unified ${category}: product=${unified.product.id}, status=${unified.status}`, unified);
222
232
 
223
233
  // Read checkout context from payments-intents (attribution, discount, supplemental)