fix(checkout): CHECKOUT-10026 Add new Places API support for Google Autocomplete with legacy fallback#3110
Draft
bc-maxy wants to merge 22 commits into
Draft
fix(checkout): CHECKOUT-10026 Add new Places API support for Google Autocomplete with legacy fallback#3110bc-maxy wants to merge 22 commits into
bc-maxy wants to merge 22 commits into
Conversation
Contributor
Author
|
cursor review |
Contributor
Author
|
cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e02bfce. Configure here.
Contributor
Author
|
cursor review |
Contributor
Author
|
cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
1 issue from previous review remains unresolved.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 45efb30. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What/Why?
Makes the new Google Places API the primary autocomplete provider (behind experiment flag
CHECKOUT-10026.new_google_places_api), falling back to the legacy API on permission errors. Moves merchants onto the cheaper new API automatically, with no change for stores whose keys aren't yet provisioned for it.How
GoogleAutocomplete.tsx now tries the new API first. On gRPC
PERMISSION_DENIEDit latches a page-session-wide fallback flag and switches to the legacy AutocompleteService/PlacesService for the rest of the session. Added a 300ms debounce on suggestion fetching. New newGooglePlacesApi/ module handles the new API (loader, service, session tokens, field mapping). Both old and new loaders now share one Maps script load via importLibrary, since loading the Maps JS API twice breaks it.Billing
Session tokens bundle keystrokes + selection into one billed session. Field masks request only addressComponents/displayName, keeping calls in the cheapest pricing tier so this should improve costs significantly.
Rollout/Rollback
Revert the PR.
Testing
CI + Manual testing.
Before
Existing customers with old API keys:
Screen.Recording.2026-06-30.at.3.16.03.PM.mov
New customers with new API keys (doesn't work):
Screen.Recording.2026-06-30.at.3.18.15.PM.mov
After
Existing customers with old API keys (Initial 403, then fallback to the old service. Billing step will remember that we fallback and skips new api):
Screen.Recording.2026-06-30.at.3.30.18.PM.mov
New customers with new API keys:
Screen.Recording.2026-06-30.at.3.24.12.PM.mov
Note
Medium Risk
Changes checkout address entry and external Google SDK loading with session-wide fallback behavior; regressions could affect suggestion quality, latency, or merchants on legacy-only keys, though legacy paths are preserved.
Overview
Checkout address Google Autocomplete now prefers the new Places API (
AutocompleteSuggestion/Place) and falls back to the legacyAutocompleteService/PlacesServicewhen the new API fails. A sharednewGooglePlacesApiState.isUnavailableflag latches after gRPC PERMISSION_DENIED so legacy-only API keys skip repeated new-API calls for the rest of the page session; transient errors still retry the new API.GoogleAutocompletewires both services, adds 300ms debounced suggestion fetching (immediate clear when the input is empty), and routes selection through new or legacy place-details paths with the samePlaceResultshape foronSelect.The Maps loader is replaced with Google’s
importLibrarybootstrap andloadPlacesLibrary(no@bigcommerce/script-loadercallback URL). LegacyGoogleAutocompleteServicenow loads the places library the same way. NewNewGooglePlacesApiServiceadds session tokens, prediction caching viatoPlace(), minimal field masks, and legacy↔new mapping helpers.Broad unit tests cover the component fallback matrix, loader bootstrap/memoization, and the new service/utils.
Reviewed by Cursor Bugbot for commit 45efb30. Bugbot is set up for automated code reviews on this repo. Configure here.