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 related hooks #3662

Merged
merged 4 commits into from
Jan 16, 2025
Merged

feat: Add ACH related hooks #3662

merged 4 commits into from
Jan 16, 2025

Conversation

suejung-sentry
Copy link
Contributor

@suejung-sentry suejung-sentry commented Jan 16, 2025

Add hooks related to project to add ACH payment method.

The below changes are made:

  1. useAccountDetails [edit existing] - add usBankAccount as a possible return value
  2. useUpdateBillingEmail [edit existing] - adds a knob to propagate the updated email to the default payment method
  3. useCreateStripeSetupIntent [new] - This will be in order to cut over from the existing Stripe CardElement to their PaymentElement. PaymentElement requires a clientSecret from api which establishes a Stripe SetupIntent (done in api here)
  4. updatePaymentMethod [new] - pretty similar to existing updateCard except uses stripe's "confirmSetup" api instead of "createPayment". We can deprecate updateCard once we cut over to this one. This is needed to hook in with the PaymentElement stripe component (vs. CardElement)

Other notes:
Added the Provider type instead of string and that needed a bunch of files touched FYI

Closes codecov/engineering-team#3109

@codecov-staging
Copy link

codecov-staging bot commented Jan 16, 2025

Bundle Report

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

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

Copy link

codecov bot commented Jan 16, 2025

Bundle Report

Changes will increase total bundle size by 825 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 6.05MB 419 bytes (0.01%) ⬆️
gazebo-production-esm 6.1MB 406 bytes (0.01%) ⬆️

@codecov-releaser
Copy link
Contributor

codecov-releaser commented Jan 16, 2025

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
530b60a Thu, 16 Jan 2025 02:19:10 GMT Expired Expired
530b60a Thu, 16 Jan 2025 02:22:31 GMT Expired Expired
6d5dbdb Thu, 16 Jan 2025 18:58:00 GMT Expired Expired
72cd37d Thu, 16 Jan 2025 19:37:23 GMT Expired Expired
2472671 Thu, 16 Jan 2025 23:29:49 GMT Expired Expired
2472671 Thu, 16 Jan 2025 23:31:55 GMT Cloud Enterprise

@codecov-staging
Copy link

codecov-staging bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/services/account/useCreateStripeSetupIntent.ts 92.85% 1 Missing ⚠️
src/services/account/useUpdatePaymentMethod.ts 95.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #3662      +/-   ##
==========================================
- Coverage   98.93%   98.91%   -0.02%     
==========================================
  Files         815      817       +2     
  Lines       14686    14720      +34     
  Branches     4168     4165       -3     
==========================================
+ Hits        14529    14561      +32     
- Misses        150      152       +2     
  Partials        7        7              
Files with missing lines Coverage Δ
...anPage/subRoutes/CancelPlanPage/CancelPlanPage.tsx 100.00% <ø> (ø)
...s/CurrentOrgPlan/BillingDetails/BillingDetails.tsx 100.00% <ø> (ø)
...gPlan/BillingDetails/EmailAddress/EmailAddress.tsx 100.00% <ø> (ø)
...anPage/subRoutes/CurrentOrgPlan/CurrentOrgPlan.tsx 100.00% <ø> (ø)
...CurrentOrgPlan/CurrentPlanCard/CurrentPlanCard.tsx 100.00% <ø> (ø)
...Plan/CurrentPlanCard/PaidPlanCard/PaidPlanCard.tsx 100.00% <ø> (ø)
...rs/ProPlanController/PriceCallout/PriceCallout.tsx 100.00% <100.00%> (ø)
...trollers/ProPlanController/UserCount/UserCount.tsx 100.00% <100.00%> (ø)
...SentryPlanController/PriceCallout/PriceCallout.tsx 100.00% <100.00%> (ø)
...llers/SentryPlanController/UserCount/UserCount.tsx 100.00% <100.00%> (ø)
... and 7 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.62% <100.00%> (ø)
Services 99.28% <94.11%> (-0.06%) ⬇️
Shared 99.37% <ø> (ø)
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 a910857...2472671. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 98.91%. Comparing base (a910857) to head (2472671).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/services/account/useCreateStripeSetupIntent.ts 92.85% 1 Missing ⚠️
src/services/account/useUpdatePaymentMethod.ts 95.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #3662      +/-   ##
==========================================
- Coverage   98.93%   98.91%   -0.02%     
==========================================
  Files         815      817       +2     
  Lines       14686    14720      +34     
  Branches     4160     4173      +13     
