Skip to content

Commit ec7bc62

Browse files
authored
remove legacy-bridge (#190)
### What changes are you making? Removes the legacy `CheckoutBridge` JS interface (registered under the `"android"` name) and replaces it entirely with `EmbeddedCheckoutProtocol` as the sole JavaScript interface attached to `CheckoutWebView`. As part of this: - `CheckoutBridge.kt` and its associated `WebToSdkEvent` model are deleted. - The `errorevents` subpackage (`CheckoutErrorDecoder`, `CheckoutErrorGroup`, `CheckoutErrorPayload`) is removed, along with the error-group-based exception mapping it performed. - The `lifecycleevents` subpackage models (`Address`, `CartInfo`, `CartLine`, `CartLineImage`, `CheckoutCompletedEvent`, `CheckoutCompletedEventDecoder`, `CompletedEvent`, `DeliveryDetails`, `DeliveryInfo`, `Discount`, `MoneyV2`, `OrderDetails`, `PaymentMethod`, `Price`) are removed from the public API surface, as they are now generated from the protocol definition. - `ConfigurationException` and `ClientException` are removed from the documented exception hierarchy and error table. `CheckoutExpiredException` error codes `cart_completed` and `invalid_cart` are also removed. - `CheckoutWebViewListener` no longer holds a `toggleHeader` callback, and `CheckoutDialog` no longer wires up header visibility toggling in response to modal events. - `CheckoutWebView` now holds the listener directly rather than delegating through `CheckoutBridge`. - All tests covering `CheckoutBridge`, `CheckoutCompletedEventDecoder`, `CheckoutErrorDecoder`, and the corresponding Java interop cases are removed. - `AGENTS.md` is updated to reflect the new architecture, replacing references to `CheckoutBridge` and its `SCHEMA_VERSION` contract with `EmbeddedCheckoutProtocol`. ### How to test 1. Build the library and confirm it compiles cleanly with no references to `CheckoutBridge` or the removed `errorevents`/`lifecycleevents` classes. 2. Run the existing test suite (`./gradlew :lib:test`) and confirm all remaining tests pass. 3. Run `CheckoutWebViewTest` and verify the JavaScript interface assertions now reference `EmbeddedCheckoutProtocol.INTERFACE_NAME`. 4. Open a checkout flow in the `MobileBuyIntegration` sample app and verify that checkout loads, completes, and surfaces errors correctly through `EmbeddedCheckoutProtocol`. 5. Verify the Java interop test (`InteropTest.java`) compiles and passes without the removed decoder tests. --- ### Before you merge > [!IMPORTANT] > > - [ ] I've added tests to support my implementation > - [ ] I have read and agree with the [Contribution Guidelines](./CONTRIBUTING.md) > - [ ] I have read and agree with the [Code of Conduct](./CODE_OF_CONDUCT.md) > - [ ] I've updated the relevant platform README (`platforms/swift/README.md` and/or `platforms/android/README.md`) --- <details> <summary>Releasing a new Swift version?</summary> - [ ] I have bumped the version in `ShopifyCheckoutKit.podspec` - [ ] I have bumped the version in `platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift` - [ ] I have updated `platforms/swift/CHANGELOG.md` - [ ] I have updated the SwiftPM/CocoaPods version snippets in `platforms/swift/README.md` (major version only) </details> <details> <summary>Releasing a new Android version?</summary> - [ ] I have bumped the `versionName` in `platforms/android/lib/build.gradle` - [ ] I have updated `platforms/android/CHANGELOG.md` - [ ] I have updated the Gradle/Maven version snippets in `platforms/android/README.md` </details> > [!TIP] > See the [Contributing documentation](./CONTRIBUTING.md) for the full release process per platform.
1 parent a1dac09 commit ec7bc62

18 files changed

Lines changed: 17 additions & 1683 deletions

platforms/android/AGENTS.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ The sample is a separate Gradle composite (`samples/MobileBuyIntegration/setting
1515

1616
## Where to make changes
1717

18-
- Library source: `lib/src/main/java/com/shopify/checkoutkit/`. Flat package at the top level with a few subpackages (`errorevents/`, `lifecycleevents/`).
18+
- Library source: `lib/src/main/java/com/shopify/checkoutkit/`. Flat package at the top level, including generated protocol models.
1919
- Library tests: `lib/src/test/java/com/shopify/checkoutkit/`. "No test, no merge" is a listed reject criterion in the repo-root `.github/CONTRIBUTING.md`.
2020
- Java interop is a first-class concern — the library is commonly consumed from Java code. `lib/src/test/java/com/shopify/checkoutkit/InteropTest.java` exercises the public API from Java specifically; treat breakage there as a consumer-facing issue.
2121

2222
## Key components
2323

2424
- **`ShopifyCheckoutKit.kt`** — the public singleton. Entry point for all consumer interactions (configure, present).
2525
- **`CheckoutDialog.kt`** — the dialog that hosts the WebView, including the progress indicator and checkout error coordination.
26-
- **`CheckoutWebView.kt`** — primary WebView. Instruments page loads; routes bridge messages.
27-
- **`BaseWebView.kt`** — abstract base class. Any new WebView variant must extend this so shared configuration (JS interface name, user agent suffix, client handling) is consistent.
28-
- **`CheckoutBridge.kt`** — the JS ↔ native bridge. `SCHEMA_VERSION` is a cross-boundary contract with the web checkout team; bumping it requires coordination with them.
26+
- **`CheckoutWebView.kt`** — primary WebView. Instruments page loads and attaches the ECP JavaScript interface.
27+
- **`BaseWebView.kt`** — abstract base class. Any new WebView variant must extend this so shared configuration (user agent suffix, WebChromeClient hooks, navigation error handling) is consistent.
28+
- **`EmbeddedCheckoutProtocol.kt`** — the Embedded Checkout Protocol JavaScript interface. Handles `ec.ready`, ECP notifications, and request/response delegations.
2929
- **`Configuration.kt`** — runtime config container (color scheme, log level).
3030
- **`CheckoutListener.kt`** + **`DefaultCheckoutListener`** — consumer-implemented lifecycle interface (failure, cancellation, permission prompts, file chooser). Changes here are consumer API changes.
3131
- **`CheckoutPresentation.kt`** — Kotlin-first builder for per-presentation callbacks (`onFail`, `onCancel`, browser/system hooks, ECP `connect(...)`). Builds a `DefaultCheckoutListener` internally.
@@ -93,5 +93,4 @@ Publishing goes through GitHub Releases → the repo-root `.github/workflows/and
9393

9494
- **Library Kotlin version pin.** Consumer compatibility floor; any migration is a deliberate major-version decision.
9595
- **`minSdk` / JVM target.** Same story.
96-
- **`CheckoutBridge.SCHEMA_VERSION`.** Cross-team contract with the web checkout — changing it without coordination breaks the bridge.
9796
- **`-Xexplicit-api=strict`.** Removing this would let implicit public declarations ship; keeping it is a consumer-protection invariant.

platforms/android/README.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -346,18 +346,9 @@ recreate the cart, retry later, or show an error state in the host app.
346346

347347
| Exception Class | Error Code | Description | Recommendation |
348348
| ------------------------------ | ------------------------------ | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
349-
| `ConfigurationException` | 'storefront_password_required' | Access to checkout is password protected. | We are working on ways to enable the Checkout Kit for usage with password protected stores. |
350-
| `ConfigurationException` | 'unknown' | Other configuration issue, see error details for more info. | Resolve the configuration issue in the error message. |
351349
| `CheckoutExpiredException` | 'cart_expired' | The cart or checkout is no longer available. | Create a new cart and open a new checkout URL. |
352-
| `CheckoutExpiredException` | 'cart_completed' | The cart associated with the checkout has completed checkout. | Create new cart and open a new checkout URL. |
353-
| `CheckoutExpiredException` | 'invalid_cart' | The cart associated with the checkout is invalid (e.g. empty). | Create a new cart and open a new checkout URL. |
354-
| `CheckoutKitException` | 'error_receiving_message' | Checkout Kit failed to receive a message from checkout. | Handle as a checkout failure in the host app. |
355-
| `CheckoutKitException` | 'error_sending_message' | Checkout Kit failed to send a message to checkout. | Handle as a checkout failure in the host app. |
356-
| `CheckoutKitException` | 'render_process_gone' | The render process for the checkout WebView is gone. | Handle as a checkout failure in the host app. |
357-
| `CheckoutKitException` | 'unknown' | An error in Checkout Kit has occurred, see error details for more info. | Handle as a checkout failure in the host app. |
350+
| `CheckoutKitException` | 'render_process_gone' | The render process for the checkout WebView is gone. | Handle as a checkout failure in the host app. |
358351
| `HttpException` | 'http_error' | An unexpected server error has been encountered. | Handle as a checkout failure in the host app. |
359-
| `ClientException` | 'client_error' | An unhandled client error was encountered. | Handle as a checkout failure in the host app. |
360-
| `CheckoutUnavailableException` | 'unknown' | Checkout is unavailable for another reason, see error details for more info. | Handle as a checkout failure in the host app. |
361352

362353
#### Exception Hierarchy
363354

@@ -366,32 +357,24 @@ recreate the cart, retry later, or show an error state in the host app.
366357
title: Checkout Kit Exception Hierarchy
367358
---
368359
classDiagram
369-
CheckoutException <|-- ConfigurationException
370360
CheckoutException <|-- CheckoutExpiredException
371361
CheckoutException <|-- CheckoutKitException
372362
CheckoutException <|-- CheckoutUnavailableException
373363
CheckoutUnavailableException <|-- HttpException
374-
CheckoutUnavailableException <|-- ClientException
375364

376365
<<Abstract>> CheckoutException
377366
CheckoutException : +String errorDescription
378367
CheckoutException : +String errorCode
379-
class ConfigurationException{
380-
note: "Store or checkout configuration issues."
381-
}
382368
class CheckoutExpiredException{
383-
note: "Expired or invalid carts/checkouts."
369+
note: "Expired checkouts."
384370
}
385371
class CheckoutUnavailableException{
386-
note: "Unexpected errors."
372+
note: "Base class for availability failures."
387373
}
388374
class HttpException{
389375
note: "Unexpected Http response"
390376
+int statusCode
391377
}
392-
class ClientException{
393-
note: "Unexpected client/web error"
394-
}
395378
class CheckoutKitException{
396379
note: "Error in Checkout Kit code"
397380
}

0 commit comments

Comments
 (0)