Skip to content

Commit b2e7082

Browse files
authored
Removed Portal billing section for gift members (TryGhost#27706)
closes https://linear.app/ghost/issue/BER-3613 Hide the "Billing info & receipts" section in Portal's account home page for gift members. Gift members do not have a card on file or an active Stripe subscription, so the section's "Update" button (which calls `manageBilling`) led to a dead end. Complimentary members were already excluded for the same reason — gift members were an oversight.
1 parent 0a696d0 commit b2e7082

2 files changed

Lines changed: 68 additions & 5 deletions

File tree

apps/portal/src/components/pages/AccountHomePage/components/paid-account-actions.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,11 @@ const PaidAccountActions = () => {
145145
return null;
146146
};
147147

148-
const BillingSection = ({defaultCardLast4, isComplimentary}) => {
148+
const BillingSection = ({defaultCardLast4}) => {
149149
const {action} = useContext(AppContext);
150150
const label = action === 'manageBilling:running' ? (
151151
<LoaderIcon className='gh-portal-billing-button-loader' />
152152
) : t('Update');
153-
if (isComplimentary) {
154-
return null;
155-
}
156153

157154
return (
158155
<section>
@@ -173,6 +170,7 @@ const PaidAccountActions = () => {
173170

174171
const subscription = getMemberSubscription({member});
175172
const isComplimentary = isComplimentaryMember({member});
173+
const isGift = isGiftMember({member});
176174
const isPaid = isPaidMember({member});
177175
if (subscription || isComplimentary) {
178176
const {
@@ -203,7 +201,7 @@ const PaidAccountActions = () => {
203201
</div>
204202
<PlanUpdateButton isPaid={isPaid} />
205203
</section>
206-
<BillingSection isComplimentary={isComplimentary} defaultCardLast4={defaultCardLast4} />
204+
{!isComplimentary && !isGift && <BillingSection defaultCardLast4={defaultCardLast4} />}
207205
</>
208206
);
209207
}

apps/portal/test/unit/components/pages/AccountHomePage/paid-account-actions.test.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,71 @@ describe('PaidAccountActions', () => {
674674
});
675675
});
676676

677+
describe('Billing section', () => {
678+
test('renders for a regular paid member', () => {
679+
const products = getProductsData({numOfProducts: 1});
680+
const site = getSiteData({products, portalProducts: products.map(p => p.id)});
681+
const member = getMemberData({
682+
paid: true,
683+
subscriptions: [
684+
getSubscriptionData({
685+
status: 'active',
686+
amount: 500,
687+
currency: 'USD',
688+
interval: 'month'
689+
})
690+
]
691+
});
692+
693+
const {container} = setup({site, member});
694+
695+
expect(container.querySelector('[data-test-button="manage-billing"]')).toBeInTheDocument();
696+
});
697+
698+
test('does not render for a gift member', () => {
699+
const products = getProductsData({numOfProducts: 1});
700+
const site = getSiteData({products, portalProducts: products.map(p => p.id)});
701+
const member = getMemberData({
702+
paid: true,
703+
status: 'gift',
704+
subscriptions: [
705+
getSubscriptionData({
706+
status: 'active',
707+
amount: 0,
708+
currency: 'USD',
709+
interval: 'month',
710+
tier: {id: products[0].id, expiry_at: new Date('2099-01-01T12:00:00.000Z')}
711+
})
712+
]
713+
});
714+
715+
const {container} = setup({site, member});
716+
717+
expect(container.querySelector('[data-test-button="manage-billing"]')).not.toBeInTheDocument();
718+
});
719+
720+
test('does not render for a complimentary member', () => {
721+
const products = getProductsData({numOfProducts: 1});
722+
const site = getSiteData({products, portalProducts: products.map(p => p.id)});
723+
const member = getMemberData({
724+
paid: true,
725+
status: 'comped',
726+
subscriptions: [
727+
getSubscriptionData({
728+
status: 'active',
729+
amount: 0,
730+
currency: 'USD',
731+
interval: 'month'
732+
})
733+
]
734+
});
735+
736+
const {container} = setup({site, member});
737+
738+
expect(container.querySelector('[data-test-button="manage-billing"]')).not.toBeInTheDocument();
739+
});
740+
});
741+
677742
describe('Canceled badge', () => {
678743
test('displays CANCELED badge when cancel_at_period_end is true', () => {
679744
const products = getProductsData({numOfProducts: 1});

0 commit comments

Comments
 (0)