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
Open

feat: Add ACH payment method #3616

wants to merge 13 commits into from

Conversation

suejung-sentry
Copy link
Contributor

@suejung-sentry suejung-sentry commented Dec 31, 2024

This PR adds ability to choose ACH as a payment method. It also sets sockets for a secondary payment method (to be fully built out next quarter).

  1. Updates the View state to show Primary and Secondary payment methods, and in columns instead of rows (secondary will stay hidden until feature is finished next quarter)
  2. Updates the Edit state to a new form with tabs and sections for the 2 payment methods (secondary tab hidden)
  3. Cuts over from the existing Stripe CardElement to their PaymentElement. Note that the PaymentElement requires a clientSecret from api which establishes a Stripe setupIntent

Other notes:

  1. Moves the Stripe Appearance to a shared location so settings are not repeated across the stripe AddressElement and PaymentElement
  2. Initializes the Stripe Elements provider in mode: setup, currency: usd as required per here, here if using the PaymentElement. Otherwise stripe console errors that mode or client secret missing
  3. Updates hooks for the new ACH related tweaks to apis (done here)
  4. Updates the folder structure to accommodate the new designs.

from:

Billing Details
    BillingDetails.tsx
    |--EmailAddress
         |--EmailAddress.tsx
    |--Address
         |--AddressCard.tsx
         |--AddressForm.tsx
    |--PaymentCard
         |--CardInformation.tsx
         |--CreditCardForm.tsx
         |--PaymentCard.tsx

to:

Billing Details
   BillingDetails.tsx
   |--EmailAddress
         |--EmailAddress.tsx
   |--EditPaymentMethods
        EditPaymentMethods.tsx
        |--Address
             |--AddressForm.tsx
        |--PaymentMethod
             |--PaymentMethodForm.tsx
   |--ViewPaymentMethod
        ViewPaymentMethod.tsx
        |--Address
             |--AddressCard.tsx
        |--PaymentMethod
             |--PaymentMethod.tsx

Figma: https://www.figma.com/design/ftdTGGX43YyurDlxPCLTFy/GH-2621?node-id=1-2&p=f&t=lQMWI0ok827VpgVr-0

Closes codecov/engineering-team#3108

Copy link

sentry-io bot commented Dec 31, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: src/services/navigation/useNavLinks/useNavLinks.ts

Function Unhandled Issue
useNavLinks TypeError: Cannot read properties of undefined (reading 'match') /gh/docker/cli/commit/0f058041c4775b17b65fbb48...
Event Count: 3 Affected Users: 123

Did you find this useful? React with a 👍 or 👎

@codecov-staging
Copy link

codecov-staging bot commented Dec 31, 2024

Codecov Report

Attention: Patch coverage is 85.97561% with 23 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...gDetails/EditPaymentMethods/EditPaymentMethods.tsx 63.63% 8 Missing ⚠️
...s/CurrentOrgPlan/BillingDetails/BillingDetails.tsx 64.28% 5 Missing ⚠️
...PaymentMethods/PaymentMethod/PaymentMethodForm.tsx 78.94% 4 Missing ⚠️
...ingDetails/ViewPaymentMethod/ViewPaymentMethod.tsx 66.66% 3 Missing ⚠️
...llingDetails/ViewPaymentMethod/Address/Address.tsx 91.66% 2 Missing ⚠️
src/services/account/useUpdatePaymentMethod.ts 95.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #3616      +/-   ##
==========================================
- Coverage   98.94%   98.80%   -0.14%     
==========================================
  Files         815      820       +5     
  Lines       14676    14752      +76     
  Branches     4156     4202      +46     
==========================================
+ Hits        14521    14576      +55     
- Misses        148      170      +22     
+ Partials        7        6       -1     
Files with missing lines Coverage Δ
src/pages/PlanPage/PlanPage.jsx 100.00% <100.00%> (ø)
...Details/EditPaymentMethods/Address/AddressForm.tsx 91.66% <100.00%> (ø)
...iewPaymentMethod/PaymentMethod/BankInformation.tsx 100.00% <100.00%> (ø)
...iewPaymentMethod/PaymentMethod/CardInformation.tsx 100.00% <100.00%> (ø)
.../ViewPaymentMethod/PaymentMethod/PaymentMethod.tsx 100.00% <100.00%> (ø)
src/services/account/useAccountDetails.ts 95.23% <ø> (ø)
src/services/account/useCreateStripeSetupIntent.ts 100.00% <100.00%> (ø)
src/services/account/useUpdateBillingEmail.ts 100.00% <ø> (ø)
src/shared/ThemeContext/ThemeContext.tsx 96.87% <100.00%> (+0.10%) ⬆️
src/shared/utils/billing.ts 100.00% <100.00%> (ø)
... and 8 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.41% <79.43%> (-0.24%) ⬇️
Services 99.31% <96.77%> (-0.03%) ⬇️
Shared 99.37% <100.00%> (+<0.01%) ⬆️
UI 99.14% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 333b4e9...2dc8211. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Dec 31, 2024

