diff --git a/services/web/scripts/stripe/add_user_id_to_stripe_customer.mjs b/services/web/scripts/stripe/add_user_id_to_stripe_customer.mjs index 251d991dea..de702602ea 100644 --- a/services/web/scripts/stripe/add_user_id_to_stripe_customer.mjs +++ b/services/web/scripts/stripe/add_user_id_to_stripe_customer.mjs @@ -80,6 +80,12 @@ async function processSubscription( // Get customer details to check current metadata const customer = subscription.customer + if (customer.deleted) { + if (verbose) { + console.info(`Customer ${customer.id} is deleted, skipping`) + } + return + } if (customer.metadata?.userId === adminUserId) { if (verbose) { @@ -164,6 +170,7 @@ async function main(trackProgress) { const listParams = { limit: 100, // Stripe's maximum limit per request expand: ['data.customer'], // Expand customer data to reduce additional API calls + status: 'all', // Include subscriptions in all statuses (active, past_due, unpaid, canceled, etc.) } let hasMore = true diff --git a/services/web/scripts/stripe/remove_admin_user_id_from_stripe_subscription.mjs b/services/web/scripts/stripe/remove_admin_user_id_from_stripe_subscription.mjs index a44eb629ee..c2425b6ddd 100644 --- a/services/web/scripts/stripe/remove_admin_user_id_from_stripe_subscription.mjs +++ b/services/web/scripts/stripe/remove_admin_user_id_from_stripe_subscription.mjs @@ -143,6 +143,7 @@ async function main(trackProgress) { const listParams = { limit: 100, // Stripe's maximum limit per request + status: 'all', // Include subscriptions in all statuses (active, past_due, unpaid, canceled, etc.) } let hasMore = true