[Swift] Restore CheckoutDelegate with trimmed lifecycle API#131
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
d27977c to
7dceb15
Compare
7dceb15 to
86ecd8b
Compare
86ecd8b to
9aa6c02
Compare
ca7804f to
401beb2
Compare
9aa6c02 to
b4e5670
Compare
| } | ||
| } | ||
| ``` | ||
| External links opened from within checkout (HTTPS, deep links, `mailto:`, `tel:`) are forwarded to `UIApplication.shared.open(_:)` by the kit, so universal links and Offsite Payments redirects route back to your app automatically once the rest of the universal-links setup is in place. |
There was a problem hiding this comment.
We will likely need to test this a bit more I just wanted to note that for our tracking
There was a problem hiding this comment.
Acked — agreed the universal-links / offsite payments path still needs end-to-end coverage. Tracking that separately, not in this PR.
| let id = orderId ?? "" | ||
| let orderJson = orderId.map { ",\"order\":{\"id\":\"\($0)\"}" } ?? "" | ||
| return "{\"jsonrpc\":\"2.0\",\"method\":\"ec.complete\"," | ||
| + "\"params\":{\"id\":\"\(id)\",\"currency\":\"\",\"line_items\":[],\"links\":[]," |
There was a problem hiding this comment.
CheckoutWebView.swift builds the synthetic ec.complete as params: { id, currency, ... }, but the Swift protocol decoder only dispatches checkout notifications when the payload is nested at params.checkout (Codec.swift). As written, client.process(message) decodes this as .unknown, so .on(CheckoutProtocol.complete) handlers never fire in the recovery confirmation path.
There was a problem hiding this comment.
Good catch — that was the actual bug, decoder was hitting .unknown and dropping completion in recovery. Construction now lives in CheckoutProtocol.encodeRecoveryCompleteNotification(orderId:) which nests under params.checkout. Added round-trip tests on both encode and dispatch.
There was a problem hiding this comment.
Update: helper is gone, your params.checkout catch is now moot for this PR. Keeping the note for when synthesis comes back properly — the bug would have shipped without it.
b4e5670 to
b578111
Compare
kieran-osgood-shopify
left a comment
There was a problem hiding this comment.
The delegate changes look good for cancel and fail
I think the recovery mode changes can be trimmed back at this point?
b578111 to
dfa64f0
Compare
dfa64f0 to
4037fe6
Compare
|
|
||
| 1. The checkout experience may look different to buyers. Though the kit will attempt to load any checkout customizations for the storefront, there is no guarantee they will show in recovery mode. | ||
| 2. The `checkoutDidComplete(event:)` will be emitted with partial data. Invocations will only receive the order ID via `event.orderDetails.id`. | ||
| 2. Completion events delivered via `CheckoutProtocol.complete` during recovery may contain partial data — typically only the order ID. |
There was a problem hiding this comment.
Recovery completion events are not emitted. This should be updated.
4037fe6 to
623b169
Compare
623b169 to
70531ba
Compare

What changes are you making?
Restores the
CheckoutDelegateprotocol on iOS for host-level lifecycle callbacks, trimmed to:checkoutDidCancel()checkoutDidFail(error:)CheckoutDelegatecovers 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 usingCheckoutError.isRecoverable, andcheckoutDidFail(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.How to test
Before you merge
Important