Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

feature(plg): Use custom Stripe checkout#62955

Merged
vdavid merged 12 commits into
mainfrom
dv/use-custom-stripe-checkout
Jun 4, 2024
Merged

feature(plg): Use custom Stripe checkout#62955
vdavid merged 12 commits into
mainfrom
dv/use-custom-stripe-checkout

Conversation

@vdavid

@vdavid vdavid commented May 28, 2024

Copy link
Copy Markdown
Contributor

The PR

Context: In our previous Stripe checkout implementation, we didn't have the freedom to design our seat selection UI and other parts of our checkout experience.

Problem: The current state causes three difficulties:

  1. We can't implement Rob's nice seat selector UI
  2. We need to be able to add/remove seats after a subscription already exists.
  3. We can't add an "Explore an enterprise plan" notification (tracked by https://github.com/sourcegraph/self-serve-cody/issues/784 and https://github.com/sourcegraph/self-serve-cody/issues/711)

Solution:

I found Stripe's "Custom Checkout with Elements" solution (here), which seemed to solve all our problems without major changes or completely custom implementations of complex controls like the payment form or the address form. But then I realized that this solution was in a "Private Beta" state. I contacted Stripe, who quickly got back to me and gave us access to the API, assuring us that regardless of the Beta state, it's safe to use in production.

So I've modified the back end in:

Notes:

Current caveats:

  • (Only affects development) The current solution needs the Stripe CLI webhook forwarder to be running locally
  • Design—I will address these before merging this PR, and ask for a design re-review:

Changelog

  • Added Stripe Custom Checkout for Cody PLG

Test plan

No automated test, but I did a thorough QA.

  • The "Subscribe" flow triggers a subscription creation in SSC with the correct parameters.
  • I show a "Loading" state in two places, and ensured that the "Subscribe" button can only be pressed once.

Here is a 4-minute demo of a run-through.

Note: the new page is behind a feature flag and won't be in production yet.

@cla-bot cla-bot Bot added the cla-signed label May 28, 2024
@vdavid vdavid force-pushed the dv/use-custom-stripe-checkout branch from 0924826 to 7025763 Compare May 29, 2024 15:42

@chrsmith chrsmith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'll follow up with more specific questions in Slack, but I don't see what the actual benefit to this PR is.

Does the "Custom Stripe Checkout" just give us more flexibility in how we render the Stripe Checkout page? If so, then is the point of all of this just to restyle the "+/- seats" buttons when a new subscription is created? But we would still have the same limitations that we have today with Stripe Checkout, in that it can only be used for creating new subscriptions, but we would still need to roll our own UX for updating existing subscriptions?

Ultimately, this doesn't seem like it is something we would want to merge.

@vdavid

vdavid commented May 29, 2024

Copy link
Copy Markdown
Contributor Author

@chrsmith

I'll follow up with more specific questions in Slack, but I don't see what the actual benefit to this PR is.

Does the "Custom Stripe Checkout" just give us more flexibility in how we render the Stripe Checkout page? If so, then is the point of all of this just to restyle the "+/- seats" buttons when a new subscription is created? But we would still have the same limitations that we have today with Stripe Checkout, in that it can only be used for creating new subscriptions, but we would still need to roll our own UX for updating existing subscriptions?

Ultimately, this doesn't seem like it is something we would want to merge.

We want to:

  • Render the "+/- seats" UI the way we designed it, which we can't do with the EmbeddedCheckoutProvider as it doesn't allow for the level of customization we want.
  • Show an "Upgrade to Enterprise" notification in case of 30+ seats, which we also can't do with EmbeddedCheckoutProvider.
  • Use the same UI (with the credit card and address parts disabled) for the "Add seats" functionality. For this, we had to develop the custom UI we have on the left side of the page, so that's not extra work to use it here.
  • Avoid having to recreate the payment method and address logic because we lack the time for it.

I've investigated the alternatives and haven't found a good one, so I currently intend to merge this PR once it's done. I'm open to hearing the alternatives I might've missed, though.

@vdavid vdavid force-pushed the dv/use-custom-stripe-checkout branch from 6f1fca7 to 8270582 Compare May 31, 2024 09:52
@vdavid vdavid force-pushed the dv/use-custom-stripe-checkout branch 2 times, most recently from aecdd3e to 19528b6 Compare May 31, 2024 14:59
Use debouncing
Add "loading" states
Redirect after successful payment
@vdavid vdavid force-pushed the dv/use-custom-stripe-checkout branch from 19528b6 to cc6a388 Compare May 31, 2024 15:15
@vdavid vdavid requested a review from a team May 31, 2024 16:12
@vdavid vdavid marked this pull request as ready for review May 31, 2024 16:12

@chrsmith chrsmith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I didn't look super-close at the React code, but this all looks good to me. :shipit:

We want to:
...
I've investigated the alternatives and haven't found a good one, so I currently intend to merge this PR once it's done. I'm open to hearing the alternatives I might've missed, though.

All of the things you listed are great, and I am super-duper excited to have a better looking UI for the new subscription experience!

The "alternative" I'm referring to is just that, once we have all of the UI components working the way we want. (And aren't relying on Stripe Checkout to power the specific HTML/DOM.) Then we should be able to cut Stripe Checkout out of the equation entirely.

And just call our own API to create the new Stripe Customer / Subscription object. Since if we have the user-supplied seat count, name and billing address, and payment method, we have all the things we need. And being able to remove Stripe Checkout and rely on just our code for the entire experience, seems like it would simplify our overall codebase. (So perhaps not in this PR, but maybe we are within striking distance of doing that in 1-2 follow up PRs.)

Comment thread client/web/src/cody/management/api/stripeCheckout.ts Outdated
Comment thread client/web/src/cody/management/subscription/new/CodyProCheckoutForm.tsx Outdated
Comment thread client/web/src/cody/management/subscription/new/CodyProCheckoutForm.tsx Outdated

@taras-yemets taras-yemets left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thank you!
Left a few comments inline.

@vdavid vdavid deleted the dv/use-custom-stripe-checkout branch June 4, 2024 15:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants