Skip to content

Protocol-agnostic checkout events for Swift - #748

Open
markmur wants to merge 23 commits into
namespace-swift-protocol-checkoutfrom
prototype/protocol-agnostic-events
Open

markmur wants to merge 23 commits into
namespace-swift-protocol-checkoutfrom
prototype/protocol-agnostic-events

Conversation

@markmur

@markmur markmur commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Stack

Top to bottom:

  1. Web: Add protocol-agnostic checkout events for web #766
  2. Android: Add protocol-agnostic checkout events for Android #767
  3. Swift events (this PR): Protocol-agnostic checkout events for Swift #748
  4. Swift protocol namespace: Namespace Swift protocol payloads #777

Summary

  • adds a Kit-owned top-level Checkout that preserves every checkout snapshot field except the protocol-only ucp field
  • reuses generated Embedded Checkout Protocol domain types directly instead of duplicating them or publishing Kit-prefixed type aliases
  • preserves unknown top-level extension fields in additionalProperties; generated nested models retain their own extension fields
  • translates ECP start, supported change, and complete notifications through an internal adapter with equal-snapshot deduplication
  • exposes concrete CheckoutStartEvent, CheckoutUpdateEvent, CheckoutCompleteEvent, and CheckoutFailureEvent payloads through idiomatic SwiftUI modifiers and UIKit delegate callbacks
  • keeps lineItems as a plain array without derived inventory annotations
  • maps delegated window-open requests to onLinkClick in SwiftUI and checkoutAction(for:) in UIKit, with .open, .handled, and .cancel policies
  • removes public protocol-client injection and the Accelerated Checkouts .connect(client) modifier, and updates the sample to use Kit callbacks
  • decodes RFC 3339 dates, including fractional seconds, so shipping-method updates reach onUpdate

Design notes

Checkout is a thin top-level projection of the protocol checkout snapshot. It removes only ucp; attribution, buyer, context, continuation URL, currency, discounts, expiry, fulfillment, ID, line items, links, messages, order, payment, signals, status, totals, and unknown extension fields remain intact. Optional values remain optional, arrays are not synthesized for absent values, and enum values are not coerced to defaults.

The protocol client remains behind the web bridge. The currently supported ECP checkout change notifications—line items, messages, totals, and fulfillment—become the same public CheckoutUpdateEvent. Buyer and payment change notifications are intentionally not registered because Checkout Kit does not support those update sources yet. Registration syntax stays native to SwiftUI and UIKit.

Separate event payload types give each callback room to gain event-specific metadata later without changing the closure or delegate shape. The public checkout snapshot does not infer inventory state from protocol messages.

Window-open requests are similarly abstracted: consumers receive only a validated URL and return a Kit-owned action. .open preserves the default Safari/system behavior, .handled reports success without opening the URL again, and .cancel rejects the request. The default is .open.

The protocol namespace and API comparison ordering fix are supplied by #777.

Validation passed: CocoaPods lint, Swift formatting and lint, 71 Swift protocol tests, 8 checkout adapter tests, and all three public Swift API baseline checks.

@github-actions github-actions Bot added the #gsd:50662 Rebase Checkout Kit on UCP label Sep 8, 2026
@markmur markmur changed the title Prototype protocol-agnostic checkout events for Swift Protocol-agnostic checkout events for Swift Sep 14, 2026
@markmur markmur self-assigned this Sep 14, 2026
@markmur
markmur marked this pull request as ready for review September 14, 2026 13:41
@markmur
markmur requested a review from a team as a code owner September 14, 2026 13:41
@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown

React Native — Coverage Report

Lines Statements Branches Functions
Coverage: 91%
90.97% (363/399) 87.29% (213/244) 100% (92/92)

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown

Web — Coverage Report

Lines Statements Branches Functions
Coverage: 96%
94.46% (290/307) 81.11% (146/180) 98.73% (78/79)

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown

Package Size

