From 48a5253023ecaab0d561d1a5ea45a7d6fb90efc1 Mon Sep 17 00:00:00 2001 From: Victoria Park Date: Fri, 20 Dec 2024 07:20:52 -0800 Subject: [PATCH] guard against crash on blank fields --- Sources/CardPaySheet/CardFormViewController.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sources/CardPaySheet/CardFormViewController.swift b/Sources/CardPaySheet/CardFormViewController.swift index 381639c6..c6aaa330 100644 --- a/Sources/CardPaySheet/CardFormViewController.swift +++ b/Sources/CardPaySheet/CardFormViewController.swift @@ -120,6 +120,16 @@ class CardFormViewController: UIViewController { } @objc private func handleContinueButton() { + guard let cardNumber = cardForm.cardNumber, let expirationDate = cardForm.expiryDate, let cvv = cardForm.expiryDate else { + // handle error + return + } + + if cardNumber.isEmpty || expirationDate.isEmpty || cvv.isEmpty { + // handle error + return + } + let card = Card.createCard( cardNumber: cardForm.cardNumber ?? "", expirationDate: cardForm.expiryDate ?? "",