==========================================
+ Hits        14529    14561      +32     
- Misses        150      152       +2     
  Partials        7        7              
Files with missing lines Coverage Δ
...anPage/subRoutes/CancelPlanPage/CancelPlanPage.tsx 100.00% <ø> (ø)
...s/CurrentOrgPlan/BillingDetails/BillingDetails.tsx 100.00% <ø> (ø)
...gPlan/BillingDetails/EmailAddress/EmailAddress.tsx 100.00% <ø> (ø)
...anPage/subRoutes/CurrentOrgPlan/CurrentOrgPlan.tsx 100.00% <ø> (ø)
...CurrentOrgPlan/CurrentPlanCard/CurrentPlanCard.tsx 100.00% <ø> (ø)
...Plan/CurrentPlanCard/PaidPlanCard/PaidPlanCard.tsx 100.00% <ø> (ø)
...rs/ProPlanController/PriceCallout/PriceCallout.tsx 100.00% <100.00%> (ø)
...trollers/ProPlanController/UserCount/UserCount.tsx 100.00% <100.00%> (ø)
...SentryPlanController/PriceCallout/PriceCallout.tsx 100.00% <100.00%> (ø)
...llers/SentryPlanController/UserCount/UserCount.tsx 100.00% <100.00%> (ø)
... and 7 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.62% <100.00%> (ø)
Services 99.28% <94.11%> (-0.06%) ⬇️
Shared 99.37% <ø> (ø)
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 a910857...2472671. Read the comment docs.

Copy link

codecov-public-qa bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 98.91%. Comparing base (a910857) to head (2472671).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/services/account/useCreateStripeSetupIntent.ts 92.85% 1 Missing ⚠️
src/services/account/useUpdatePaymentMethod.ts 95.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #3662      +/-   ##
==========================================
- Coverage   98.93%   98.91%   -0.02%     
==========================================
  Files         815      817       +2     
  Lines       14686    14720      +34     
  Branches     4160     4173      +13     
==========================================
+ Hits        14529    14561      +32     
- Misses        150      152       +2     
  Partials        7        7              
Files with missing lines Coverage Δ
...anPage/subRoutes/CancelPlanPage/CancelPlanPage.tsx 100.00% <ø> (ø)
...s/CurrentOrgPlan/BillingDetails/BillingDetails.tsx 100.00% <ø> (ø)
...gPlan/BillingDetails/EmailAddress/EmailAddress.tsx 100.00% <ø> (ø)
...anPage/subRoutes/CurrentOrgPlan/CurrentOrgPlan.tsx 100.00% <ø> (ø)
...CurrentOrgPlan/CurrentPlanCard/CurrentPlanCard.tsx 100.00% <ø> (ø)
...Plan/CurrentPlanCard/PaidPlanCard/PaidPlanCard.tsx 100.00% <ø> (ø)
...rs/ProPlanController/PriceCallout/PriceCallout.tsx 100.00% <100.00%> (ø)
...trollers/ProPlanController/UserCount/UserCount.tsx 100.00% <100.00%> (ø)
...SentryPlanController/PriceCallout/PriceCallout.tsx 100.00% <100.00%> (ø)
...llers/SentryPlanController/UserCount/UserCount.tsx 100.00% <100.00%> (ø)
... and 7 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.62% <100.00%> (ø)
Services 99.28% <94.11%> (-0.06%) ⬇️
Shared 99.37% <ø> (ø)
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 a910857...2472671. Read the comment docs.

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 98.91%. Comparing base (a910857) to head (2472671).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/services/account/useCreateStripeSetupIntent.ts 92.85% 1 Missing ⚠️
src/services/account/useUpdatePaymentMethod.ts 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3662      +/-   ##
==========================================
- Coverage   98.93%   98.91%   -0.02%     
==========================================
  Files         815      817       +2     
  Lines       14686    14720      +34     
  Branches     4160     4165       +5     