Platform Artifact Base Head Delta
Web npm tarball 80.1 KiB 80.1 KiB 0 B
React Native npm tarball 108.6 KiB 108.6 KiB 0 B
Android release AAR 366.6 KiB 366.6 KiB 0 B
Web file breakdown
File Base Head Delta
dist/index.js.map 217.7 KiB 217.7 KiB 0 B
dist/custom-elements.json 51.4 KiB 51.4 KiB 0 B
dist/index.d.ts 45.9 KiB 45.9 KiB 0 B
dist/index.js 39.5 KiB 39.5 KiB 0 B
README.md 20.0 KiB 20.0 KiB 0 B
package.json 2.9 KiB 2.9 KiB 0 B
LICENSE 1.1 KiB 1.1 KiB 0 B
React Native file breakdown
File Base Head Delta
node_modules/@shopify/checkout-kit-protocol/src/generated/Models.ts 85.4 KiB 85.4 KiB 0 B
node_modules/@shopify/checkout-kit-protocol/src/generated/Models.d.ts 53.0 KiB 53.0 KiB 0 B
android/src/main/java/com/shopify/reactnative/checkoutkit/ShopifyCheckoutKitModule.java 16.2 KiB 16.2 KiB 0 B
ios/ShopifyCheckoutKit.swift 16.1 KiB 16.1 KiB 0 B
ios/AcceleratedCheckoutButtons.swift 14.1 KiB 14.1 KiB 0 B
src/components/AcceleratedCheckoutButtons.tsx 13.0 KiB 13.0 KiB 0 B
src/index.ts 12.7 KiB 12.7 KiB 0 B
lib/commonjs/index.js 12.4 KiB 12.4 KiB 0 B
lib/commonjs/components/AcceleratedCheckoutButtons.js 11.4 KiB 11.4 KiB 0 B
src/index.d.ts 11.3 KiB 11.3 KiB 0 B
lib/commonjs/components/AcceleratedCheckoutButtons.js.map 10.4 KiB 10.4 KiB 0 B
lib/module/index.js 10.4 KiB 10.4 KiB 0 B
lib/module/components/AcceleratedCheckoutButtons.js 10.2 KiB 10.2 KiB 0 B
node_modules/@shopify/checkout-kit-protocol/src/generated/ProtocolNotifications.ts 9.5 KiB 9.5 KiB 0 B
lib/module/components/AcceleratedCheckoutButtons.js.map 9.1 KiB 9.1 KiB 0 B
lib/module/index.js.map 8.1 KiB 8.1 KiB 0 B
src/present-dispatcher.ts 8.0 KiB 8.0 KiB 0 B
lib/commonjs/index.js.map 7.9 KiB 7.9 KiB 0 B
node_modules/@shopify/checkout-kit-protocol/src/generated/ProtocolNotifications.d.ts 7.6 KiB 7.6 KiB 0 B
node_modules/@shopify/checkout-kit-protocol/src/generated/ProtocolRenameMap.ts 7.2 KiB 7.2 KiB 0 B
…and 117 smaller files
Android file breakdown
File Base Head Delta
classes.jar 390.5 KiB 390.5 KiB 0 B
res/layout/checkout_view_content.xml 2.6 KiB 2.6 KiB 0 B
res/layout/checkout_sheet_content.xml 2.0 KiB 2.0 KiB 0 B
res/values/values.xml 1.3 KiB 1.3 KiB 0 B
R.txt 1.2 KiB 1.2 KiB 0 B
AndroidManifest.xml 922 B 922 B 0 B
proguard.txt 798 B 798 B 0 B
res/drawable/close.xml 431 B 431 B 0 B
res/menu/checkout_menu.xml 354 B 354 B 0 B
META-INF/com/android/build/gradle/aar-metadata.properties 157 B 157 B 0 B

Measured from the PR base SHA and PR head SHA. The file breakdown shows uncompressed sizes within each package artifact, so individual files do not sum to the compressed artifact total. This comment reports package artifact sizes only; it is not a final app binary-size report.

