Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(billing): hide pay now for self serve partner #86163

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion static/gsApp/views/invoiceDetails/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ function InvoiceDetailsActions({organization, invoice, reloadInvoice}: Props) {
}
}, [invoice, organization, reloadInvoice, location.query.referrer]);

const isSelfServePartner =
'isSelfServePartner' in invoice.customer && invoice.customer.isSelfServePartner;
const showPayNowButton = !invoice.isPaid && !invoice.isClosed && !isSelfServePartner;

return (
<Fragment>
<ActionContainer className="no-print">
Expand All @@ -95,7 +99,7 @@ function InvoiceDetailsActions({organization, invoice, reloadInvoice}: Props) {
</StyledButton>
</Fragment>
)}
{!invoice.isPaid && !invoice.isClosed && (
{showPayNowButton && (
<StyledButton
priority="primary"
onClick={handlePayNow}
Expand Down
55 changes: 55 additions & 0 deletions static/gsApp/views/invoiceDetails/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,61 @@ describe('InvoiceDetails', function () {
expect(screen.getByTestId('submit')).toBeInTheDocument();
});

it('renders without pay now for self serve partner', async function () {
router.location = {
...router.location,
query: {referrer: 'billing-failure'},
};

const pastDueInvoice = InvoiceFixture(
{
amount: 8900,
isClosed: false,
isPaid: false,
items: [
{
type: InvoiceItemType.SUBSCRIPTION,
description: 'Subscription to Business',
amount: 8900,
periodEnd: '2021-10-21',
periodStart: '2021-09-21',
data: {},
},
],
},
organization
);

pastDueInvoice.customer = SubscriptionFixture({
organization,
isSelfServePartner: true,
});

const pastDueParams = {invoiceGuid: pastDueInvoice.id};
const mockapiInvoice = MockApiClient.addMockResponse({
url: `/customers/${organization.slug}/invoices/${pastDueInvoice.id}/`,
method: 'GET',
body: pastDueInvoice,
});

render(
<InvoiceDetails
{...routerProps}
params={pastDueParams}
organization={organization}
/>,
{
router,
}
);

await waitFor(() => expect(mockapiInvoice).toHaveBeenCalled());

expect(screen.getByText(/Invoice Details/)).toBeInTheDocument();
expect(screen.getByText(/AWAITING PAYMENT/)).toBeInTheDocument();
expect(screen.queryByText(/Pay Now/)).not.toBeInTheDocument();
});

describe('Invoice Details Attributes', function () {
const billingDetails = BillingDetailsFixture({taxNumber: '123456789'});
SubscriptionFixture({organization});
Expand Down
Loading