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

Migrate donate Netlify function to Cloudflare (#proj-donor-page v2 option 1) #2998

Merged
merged 31 commits into from
Jan 11, 2024

Conversation

mlbrgl
Copy link
Member

@mlbrgl mlbrgl commented Dec 6, 2023

This is part of the migration of the donor flow from Netlify to Cloudflare, tracked in #2947.

This PR deals specifically with the migration of the donate function, which handles the creation of a Stripe checkout session upon clicking on "Donate" on /donate. See README.md for a complete sequence diagram.

Additionally, it tackles:

  • upgrading the Stripe API version from 2020-08-27 to 2023-10-16
  • switching to inline pricing for code-driven pricing (vs configuration in the Stripe dashboard)
  • fixes reCAPTCHA validation
  • a more isomorphic take on errors reported to the donor. Donation payloads are statically typed on the client and the server, and checked for proper type at runtime when received over the wire - all using a single type (thanks to Typebox). There is however no particular reporting of more general errors at this stage, beyond what might be surfaced in the Cloudflare panel. This needs to be addressed.

This PR also brings some reader-facing improvements:

Non-code actions:

  • add env variables to Cloudflare dashboard (production and preview environments)
  • (when deploying live) remove STRIPE_PUBLIC_KEY from .env (it is not used anymore)
  • (when deploying live) update DONATE_API_URL env var (/donation/donate)
  • (when deploying live) update API version on stripe dashboard
  • (when deploying live) merge https://github.com/owid/owid-donors/pull/1

Still unclear:

Reference:

@mlbrgl mlbrgl changed the title Migrate donate flow to Cloudflare Migrate donate Netlify function to Cloudflare Dec 8, 2023
@mlbrgl mlbrgl changed the title Migrate donate Netlify function to Cloudflare Migrate donate Netlify function to Cloudflare (#proj-donor-flow v2 option 1) Dec 8, 2023
@mlbrgl mlbrgl changed the title Migrate donate Netlify function to Cloudflare (#proj-donor-flow v2 option 1) Migrate donate Netlify function to Cloudflare (#proj-donor-page v2 option 1) Dec 8, 2023
@mlbrgl mlbrgl linked an issue Dec 8, 2023 that may be closed by this pull request
@mlbrgl mlbrgl force-pushed the donate-cloudflare branch from c350559 to 1bbd0cb Compare December 8, 2023 16:39
@mlbrgl mlbrgl marked this pull request as ready for review December 8, 2023 17:58
@mlbrgl mlbrgl requested a review from danyx23 December 8, 2023 17:59
@mlbrgl mlbrgl force-pushed the local-env-cloudflare-functions branch from edd1096 to d951ef4 Compare December 12, 2023 08:14
@mlbrgl mlbrgl force-pushed the donate-cloudflare branch 5 times, most recently from c2a847e to f78ea7d Compare December 13, 2023 17:38
@mlbrgl mlbrgl force-pushed the local-env-cloudflare-functions branch from d951ef4 to 4629849 Compare December 14, 2023 08:20
@mlbrgl mlbrgl force-pushed the donate-cloudflare branch 3 times, most recently from e5c086c to d1eaadf Compare December 14, 2023 08:40
@mlbrgl mlbrgl force-pushed the local-env-cloudflare-functions branch from 4629849 to 8c325fd Compare December 19, 2023 09:46
Copy link
Contributor

@danyx23 danyx23 left a comment

Choose a reason for hiding this comment

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

I tried this and it works. Some questions:

  • I never saw a captcha (I tried with an incognito browser to check if this is because of cookies by google or similar but no captcha there either). Is that ok?
  • I didn't get any email - is that expected?

Small nit: when you enter amount "0" you see the wrong error message (you should see the one that tells you the valid amount but instead it says you should enter an amount - i.e. it treats 0 as empty)
Another nit: there is a missing closing quote after the name in the summary message that is shown in stripe

@mlbrgl mlbrgl force-pushed the local-env-cloudflare-functions branch from 8c325fd to 5b3df75 Compare December 27, 2023 07:23
@mlbrgl mlbrgl force-pushed the local-env-cloudflare-functions branch from 5b3df75 to 4fac8a1 Compare December 29, 2023 19:35
mlbrgl and others added 27 commits January 11, 2024 17:30
Prevent conflict with /donate/thank-you redirect
@mlbrgl mlbrgl force-pushed the donate-cloudflare branch from f7892b9 to 98022de Compare January 11, 2024 17:30
@mlbrgl mlbrgl merged commit 4e57559 into master Jan 11, 2024
12 of 14 checks passed
@mlbrgl mlbrgl deleted the donate-cloudflare branch January 11, 2024 17:32
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.

(donate) Clear error when ticking the "name" checkbox
3 participants