==========================================
+ Hits        14529    14561      +32     
- Misses        150      152       +2     
  Partials        7        7              
Files with missing lines Coverage Δ
...anPage/subRoutes/CancelPlanPage/CancelPlanPage.tsx 100.00% <ø> (ø)
...s/CurrentOrgPlan/BillingDetails/BillingDetails.tsx 100.00% <ø> (ø)
...gPlan/BillingDetails/EmailAddress/EmailAddress.tsx 100.00% <ø> (ø)
...anPage/subRoutes/CurrentOrgPlan/CurrentOrgPlan.tsx 100.00% <ø> (ø)
...CurrentOrgPlan/CurrentPlanCard/CurrentPlanCard.tsx 100.00% <ø> (ø)
...Plan/CurrentPlanCard/PaidPlanCard/PaidPlanCard.tsx 100.00% <ø> (ø)
...rs/ProPlanController/PriceCallout/PriceCallout.tsx 100.00% <100.00%> (ø)
...trollers/ProPlanController/UserCount/UserCount.tsx 100.00% <100.00%> (ø)
...SentryPlanController/PriceCallout/PriceCallout.tsx 100.00% <100.00%> (ø)
...llers/SentryPlanController/UserCount/UserCount.tsx 100.00% <100.00%> (ø)
... and 7 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.62% <100.00%> (ø)
Services 99.28% <94.11%> (-0.06%) ⬇️
Shared 99.37% <ø> (ø)
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 a910857...2472671. Read the comment docs.

@suejung-sentry suejung-sentry force-pushed the sshin/stripe-1 branch 4 times, most recently from cd705a2 to 71bc658 Compare January 16, 2025 19:27
@suejung-sentry suejung-sentry marked this pull request as ready for review January 16, 2025 19:37
queryFn: ({ signal }) =>
createStripeSetupIntent({ provider, owner, signal }).then((res) => {
const parsedRes = CreateStripeSetupIntentSchema.safeParse(res.data)
if (!parsedRes.success) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to return different stuff if one of the "error" types comes back?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm true, I'll have those errors reject as well (seems that is the pattern in other hooks too). I'll do a pass at the error pathways too to make sure these get reacted to correctly as well

reset: () => void
error: null | Error
isLoading: boolean
mutate: (variables: any, data: any) => void
Copy link
Contributor

Choose a reason for hiding this comment

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

is variables actually "any" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah just copied that over from the updateCard implementation, good catch of a lazy moment lol. Updated.

},
})
.then((result) => {
if (result.error) return Promise.reject(result.error)
Copy link
Contributor

Choose a reason for hiding this comment

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

This error object is a user readable thing right? And not like a stack trace or something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would take the shape of a stripe error like below. And our current error framework would have that propagate to the user as the generic error page.
I don't think the contents of the error are ever shown to the user. I'll take a pass in the next PRs on the error flows that not missing something in there, good callout.

{
  "type": "some_error",
  "message": "Some message",
  "code": "some_code",
  "payment_intent": {
    "id": "pi_xyz",
    "status": "requires_payment_method"
  }
}

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.

lgtm, couple thoughts on things

@suejung-sentry suejung-sentry added this pull request to the merge queue Jan 16, 2025
Merged via the queue into main with commit 162b8ca Jan 16, 2025
50 of 62 checks passed
@suejung-sentry suejung-sentry deleted the sshin/stripe-1 branch January 16, 2025 23:41
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 useUpdateCard hook to useUpdatePaymentMethod Hook
3 participants