{"action":"created","comment":{"url":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls/comments/125462863","pull_request_review_id":47853777,"id":125462863,"diff_hunk":"@@ -0,0 +1,128 @@\n+//\n+//  WebCheckoutSession.swift\n+//  UnityBuySDK\n+//\n+//  Created by Shopify.\n+//  Copyright © 2017 Shopify Inc. All rights reserved.\n+//\n+//  Permission is hereby granted, free of charge, to any person obtaining a copy\n+//  of this software and associated documentation files (the \"Software\"), to deal\n+//  in the Software without restriction, including without limitation the rights\n+//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+//  copies of the Software, and to permit persons to whom the Software is\n+//  furnished to do so, subject to the following conditions:\n+//\n+//  The above copyright notice and this permission notice shall be included in\n+//  all copies or substantial portions of the Software.\n+//\n+//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+//  THE SOFTWARE.\n+//\n+\n+import Foundation\n+import WebKit\n+\n+private var activeWebPaySession: WebCheckoutSession?\n+\n+protocol WebCheckoutDelegate: class {\n+    func didLoadThankYouPage()\n+    func willDismiss(completionHandler: UnityMessage.MessageCompletion?)\n+}\n+\n+@objc class WebCheckoutSession: NSObject {\n+    static func createSession(unityDelegateObjectName: String, url: String) -> WebCheckoutSession {\n+        let session = WebCheckoutSession(unityDelegateObjectName: unityDelegateObjectName,\n+                                         checkoutURL: url)\n+        activeWebPaySession = session\n+        return session;\n+    }\n+    \n+    fileprivate var webViewController: Checkout.WebViewController!\n+    fileprivate var overlay: UIView?\n+    \n+    private let checkoutURL: String\n+    private let overlayAnimationDuration: TimeInterval = 0.4\n+    fileprivate let unityDelegateObjectName: String\n+    \n+    init(unityDelegateObjectName: String, checkoutURL: String) {\n+        self.unityDelegateObjectName = unityDelegateObjectName\n+        self.checkoutURL = checkoutURL\n+        self.overlay = {\n+            let view = UIView(frame: UIScreen.main.bounds)\n+            view.autoresizingMask = [.flexibleHeight, .flexibleWidth]\n+            view.backgroundColor = .black\n+            view.alpha = 0\n+            return view\n+        }()\n+        \n+        super.init()\n+    }\n+    \n+    func startCheckout() -> Bool {\n+        let root = UnityAppController.root\n+        guard let url = URL(string: checkoutURL) else {\n+            return false;","path":"Assets/Plugins/iOS/Shopify/WebCheckoutSession.swift","position":69,"original_position":69,"commit_id":"18aa52f495bb0cd174837744708f11a37284e16e","original_commit_id":"18aa52f495bb0cd174837744708f11a37284e16e","user":{"login":"dbart01","id":5244861,"avatar_url":"https://avatars3.githubusercontent.com/u/5244861?v=3","gravatar_id":"","url":"https://api.github.com/users/dbart01","html_url":"https://github.com/dbart01","followers_url":"https://api.github.com/users/dbart01/followers","following_url":"https://api.github.com/users/dbart01/following{/other_user}","gists_url":"https://api.github.com/users/dbart01/gists{/gist_id}","starred_url":"https://api.github.com/users/dbart01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbart01/subscriptions","organizations_url":"https://api.github.com/users/dbart01/orgs","repos_url":"https://api.github.com/users/dbart01/repos","events_url":"https://api.github.com/users/dbart01/events{/privacy}","received_events_url":"https://api.github.com/users/dbart01/received_events","type":"User","site_admin":false},"body":"`;` 🔥 ","created_at":"2017-07-04T12:38:06Z","updated_at":"2017-07-04T12:38:06Z","html_url":"https://github.com/Shopify/unity-buy-sdk/pull/120#discussion_r125462863","pull_request_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls/120","_links":{"self":{"href":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls/comments/125462863"},"html":{"href":"https://github.com/Shopify/unity-buy-sdk/pull/120#discussion_r125462863"},"pull_request":{"href":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls/120"}}},"pull_request":{"url":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls/120","id":127561306,"html_url":"https://github.com/Shopify/unity-buy-sdk/pull/120","diff_url":"https://github.com/Shopify/unity-buy-sdk/pull/120.diff","patch_url":"https://github.com/Shopify/unity-buy-sdk/pull/120.patch","issue_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/issues/120","number":120,"state":"open","locked":false,"title":"[iOS] iOS implementation for Web Checkouts","user":{"login":"sleroux","id":434322,"avatar_url":"https://avatars3.githubusercontent.com/u/434322?v=3","gravatar_id":"","url":"https://api.github.com/users/sleroux","html_url":"https://github.com/sleroux","followers_url":"https://api.github.com/users/sleroux/followers","following_url":"https://api.github.com/users/sleroux/following{/other_user}","gists_url":"https://api.github.com/users/sleroux/gists{/gist_id}","starred_url":"https://api.github.com/users/sleroux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sleroux/subscriptions","organizations_url":"https://api.github.com/users/sleroux/orgs","repos_url":"https://api.github.com/users/sleroux/repos","events_url":"https://api.github.com/users/sleroux/events{/privacy}","received_events_url":"https://api.github.com/users/sleroux/received_events","type":"User","site_admin":false},"body":"This patch implements the _StartWebCheckout(..) API from the Unity side on iOS. From a high level,\n\n* The Unity code calls into the native plugin via `_StartWebCheckout(unityDelegateName, checkoutURL)`.\n* The API creates a `WebCheckoutSession` which encapsulates the web checkout.\n* `WebCheckoutSession` creates the `WebCheckoutViewController` which contains all of the custom UI for checking out.\n* `WebCheckoutSession` implements the `WebCheckoutDelegate` which receives events of what happened during the web checkout. In a later patch this will \n  interact with the `UnityMessage` class to bubble up callbacks to the Unity layer.\n* `WebCheckoutViewController` contains a few helper classes inside for creating the views it displays.\n\nA couple of notes about the checking out experience:\n\n* I've made the web checkout look like an overlay modal so the user can see the game in the background instead of fully covering the screen. Makes it feel like\n  you're still in the game.\n* The button at the bottom changes from Cancel -> Finish when the web view navigates to the last page of the checkout process (.../thank_you).\n* The web view doesn't get auto-dismissed but is something we can add. I'm not sure if we want this since as a customer I'd like to see the final screen before closing.\n\nI have some tests I'm working on still as well so I'll follow up with those and the C# implementation.","created_at":"2017-06-26T20:54:05Z","updated_at":"2017-07-04T12:38:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8b90ccd3a14b9d9a6fc5c0ba85a9781de0aca246","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls/120/commits","review_comments_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls/120/comments","review_comment_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/issues/120/comments","statuses_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/statuses/18aa52f495bb0cd174837744708f11a37284e16e","head":{"label":"Shopify:sleroux/ios-web-checkout","ref":"sleroux/ios-web-checkout","sha":"18aa52f495bb0cd174837744708f11a37284e16e","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars2.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":75216845,"name":"unity-buy-sdk","full_name":"Shopify/unity-buy-sdk","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars2.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/unity-buy-sdk","description":"The Unity Buy SDK allows Unity developers to query and sell products from Shopify directly in Unity.","fork":false,"url":"https://api.github.com/repos/Shopify/unity-buy-sdk","forks_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/forks","keys_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/teams","hooks_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/hooks","issue_events_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/events","assignees_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/tags","blobs_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/languages","stargazers_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/stargazers","contributors_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/contributors","subscribers_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/subscribers","subscription_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/subscription","commits_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/merges","archive_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/downloads","issues_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/releases{/id}","deployments_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/deployments","created_at":"2016-11-30T18:51:35Z","updated_at":"2017-05-29T19:07:58Z","pushed_at":"2017-06-30T22:43:14Z","git_url":"git://github.com/Shopify/unity-buy-sdk.git","ssh_url":"git@github.com:Shopify/unity-buy-sdk.git","clone_url":"https://github.com/Shopify/unity-buy-sdk.git","svn_url":"https://github.com/Shopify/unity-buy-sdk","homepage":"https://help.shopify.com/api/sdks/custom-storefront/unity-buy-sdk","size":3129,"stargazers_count":12,"watchers_count":12,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":20,"forks":1,"open_issues":20,"watchers":12,"default_branch":"master"}},"base":{"label":"Shopify:beta","ref":"beta","sha":"4811655ec74926905a3fa94d451eb352521c0325","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars2.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":75216845,"name":"unity-buy-sdk","full_name":"Shopify/unity-buy-sdk","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars2.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/unity-buy-sdk","description":"The Unity Buy SDK allows Unity developers to query and sell products from Shopify directly in Unity.","fork":false,"url":"https://api.github.com/repos/Shopify/unity-buy-sdk","forks_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/forks","keys_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/teams","hooks_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/hooks","issue_events_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/events","assignees_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/tags","blobs_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/languages","stargazers_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/stargazers","contributors_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/contributors","subscribers_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/subscribers","subscription_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/subscription","commits_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/merges","archive_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/downloads","issues_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/releases{/id}","deployments_url":"https://api.github.com/repos/Shopify/unity-buy-sdk/deployments","created_at":"2016-11-30T18:51:35Z","updated_at":"2017-05-29T19:07:58Z","pushed_at":"2017-06-30T22:43:14Z","git_url":"git://github.com/Shopify/unity-buy-sdk.git","ssh_url":"git@github.com:Shopify/unity-buy-sdk.git","clone_url":"https://github.com/Shopify/unity-buy-sdk.git","svn_url":"https://github.com/Shopify/unity-buy-sdk","homepage":"https://help.shopify.com/api/sdks/custom-storefront/unity-buy-sdk","size":3129,"stargazers_count":12,"watchers_count":12,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":20,"forks":1,"open_issues":20,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls/120"},"html":{"href":"https://github.com/Shopify/unity-buy-sdk/pull/120"},"issue":{"href":"https://api.github.com/repos/Shopify/unity-buy-sdk/issues/120"},"comments":{"href":"https://api.github.com/repos/Shopify/unity-buy-sdk/issues/120/comments"},"review_comments":{"href":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls/120/comments"},"review_comment":{"href":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Shopify/unity-buy-sdk/pulls/120/commits"},"statuses":{"href":"https://api.github.com/repos/Shopify/unity-buy-sdk/statuses/18aa52f495bb0cd174837744708f11a37284e16e"}}}}
{"actor":{"display_login":"dbart01"}}