|
1 | 1 | # Changelog
|
2 | 2 |
|
| 3 | +## 3.0.0 - May 20, 2024 |
| 4 | + |
| 5 | +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. |
| 6 | + |
| 7 | +### Error handling |
| 8 | + |
| 9 | +```swift |
| 10 | +func checkoutDidFail(error: ShopifyCheckoutSheetKit.CheckoutError) { |
| 11 | + var errorMessage: String = "" |
| 12 | + |
| 13 | + /// Internal Checkout SDK error |
| 14 | + if case .sdkError(let underlying, let recoverable) = error { |
| 15 | + errorMessage = "\(underlying.localizedDescription)" |
| 16 | + } |
| 17 | + |
| 18 | + /// Checkout unavailable error |
| 19 | + if case .checkoutUnavailable(let message, let code, let recoverable) = error { |
| 20 | + errorMessage = message |
| 21 | + switch code { |
| 22 | + case .clientError(let clientErrorCode): |
| 23 | + errorMessage = "Client Error: \(clientErrorCode)" |
| 24 | + case .httpError(let statusCode): |
| 25 | + errorMessage = "HTTP Error: \(statusCode)" |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + /// Storefront configuration error |
| 30 | + if case .configurationError(let message, let code, let recoverable) = error { |
| 31 | + errorMessage = message |
| 32 | + } |
| 33 | + |
| 34 | + /// Checkout has expired, re-create cart to fetch a new checkout URL |
| 35 | + if case .checkoutExpired(let message, let code, let recoverable) = error { |
| 36 | + errorMessage = message |
| 37 | + } |
| 38 | + |
| 39 | + if !error.isRecoverable { |
| 40 | + handleUnrecoverableError(errorMessage) |
| 41 | + } |
| 42 | + } |
| 43 | +``` |
| 44 | + |
| 45 | +### Opting out |
| 46 | + |
| 47 | +To opt out of the recovery feature, or to opt-out of the recovery of a specific error, extend the `shouldRecoverFromError` delegate method: |
| 48 | + |
| 49 | +```swift |
| 50 | +class Controller: CheckoutDelegate { |
| 51 | + shouldRecoverFromError(error: CheckoutError) { |
| 52 | + // default: |
| 53 | + return error.isRecoverable |
| 54 | + } |
| 55 | + |
| 56 | + checkoutDidFail(error: CheckoutError) { |
| 57 | + // Error handling... |
| 58 | + } |
| 59 | +} |
| 60 | +``` |
| 61 | + |
| 62 | +### Caveats |
| 63 | + |
| 64 | +In the event that the Checkout Sheet Kit has triggered the recovery experience, certain features _may_ not be available. |
| 65 | + |
| 66 | +1. Theming may not work as intended. |
| 67 | +2. **Web pixel lifecycle events will not fire.** |
| 68 | +3. `checkoutDidComplete` lifecycle events will contain only an `orderId`. |
| 69 | + |
3 | 70 | ## 2.0.1 - March 19, 2024
|
4 | 71 |
|
5 | 72 | - Makes `CheckoutCompletedEvent` encodable/decodable.
|
|
13 | 80 |
|
14 | 81 | ```json
|
15 | 82 | {
|
16 |
| - "sourceLanguage" : "en", |
17 |
| - "strings" : { |
18 |
| - "shopify_checkout_sheet_title" : { |
19 |
| - "comment" : "The title of the checkout sheet.", |
20 |
| - "extractionState" : "manual", |
21 |
| - "localizations" : { |
22 |
| - "en" : { |
23 |
| - "stringUnit" : { |
24 |
| - "state" : "translated", |
25 |
| - "value" : "Checkout" |
| 83 | + "sourceLanguage": "en", |
| 84 | + "strings": { |
| 85 | + "shopify_checkout_sheet_title": { |
| 86 | + "comment": "The title of the checkout sheet.", |
| 87 | + "extractionState": "manual", |
| 88 | + "localizations": { |
| 89 | + "en": { |
| 90 | + "stringUnit": { |
| 91 | + "state": "translated", |
| 92 | + "value": "Checkout" |
26 | 93 | }
|
27 |
| - }, |
| 94 | + } |
28 | 95 | }
|
29 | 96 | }
|
30 | 97 | }
|
31 | 98 | }
|
32 |
| - |
33 | 99 | ```
|
34 | 100 |
|
35 | 101 | ### Breaking Changes
|
|
0 commit comments