@bitrise

bitrise Bot commented Sep 14, 2026

Copy link
Copy Markdown

Install this build

Open Tophat, select your target device, then click Install. Links open on the Mac running Tophat.

SDK Install
React Native Install with Tophat
Swift Install with Tophat
Kotlin Install with Tophat

Checkout Kit E2E results

Status Tags Target Platform OS version tag Device
launch, checkout-presentation, checkout-completion, buyer-identity react-native ios latest iPhone 15
iOS 27 Beta
launch, checkout-presentation, checkout-completion, buyer-identity react-native android latest Google Pixel 9
Android 17.0
launch, checkout-presentation, checkout-completion, buyer-identity, preload kotlin android latest Google Pixel 9
Android 17.0
launch, checkout-presentation, checkout-completion, buyer-identity, preload swift ios latest iPhone 15
iOS 27 Beta

Failures

Caution

If you believe an assertion is flaky, please raise a ticket in the #checkout-kit-devs channel so it can be addressed.

BrowserStack artifacts require BrowserStack access. Sign in to BrowserStack App Automate before opening artifact links.

iOS — react-native

Test Status Artifacts
./tests/shared/checkout-guest BrowserStack · Video · Screenshot · Maestro commands · Maestro log

iOS — swift

Test Status Artifacts
./tests/shared/checkout-hardcoded-buyer-identity BrowserStack · Video · Screenshot · Maestro commands · Maestro log
./tests/shared/checkout-guest BrowserStack · Video · Screenshot · Maestro commands · Maestro log

@markmur
markmur force-pushed the prototype/protocol-agnostic-events branch from 9a1a1a7 to 67f6e15 Compare September 14, 2026 17:03
@markmur
markmur changed the base branch from main to namespace-swift-protocol-checkout September 14, 2026 17:03
@markmur
markmur force-pushed the prototype/protocol-agnostic-events branch 3 times, most recently from 47abfe1 to 8e3dbfb Compare September 15, 2026 13:19

@tiagocandido tiagocandido left a comment

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.

Two README issues I could not attach inline (the lines are outside the diff):

  • Line ~351: the Checkout lifecycle section still teaches CheckoutProtocol.Client + present(client:) + .connect, all removed in this PR. Needs a rewrite around the delegate methods and onStart/onUpdate/onComplete.
  • Line ~123: still the old checkoutDidFail(error:) spelling — here and at ~305, 319, 368, 411, 422. With the new default no-op, copying this compiles but never receives failures.

Comment thread platforms/swift/Sources/ShopifyCheckoutKit/CheckoutDelegate.swift Outdated
@markmur
markmur force-pushed the namespace-swift-protocol-checkout branch from 52fc225 to 3537557 Compare September 16, 2026 12:11
@markmur
markmur force-pushed the prototype/protocol-agnostic-events branch from 8e3dbfb to 0775be4 Compare September 16, 2026 12:11
@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown

Protocol — Coverage Report

Lines Statements Branches Functions
Coverage: 94%
93.58% (146/156) 87.75% (86/98) 90% (27/30)

@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown

Web — Coverage Report

Lines Statements Branches Functions
Coverage: 96%
94.47% (342/362) 81.77% (166/203) 96.84% (92/95)

@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown

React Native — Coverage Report

Lines Statements Branches Functions
Coverage: 91%
90.97% (363/399) 87.29% (213/244) 100% (92/92)

@markmur
markmur force-pushed the namespace-swift-protocol-checkout branch from 3537557 to c68b132 Compare September 17, 2026 11:04
@markmur
markmur force-pushed the prototype/protocol-agnostic-events branch from 5a48d81 to 0f3715c Compare September 18, 2026 09:12
@markmur
markmur force-pushed the namespace-swift-protocol-checkout branch from c68b132 to 7f40b94 Compare September 18, 2026 10:09
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