diff --git a/app/client/models/BillingModel.ts b/app/client/models/BillingModel.ts index d9651b65..32826d7e 100644 --- a/app/client/models/BillingModel.ts +++ b/app/client/models/BillingModel.ts @@ -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'); } diff --git a/app/client/ui/BillingPage.ts b/app/client/ui/BillingPage.ts index b7d169bb..9c7aa3f1 100644 --- a/app/client/ui/BillingPage.ts +++ b/app/client/ui/BillingPage.ts @@ -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'), diff --git a/app/common/BillingAPI.ts b/app/common/BillingAPI.ts index 73931804..3762b8b8 100644 --- a/app/common/BillingAPI.ts +++ b/app/common/BillingAPI.ts @@ -10,7 +10,7 @@ export type BillingSubPage = typeof BillingSubPage.type; export const BillingPage = StringUnion(...BillingSubPage.values, 'billing'); export type BillingPage = typeof BillingPage.type; -export const BillingTask = StringUnion('signUp', 'updatePlan', 'addCard', 'updateCard', 'updateAddress'); +export const BillingTask = StringUnion('signUp', 'signUpLite', 'updatePlan', 'addCard', 'updateCard', 'updateAddress'); export type BillingTask = typeof BillingTask.type; // Note that IBillingPlan includes selected fields from the Stripe plan object along with diff --git a/app/gen-server/lib/HomeDBManager.ts b/app/gen-server/lib/HomeDBManager.ts index 2ffee5c4..2ace1d53 100644 --- a/app/gen-server/lib/HomeDBManager.ts +++ b/app/gen-server/lib/HomeDBManager.ts @@ -1673,7 +1673,8 @@ export class HomeDBManager extends EventEmitter { // Pick out properties that are allowed to be changed, to prevent accidental updating // of other information. const updated = pick(billingAccountCopy, 'inGoodStanding', 'status', 'stripeCustomerId', - 'stripeSubscriptionId', 'stripePlanId', 'product'); + 'stripeSubscriptionId', 'stripePlanId', 'product', 'externalId', + 'externalOptions'); billingAccount.paid = undefined; // workaround for a typeorm bug fixed upstream in // https://github.com/typeorm/typeorm/pull/4035 await transaction.save(Object.assign(billingAccount, updated));