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

feat: Add ACH payment method #3616

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
use the graphql endpoint, fix some tests
  • Loading branch information
suejung-sentry committed Jan 14, 2025
commit a59427f4a811a696bf5322c0793a6c2967b455ee
Original file line number Diff line number Diff line change
@@ -9,6 +9,9 @@ import EditPaymentMethods from './EditPaymentMethods'
import EmailAddress from './EmailAddress'
import { ViewPaymentMethod } from './ViewPaymentMethod'

// Remove this when we build Secondary Payment Method feature
export const SECONDARY_PAYMENT_FEATURE_ENABLED = false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag can get removed when we build out the rest of the secondary payment method feature (next quarter)


interface URLParams {
provider: string
owner: string
@@ -22,7 +25,8 @@ function BillingDetails() {
})
const subscriptionDetail = accountDetails?.subscriptionDetail
const [isEditMode, setEditMode] = useState(false)
const secondaryPaymentFeatureEnabled = false

const secondaryPaymentFeatureEnabled = SECONDARY_PAYMENT_FEATURE_ENABLED

if (!subscriptionDetail) {
return null
@@ -75,7 +79,6 @@ function BillingDetails() {
<ViewPaymentMethod
heading="Primary Payment Method"
isPrimaryPaymentMethod={true}
isEditMode={isEditMode}
setEditMode={setEditMode}
subscriptionDetail={subscriptionDetail}
provider={provider}
@@ -85,7 +88,6 @@ function BillingDetails() {
<ViewPaymentMethod
heading="Secondary Payment Method"
isPrimaryPaymentMethod={false}
isEditMode={isEditMode}
setEditMode={setEditMode}
subscriptionDetail={subscriptionDetail}
provider={provider}
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import Button from 'ui/Button'

interface AddressFormProps {
address?: z.infer<typeof AddressSchema>
name?: string
name?: string | null | undefined
closeForm: () => void
provider: string
owner: string
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@ import { SubscriptionDetailSchema } from 'services/account/useAccountDetails'
import AddressForm from './Address/AddressForm'
import PaymentMethodForm from './PaymentMethod/PaymentMethodForm'

import { SECONDARY_PAYMENT_FEATURE_ENABLED } from '../BillingDetails'

interface EditPaymentMethodProps {
setEditMode: (isEditMode: boolean) => void
provider: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This can be typed as Provider now

@@ -20,7 +22,8 @@ const EditPaymentMethod = ({
existingSubscriptionDetail,
}: EditPaymentMethodProps) => {
const [activeTab, setActiveTab] = useState<'primary' | 'secondary'>('primary')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be able to clean this up with a specific type. Like type PaymentMethod = 'primary' | 'secondary', which you could then use on line 45 as well

const isSecondaryPaymentMethodFeatureEnabled = false

const secondaryPaymentMethodFeatureEnabled = SECONDARY_PAYMENT_FEATURE_ENABLED

return (
<div className="flex flex-col gap-4 p-4">
@@ -30,7 +33,7 @@ const EditPaymentMethod = ({
<div className="ml-2 flex border-b border-ds-gray-tertiary">
{[
'primary',
...(isSecondaryPaymentMethodFeatureEnabled ? ['secondary'] : []),
...(secondaryPaymentMethodFeatureEnabled ? ['secondary'] : []),
].map((tab) => (
<button
key={tab}
@@ -71,22 +74,21 @@ const EditPaymentMethod = ({
/>
</div>
)}
{activeTab === 'secondary' &&
isSecondaryPaymentMethodFeatureEnabled && (
<div>
<PaymentMethodForm
closeForm={() => setEditMode(false)}
provider={provider}
owner={owner}
existingSubscriptionDetail={existingSubscriptionDetail}
/>
<AddressForm
closeForm={() => setEditMode(false)}
provider={provider}
owner={owner}
/>
</div>
)}
{activeTab === 'secondary' && (
<div>
<PaymentMethodForm
closeForm={() => setEditMode(false)}
provider={provider}
owner={owner}
existingSubscriptionDetail={existingSubscriptionDetail}
/>
<AddressForm
closeForm={() => setEditMode(false)}
provider={provider}
owner={owner}
/>
</div>
)}
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
import { z } from 'zod'

import { SubscriptionDetailSchema } from 'services/account'
import { useStripeSetupIntent } from 'services/account/useStripeSetupIntent'
import { useCreateStripeSetupIntent } from 'services/account/useCreateStripeSetupIntent'
import { useUpdatePaymentMethod } from 'services/account/useUpdatePaymentMethod'
import Button from 'ui/Button'

@@ -22,10 +22,11 @@
existingSubscriptionDetail,
}: PaymentMethodFormProps) => {
const [errorState, _] = useState('')
const { data: setupIntent } = useStripeSetupIntent({ owner, provider })
const { data: setupIntent } = useCreateStripeSetupIntent({ owner, provider })
const elements = useElements()

elements?.update({
// @ts-expect-error clientSecret works actually
clientSecret: setupIntent?.clientSecret,
})

@@ -37,7 +38,7 @@
} = useUpdatePaymentMethod({
provider,
owner,
email:

Check failure on line 41 in src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/EditPaymentMethods/PaymentMethod/PaymentMethodForm.tsx

GitHub Actions / Upload Bundle Stats - Production

Type 'string | null | undefined' is not assignable to type 'string'.

Check failure on line 41 in src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/EditPaymentMethods/PaymentMethod/PaymentMethodForm.tsx

GitHub Actions / Upload Bundle Stats - Staging

Type 'string | null | undefined' is not assignable to type 'string'.

Check failure on line 41 in src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/EditPaymentMethods/PaymentMethod/PaymentMethodForm.tsx

GitHub Actions / Run Type Checker

Type 'string | null | undefined' is not assignable to type 'string'.
existingSubscriptionDetail?.defaultPaymentMethod?.billingDetails?.email,
})

@@ -51,7 +52,9 @@
const paymentElement = elements.getElement(PaymentElement)

updatePaymentMethod(paymentElement, {
onSuccess: closeForm,
onSuccess: async () => {
closeForm()
},
})
}

Original file line number Diff line number Diff line change
@@ -85,13 +85,18 @@
// BillingDetails.tsx if there is no subscriptionDetail
it('renders the set card message', () => {
render(
<AddressCard subscriptionDetail={null} provider="gh" owner="codecov" />,
<AddressCard
subscriptionDetail={null}
provider="gh"
owner="codecov"
setEditMode={() => {}}
/>,
{ wrapper }
)

expect(
screen.getByText(

Check failure on line 98 in src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx

GitHub Actions / Test Runner #2 - Vitest

src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx > AddressCard > when the user doesn't have any subscriptionDetail > renders the set card message

TestingLibraryElementError: Unable to find an element with the text: /No address has been set. Please contact support if you think it's an error or set it yourself./. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. Ignored nodes: comments, script, style <body class="light" > <div> <div class="flex gap-2" > <div class="flex flex-col gap-4 text-ds-gray-quinary" > <p class="mt-4" > No address has been set. Please contact support if you think it’s an error or set it yourself. </p> <div class="flex self-start" > <button class=" flex items-center gap-1 rounded py-1 px-4 transition-colors duration-150 motion-reduce:transition-none focus:outline-none focus:ring disabled:cursor-not-allowed disabled:text-ds-gray-quaternary disabled:border-ds-gray-tertiary disabled:bg-ds-gray-primary justify-center font-semibold text-white bg-ds-blue-darker dark:bg-ds-blue-nonary border-ds-blue-quinary border-solid border shadow hover:bg-ds-blue-quinary " data-cy="open-modal" data-marketing="open-modal" data-testid="open-modal" > Set address </button> </div> </div> </div> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:52:17 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:95:19 ❯ src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx:98:16
/No address has been set. Please contact support if you think its an error or set it yourself./
/No address has been set. Please contact support if you think it's an error or set it yourself./
)
).toBeInTheDocument()
})
@@ -108,13 +113,14 @@
}}
provider="gh"
owner="codecov"
setEditMode={() => {}}
/>,
{ wrapper }
)

expect(
screen.getByText(

Check failure on line 122 in src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx

GitHub Actions / Test Runner #2 - Vitest

src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx > AddressCard > when the user doesn't have billing details > renders an error message

TestingLibraryElementError: Unable to find an element with the text: /No address has been set. Please contact support if you think it's an error or set it yourself./. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. Ignored nodes: comments, script, style <body class="light" > <div> <div class="flex gap-2" > <div class="flex flex-col gap-4 text-ds-gray-quinary" > <p class="mt-4" > No address has been set. Please contact support if you think it’s an error or set it yourself. </p> <div class="flex self-start" > <button class=" flex items-center gap-1 rounded py-1 px-4 transition-colors duration-150 motion-reduce:transition-none focus:outline-none focus:ring disabled:cursor-not-allowed disabled:text-ds-gray-quaternary disabled:border-ds-gray-tertiary disabled:bg-ds-gray-primary justify-center font-semibold text-white bg-ds-blue-darker dark:bg-ds-blue-nonary border-ds-blue-quinary border-solid border shadow hover:bg-ds-blue-quinary " data-cy="open-modal" data-marketing="open-modal" data-testid="open-modal" > Set address </button> </div> </div> </div> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:52:17 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:95:19 ❯ src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx:122:16
/No address has been set. Please contact support if you think its an error or set it yourself./
/No address has been set. Please contact support if you think it's an error or set it yourself./
)
).toBeInTheDocument()
})
@@ -131,6 +137,7 @@
}}
provider="gh"
owner="codecov"
setEditMode={() => {}}
/>,
{ wrapper }
)
@@ -157,6 +164,7 @@
}}
provider="gh"
owner="codecov"
setEditMode={() => {}}
/>,
{ wrapper }
)
@@ -168,7 +176,7 @@
await user.click(screen.getByTestId('open-modal'))

