diff --git a/ghost/portal/src/components/ParentContainer.js b/ghost/portal/src/components/ParentContainer.js index 4e0c986ee7..92ab3a4b3c 100644 --- a/ghost/portal/src/components/ParentContainer.js +++ b/ghost/portal/src/components/ParentContainer.js @@ -171,14 +171,14 @@ export default class ParentContainer extends React.Component { await this.GhostApi.member.checkoutPlan({ plan }); - } else if (action === 'updatePlan') { - const {plan, subscriptionId} = data; + } else if (action === 'updateSubscription') { + const {plan, subscriptionId, cancelAtPeriodEnd} = data; await this.GhostApi.member.updateSubscription({ - planName: plan, subscriptionId + planName: plan, subscriptionId, cancelAtPeriodEnd }); const member = await this.GhostApi.member.sessionData(); this.setState({ - action: 'updatePlan:success', + action: 'updateSubscription:success', page: 'accountHome', member: member }); diff --git a/ghost/portal/src/components/pages/AccountPlanPage.js b/ghost/portal/src/components/pages/AccountPlanPage.js index 7edf7e9369..0d884c38de 100644 --- a/ghost/portal/src/components/pages/AccountPlanPage.js +++ b/ghost/portal/src/components/pages/AccountPlanPage.js @@ -41,7 +41,7 @@ export default class AccountPlanPage extends React.Component { if (member.paid) { const {subscriptions} = member; const subscriptionId = subscriptions[0].id; - onAction('updatePlan', {plan, subscriptionId}); + onAction('updateSubscription', {plan, subscriptionId}); } else { onAction('checkoutPlan', {plan}); } diff --git a/ghost/portal/src/utils/api.js b/ghost/portal/src/utils/api.js index 7462e05c88..df4bb99960 100644 --- a/ghost/portal/src/utils/api.js +++ b/ghost/portal/src/utils/api.js @@ -197,7 +197,7 @@ function setupGhostApi() { throw err; }); }, - async updateSubscription({subscriptionId, planName}) { + async updateSubscription({subscriptionId, planName, cancelAtPeriodEnd}) { const identity = await api.member.identity(); const url = endpointFor({type: 'members', resource: 'subscriptions'}) + subscriptionId + '/'; return makeRequest({ @@ -207,6 +207,7 @@ function setupGhostApi() { 'Content-Type': 'application/json' }, body: JSON.stringify({ + cancel_at_period_end: cancelAtPeriodEnd, identity: identity, planName })