ShopifyCheckoutKit 0.8.1

ShopifyCheckoutKit 0.8.1

Shopify 维护。



  • Shopify Inc.

{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":".github","path":".github","contentType":"directory"},{"name":"Samples","path":"Samples","contentType":"directory"},{"name":"Scripts","path":"Scripts","contentType":"directory"},{"name":"Sources","path":"Sources","contentType":"directory"},{"name":"Tests","path":"Tests","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".ruby-version","path":".ruby-version","contentType":"file"},{"name":".swiftlint.yml","path":".swiftlint.yml","contentType":"file"},{"name":"CHANGELOG.md","path":"CHANGELOG.md","contentType":"file"},{"name":"Gemfile","path":"Gemfile","contentType":"file"},{"name":"Gemfile.lock","path":"Gemfile.lock","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"Package.resolved","path":"Package.resolved","contentType":"file"},{"name":"Package.swift","path":"Package.swift","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"ShopifyCheckoutKit.podspec","path":"ShopifyCheckoutKit.podspec","contentType":"file"}],"totalCount":16}},"fileTreeProcessingTime":1.880794,"foldersToFetch":[],"reducedMotionEnabled":null,"repo":{"id":687512015,"defaultBranch":"main","name":"checkout-kit-swift","ownerLogin":"Shopify","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2023-09-05T14:03:03.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/8085?v=4","public":true,"private":false,"isOrgOwned":true},"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"main","listCacheKey":"v0:1700518320.0","canEdit":false,"refType":"branch","currentOid":"e6fd696197b0fcadec37c4c5447dd60b528e28c1"},"path":"README.md","currentUser":null,"blob":{"rawLines":null,"stylingDirectives":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/Shopify/checkout-kit-swift/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null,"repoAlertsPath":"/Shopify/checkout-kit-swift/security/dependabot","repoSecurityAndAnalysisPath":"/Shopify/checkout-kit-swift/settings/security_analysis","repoOwnerIsOrg":true,"currentUserCanAdminRepo":false},"displayName":"README.md","displayUrl":"https://github.com/Shopify/checkout-kit-swift/blob/main/README.md?raw=true","headerInfo":{"blobSize":"12.2 KB","deleteInfo":{"deleteTooltip":"您必须登录才能进行或提议更改操作"},"editInfo":{"editTooltip":"您必须登录才能进行或提议更改操作"},"ghDesktopPath":"https://desktop.github.com","gitLfsPath":null,"onBranch":true,"shortPath":"d863261","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2FShopify%2Fcheckout-kit-swift%2Fblob%2Fmain%2FREADME.md","isCSV":false,"isRichtext":true,"toc":[{"level":1,"text":"Shopify Checkout Kit - Swift","anchor":"shopify-checkout-kit---swift","htmlText":"Shopify Checkout Kit - Swift"},{"level":3,"text":"要求","anchor":"requirements","htmlText":"要求"},{"level":3,"text":"入门","anchor":"getting-started","htmlText":"入门"},{"level":4,"text":"Package.swift","anchor":"packageswift","htmlText":"Package.swift"},{"level":4,"text":"Xcode","anchor":"xcode","htmlText":"Xcode"},{"level":4,"text":"Cocoapods","anchor":"cocoapods","htmlText":"Cocoapods"},{"level":3,"text":"基本使用","anchor":"basic-usage","htmlText":"基本使用"},{"level":3,"text":"配置","anchor":"configuration","htmlText":"配置"},{"level":4,"text":"颜色方案","anchor":"colorscheme","htmlText":"颜色方案"},{"level":4,"text":"加载器颜色","anchor":"sp","htmlText":"加载器颜色"},{"level":4,"text":"背景颜色","anchor":"backgroundcolor","htmlText":"背景颜色"},{"level":3,"text":"预加载","anchor":"preloading","htmlText":"预加载"},{"level":3,"text":"监控结账会话的生命周期","anchor":"monitoring-the-lifecycle-of-a-checkout-session","htmlText":"监控结账会话的生命周期"},{"level":4,"text":"与Web像素集成,监控行为数据","anchor":"integrating-with-web-pixels-monitoring-behavioral-data","htmlText":"与Web像素集成,监控行为数据"},{"level":3,"text":"集成身份和客户账户","anchor":"integrating-identity--customer-accounts","htmlText":"集成身份和客户账户"},{"level":4,"text":"购物车:买家包、身份和偏好设置","anchor":"cart-buyer-bag-identity-and-preferences","htmlText":"购物车:买家包、身份和偏好设置"},{"level":4,"text":"多路径","anchor":"multipass","htmlText":"多路径"},{"level":4,"text":"Shop Pay","anchor":"shop-pay","htmlText":"Shop Pay"},{"level":4,"text":"客户账户API","anchor":"customer-account-api","htmlText":"客户账户API"},{"level":3,"text":"贡献","anchor":"contributing","htmlText":"贡献"},{"level":3,"text":"许可协议","anchor":"license","htmlText":"许可协议"}],"lineInfo":{"truncatedLoc":"254","truncatedSloc":"173"}}},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplateHelpUrl":"https://githubdocs.cn/articles/about-issue-and-pull-request-templates","issueTemplate":null,"discussionTemplate":null,"language":"Markdown","languageID":222,"large":false,"loggedIn":false,"newDiscussionPath":"/Shopify/checkout-kit-swift/discussions/new","newIssuePath":"/Shopify/checkout-kit-swift/issues/new","planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/Shopify/checkout-kit-swift/blob/main/README.md","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","dismissStackNoticePath":"/settings/dismiss-notice/publish_stack_from_file","releasePath":"/Shopify/checkout-kit-swift/releases/new?marketplace=true","showPublishActionBanner":false,"showPublishStackBanner":false},"rawBlobUrl":"https://github.com/Shopify/checkout-kit-swift/raw/main/README.md","renderImageOrRaw":false,"richText":"

