diff --git a/ghost/portal/src/components/ParentContainer.js b/ghost/portal/src/components/ParentContainer.js index 3bf2a7ceec..a535d9bced 100644 --- a/ghost/portal/src/components/ParentContainer.js +++ b/ghost/portal/src/components/ParentContainer.js @@ -171,6 +171,11 @@ export default class ParentContainer extends React.Component { await this.GhostApi.member.checkoutPlan({ plan }); + } else if (action === 'updatePlan') { + const {plan, subscriptionId} = data; + await this.GhostApi.member.updateSubscription({ + plan, subscriptionId + }); } else if (action === 'editBilling') { await this.GhostApi.member.editBilling(); } diff --git a/ghost/portal/src/components/pages/AccountPlanPage.js b/ghost/portal/src/components/pages/AccountPlanPage.js index b0e63d56b2..faf52d9299 100644 --- a/ghost/portal/src/components/pages/AccountPlanPage.js +++ b/ghost/portal/src/components/pages/AccountPlanPage.js @@ -34,9 +34,15 @@ export default class AccountPlanPage extends React.Component { onPlanCheckout(e) { e.preventDefault(); - const {onAction} = this.context; + const {onAction, member} = this.context; const plan = this.state.plan; - onAction('checkoutPlan', {plan}); + if (member.paid) { + const {subscriptions} = member; + const subscriptionId = subscriptions[0].id; + onAction('updatePlan', {plan, subscriptionId}); + } else { + onAction('checkoutPlan', {plan}); + } } onPlanSelect(e, name) {