expect(
screen.getByRole('button', { name: /update/i })

Check failure on line 179 in src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx

GitHub Actions / Test Runner #2 - Vitest

src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx > AddressCard > when the user doesn't have billing details > when the user clicks on "Set Address" > renders the address form component

TestingLibraryElementError: Unable to find an accessible element with the role "button" and name `/update/i` Here are the accessible roles: paragraph: Name "": <p class="mt-4" /> -------------------------------------------------- button: Name "Set address": <button class=" flex items-center gap-1 rounded py-1 px-4 transition-colors duration-150 motion-reduce:transition-none focus:outline-none focus:ring disabled:cursor-not-allowed disabled:text-ds-gray-quaternary disabled:border-ds-gray-tertiary disabled:bg-ds-gray-primary justify-center font-semibold text-white bg-ds-blue-darker dark:bg-ds-blue-nonary border-ds-blue-quinary border-solid border shadow hover:bg-ds-blue-quinary " data-cy="open-modal" data-marketing="open-modal" data-testid="open-modal" /> -------------------------------------------------- Ignored nodes: comments, script, style <body class="light" > <div> <div class="flex gap-2" > <div class="flex flex-col gap-4 text-ds-gray-quinary" > <p class="mt-4" > No address has been set. Please contact support if you think it’s an error or set it yourself. </p> <div class="flex self-start" > <button class=" flex items-center gap-1 rounded py-1 px-4 transition-colors duration-150 motion-reduce:transition-none focus:outline-none focus:ring disabled:cursor-not-allowed disabled:text-ds-gray-quaternary disabled:border-ds-gray-tertiary disabled:bg-ds-gray-primary justify-center font-semibold text-white bg-ds-blue-darker dark:bg-ds-blue-nonary border-ds-blue-quinary border-solid border shadow hover:bg-ds-blue-quinary " data-cy="open-modal" data-marketing="open-modal" data-testid="open-modal" > Set address </button> </div> </div> </div> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:52:17 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:95:19 ❯ src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx:179:18
).toBeInTheDocument()
})
})
@@ -181,6 +189,7 @@
subscriptionDetail={subscriptionDetail}
provider="gh"
owner="codecov"
setEditMode={() => {}}
/>,
{ wrapper }
)
@@ -220,11 +229,12 @@
}}
provider="gh"
owner="codecov"
setEditMode={() => {}}
/>,
{ wrapper }
)

