diff --git a/Sources/ShopifyCheckoutSheetKit/CheckoutBridge.swift b/Sources/ShopifyCheckoutSheetKit/CheckoutBridge.swift index 812763a6..e2ad3ce9 100644 --- a/Sources/ShopifyCheckoutSheetKit/CheckoutBridge.swift +++ b/Sources/ShopifyCheckoutSheetKit/CheckoutBridge.swift @@ -22,6 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO */ import WebKit +import os.log enum BridgeError: Swift.Error { case invalidBridgeEvent(Swift.Error? = nil) @@ -101,8 +102,13 @@ extension CheckoutBridge { switch name { case "completed": let checkoutCompletedEventDecoder = CheckoutCompletedEventDecoder() - let checkoutCompletedEvent = try checkoutCompletedEventDecoder.decode(from: container, using: decoder) - self = .checkoutComplete(event: checkoutCompletedEvent) + do { + let checkoutCompletedEvent = try checkoutCompletedEventDecoder.decode(from: container, using: decoder) + self = .checkoutComplete(event: checkoutCompletedEvent) + } catch { + os_log(.error, "[ShopifyCheckoutSheetKit] Error decoding CheckoutCompletedEvent: %{public}@", error as CVarArg) + self = .checkoutComplete(event: CheckoutCompletedEvent()) + } case "error": // needs to support .checkoutUnavailable by parsing error payload on body self = .checkoutExpired diff --git a/Sources/ShopifyCheckoutSheetKit/CheckoutDelegate.swift b/Sources/ShopifyCheckoutSheetKit/CheckoutDelegate.swift index 293084a7..a2556b3c 100644 --- a/Sources/ShopifyCheckoutSheetKit/CheckoutDelegate.swift +++ b/Sources/ShopifyCheckoutSheetKit/CheckoutDelegate.swift @@ -44,9 +44,6 @@ public protocol CheckoutDelegate: AnyObject { } extension CheckoutDelegate { - /// Deprecated and will be removed in the next major release - public func checkoutDidComplete() {} - public func checkoutDidComplete(event: CheckoutCompletedEvent) { /// No-op by default }