Skip to content

[Android] Rename CheckoutEventProcessor → CheckoutListener, drop stale callbacks#132

Merged
tiagocandido merged 2 commits into
mainfrom
05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks
May 19, 2026
Merged

[Android] Rename CheckoutEventProcessor → CheckoutListener, drop stale callbacks#132
tiagocandido merged 2 commits into
mainfrom
05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks

Conversation

@tiagocandido
Copy link
Copy Markdown
Contributor

@tiagocandido tiagocandido commented May 15, 2026

What changes are you making?

Renames CheckoutEventProcessorCheckoutListener on Android (with DefaultCheckoutEventProcessorDefaultCheckoutListener) and drops two methods now owned by the protocol layer:

  • onCheckoutCompleted → use CheckoutProtocol.complete
  • onCheckoutLinkClicked → use CheckoutCommunicationClient.openExternalUrl(...)

Removes the legacy code paths that fed those callbacks: the COMPLETED case in CheckoutBridge and the legacy intent-launching defaults on DefaultCheckoutEventProcessor. CheckoutWebView's shouldOverrideUrlLoading override stays — it's still the only path that catches mailto:/tel: clicks, which checkout-web deliberately doesn't route through window.open (see checkoutProtocolLinkInterceptor.ts:18).

One behavior tweak to keep parity with the previous Android implementation: the ec.complete handler now invalidates the preload cache (was done by the old onCheckoutViewComplete path).

Internal field/class names follow the rename for consistency (CheckoutWebViewEventProcessorCheckoutWebViewListener, eventProcessorlistener throughout). README and lib/api/lib.api are updated.

Note: The React Native Android wrapper extends DefaultCheckoutEventProcessor and overrides onCheckoutCompleted — it will need a follow-up PR to rename the extends clause and route completion through CheckoutProtocol.complete.

How to test

  • ./gradlew :lib:test :lib:apiCheck :lib:detekt :lib:lintRelease
  • Build the MobileBuyIntegration sample and complete a checkout end-to-end; confirm the CheckoutProtocol.complete handler in CartViewModel fires (clears cart and pops back to the product screen)

Before you merge

Important

  • I've added tests to support my implementation
  • I have read and agree with the Contribution Guidelines
  • I have read and agree with the Code of Conduct
  • I've updated the relevant platform README (`platforms/swift/README.md` and/or `platforms/android/README.md`)

Copy link
Copy Markdown
Contributor Author

tiagocandido commented May 15, 2026

