Releases: Shopify/checkout-sheet-kit-swift
3.0.2
3.0.1
3.0.0
Version 3.0.0
of the Checkout Sheet Kit ships with numerous improvements to error handling, including graceful degradation. In the event that your app receives an HTTP error on load or crashes mid-experience, the kit will implement a retry in an effort to attempt to recover.
Error handling
func checkoutDidFail(error: ShopifyCheckoutSheetKit.CheckoutError) {
var errorMessage: String = ""
/// Internal Checkout SDK error
if case .sdkError(let underlying, let recoverable) = error {
errorMessage = "\(underlying.localizedDescription)"
}
/// Checkout unavailable error
if case .checkoutUnavailable(let message, let code, let recoverable) = error {
errorMessage = message
switch code {
case .clientError(let clientErrorCode):
errorMessage = "Client Error: \(clientErrorCode)"
case .httpError(let statusCode):
errorMessage = "HTTP Error: \(statusCode)"
}
}
/// Storefront configuration error
if case .configurationError(let message, let code, let recoverable) = error {
errorMessage = message
}
/// Checkout has expired, re-create cart to fetch a new checkout URL
if case .checkoutExpired(let message, let code, let recoverable) = error {
errorMessage = message
}
if !error.isRecoverable {
handleUnrecoverableError(errorMessage)
}
}
Opting out
To opt out of the recovery feature, or to opt-out of the recovery of a specific error, extend the shouldRecoverFromError
delegate method:
class Controller: CheckoutDelegate {
func shouldRecoverFromError(error: CheckoutError) {
// default:
return error.isRecoverable
// Opt-out of all recovery
return false
}
func checkoutDidFail(error: CheckoutError) {
// Error handling...
}
}
Caveats
In the event that the Checkout Sheet Kit has triggered the recovery experience, certain features may not be available.
- Theming may not work as intended.
- Web pixel lifecycle events will not fire.
checkoutDidComplete
lifecycle events will contain only anorderId
.
Also included
- Improve error handling (HTTP + Bridge events) by @markmur in #156
- Graceful degradation with webview reuse by @markmur in #163
- Bump rexml from 3.2.6 to 3.2.8 in the bundler group across 1 directory by @dependabot in #177
Full Changelog: 2.0.1...3.0.0
3.0.0-beta.5
Full Changelog: 3.0.0-beta.4...3.0.0-beta.5
3.0.0-beta.4
Full Changelog: 3.0.0-beta.3...3.0.0-beta.4
3.0.0-beta.3
Full Changelog: 3.0.0-beta.2...3.0.0-beta.3
3.0.0-beta.2
Full Changelog: 3.0.0-beta.1...3.0.0-beta.2
3.0.0-beta.1
Full Changelog: 2.0.1...3.0.0-beta.1
2.0.1
2.0.0
New Features
- The loading spinner has been replaced by a progress bar on the webview. This will result in a faster perceived load time for checkout because the SDK will no longer wait for full page load to show the DOM content. #129
- Localization has been added for the sheet title. Customize this value by modifying a
shopify_checkout_sheet_title
string in yourLocalizable.xcstrings
file. #138
{
"sourceLanguage" : "en",
"strings" : {
"shopify_checkout_sheet_title" : {
"comment" : "The title of the checkout sheet.",
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Checkout"
}
},
}
}
}
}
Breaking Changes
- The
checkoutDidComplete
delegate method now returns a completed event object, containing details about the order: #128
checkoutDidComplete(event: ShopifyCheckoutSheetKit.CheckoutCompletedEvent) {
print(event.orderDetails.id)
}
spinnerColor
has been replaced bytintColor
:
- ShopifyCheckoutSheetKit.configuration.spinnerColor = .systemBlue
+ ShopifyCheckoutSheetKit.configuration.tintColor = .systemBlue
Deprecations
CheckoutViewController.Representable()
for SwiftUI has been deprecated. Please useCheckoutSheet(checkout:)
now instead.
.sheet(isPresented: $isShowingCheckout, onDismiss: didDismiss) {
- CheckoutViewController.Representable(checkout: $checkoutURL, delegate: eventHandler)
- .onReceive(eventHandler.$didCancel, perform: { didCancel in
- if didCancel {
- isShowingCheckout = false
- }
- })
+ CheckoutSheet(checkout: $checkoutURL)
+ .title("Custom title")
+ .colorScheme(.automatic)
+ .backgroundColor(.black)
+ .tintColor(.systemBlue)
+ .onCancel {
+ isShowingCheckout = false
+ }
+ .onComplete { }
+ .onPixelEvent { }
+ .onFail { }
+ .onLinkClick { }
}