Shopify Checkout Kit - Swift

\n

\"GitHub \"Swift \"Tests\"

\n

\"image\"

\n

Shopify付款组件是一个Swift包库,是Shopify原生软件开发工具包的部分,它允许Swift应用程序在应用内提供世界最高转换率的、可定制的、单页付款体验。所呈现的体验是一个功能齐全的付款体验,保留了所有店铺自定义内容:付款UI扩展、函数、品牌化以及更多。它还提供了平台特有的默认选项,如支持浅色和深色模式,以及方便的开发者API来嵌入、自定义和跟踪付款体验的生命周期。查看我们的博客了解为何我们要构建付款组件以及如何使用它。

\n

要求

\n
    \n
  • Swift 5.7+
  • \n
  • iOS SDK 13.0+
  • \n
  • SDK与checkout.liquid不兼容。Shopify Store必须迁移才能扩展
  • \n
\n

入门

\n

SDK是一个开源的Swift包库。作为快速开始,请参阅示例项目或使用以下方式之一将SDK集成到项目中

\n

Package.swift

\n
https://github.com/Shopify/checkout-kit-swift", from: "0.7.0")
dependencies: [\n  .package(url: \"https://github.com/Shopify/checkout-kit-swift class=\"pl-pds\">\", from: \"0.7.0\")\n]
\n

Xcode

\n
    \n
  1. 打开您的Xcode项目
  2. \n
  3. 导航到 文件 > 添加包依赖...
  4. \n
  5. 在搜索框中输入 https://github.com/Shopify/checkout-kit-swift
  6. \n¨C50C\n
\n

关于如何在Xcode中管理Swift Package依赖的更多细节,请参阅Apple的文档

\n

Cocoapods

\n
¨C51C
\n

Basic Usage

\n

一旦将SDK添加为依赖项,您就可以导入该库

\n
¨C52C
\n

要向买家展示结账窗口,您的应用程序必须首先获取结账URL。最常见的方法是使用Storefront GraphQL API通过(-4C和相关更新突变)组装购物车并查询checkoutUrl。您可以使用任何GraphQL客户端来完成此操作,并推荐使用 Shopify 的Mobile Buy SDK for iOS以简化开发工作流程

\n
¨C53C
\n

(-5C)对象是一个标准网页结账URL,可以在任何浏览器中打开。要在您的应用程序中显示原生结账表单,请将(-6C)以及可选的运行时配置设置一起提供给 SDK 提供的(-7C)函数

\n
¨C54C
\n

为了帮助优化并传递最佳体验,SDK 还提供了一个 预加载API,可以用于在后台和事先初始化结账会话。

\n

Configuration

\n

SDK通过(-8C)对象提供了一种定制结账体验的方法。

\n

¨C9C

\n

默认情况下,SDK会匹配用户的设备颜色表现。此行为的自定义可以通过(-10C)属性进行

\n
¨C55C
\n

廿一C

\n

如果结账会话尚未准备好即将初始化,则将显示加载旋转器,并且可以通过廿二C属性进行自定义

\n
廿三C
\n

廿四C

\n

廿五C

\n

结账会话初始化期间,可以通过廿六C属性自定义视图的背景色

\n
廿七C
\n

预加载

\n

初始化结账会话需要与Shopify服务器进行通信,并且根据网络状况和买家的连接质量,可能会导致买家不希望的等待时间。为了帮助优化并提供最佳体验,SDK提供预加载提示,允许应用开发者标记后台提前初始化结账会话。

\n

预加载是一个高级功能,可以通过运行时标志禁用

\n
廿九C
\n

启用后,预加载结账会话就像下文简述的一样简单

\n
卅C
\n

卅一C

\n
    卅二C
\n

卅三C

\n

监控结账会话的生命周期

\n
您可以使用廿七C协议来注册结账会话期间关键生命周期事件的回调
\n

与 WebPixels 集成,监控行为数据

\n

应用开发者可以使用生命周期事件来监控和记录 checkout 会话的状态。Web Pixel 事件目前在渲染的 checkout 中不执行。对客户事件和行为分析的支待正在开发中,将在 SDK 通用可用之前提供。

\n

集成身份 & 客户账户

\n

买家意识强的 checkout 体验减少了摩擦并提高了转化率。根据买家的上下文(游客或登录用户),了解买家的偏好或账户/身份系统,应用可以使用以下方法之一初始化个性化且符合上下文的买家体验。

\n

购物车:买家包、身份和偏好

\n

除了指定行项目之外,购物车还可以包括买家身份(名称、电子邮件、地址等),以及配送和支付偏好:请参阅指南。包含的信息将用于在 checkout 中向买家呈现预填充和预选择的选项。

\n

Multipass

\n

Shopify Plus 商户使用 经典顾客账户 可以使用 MultipassAPI 文档)来集成外部身份系统并初始化一个对买家身份了解的结账会话。

\n
¨C66C
\n
    \n¨C67C\n¨C68C\n
\n

¨C69C

\n

Shop Pay

\n

要初始化加速的 Shop Pay 结账流程,购物车可以设置 钱包偏好 为 'shop_pay'。买家的登录状态为应用本地。买家将在首次结账时被提示登录到他们的 Shop 账户,并且他们的登录状态将保存在未来的结账会话中。

\n

顾客账户 API

\n

我们正在开发一个库来提供由 新的顾客账户 API 提供的买家登录和身份验证功能——请耐心等待。

\n
\n

贡献

\n

我们欢迎代码贡献、特性请求和问题报告。请参阅 指南和说明

\n

许可协议

\n

Checkout Kit 遵循 MIT 许可协议

\n
","renderedFileInfo":null,"shortPath":null,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"repoOwner":"Shopify","repoName":"checkout-kit-swift","showInvalidCitationWarning":false,"citationHelpUrl":"https://githubdocs.cn/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","showDependabotConfigurationBanner":false,"actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timedOut":false,"notAnalyzed":false,"symbols":[{"name":"Shopify Checkout Kit - Swift","kind":"section_1","identStart":2,"identEnd":30,"extentStart":0,"extentEnd":12453,"fullyQualifiedName":"Shopify Checkout Kit - Swift","identUtf16":{"start":{"lineNumber":0,"utf16Col":2},"end":{"lineNumber":0,"utf16Col":30}},"extentUtf16":{"start":{"lineNumber":0,"utf16Col":0},"end":{"lineNumber":254,"utf16Col":0}}},{"name":"Requirements","kind":"section_3","identStart":1321,"identEnd":1333,"extentStart":1317,"extentEnd":1468,"fullyQualifiedName":"Requirements","identUtf16":{"start":{"lineNumber":8,"utf16Col":4},"end":{"lineNumber":8,"utf16Col":16}},"extentUtf16":{"start":{"lineNumber":8,"utf16Col":0},"end":{"lineNumber":14,"utf16Col":0}}},{"name":"Getting Started","kind":"section_3","identStart":1472,"identEnd":1487,"extentStart":1468,"extentEnd":2295,"fullyQualifiedName":"Getting Started","identUtf16":{"start":{"lineNumber":14,"utf16Col":4},"end":{"lineNumber":14,"utf16Col":19}},"extentUtf16":{"start":{"lineNumber":14,"utf16Col":0},"end":{"lineNumber":41,"utf16Col":0}}},{"name":"Package.swift","kind":"section_4","identStart":1718,"identEnd":1731,"extentStart":1713,"extentEnd":1845,"fullyQualifiedName":"Package.swift","identUtf16":{"start":{"lineNumber":18,"utf16Col":5},"end":{"lineNumber":18,"utf16Col":18}},"extentUtf16":{"start":{"lineNumber":18,"utf16Col":0},"end":{"lineNumber":26,"utf16Col":0}}},{"name":"Xcode","kind":"section_4","identStart":1850,"identEnd":1855,"extentStart":1845,"extentEnd":2231,"fullyQualifiedName":"Xcode","identUtf16":{"start":{"lineNumber":26,"utf16Col":5},"end":{"lineNumber":26,"utf16Col":10}},"extentUtf16":{"start":{"lineNumber":26,"utf16Col":0},"end":{"lineNumber":35,"utf16Col":0}}},{"name":"Cocoapods","kind":"section_4","identStart":2236,"identEnd":2245,"extentStart":2231,"extentEnd":2295,"fullyQualifiedName":"Cocoapods","identUtf16":{"start":{"lineNumber":35,"utf16Col":5},"end":{"lineNumber":35,"utf16Col":14}},"extentUtf16":{"start":{"lineNumber":35,"utf16Col":0},"end":{"lineNumber":41,"utf16Col":0}}},{"name":"Basic Usage","kind":"section_3","identStart":2299,"identEnd":2310,"extentStart":2295,"extentEnd":4068,"fullyQualifiedName":"Basic Usage","identUtf16":{"start":{"lineNumber":41,"utf16Col":4},"end":{"lineNumber":41,"utf16Col":15}},"extentUtf16":{"start":{"lineNumber":41,"utf16Col":0},"end":{"lineNumber":87,"utf16Col":0}}},{"name":"Configuration","kind":"section_3","identStart":4072,"identEnd":4085,"extentStart":4068,"extentEnd":5705,"fullyQualifiedName":"Configuration","identUtf16":{"start":{"lineNumber":87,"utf16Col":4},"end":{"lineNumber":87,"utf16Col":17}},"extentUtf16":{"start":{"lineNumber":87,"utf16Col":0},"end":{"lineNumber":135,"utf16Col":0}}},{"name":"colorScheme","kind":"section_4","identStart":4214,"identEnd":4227,"extentStart":4209,"extentEnd":4837,"fullyQualifiedName":"colorScheme","identUtf16":{"start":{"lineNumber":91,"utf16Col":5},"end":{"lineNumber":91,"utf16Col":18}},"extentUtf16":{"start":{"lineNumber":91,"utf16Col":0},"end":{"lineNumber":109,"utf16Col":0}}},{"name":"spinnerColor","kind":"section_4","identStart":4842,"identEnd":4856,"extentStart":4837,"extentEnd":5305,"fullyQualifiedName":"spinnerColor","identUtf16":{"start":{"lineNumber":109,"utf16Col":5},"end":{"lineNumber":109,"utf16Col":19}},"extentUtf16":{"start":{"lineNumber":109,"utf16Col":0},"end":{"lineNumber":123,"utf16Col":0}}},{"name":"backgroundColor","kind":"section_4","identStart":5310,"identEnd":5327,"extentStart":5305,"extentEnd":5705,"fullyQualifiedName":"backgroundColor","identUtf16":{"start":{"lineNumber":123,"utf16Col":5},"end":{"lineNumber":123,"utf16Col":22}},"extentUtf16":{"start":{"lineNumber":123,"utf16Col":0},"end":{"lineNumber":135,"utf16Col":0}}},{"name":"Preloading","kind":"section_3","identStart":5709,"identEnd":5719,"extentStart":5705,"extentEnd":7292,"fullyQualifiedName":"Preloading","identUtf16":{"start":{"lineNumber":135,"utf16Col":4},"end":{"lineNumber":135,"utf16Col":14}},"extentUtf16":{"start":{"lineNumber":135,"utf16Col":0},"end":{"lineNumber":159,"utf16Col":0}}},{"name":"Monitoring the lifecycle of a checkout session","kind":"section_3","identStart":7296,"identEnd":7342,"extentStart":7292,"extentEnd":9639,"fullyQualifiedName":"Monitoring the lifecycle of a checkout session","identUtf16":{"start":{"lineNumber":159,"utf16Col":4},"end":{"lineNumber":159,"utf16Col":50}},"extentUtf16":{"start":{"lineNumber":159,"utf16Col":0},"end":{"lineNumber":210,"utf16Col":0}}},{"name":"Integrating with Web Pixels, monitoring behavioral data","kind":"section_4","identStart":9229,"identEnd":9284,"extentStart":9224,"extentEnd":9639,"fullyQualifiedName":"Integrating with Web Pixels, monitoring behavioral data","identUtf16":{"start":{"lineNumber":206,"utf16Col":5},"end":{"lineNumber":206,"utf16Col":60}},"extentUtf16":{"start":{"lineNumber":206,"utf16Col":0},"end":{"lineNumber":210,"utf16Col":0}}},{"name":"Integrating identity & customer accounts","kind":"section_3","identStart":9643,"identEnd":9683,"extentStart":9639,"extentEnd":12222,"fullyQualifiedName":"Integrating identity & customer accounts","identUtf16":{"start":{"lineNumber":210,"utf16Col":4},"end":{"lineNumber":210,"utf16Col":44}},"extentUtf16":{"start":{"lineNumber":210,"utf16Col":0},"end":{"lineNumber":247,"utf16Col":0}}},{"name":"Cart: buyer bag, identity, and preferences","kind":"section_4","identStart":10005,"identEnd":10047,"extentStart":10000,"extentEnd":10419,"fullyQualifiedName":"Cart: buyer bag, identity, and preferences","identUtf16":{"start":{"lineNumber":214,"utf16Col":5},"end":{"lineNumber":214,"utf16Col":47}},"extentUtf16":{"start":{"lineNumber":214,"utf16Col":0},"end":{"lineNumber":218,"utf16Col":0}}},{"name":"Multipass","kind":"section_4","identStart":10424,"identEnd":10433,"extentStart":10419,"extentEnd":11523,"fullyQualifiedName":"Multipass","identUtf16":{"start":{"lineNumber":218,"utf16Col":5},"end":{"lineNumber":218,"utf16Col":14}},"extentUtf16":{"start":{"lineNumber":218,"utf16Col":0},"end":{"lineNumber":237,"utf16Col":0}}},{"name":"Shop Pay","kind":"section_4","identStart":11528,"identEnd":11536,"extentStart":11523,"extentEnd":11969,"fullyQualifiedName":"Shop Pay","identUtf16":{"start":{"lineNumber":237,"utf16Col":5},"end":{"lineNumber":237,"utf16Col":13}},"extentUtf16":{"start":{"lineNumber":237,"utf16Col":0},"end":{"lineNumber":241,"utf16Col":0}}},{"name":"Customer Account API","kind":"section_4","identStart":11974,"identEnd":11994,"extentStart":11969,"extentEnd":12222,"fullyQualifiedName":"Customer Account API","identUtf16":{"start":{"lineNumber":241,"utf16Col":5},"end":{"lineNumber":241,"utf16Col":25}},"extentUtf16":{"start":{"lineNumber":241,"utf16Col":0},"end":{"lineNumber":247,"utf16Col":0}}},{"name":"Contributing","kind":"section_3","identStart":12226,"identEnd":12238,"extentStart":12222,"extentEnd":12382,"fullyQualifiedName":"Contributing","identUtf16":{"start":{"lineNumber":247,"utf16Col":4},"end":{"lineNumber":247,"utf16Col":16}},"extentUtf16":{"start":{"lineNumber":247,"utf16Col":0},"end":{"lineNumber":251,"utf16Col":0}}},{"name":"License","kind":"section_3","identStart":12386,"identEnd":12393,"extentStart":12382,"extentEnd":12453,"fullyQualifiedName":"License","identUtf16":{"start":{"lineNumber":251,"utf16Col":4},"end":{"lineNumber":251,"utf16Col":11}},"extentUtf16":{"start":{"lineNumber":251,"utf16Col":0},"end":{"lineNumber":254,"utf16Col":0}}}]}},"copilotInfo":null,"copilotAccessAllowed":false,"csrf_tokens":{"/Shopify/checkout-kit-swift/branches":{"post":"7SajLe_225Ki8yS4Qg4UUV_xJtM_HoD3g__31vP-Zg5S81mc4DbXKAnLAcwf0g9ls-X80la4zcgtRzYNDzv3gQ"},"/repos/preferences":{"post":"0DF0SZt058QTbNZNW-Ej5bIfQt-2OmBe5mp6_Pgak7pbolsMAV2E5vn4kWyD3jZA2wEGHYVL5kpnWOBmLGj7eg"}}},"title":"checkout-kit-swift/README.md at main · Shopify/checkout-kit-swift"}