Codecov Report

Attention: Patch coverage is 85.97561% with 23 lines in your changes missing coverage. Please review.

Project coverage is 98.80%. Comparing base (333b4e9) to head (2dc8211).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...gDetails/EditPaymentMethods/EditPaymentMethods.tsx 63.63% 8 Missing ⚠️
...s/CurrentOrgPlan/BillingDetails/BillingDetails.tsx 64.28% 5 Missing ⚠️
...PaymentMethods/PaymentMethod/PaymentMethodForm.tsx 78.94% 4 Missing ⚠️
...ingDetails/ViewPaymentMethod/ViewPaymentMethod.tsx 66.66% 3 Missing ⚠️
...llingDetails/ViewPaymentMethod/Address/Address.tsx 91.66% 2 Missing ⚠️
src/services/account/useUpdatePaymentMethod.ts 95.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #3616      +/-   ##
==========================================
- Coverage   98.94%   98.80%   -0.14%     
==========================================
  Files         815      820       +5     
  Lines       14676    14752      +76     
  Branches     4164     4202      +38     
==========================================
+ Hits        14521    14576      +55     
- Misses        148      170      +22     
+ Partials        7        6       -1     
Files with missing lines Coverage Δ
src/pages/PlanPage/PlanPage.jsx 100.00% <100.00%> (ø)
...Details/EditPaymentMethods/Address/AddressForm.tsx 91.66% <100.00%> (ø)
...iewPaymentMethod/PaymentMethod/BankInformation.tsx 100.00% <100.00%> (ø)
...iewPaymentMethod/PaymentMethod/CardInformation.tsx 100.00% <100.00%> (ø)
.../ViewPaymentMethod/PaymentMethod/PaymentMethod.tsx 100.00% <100.00%> (ø)
src/services/account/useAccountDetails.ts 95.23% <ø> (ø)
src/services/account/useCreateStripeSetupIntent.ts 100.00% <100.00%> (ø)
src/services/account/useUpdateBillingEmail.ts 100.00% <ø> (ø)
src/shared/ThemeContext/ThemeContext.tsx 96.87% <100.00%> (+0.10%) ⬆️
src/shared/utils/billing.ts 100.00% <100.00%> (ø)
... and 8 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.41% <79.43%> (-0.24%) ⬇️
Services 99.31% <96.77%> (-0.03%) ⬇️
Shared 99.37% <100.00%> (+<0.01%) ⬆️
UI 99.14% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 333b4e9...2dc8211. Read the comment docs.

Copy link

codecov bot commented Dec 31, 2024

Codecov Report

Attention: Patch coverage is 85.97561% with 23 lines in your changes missing coverage. Please review.

Project coverage is 98.80%. Comparing base (333b4e9) to head (2dc8211).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...gDetails/EditPaymentMethods/EditPaymentMethods.tsx 63.63% 8 Missing ⚠️
...s/CurrentOrgPlan/BillingDetails/BillingDetails.tsx 64.28% 5 Missing ⚠️
...PaymentMethods/PaymentMethod/PaymentMethodForm.tsx 78.94% 4 Missing ⚠️
...ingDetails/ViewPaymentMethod/ViewPaymentMethod.tsx 66.66% 3 Missing ⚠️
...llingDetails/ViewPaymentMethod/Address/Address.tsx 91.66% 2 Missing ⚠️
src/services/account/useUpdatePaymentMethod.ts 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3616      +/-   ##
==========================================
- Coverage   98.94%   98.80%   -0.14%     
==========================================
  Files         815      820       +5     
  Lines       14676    14752      +76     
  Branches     4164     4210      +46     
