@@ -207,17 +207,23 @@ func (h *Handlers) renderUserSettingsBilling(w http.ResponseWriter, r *http.Requ |
| 207 | 207 | debug = h.userBillingDebugView(r, state) |
| 208 | 208 | } |
| 209 | 209 | _ = h.d.Render.RenderPage(w, r, "settings/billing", map[string]any{ |
| 210 | | - "Title": "Billing and plans", |
| 211 | | - "SettingsActive": "billing", |
| 212 | | - "CSRFToken": middleware.CSRFTokenForRequest(r), |
| 213 | | - "Username": username, |
| 214 | | - "BillingEnabled": h.d.BillingEnabled, |
| 215 | | - "Error": errMsg, |
| 216 | | - "Notice": notice, |
| 217 | | - "BillingAlert": userBillingAlertForState(state), |
| 218 | | - "Summary": userBillingSummary(state), |
| 219 | | - "CanStartCheckout": h.billingConfiguredForUser(), |
| 220 | | - "CanManageSubscription": h.billingConfiguredForUser() && state.StripeCustomerID.Valid && strings.TrimSpace(state.StripeCustomerID.String) != "", |
| 210 | + "Title": "Billing and plans", |
| 211 | + "SettingsActive": "billing", |
| 212 | + "CSRFToken": middleware.CSRFTokenForRequest(r), |
| 213 | + "Username": username, |
| 214 | + "BillingEnabled": h.d.BillingEnabled, |
| 215 | + "Error": errMsg, |
| 216 | + "Notice": notice, |
| 217 | + "BillingAlert": userBillingAlertForState(state), |
| 218 | + "Summary": userBillingSummary(state), |
| 219 | + "CanStartCheckout": h.billingConfiguredForUser(), |
| 220 | + // Gate on StripeSubscriptionID, not StripeCustomerID. A |
| 221 | + // customer record is created when the Checkout Session is |
| 222 | + // minted (before payment); a subscription id only appears |
| 223 | + // after customer.subscription.created lands. Gating on the |
| 224 | + // customer id surfaced "Manage or cancel" buttons for users |
| 225 | + // who abandoned checkout without paying. |
| 226 | + "CanManageSubscription": h.billingConfiguredForUser() && state.StripeSubscriptionID.Valid && strings.TrimSpace(state.StripeSubscriptionID.String) != "", |
| 221 | 227 | "GracePeriodLabel": userFormatGracePeriod(h.d.BillingGracePeriod), |
| 222 | 228 | "Invoices": userBillingInvoiceViews(invoices), |
| 223 | 229 | "IsSiteAdmin": viewer.IsSiteAdmin, |