expect(screen.getByText('Cardholder name')).toBeInTheDocument()

Check failure on line 237 in src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx

GitHub Actions / Test Runner #2 - Vitest

src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx > AddressCard > when the user has an address > can render partial information too

TestingLibraryElementError: Unable to find an element with the text: Cardholder name. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. Ignored nodes: comments, script, style <body class="light" > <div> <div class="flex gap-2" > <div> <h4 class="mb-2 font-semibold" > Billing address </h4> <p> </p> <p> 12345 </p> </div> </div> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:52:17 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:95:19 ❯ src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx:237:21
expect(screen.getByText('N/A')).toBeInTheDocument()
expect(screen.getByText('Billing address')).toBeInTheDocument()
expect(screen.queryByText(/null/)).not.toBeInTheDocument()
@@ -237,11 +247,12 @@
subscriptionDetail={subscriptionDetail}
provider="gh"
owner="codecov"
setEditMode={() => {}}
/>,
{ wrapper }
)

expect(screen.getByText(/Cardholder name/)).toBeInTheDocument()

Check failure on line 255 in src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx

GitHub Actions / Test Runner #2 - Vitest

src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx > AddressCard > when the user has an address > renders the card holder information

TestingLibraryElementError: Unable to find an element with the text: /Cardholder name/. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. Ignored nodes: comments, script, style <body class="light" > <div> <div class="flex gap-2" > <div> <h4 class="mb-2 font-semibold" > Billing address </h4> <p> 123 Sesame St. Apt A </p> <p> San Francisco, CA 12345 </p> </div> </div> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:52:17 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:95:19 ❯ src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx:255:21
expect(screen.getByText(/Bob Smith/)).toBeInTheDocument()
})
})
@@ -260,10 +271,11 @@
subscriptionDetail={subscriptionDetail}
provider="gh"
owner="codecov"
setEditMode={() => {}}
/>,
{ wrapper }
)
await user.click(screen.getByTestId('edit-address'))