==========================================
+ Hits        14521    14576      +55     
- Misses        148      170      +22     
+ Partials        7        6       -1     
Files with missing lines Coverage Δ
src/pages/PlanPage/PlanPage.jsx 100.00% <100.00%> (ø)
...Details/EditPaymentMethods/Address/AddressForm.tsx 91.66% <100.00%> (ø)
...iewPaymentMethod/PaymentMethod/BankInformation.tsx 100.00% <100.00%> (ø)
...iewPaymentMethod/PaymentMethod/CardInformation.tsx 100.00% <100.00%> (ø)
.../ViewPaymentMethod/PaymentMethod/PaymentMethod.tsx 100.00% <100.00%> (ø)
src/services/account/useAccountDetails.ts 95.23% <ø> (ø)
src/services/account/useCreateStripeSetupIntent.ts 100.00% <100.00%> (ø)
src/services/account/useUpdateBillingEmail.ts 100.00% <ø> (ø)
src/shared/ThemeContext/ThemeContext.tsx 96.87% <100.00%> (+0.10%) ⬆️
src/shared/utils/billing.ts 100.00% <100.00%> (ø)
... and 8 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.41% <79.43%> (-0.24%) ⬇️
Services 99.31% <96.77%> (-0.03%) ⬇️
Shared 99.37% <100.00%> (+<0.01%) ⬆️
UI 99.14% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 333b4e9...2dc8211. Read the comment docs.

Copy link

codecov-public-qa bot commented Dec 31, 2024

Codecov Report

Attention: Patch coverage is 85.97561% with 23 lines in your changes missing coverage. Please review.

Project coverage is 98.80%. Comparing base (333b4e9) to head (4aacfb6).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...gDetails/EditPaymentMethods/EditPaymentMethods.tsx 63.63% 8 Missing ⚠️
...s/CurrentOrgPlan/BillingDetails/BillingDetails.tsx 64.28% 5 Missing ⚠️
...PaymentMethods/PaymentMethod/PaymentMethodForm.tsx 78.94% 4 Missing ⚠️
...ingDetails/ViewPaymentMethod/ViewPaymentMethod.tsx 66.66% 3 Missing ⚠️
...llingDetails/ViewPaymentMethod/Address/Address.tsx 91.66% 2 Missing ⚠️
src/services/account/useUpdatePaymentMethod.ts 95.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #3616      +/-   ##
==========================================
- Coverage   98.94%   98.80%   -0.14%     
==========================================
  Files         815      820       +5     
  Lines       14676    14752      +76     
  Branches     4164     4202      +38     
==========================================
+ Hits        14521    14576      +55     
- Misses        148      170      +22     
+ Partials        7        6       -1     
Files with missing lines Coverage Δ
src/pages/PlanPage/PlanPage.jsx 100.00% <100.00%> (ø)
...Details/EditPaymentMethods/Address/AddressForm.tsx 91.66% <100.00%> (ø)
...iewPaymentMethod/PaymentMethod/BankInformation.tsx 100.00% <100.00%> (ø)
...iewPaymentMethod/PaymentMethod/CardInformation.tsx 100.00% <100.00%> (ø)
.../ViewPaymentMethod/PaymentMethod/PaymentMethod.tsx 100.00% <100.00%> (ø)
src/services/account/useAccountDetails.ts 95.23% <ø> (ø)
src/services/account/useCreateStripeSetupIntent.ts 100.00% <100.00%> (ø)
src/services/account/useUpdateBillingEmail.ts 100.00% <ø> (ø)
src/shared/ThemeContext/ThemeContext.tsx 96.87% <100.00%> (+0.10%) ⬆️
src/shared/utils/billing.ts 100.00% <100.00%> (ø)
... and 8 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.41% <79.43%> (-0.24%) ⬇️
Services 99.31% <96.77%> (-0.03%) ⬇️
Shared 99.37% <100.00%> (+<0.01%) ⬆️
UI 99.14% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 333b4e9...4aacfb6. Read the comment docs.

@aj-codecov
Copy link
Contributor

@codecov-ai-reviewer review