@tiagocandido tiagocandido force-pushed the 05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks branch from 89c10c1 to d4da055 Compare May 15, 2026 14:50
@tiagocandido tiagocandido force-pushed the 05-15-restore_checkoutdelegate_with_trimmed_lifecycle_api branch from d27977c to 7dceb15 Compare May 15, 2026 14:50
@tiagocandido tiagocandido added the #gsd:50662 Rebase Checkout Kit on UCP label May 15, 2026 — with Graphite App
@tiagocandido tiagocandido force-pushed the 05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks branch 2 times, most recently from 8b0659f to 8afa420 Compare May 15, 2026 16:07
@tiagocandido tiagocandido force-pushed the 05-15-restore_checkoutdelegate_with_trimmed_lifecycle_api branch from 7dceb15 to 86ecd8b Compare May 15, 2026 16:07
@tiagocandido tiagocandido force-pushed the 05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks branch from 8afa420 to 14a4aac Compare May 15, 2026 16:10
@tiagocandido tiagocandido marked this pull request as ready for review May 15, 2026 16:15
@tiagocandido tiagocandido requested a review from a team as a code owner May 15, 2026 16:15
@tiagocandido tiagocandido force-pushed the 05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks branch from 14a4aac to 57bb1fe Compare May 15, 2026 16:46
@tiagocandido tiagocandido force-pushed the 05-15-restore_checkoutdelegate_with_trimmed_lifecycle_api branch from 86ecd8b to 9aa6c02 Compare May 15, 2026 16:46
@tiagocandido tiagocandido force-pushed the 05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks branch from 57bb1fe to ffb59f3 Compare May 18, 2026 09:42
@tiagocandido tiagocandido force-pushed the 05-15-restore_checkoutdelegate_with_trimmed_lifecycle_api branch from 9aa6c02 to b4e5670 Compare May 18, 2026 09:42
Comment on lines +84 to +91
private fun syntheticCompleteMessage(orderId: String?): String {
val orderJson = orderId?.let { ""","order":{"id":"$it"}""" } ?: ""
return """
|{"jsonrpc":"2.0","method":"${EmbeddedCheckoutProtocol.METHOD_COMPLETE}",
|"params":{"id":"${orderId ?: ""}","currency":"","line_items":[],"links":[],
|"status":"completed","totals":[],
|"ucp":{"version":"${CheckoutProtocol.specVersion}","status":"success"}$orderJson}}
""".trimMargin().replace("\n", "")
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.

Fallback completion never reaches CheckoutProtocol.complete. FallbackWebView.kt synthesizes ec.complete with checkout fields directly under params, but CheckoutProtocol.kt only decodes params.checkout.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Moved the construction into CheckoutProtocol.encodeRecoveryCompleteNotification(orderId:) so it nests under params.checkout. Added a round-trip test so a future hand-rolled payload can't regress this — handler now fires in the recovery confirmation path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Update: pulled this back out — Kieran flagged in his Swift review that we shouldn't be adding new recovery code in this PR. Synthesis call and the protocol helper are both gone now. Full recovery removal is the next PR.

Copy link
Copy Markdown
Contributor

React Native Android still references the removed API. CustomCheckoutEventProcessor.java still extends DefaultCheckoutEventProcessor, and line 124 still overrides onCheckoutCompleted, both removed by this PR.

Comment thread platforms/android/README.md Outdated

> [!Note]
> The `DefaultCheckoutEventProcessor` provides default implementations for current and future callback functions (such as `onLinkClicked()`), which can be overridden by clients wanting to change default behavior.
> The `DefaultCheckoutListener` provides default implementations for the OS-level prompt callbacks, which can be overridden by clients wanting to change default behavior. Checkout completion and external link clicks are delivered through the Embedded Checkout Protocol client instead — register a handler on `CheckoutProtocol.complete` and implement `CheckoutCommunicationClient.openExternalUrl(...)`, then pass the client as the 4th argument of `ShopifyCheckoutKit.present(...)`.
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.

The README tells consumers to implement CheckoutCommunicationClient.openExternalUrl(...) at README.md, but CheckoutCommunicationClient.kt only exposes process(message), and ec.window.open_request is handled internally at EmbeddedCheckoutProtocol.kt.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, that was wrong — interface only exposes process(message). Dropped the line and clarified ec.window.open_request is kit-internal. Only CheckoutProtocol.complete registration stays on the consumer.

Copy link
Copy Markdown
Contributor

@josemiguel-alvarez josemiguel-alvarez left a comment

Choose a reason for hiding this comment

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

There are some references to the removed code that should be updated.

}

