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
cleanup
  • Loading branch information
suejung-sentry committed Jan 2, 2025
commit 0c413de94253fd5a360fcbb5b133a507578c78b8
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ type FormData = z.infer<typeof emailSchema>
function EmailAddress() {
const { provider, owner } = useParams<URLParams>()
const { data: accountDetails } = useAccountDetails({ provider, owner })
const [isEditMode, setEditMode] = useState(false)
const [isFormOpen, setIsFormOpen] = useState(false)
const currentCustomerEmail =
accountDetails?.subscriptionDetail?.customer?.email || 'No email provided'

@@ -50,7 +50,7 @@ function EmailAddress() {
{ newEmail: data?.newCustomerEmail },
{
onSuccess: () => {
setEditMode(false)
setIsFormOpen(false)
},
}
)
@@ -60,18 +60,18 @@ function EmailAddress() {
<div className="flex flex-col gap-2 border-t p-4">
<div className="flex justify-between">
<h4 className="font-semibold">Email address</h4>{' '}
{!isEditMode && (
{!isFormOpen && (
/* @ts-expect-error - A hasn't been typed yet */
<A
variant="semibold"
onClick={() => setEditMode(true)}
onClick={() => setIsFormOpen(true)}
hook="edit-email"
>
Edit <Icon name="chevronRight" size="sm" variant="solid" />
</A>
)}
</div>
{isEditMode ? (
{isFormOpen ? (
<form onSubmit={handleSubmit(submit)} className="flex flex-col gap-2">
<TextInput
data-testid="billing-email-input"
@@ -99,7 +99,7 @@ function EmailAddress() {
hook="cancel-email"
variant="plain"
disabled={isLoading}
onClick={() => setEditMode(false)}
onClick={() => setIsFormOpen(false)}
>
Cancel
</Button>
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
import { z } from 'zod'

import amexLogo from 'assets/billing/amex.svg'
import discoverLogo from 'assets/billing/discover.svg'
import mastercardLogo from 'assets/billing/mastercard.svg'
import visaLogo from 'assets/billing/visa.svg'
import { SubscriptionDetailSchema } from 'services/account'
import { CardBrand, CardBrands } from 'services/account/types'
import {
import {
formatTimestampToCalendarDate,
lastTwoDigits,
} from 'shared/utils/billing'

const cardBrands = {
amex: {
logo: amexLogo,
name: 'American Express',
},
discover: {
logo: discoverLogo,
name: 'Discover',
},
mastercard: {
logo: mastercardLogo,
name: 'MasterCard',
},
visa: {
logo: visaLogo,
name: 'Visa',
},
fallback: {
logo: visaLogo,
name: 'Credit card',
},
}

type CardBrand = keyof typeof cardBrands

interface CardInformationProps {
subscriptionDetail: z.infer<typeof SubscriptionDetailSchema>
card: {
@@ -17,7 +45,7 @@ interface CardInformationProps {
}
}
function CardInformation({ subscriptionDetail, card }: CardInformationProps) {
const typeCard = CardBrands[card?.brand as CardBrand] ?? CardBrands.fallback
const typeCard = cardBrands[card?.brand as CardBrand] ?? cardBrands.fallback
let nextBilling = null

if (!subscriptionDetail?.cancelAtPeriodEnd) {
3 changes: 0 additions & 3 deletions src/services/account/propTypes.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import PropType from 'prop-types'

// TODO: These types were duplicated into types.ts,
// delete this file once all usages are migrated to TS

export const invoicePropType = PropType.shape({
created: PropType.number.isRequired,
dueDate: PropType.number,
71 changes: 0 additions & 71 deletions src/services/account/types.ts

This file was deleted.

21 changes: 0 additions & 21 deletions src/services/navigation/useNavLinks/useNavLinks.ts
Original file line number Diff line number Diff line change
@@ -967,26 +967,5 @@ export function useNavLinks() {
isExternalLink: true,
openNewTab: true,
},
billingEditPrimary: {
path: (
{ provider = p, owner = o} = {
provider: p,
owner: o,
}
) =>
`/plan/${provider}/${owner}?tab=primary`,
isExternalLink: false,
text: 'Primary payment method',
},
billingEditSecondary: {
path: (
{ provider = p, owner = o} = {
provider: p,
owner: o,
}
) => `/plan/${provider}/${owner}?tab=secondary`,
isExternalLink: false,
text: 'Secondary payment method',
},
}
}
Loading
Oops, something went wrong.