@suejung-sentry suejung-sentry force-pushed the sshin/3108 branch 3 times, most recently from 5e48a4e to f8c1578 Compare January 13, 2025 04:23
@@ -45,7 +50,7 @@ function PlanPage() {
return (
<div className="flex flex-col gap-4">
<Tabs />
<Elements stripe={stripePromise}>
<Elements stripe={stripePromise} options={StripeAppearance(isDarkMode)}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the Theme was getting duped and passed in both the AddressForm and CreditCardForm before, so I consolidated them in file stripe.ts

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)

@suejung-sentry suejung-sentry force-pushed the sshin/3108 branch 2 times, most recently from 169de52 to d64d415 Compare January 14, 2025 18:54
@codecov-staging
Copy link

codecov-staging bot commented Jan 14, 2025

Bundle Report

Changes will increase total bundle size by 6.08MB (100.3%) ⬆️⚠️, exceeding the configured threshold of 5%.

Bundle name Size Change
gazebo-staging-system 6.04MB 6.04MB (100%) ⬆️⚠️
gazebo-staging-esm 6.09MB 6.09MB (100%) ⬆️⚠️
gazebo-staging-system-esm (removed) 6.06MB (-100.0%) ⬇️

Copy link

codecov bot commented Jan 14, 2025

Bundle Report

Changes will decrease total bundle size by 12.18MB (-50.1%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 6.04MB 5.83kB (0.1%) ⬆️
gazebo-production-esm 6.09MB 6.51kB (0.11%) ⬆️
gazebo-production-array-push (removed) 6.14MB (-100.0%) ⬇️
gazebo-production-system-esm (removed) 6.06MB (-100.0%) ⬇️

@codecov-releaser
Copy link
Contributor

codecov-releaser commented Jan 14, 2025

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
d64d415 Tue, 14 Jan 2025 18:59:28 GMT Expired Expired
2ade2fc Tue, 14 Jan 2025 19:57:35 GMT Expired Expired
2ade2fc Tue, 14 Jan 2025 19:59:23 GMT Expired Expired
eaaf86d Tue, 14 Jan 2025 20:05:57 GMT Expired Expired
2dc8211 Tue, 14 Jan 2025 21:15:54 GMT Cloud Enterprise

@suejung-sentry suejung-sentry marked this pull request as ready for review January 14, 2025 21:03
Copy link
Contributor

@ajay-sentry ajay-sentry left a comment

Choose a reason for hiding this comment

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

couple comments!


interface EditPaymentMethodsProps {
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

owner,
subscriptionDetail,
}: EditPaymentMethodsProps) => {
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


interface PaymentMethodFormProps {
closeForm: () => 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.

Same comment here with Provider

<Elements
stripe={stripePromise}
options={{
...StripeAppearance(isDarkMode),
Copy link
Contributor

Choose a reason for hiding this comment

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

I hadn't considered adding the appearance on the top level here but I really like this

Do we need the 'mode' and 'currency' defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah those are parameters required in order to use this Stripe Elements provider along with the setupIntent for the PaymentElement UI. There are complaints in the console if they don't get passed unfortunately

interface AddressProps {
setEditMode: (isEditMode: boolean) => void
subscriptionDetail: z.infer<typeof SubscriptionDetailSchema>
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.

Same comment here with Provider

{isAddressSameAsPrimary ? (
<p>Same as primary address</p>
) : isEmptyAddress ? (
<p>-</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe for the empty address case we could use the stuff on line 33 (like move that condition to line 33 and show that component)

@@ -20,6 +20,7 @@ export function useUpdateBillingEmail({ provider, owner }: UsePlanDataArgs) {
const body = {
/* eslint-disable camelcase */
new_email: formData?.newEmail,
should_propagate_to_payment_methods: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

reminder to update this param to the new name

provider,
owner,
}: {
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.

Another Provider

Copy link
Contributor

Choose a reason for hiding this comment

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

This file has 2 actually

@@ -29,7 +29,9 @@ interface ThemeContextProviderProps {
export const ThemeContextProvider: FC<ThemeContextProviderProps> = ({
children,
}) => {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
const prefersDark =
typeof window !== 'undefined' &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this throwing an error somewhere? Jw

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it was in one of the tests where window is not defined. Should not error in the real world, but adding this check in doesn't hurt

@@ -134,7 +134,8 @@ function Button({
const className = cs(
baseClass,
{ [baseDisabledClasses]: !isLoading },
pickVariant(variant, isLoading)
pickVariant(variant, isLoading),
props.className
Copy link
Contributor

Choose a reason for hiding this comment

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

what was this one for? :O

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had needed to add a flex-none for formatting on one of the buttons

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Gazebo] Update the Billing / Plan Page to fit the new Figma Design
4 participants