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(checkout-flow): handle credit card functionality #8005

Merged
merged 19 commits into from
Apr 24, 2023

Conversation

nickoferrall
Copy link
Contributor

@nickoferrall nickoferrall commented Apr 6, 2023

Fix #7693

Demo: https://www.loom.com/share/66aedcba66f14d6ea1ce1dcd82217c0e

I had a look on the Stripe Dashboard to see if Igor & Georg have access, but I couldn't see any other users. I think that's because I have restricted permissions where I can't see or invite other users. So if you don't have Stripe access, please tag someone in Slack that can invite you.

I'll improve the UI after the user has upgraded in the following issue: #8006

A subscription will not be created for 3D Secure payment methods. This will be handled here: #7864

To test

  • Add the checkout flow feature flag to an org on the Starter tier
  • Enter dummy card details. Click "Upgrade" before you've entered all the details and see the error messages
  • Enter dummy credit card details correctly, click Upgrade, and see the confetti animation
  • Go to the Stripe dashboard, click "Test" mode, and see that the subscription was successfully created
  • Refresh the page and see that the org has now been upgraded to the Team tier and the credit card panel no longer shows up

@@ -40,7 +40,7 @@
"Comment": "../../database/types/Comment#default as CommentDB",
"Company": "./types/Company#CompanySource",
"CreateImposterTokenPayload": "./types/CreateImposterTokenPayload#CreateImposterTokenPayloadSource",
"CreatePaymentIntentSuccess": "./types/CreatePaymentIntentSuccess#CreatePaymentIntentSuccessSource",
"CreateSetupIntentSuccess": "./types/CreateSetupIntentSuccess#CreateSetupIntentSuccessSource",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

SetupIntent is used for subscriptions whereas createPaymentIntent is used for one-off payments

await upgradeToTeamTier(orgId, stripeToken, email, dataLoader)
// TODO: remove upgradeToTeamTierOld once we rollout the new checkout flow: https://github.com/ParabolInc/parabol/milestone/150
if (paymentMethodId) {
await upgradeToTeamTier(orgId, paymentMethodId, email, dataLoader)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

upgradeToTeamTier changed quite a bit now that we're using Stripe Elements and use the paymentMethodId rather than creating a stripe token using the credit card details the user gives us.

I felt that the simplest move was to rename upgradeToTeamTier to upgradeToTeamTierOld and create a new upgradeToTeamTier helper function. We can remove the old one when we rollout the new checkout flow.

@nickoferrall nickoferrall marked this pull request as ready for review April 6, 2023 18:36
Copy link
Contributor

@igorlesnenko igorlesnenko left a comment

Choose a reason for hiding this comment

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

If I'm trying to upgrade another org after one successful upgrade, I'm getting this error:

16:11:06 1|GraphQL Executor  | SEND TO SENTRY Error: payment_method
16:11:06 1|GraphQL Executor  |     at Object.resolve [as MutationupgradeToTeamTierResolver] (/Users/igor/www/parabol/dev/gqlExecutor.js:21603:29)
16:11:06 1|GraphQL Executor  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {}

Works after some time.

Can you reproduce?

@nickoferrall
Copy link
Contributor Author

Thanks @igorlesnenko - I could reproduce the payment_method console error. I fixed this by attaching the payment to the customer before updating the default payment method.

const UpgradeButton = styled(PrimaryButton)<{isDisabled: boolean}>(({isDisabled}) => ({
background: isDisabled ? PALETTE.SLATE_200 : PALETTE.SKY_500,
color: isDisabled ? PALETTE.SLATE_600 : PALETTE.WHITE,
boxShadow: 'none',
marginTop: 16,
width: '100%',
elevation: 0,
'&:hover': {
'&:hover, &:focus': {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a side note, the "Plans" panel does not have any focus behaviour which makes it impossible to use with just the keyboard

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, that would be nice! I've created an issue to work on that: #8085

setIsLoading(false)
if (error) return
const {payment_method: paymentMethodId, status} = setupIntent
if (status === 'succeeded' && typeof paymentMethodId === 'string') {
Copy link
Contributor

Choose a reason for hiding this comment

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

-1 What about if not? If I test with a declining card 4000000000000002 or with a 3D Secure card 4000002760003184 and decline, then there is no message at all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated!

By the way, 3D Secure cards won't create subscriptions in this PR. It'll be handled in #7864

Copy link
Contributor

@Dschoordsch Dschoordsch left a comment

Choose a reason for hiding this comment

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

Before we forget, can you please also add new testing scenarios to the release test?
Could also be done a bit later, but should be logged in an issue so we don't forget.

@nickoferrall
Copy link
Contributor Author

can you please also add new testing scenarios to the release test?

Sure thing! I've added an issue here: #8089

@nickoferrall nickoferrall merged commit 80ceece into master Apr 24, 2023
@nickoferrall nickoferrall deleted the feat/7684/credit-card-func branch April 24, 2023 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checkout Flow: Make credit card info dynamic
3 participants