private fun getOrderIdFromQueryString(uri: Uri): String? = uri.getQueryParameter("order_id")
private fun syntheticCompleteMessage(orderId: String?): String {
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.

Similar question from swift side too, I was thinking these are handled by the protocol stuff @kieran-osgood-shopify setup so hopefully dont need to be manually constructed, but let me know if complete has something unique about it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, you're right. Pushed it down — Android has CheckoutProtocol.encodeRecoveryCompleteNotification(orderId:), Swift has the same in CheckoutProtocol+Recovery.swift. Fallback paths just call into it, no hand-rolled JSON on either side. Nothing unique about complete, the manual one was just buggy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted — see Jose's thread above. Helper and synthesis call are both out now, full recovery removal lands next.

@tiagocandido tiagocandido force-pushed the 05-15-restore_checkoutdelegate_with_trimmed_lifecycle_api branch from b4e5670 to b578111 Compare May 18, 2026 15:51
@tiagocandido tiagocandido force-pushed the 05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks branch 2 times, most recently from 114f122 to bcf828a Compare May 18, 2026 17:06
*/
public abstract class DefaultCheckoutEventProcessor : CheckoutEventProcessor {
public abstract class DefaultCheckoutListener @JvmOverloads constructor(
@Suppress("UnusedPrivateProperty") private val context: Context,
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.

maybe I'm mixing things up, but I think we said we could just remove these params rather than suppress?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, dropped both. Context and LogWrapper are gone from the constructor — subclasses pass through if they need them. apiDump regenerated to match.

log.d(LOG_TAG, "Finished page has confirmationUrl. Emitting minimal checkout completed event.")
getEventProcessor().onCheckoutViewComplete(
emptyCompletedEvent(id = getOrderIdFromQueryString(uri))
log.d(LOG_TAG, "Confirmation page reached in fallback; synthesizing ec.complete with partial data.")
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.

Are we supporting recovery in V1?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question — Kieran flagged the same thing on the Swift PR. We're not shipping recovery in v1. For this PR I pulled the new synthesis additions back out so we're not growing the surface we're about to delete. Full recovery removal lands as the next PR on the stack.

@tiagocandido tiagocandido force-pushed the 05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks branch 3 times, most recently from b93b925 to ba15a01 Compare May 19, 2026 11:09
@tiagocandido tiagocandido force-pushed the 05-15-restore_checkoutdelegate_with_trimmed_lifecycle_api branch from b578111 to dfa64f0 Compare May 19, 2026 11:09
@tiagocandido
Copy link
Copy Markdown
Contributor Author

Tracked for the RN follow-up PR — needs the rename plus the zero-arg DefaultCheckoutListener() super call. Not in tree here.

@tiagocandido tiagocandido changed the base branch from 05-15-restore_checkoutdelegate_with_trimmed_lifecycle_api to graphite-base/132 May 19, 2026 12:47
@tiagocandido tiagocandido force-pushed the 05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks branch from ba15a01 to 3d6f9c6 Compare May 19, 2026 12:51
@tiagocandido tiagocandido changed the base branch from graphite-base/132 to 05-15-restore_checkoutdelegate_with_trimmed_lifecycle_api May 19, 2026 12:51
Comment thread platforms/android/lib/api/lib.api Outdated
Comment on lines +755 to +766
public final fun onGeolocationPermissionsShowPrompt (Lkotlin/jvm/functions/Function2;)V
public final fun onPermissionRequest (Lkotlin/jvm/functions/Function1;)V
public final fun onShowFileChooser (Lkotlin/jvm/functions/Function3;)V
=======
public abstract interface class com/shopify/checkoutkit/CheckoutListener {
public abstract fun onCheckoutCanceled ()V
public abstract fun onCheckoutFailed (Lcom/shopify/checkoutkit/CheckoutException;)V
public abstract fun onGeolocationPermissionsHidePrompt ()V
public abstract fun onGeolocationPermissionsShowPrompt (Ljava/lang/String;Landroid/webkit/GeolocationPermissions$Callback;)V
public abstract fun onPermissionRequest (Landroid/webkit/PermissionRequest;)V
public abstract fun onShowFileChooser (Landroid/webkit/WebView;Landroid/webkit/ValueCallback;Landroid/webkit/WebChromeClient$FileChooserParams;)Z
>>>>>>> ba15a01 ([Android] Rename CheckoutEventProcessor → CheckoutListener, drop stale callbacks)
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.

[Re: lines +749 to +766]

There are still conflict markers here.

See this comment inline on Graphite.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, pushed too soon, fixing them

@tiagocandido tiagocandido force-pushed the 05-15-restore_checkoutdelegate_with_trimmed_lifecycle_api branch from 4037fe6 to 623b169 Compare May 19, 2026 14:02
@tiagocandido tiagocandido force-pushed the 05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks branch from 3d6f9c6 to 035d5a7 Compare May 19, 2026 14:02
Copy link
Copy Markdown
Contributor

@josemiguel-alvarez josemiguel-alvarez left a comment

Choose a reason for hiding this comment

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

React Native Android still references the removed Android API. CustomCheckoutEventProcessor.java still extends DefaultCheckoutEventProcessor, and it still overrides onCheckoutCompleted.

Copy link
Copy Markdown
Contributor

@josemiguel-alvarez josemiguel-alvarez left a comment

Choose a reason for hiding this comment

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

Just saw that there's a follow-up for the React Native stale code.

There are some conflicts markers that should be removed. Everything else looks good to me!

@tiagocandido tiagocandido force-pushed the 05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks branch from 035d5a7 to 1951caf Compare May 19, 2026 14:14
@tiagocandido tiagocandido force-pushed the 05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks branch from 1951caf to c24c019 Compare May 19, 2026 14:29
@tiagocandido tiagocandido force-pushed the 05-15-restore_checkoutdelegate_with_trimmed_lifecycle_api branch from 623b169 to 70531ba Compare May 19, 2026 14:29
Base automatically changed from 05-15-restore_checkoutdelegate_with_trimmed_lifecycle_api to main May 19, 2026 14:38
@tiagocandido tiagocandido merged commit 4a2c909 into main May 19, 2026
33 of 35 checks passed
@tiagocandido tiagocandido deleted the 05-15-_android_rename_checkouteventprocessor_checkoutlistener_drop_stale_callbacks branch May 19, 2026 14:40
kieran-osgood-shopify added a commit that referenced this pull request May 19, 2026
)

### What changes are you making?

react native android CI was failing after #132  merged because it didn't run CI for react-native
This PR renames the android portion to match the new naming of the event processor
<img width="847" height="556" alt="image" src="https://github.com/user-attachments/assets/b3366989-2b9d-4bf6-a67d-496fea4561a0" />


### How to test

<!-- Please outline the steps to test your changes -->

---

### 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

#gsd:50662 Rebase Checkout Kit on UCP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants