From b26b31f2e8e363906021376200636a5838cc1846 Mon Sep 17 00:00:00 2001 From: tconfrey Date: Thu, 10 Oct 2024 11:21:19 -0400 Subject: [PATCH] Addressed a couple of issues with the subscriber portal - warning it takes a few seconds and checking that firebase is initialized --- app/subscriptionManager.js | 4 ++++ versions/1.0.3/app/subscriptionManager.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/subscriptionManager.js b/app/subscriptionManager.js index fbeb1a6..e32debf 100644 --- a/app/subscriptionManager.js +++ b/app/subscriptionManager.js @@ -114,6 +114,7 @@ async function openStripePortal() { alert('BrainTool Id not set!'); return; } + alert("Opening Stripe portal to manage your subscription. This may take a few seconds."); const url = await getStripePortalURL(); window.open(url, '_blank'); } @@ -316,6 +317,7 @@ async function subscribe(productPrice) { line_items: [selectedPrice], success_url: baseURL + '?purchase=' + encodeURIComponent('subscription'), cancel_url: baseURL + '?purchase=' + encodeURIComponent('cancelled'), + // description: "BrainTool Supporter Subscription ID: " + BTId, }; try { const docRef = await FBDB @@ -355,6 +357,7 @@ async function purchase(productPrice) { allow_promotion_codes: true, success_url: baseURL+ '?purchase=' + encodeURIComponent('product'), cancel_url: baseURL + '?purchase=' + encodeURIComponent('cancelled'), + // description: "BrainTool Supporter License ID: " + BTId, }; try { const docRef = await FBDB.collection("customers").doc(BTId).collection("checkout_sessions").add(checkoutSession); @@ -411,6 +414,7 @@ async function RCPurchase(sessionId) { async function getStripePortalURL() { // Billing portal handler let rsp; + FBDB || await initializeFirebase(); try { const functionRef = firebase .app() diff --git a/versions/1.0.3/app/subscriptionManager.js b/versions/1.0.3/app/subscriptionManager.js index fbeb1a6..e32debf 100644 --- a/versions/1.0.3/app/subscriptionManager.js +++ b/versions/1.0.3/app/subscriptionManager.js @@ -114,6 +114,7 @@ async function openStripePortal() { alert('BrainTool Id not set!'); return; } + alert("Opening Stripe portal to manage your subscription. This may take a few seconds."); const url = await getStripePortalURL(); window.open(url, '_blank'); } @@ -316,6 +317,7 @@ async function subscribe(productPrice) { line_items: [selectedPrice], success_url: baseURL + '?purchase=' + encodeURIComponent('subscription'), cancel_url: baseURL + '?purchase=' + encodeURIComponent('cancelled'), + // description: "BrainTool Supporter Subscription ID: " + BTId, }; try { const docRef = await FBDB @@ -355,6 +357,7 @@ async function purchase(productPrice) { allow_promotion_codes: true, success_url: baseURL+ '?purchase=' + encodeURIComponent('product'), cancel_url: baseURL + '?purchase=' + encodeURIComponent('cancelled'), + // description: "BrainTool Supporter License ID: " + BTId, }; try { const docRef = await FBDB.collection("customers").doc(BTId).collection("checkout_sessions").add(checkoutSession); @@ -411,6 +414,7 @@ async function RCPurchase(sessionId) { async function getStripePortalURL() { // Billing portal handler let rsp; + FBDB || await initializeFirebase(); try { const functionRef = firebase .app()