-
Notifications
You must be signed in to change notification settings - Fork 1
Wire Swift kit for UCP events #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
5f6abd9
Move ec param decoration to kit
markmur 462ad41
Update CheckoutProtocol to remove delegations
markmur 8ca0983
Update UA + create shared client
markmur 93d9fb0
Bump to 2026-04-08
markmur 76f741d
Update CI to run swift protocol tests
markmur 56e7243
Regenerate models + wire new events
markmur d3855c5
Bundle protocol with cocoapod
markmur abaad82
Move protocol Sources under platforms/swift, fix Binding rename
markmur 9592a2d
Flip protocol Sources canonical location to protocol/
markmur 44edbc4
Remove CheckoutProtocol.paymentChange
markmur 6220616
Remove redundant debug logs
markmur 5c4ef0d
Remove payment change
markmur 1c7b919
Update UA tests
markmur 3189011
Move protocol from protocol dir to swift sources
markmur effab32
Fix MobileBuyIntegration package refs after protocol move
markmur 9b6a2aa
Restore @_spi(Execution) @_spi(Unsafe) ApolloAPI import to generated …
markmur 2530dbb
add missing Sendable types
markmur 3241a78
Clean up project.pbxproj
markmur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...ft/Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/CheckoutProtocolClient.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| MIT License | ||
|
|
||
| Copyright 2023 - Present, Shopify Inc. | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| */ | ||
|
|
||
| import ShopifyCheckoutProtocol | ||
|
|
||
| enum CheckoutProtocolClient { | ||
| static let shared = CheckoutProtocol.Client() | ||
| .on(CheckoutProtocol.start) { checkout in | ||
| print("[UCP] ec.start: \(checkout.id)") | ||
| } | ||
| .on(CheckoutProtocol.complete) { checkout in | ||
| print("[UCP] ec.complete: \(checkout.order?.id ?? "unknown")") | ||
| CartManager.shared.resetCart() | ||
| } | ||
| .on(CheckoutProtocol.buyerChange) { checkout in | ||
| print("[UCP] ec.buyer.change: \(checkout.id)") | ||
| } | ||
| .on(CheckoutProtocol.lineItemsChange) { checkout in | ||
| print("[UCP] ec.line_items.change: \(checkout.id)") | ||
| } | ||
| .on(CheckoutProtocol.messagesChange) { checkout in | ||
| print("[UCP] ec.messages.change: \(checkout.id)") | ||
| } | ||
| .on(CheckoutProtocol.totalsChange) { checkout in | ||
| print("[UCP] ec.totals.change: \(checkout.id)") | ||
| } | ||
| .on(CheckoutProtocol.error) { error in | ||
| print("[UCP] ec.error: \(error.messages.first?.content ?? "(no message)")") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Ref Line 103) Worth checking:
sendResponsenow interpolates the encoded JSON-RPC payload directly into JavaScript, sowindow.EmbeddedCheckoutProtocol.postMessage(...)receives an object literal instead of the response string. Could this break things? Is ite better to escape the encoded JSON and callwindow.EmbeddedCheckoutProtocol.postMessage('...')so checkout receives a JSON-RPC string, not a JS object.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to look into this in a follow up 👍