fix: paymentUrls is null (#1786)

* fix: paymentUrls is null

* feat: potential secure storage error
This commit is contained in:
Rafael
2024-11-09 07:20:06 +02:00
committed by GitHub
parent 389c334f10
commit 8e12fb1ad9
3 changed files with 9 additions and 4 deletions
-1
View File
@@ -1,4 +1,3 @@
class CakePayOrder {
final String orderId;
final List<OrderCard> cards;
+4 -2
View File
@@ -82,10 +82,12 @@ class CakePayService {
}
/// Logout
Future<void> logout(String email) async {
Future<void> 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
@@ -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();
}
}
}