(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:
Paul Fitzpatrick
2021-06-24 09:25:36 -04:00
parent 6240fd6982
commit 1af99e9567
4 changed files with 24 additions and 7 deletions

View File

@@ -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'),