mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) link AppSumo activations with stripe, and support upgrades/downgrades
Summary: This links AppSumo sign-ups with Stripe subscriptions and our billing pages. Different AppSumo tiers are supported by different coupons on the standard plan. Configuration of this is in stripe, and then cached in the database. The front end is tweaked just enough to make completing a sign-up possible. It is not yet friendly. Not covered includes: * Streamlining landing page. * Making billing pages git clearer summaries of AppSumo states. * Making flow through Cognito as graceful as possible - default probably doesn't meet AppSumo requirements. * Disabling site on cancellation/refund. * Downgrades when more seats in use than lower tier allows. Test Plan: api-level tests added. No front-end tests yet. Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2878
This commit is contained in:
@@ -175,6 +175,19 @@ export class BillingModelImpl extends Disposable implements BillingModel {
|
||||
}
|
||||
// If there is an org update, re-initialize the org in the client.
|
||||
if (newSettings) { this._appModel.topAppModel.initialize(); }
|
||||
} else if (task === 'signUpLite') {
|
||||
// This is a sign up variant where payment info is handled externally.
|
||||
// All that can change here is company name, and domain.
|
||||
const org = this._appModel.currentOrg;
|
||||
const name = formData.settings && formData.settings.name;
|
||||
const domain = formData.settings && formData.settings.domain;
|
||||
const newSettings = org && (name !== org.name || domain !== org.domain) && formData.settings;
|
||||
// If the address or settings have a new value, run the update.
|
||||
if (newSettings) {
|
||||
await this._billingAPI.updateAddress(undefined, newSettings || undefined);
|
||||
}
|
||||
// If there is an org update, re-initialize the org in the client.
|
||||
if (newSettings) { this._appModel.topAppModel.initialize(); }
|
||||
} else {
|
||||
throw new Error('BillingPage _submit error: no task in progress');
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ const taskActions = {
|
||||
updatePlan: 'Update Plan',
|
||||
addCard: 'Add Payment Method',
|
||||
updateCard: 'Update Payment Method',
|
||||
updateAddress: 'Update Address'
|
||||
updateAddress: 'Update Address',
|
||||
signUpLite: 'Complete Sign Up'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -310,10 +311,10 @@ export class BillingPage extends Disposable {
|
||||
// If there is an immediate charge required, require re-entering the card info.
|
||||
// Show all forms on sign up.
|
||||
this._form = new BillingForm(org, (...args) => this._model.isDomainAvailable(...args), {
|
||||
payment: task !== 'updateAddress',
|
||||
address: task === 'signUp' || task === 'updateAddress',
|
||||
settings: task === 'signUp' || task === 'updateAddress',
|
||||
domain: task === 'signUp'
|
||||
payment: ['signUp', 'updatePlan', 'addCard', 'updateCard'].includes(task),
|
||||
address: ['signUp', 'updateAddress'].includes(task),
|
||||
settings: ['signUp', 'signUpLite', 'updateAddress'].includes(task),
|
||||
domain: ['signUp', 'signUpLite'].includes(task)
|
||||
}, { address: currentAddress, settings: currentSettings, card: this._formData.card });
|
||||
return dom('div',
|
||||
dom.onDispose(() => {
|
||||
@@ -447,6 +448,8 @@ export class BillingPage extends Disposable {
|
||||
}
|
||||
|
||||
private _buildDomainSummary(domain: string|null) {
|
||||
const task = this._model.currentTask.get();
|
||||
if (task === 'signUpLite') { return null; }
|
||||
return css.summaryItem(
|
||||
css.summaryHeader(
|
||||
css.billingBoldText('Billing Info'),
|
||||
|
||||
Reference in New Issue
Block a user