Skip to content

3.0.0

Compare
Choose a tag to compare
@markmur markmur released this 20 May 12:11
· 55 commits to main since this release
2895726

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