From 8e12fb1ad9c4475abb846937946fc7c9ede6daf8 Mon Sep 17 00:00:00 2001 From: Rafael Date: Sat, 9 Nov 2024 02:20:06 -0300 Subject: [PATCH] fix: paymentUrls is null (#1786) * fix: paymentUrls is null * feat: potential secure storage error --- lib/cake_pay/cake_pay_order.dart | 1 - lib/cake_pay/cake_pay_service.dart | 6 ++++-- .../cake_pay/cards/cake_pay_confirm_purchase_card_page.dart | 6 +++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/cake_pay/cake_pay_order.dart b/lib/cake_pay/cake_pay_order.dart index 8cb6e784a..acdf86ea0 100644 --- a/lib/cake_pay/cake_pay_order.dart +++ b/lib/cake_pay/cake_pay_order.dart @@ -1,4 +1,3 @@ - class CakePayOrder { final String orderId; final List cards; diff --git a/lib/cake_pay/cake_pay_service.dart b/lib/cake_pay/cake_pay_service.dart index 39f2ca77a..cf2ec254c 100644 --- a/lib/cake_pay/cake_pay_service.dart +++ b/lib/cake_pay/cake_pay_service.dart @@ -82,10 +82,12 @@ class CakePayService { } /// Logout - Future logout(String email) async { + Future logout([String? email]) async { await secureStorage.delete(key: cakePayUsernameStorageKey); await secureStorage.delete(key: cakePayUserTokenKey); - await cakePayApi.logoutUser(email: email, apiKey: cakePayApiKey); + if (email != null) { + await cakePayApi.logoutUser(email: email, apiKey: cakePayApiKey); + } } /// Purchase Gift Card diff --git a/lib/src/screens/cake_pay/cards/cake_pay_confirm_purchase_card_page.dart b/lib/src/screens/cake_pay/cards/cake_pay_confirm_purchase_card_page.dart index 81f6a354f..309c435a2 100644 --- a/lib/src/screens/cake_pay/cards/cake_pay_confirm_purchase_card_page.dart +++ b/lib/src/screens/cake_pay/cards/cake_pay_confirm_purchase_card_page.dart @@ -258,7 +258,11 @@ class CakePayBuyCardDetailPage extends BasePage { if (!isLogged) { Navigator.of(context).pushNamed(Routes.cakePayWelcomePage); } else { - await cakePayPurchaseViewModel.createOrder(); + try { + await cakePayPurchaseViewModel.createOrder(); + } catch (_) { + await cakePayPurchaseViewModel.cakePayService.logout(); + } } }