fix: paymentUrls is null (#1786)
* fix: paymentUrls is null * feat: potential secure storage error
Rafael committed
Nov 9, 2024 at 02:20 UTC
8e12fb1ad9c4475abb846937946fc7c9ede6daf8
3 files changed
+9
-4
lib/cake_pay/cake_pay_order.dart
-1
@@ -1,4 +1,3 @@
1
-
1
class CakePayOrder {
2
final String orderId;
3
final List<OrderCard> cards;
lib/cake_pay/cake_pay_service.dart
+4
-2
@@ -82,10 +82,12 @@ class CakePayService {
82
}
83
84
/// Logout
85
- Future<void> logout(String email) async {
85
+ Future<void> logout([String? email]) async {
86
await secureStorage.delete(key: cakePayUsernameStorageKey);
87
await secureStorage.delete(key: cakePayUserTokenKey);
88
- await cakePayApi.logoutUser(email: email, apiKey: cakePayApiKey);
88
+ if (email != null) {
89
+ await cakePayApi.logoutUser(email: email, apiKey: cakePayApiKey);
90
+ }
91
}
92
93
/// Purchase Gift Card
lib/src/screens/cake_pay/cards/cake_pay_confirm_purchase_card_page.dart
+5
-1
@@ -258,7 +258,11 @@ class CakePayBuyCardDetailPage extends BasePage {
258
if (!isLogged) {
259
Navigator.of(context).pushNamed(Routes.cakePayWelcomePage);
260
} else {
261
- await cakePayPurchaseViewModel.createOrder();
261
+ try {
262
+ await cakePayPurchaseViewModel.createOrder();
263
+ } catch (_) {
264
+ await cakePayPurchaseViewModel.cakePayService.logout();
265
+ }
266
}
267
}
268