From dcf1e774d2240ec0f57b088ea4ecf7b2dc3d5a90 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 28 Oct 2024 16:43:10 -0500 Subject: [PATCH] Add active subscriptions to response --- subs-mock/src/index.ts | 3 ++- subs-mock/src/util.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/subs-mock/src/index.ts b/subs-mock/src/index.ts index 9801d6ea07..33c8d3685e 100644 --- a/subs-mock/src/index.ts +++ b/subs-mock/src/index.ts @@ -80,6 +80,7 @@ export default new Hono<{Bindings: Bindings; Variables: Variables}>() } catch (e) {} let products = getMainSubscriptionProducts(allProducts.items, subscriptions) + const activeProducts = products.filter(p => p.active) if (platform === 'web') { const stripe = c.get('stripe') @@ -116,7 +117,7 @@ export default new Hono<{Bindings: Bindings; Variables: Variables}>() products = products.filter(p => p.provider === 'play_store') } - return c.json({subscriptions: products}) + return c.json({active: activeProducts, subscriptions: products}) }) /** diff --git a/subs-mock/src/util.ts b/subs-mock/src/util.ts index c38a678d86..12edbdb124 100644 --- a/subs-mock/src/util.ts +++ b/subs-mock/src/util.ts @@ -131,6 +131,7 @@ export type Subscription = * The rest of this is pretty generic */ interval: 'monthly' | 'annual' + active: boolean autoRenew: boolean provider: RevenueCatSubscription['store'] status: RevenueCatSubscription['status'] | null @@ -146,6 +147,7 @@ export type Subscription = lookupKey: string checkoutId: string interval: 'monthly' | 'annual' + active: boolean autoRenew: boolean storeSubscriptionIdentifier: string | null provider: RevenueCatSubscription['store'] @@ -191,6 +193,7 @@ export function normalizeMainSubscriptionProduct({ lookupKey: 'bsky_tier_0', checkoutId: product.store_identifier, interval: 'monthly', + active: subscription?.gives_access ?? false, autoRenew: true, platform: 'android', provider: 'play_store', @@ -212,6 +215,7 @@ export function normalizeMainSubscriptionProduct({ lookupKey: 'bsky_tier_0', checkoutId: product.store_identifier, interval: 'annual', + active: subscription?.gives_access ?? false, autoRenew: true, platform: 'android', provider: 'play_store', @@ -233,6 +237,7 @@ export function normalizeMainSubscriptionProduct({ lookupKey: 'bsky_tier_1', checkoutId: product.store_identifier, interval: 'monthly', + active: subscription?.gives_access ?? false, autoRenew: true, platform: 'android', provider: 'play_store', @@ -254,6 +259,7 @@ export function normalizeMainSubscriptionProduct({ lookupKey: 'bsky_tier_1', checkoutId: product.store_identifier, interval: 'annual', + active: subscription?.gives_access ?? false, autoRenew: true, platform: 'android', provider: 'play_store', @@ -275,6 +281,7 @@ export function normalizeMainSubscriptionProduct({ lookupKey: 'bsky_tier_2', checkoutId: product.store_identifier, interval: 'monthly', + active: subscription?.gives_access ?? false, autoRenew: true, platform: 'android', provider: 'play_store', @@ -296,6 +303,7 @@ export function normalizeMainSubscriptionProduct({ lookupKey: 'bsky_tier_2', checkoutId: product.store_identifier, interval: 'annual', + active: subscription?.gives_access ?? false, autoRenew: true, platform: 'android', provider: 'play_store', @@ -321,6 +329,7 @@ export function normalizeMainSubscriptionProduct({ lookupKey: product.store_identifier, checkoutId: product.store_identifier, interval: 'monthly', + active: subscription?.gives_access ?? false, autoRenew: true, platform: 'web', provider: 'stripe', @@ -343,6 +352,7 @@ export function normalizeMainSubscriptionProduct({ lookupKey: product.store_identifier, checkoutId: product.store_identifier, interval: 'annual', + active: subscription?.gives_access ?? false, autoRenew: true, platform: 'web', provider: 'stripe', @@ -365,6 +375,7 @@ export function normalizeMainSubscriptionProduct({ lookupKey: product.store_identifier, checkoutId: product.store_identifier, interval: 'monthly', + active: subscription?.gives_access ?? false, autoRenew: true, platform: 'web', provider: 'stripe', @@ -387,6 +398,7 @@ export function normalizeMainSubscriptionProduct({ lookupKey: product.store_identifier, checkoutId: product.store_identifier, interval: 'annual', + active: subscription?.gives_access ?? false, autoRenew: true, platform: 'web', provider: 'stripe', @@ -409,6 +421,7 @@ export function normalizeMainSubscriptionProduct({ lookupKey: product.store_identifier, checkoutId: product.store_identifier, interval: 'monthly', + active: subscription?.gives_access ?? false, autoRenew: true, platform: 'web', provider: 'stripe', @@ -431,6 +444,7 @@ export function normalizeMainSubscriptionProduct({ lookupKey: product.store_identifier, checkoutId: product.store_identifier, interval: 'annual', + active: subscription?.gives_access ?? false, autoRenew: true, platform: 'web', provider: 'stripe',