Skip to content

Releases: Shopify/checkout-sheet-kit-swift

3.0.2

24 Jul 12:47
4dfe8a8
Compare
Choose a tag to compare

What's Changed

  • Set allowsInlineMediaPlayback to true on webview by @markmur in #204

New Contributors

Full Changelog: 3.0.1...3.0.2

3.0.1

19 Jun 10:43
3b508af
Compare
Choose a tag to compare

What's Changed

    • Fixes an issue where web pixels events do not fire after checkout completion by @markmur in #184

Full Changelog: 3.0.0...3.0.1

3.0.0

20 May 12:11
2895726
Compare
Choose a tag to compare

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.

  1. Theming may not work as intended.
  2. Web pixel lifecycle events will not fire.
  3. checkoutDidComplete lifecycle events will contain only an orderId.

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

16 May 10:29
e65945b
Compare
Choose a tag to compare
3.0.0-beta.5 Pre-release
Pre-release

3.0.0-beta.4

16 May 08:09
cd493e9
Compare
Choose a tag to compare
3.0.0-beta.4 Pre-release
Pre-release

3.0.0-beta.3

15 May 12:21
700deab
Compare
Choose a tag to compare
3.0.0-beta.3 Pre-release
Pre-release

3.0.0-beta.2

14 May 15:52
55d9a73
Compare
Choose a tag to compare
3.0.0-beta.2 Pre-release
Pre-release

3.0.0-beta.1

10 May 11:24
ec1978a
Compare
Choose a tag to compare
3.0.0-beta.1 Pre-release
Pre-release

Full Changelog: 2.0.1...3.0.0-beta.1

2.0.1

19 Mar 12:12
eb2df08
Compare
Choose a tag to compare

What's Changed

Full Changelog: 2.0.0...2.0.1

2.0.0

18 Mar 15:46
1895d9a
Compare
Choose a tag to compare

New Features

  1. 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
  2. Localization has been added for the sheet title. Customize this value by modifying a shopify_checkout_sheet_title string in your Localizable.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

  1. The checkoutDidComplete delegate method now returns a completed event object, containing details about the order: #128
checkoutDidComplete(event: ShopifyCheckoutSheetKit.CheckoutCompletedEvent) {
  print(event.orderDetails.id)
}
  1. spinnerColor has been replaced by tintColor:
- ShopifyCheckoutSheetKit.configuration.spinnerColor = .systemBlue
+ ShopifyCheckoutSheetKit.configuration.tintColor = .systemBlue

Deprecations

  1. CheckoutViewController.Representable() for SwiftUI has been deprecated. Please use CheckoutSheet(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 { }
}