Check failure on line 278 in src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx

GitHub Actions / Test Runner #2 - Vitest

src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx > AddressCard > when the user clicks on Edit > doesn't render the card anymore

TestingLibraryElementError: Unable to find an element by: [data-testid="edit-address"] Ignored nodes: comments, script, style <body class="light" > <div> <div class="flex gap-2" > <div> <h4 class="mb-2 font-semibold" > Billing address </h4> <p> 123 Sesame St. Apt A </p> <p> San Francisco, CA 12345 </p> </div> </div> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:52:17 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:95:19 ❯ src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx:278:31

expect(screen.queryByText(/Cardholder name/)).not.toBeInTheDocument()
expect(screen.queryByText(/Bob Smith/)).not.toBeInTheDocument()
@@ -286,10 +298,11 @@
subscriptionDetail={subscriptionDetail}
provider="gh"
owner="codecov"
setEditMode={() => {}}
/>,
{ wrapper }
)
await user.click(screen.getByTestId('edit-address'))

Check failure on line 305 in src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx

GitHub Actions / Test Runner #2 - Vitest

src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx > AddressCard > when the user clicks on Edit > renders the form

TestingLibraryElementError: Unable to find an element by: [data-testid="edit-address"] Ignored nodes: comments, script, style <body class="light" > <div> <div class="flex gap-2" > <div> <h4 class="mb-2 font-semibold" > Billing address </h4> <p> 123 Sesame St. Apt A </p> <p> San Francisco, CA 12345 </p> </div> </div> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:52:17 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:95:19 ❯ src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx:305:31

expect(
screen.getByRole('button', { name: /update/i })
@@ -309,10 +322,11 @@
subscriptionDetail={subscriptionDetail}
provider="gh"
owner="codecov"
setEditMode={() => {}}
/>,
{ wrapper }
)
await user.click(screen.getByTestId('edit-address'))

Check failure on line 329 in src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx

GitHub Actions / Test Runner #2 - Vitest

src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx > AddressCard > when the user clicks on Edit > when submitting > calls the service to update the address

