Skip to content

[Swift] Restore CheckoutDelegate with trimmed lifecycle API#131

Open
tiagocandido wants to merge 1 commit into
kieran-osgood/05-14-featremovecheckoutlifecyclefromreact-nativefrom
05-15-restore_checkoutdelegate_with_trimmed_lifecycle_api
Open

[Swift] Restore CheckoutDelegate with trimmed lifecycle API#131
tiagocandido wants to merge 1 commit into
kieran-osgood/05-14-featremovecheckoutlifecyclefromreact-nativefrom
05-15-restore_checkoutdelegate_with_trimmed_lifecycle_api

Conversation

@tiagocandido
Copy link
Copy Markdown
Contributor

@tiagocandido tiagocandido commented May 15, 2026

What changes are you making?

Restores the CheckoutDelegate protocol on iOS for host-level lifecycle callbacks, trimmed to:

  • checkoutDidCancel()
  • checkoutDidFail(error:)

CheckoutDelegate covers lifecycle outcomes the host app needs to react to (cancel, fail). Completion and link clicks are delivered through the protocol client (CheckoutProtocol.complete, ec.window.open_request), so they're not part of this surface. Recovery is decided internally using CheckoutError.isRecoverable, and checkoutDidFail(error:) only fires once the SDK has given up recovering — not on each intermediate failure.

UIKit consumers can now observe cancel/fail by passing a delegate to ShopifyCheckoutKit.present(checkout:from:delegate:client:). SwiftUI still uses .onCancel/.onFail; there's no .delegate(_:) modifier — SwiftUI structs can't hold a weak delegate reliably across recreations.

Two related fixes ride along: the library now ships CheckoutProtocol.Client: CheckoutCommunicationProtocol so consumers don't need a retroactive extension to wire a client into present(...), and the iOS recovery webview forwards a partial ec.complete to the client on the confirmation page — parity with Android FallbackWebView, making the README claim about partial completion during recovery actually true.

How to test

  • Build the sample app, present checkout, verify the delegate fires on cancel and on an induced failure

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

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@tiagocandido tiagocandido changed the title Restore CheckoutDelegate with trimmed lifecycle API [Swift] Restore CheckoutDelegate with trimmed lifecycle API May 15, 2026
@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-restore_checkoutdelegate_with_trimmed_lifecycle_api branch from 7dceb15 to 86ecd8b Compare May 15, 2026 16:07
@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-restore_checkoutdelegate_with_trimmed_lifecycle_api branch from 86ecd8b to 9aa6c02 Compare May 15, 2026 16:46
static func syntheticCompleteMessage(orderId: String?) -> String {
let id = orderId ?? ""
let orderJson = orderId.map { ",\"order\":{\"id\":\"\($0)\"}" } ?? ""
return "{\"jsonrpc\":\"2.0\",\"method\":\"ec.complete\","
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 think with ready we wrapped it up in the protocol lib - seems like this json could be moved over there

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.

2 participants