TestingLibraryElementError: Unable to find an element by: [data-testid="edit-address"] Ignored nodes: comments, script, style <body class="light" > <div> <div class="flex gap-2" > <div> <h4 class="mb-2 font-semibold" > Billing address </h4> <p> 123 Sesame St. Apt A </p> <p> San Francisco, CA 12345 </p> </div> </div> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:52:17 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:95:19 ❯ src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/ViewPaymentMethod/Address/AddressCard.test.tsx:329:33
await user.click(screen.queryByRole('button', { name: /update/i })!)

expect(updateAddress).toHaveBeenCalled()
@@ -331,6 +345,7 @@
subscriptionDetail={subscriptionDetail}
provider="gh"
owner="codecov"
setEditMode={() => {}}
/>,
{ wrapper }
)
@@ -358,6 +373,7 @@
subscriptionDetail={subscriptionDetail}
provider="gh"
owner="codecov"
setEditMode={() => {}}
/>,
{ wrapper }
)
@@ -380,6 +396,7 @@
subscriptionDetail={subscriptionDetail}
provider="gh"
owner="codecov"
setEditMode={() => {}}
/>,
{ wrapper }
)
Original file line number Diff line number Diff line change
@@ -7,8 +7,9 @@ import {
import { cn } from 'shared/utils/cn'
import Button from 'ui/Button'

import { SECONDARY_PAYMENT_FEATURE_ENABLED } from '../../BillingDetails'

interface AddressCardProps {
isEditMode: boolean
setEditMode: (isEditMode: boolean) => void
subscriptionDetail: z.infer<typeof SubscriptionDetailSchema>
provider: string
@@ -24,7 +25,10 @@ function AddressCard({
const billingDetails =
subscriptionDetail?.defaultPaymentMethod?.billingDetails

const isAddressSameAsPrimary = false // TODO
// TODO: Implement this when we have secondary payment method feature
const isAddressSameAsPrimary = SECONDARY_PAYMENT_FEATURE_ENABLED
? true
: undefined

return (
<div className={cn('flex gap-2', className)}>
@@ -40,7 +44,7 @@ function AddressCard({
interface BillingInnerProps {
billingDetails?: z.infer<typeof BillingDetailsSchema>
setEditMode: (val: boolean) => void
isAddressSameAsPrimary: boolean
isAddressSameAsPrimary?: boolean
}

function BillingInner({
Original file line number Diff line number Diff line change
@@ -10,21 +10,19 @@ import PaymentMethod from './PaymentMethod/PaymentMethod'
function ViewPaymentMethod({
heading,
isPrimaryPaymentMethod,
isEditMode,
setEditMode,
subscriptionDetail,
provider,
owner,
}: {
heading: string
isPrimaryPaymentMethod?: boolean
isEditMode: boolean
setEditMode: (isEditMode: boolean) => void
subscriptionDetail: z.infer<typeof SubscriptionDetailSchema>
provider: string
owner: string
}) {
const isCreditCard = subscriptionDetail?.defaultPaymentMethod?.card // TODO
const isCreditCard = subscriptionDetail?.defaultPaymentMethod?.card

return (
<div>
@@ -47,7 +45,6 @@ function ViewPaymentMethod({
{/* Payment method summary */}
<PaymentMethod
className="w-2/5 flex-1"
isEditMode={isEditMode}
setEditMode={setEditMode}
subscriptionDetail={subscriptionDetail}
provider={provider}
@@ -68,7 +65,6 @@ function ViewPaymentMethod({
{/* Address */}
<AddressCard
className="flex-1"
isEditMode={isEditMode}
setEditMode={setEditMode}
subscriptionDetail={subscriptionDetail}
provider={provider}
3 changes: 0 additions & 3 deletions src/services/account/useAccountDetails.ts
Original file line number Diff line number Diff line change
@@ -77,11 +77,8 @@ export const PaymentMethodSchema = z
.nullish(),
usBankAccount: z
.object({
accountHolderType: z.string(),
accountType: z.string(),
bankName: z.string(),
last4: z.string(),
routingNumber: z.string(),
})
.nullish(),
billingDetails: BillingDetailsSchema.nullable(),
Loading
Oops, something went wrong.
Loading
Oops, something went wrong.