Multiple Wallet support, history of each wallet and updated payment page
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
abstract class BalanceService {
|
||||
Future<double> getBalance();
|
||||
Future<String> getWalletName();
|
||||
Future<String> getWalletId();
|
||||
}
|
||||
|
||||
class MockBalanceService implements BalanceService {
|
||||
@override
|
||||
Future<double> getBalance() async {
|
||||
return 3000000.56;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> getWalletName() async {
|
||||
return "Wallet";
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> getWalletId() async {
|
||||
return "WA-12345667";
|
||||
}
|
||||
}
|
||||
85
frontend/pweb/lib/services/operations.dart
Normal file
85
frontend/pweb/lib/services/operations.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
import 'package:pshared/models/payment/operation.dart';
|
||||
import 'package:pshared/models/payment/status.dart';
|
||||
|
||||
|
||||
class OperationService {
|
||||
Future<List<OperationItem>> fetchOperations() async {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
|
||||
return [
|
||||
OperationItem(
|
||||
status: OperationStatus.error,
|
||||
fileName: 'cards_payout_sample_june.csv',
|
||||
amount: 10,
|
||||
currency: 'EUR',
|
||||
toAmount: 10,
|
||||
toCurrency: 'EUR',
|
||||
payId: '860163800',
|
||||
cardNumber: null,
|
||||
name: 'John Snow',
|
||||
date: DateTime(2025, 7, 14, 19, 59, 2),
|
||||
comment: 'EUR visa',
|
||||
),
|
||||
OperationItem(
|
||||
status: OperationStatus.processing,
|
||||
fileName: 'cards_payout_sample_june.csv',
|
||||
amount: 10,
|
||||
currency: 'EUR',
|
||||
toAmount: 10,
|
||||
toCurrency: 'EUR',
|
||||
payId: '860163700',
|
||||
cardNumber: null,
|
||||
name: 'Baltasar Gelt',
|
||||
date: DateTime(2025, 7, 14, 19, 59, 2),
|
||||
comment: 'EUR master',
|
||||
),
|
||||
OperationItem(
|
||||
status: OperationStatus.error,
|
||||
fileName: 'cards_payout_sample_june.csv',
|
||||
amount: 10,
|
||||
currency: 'EUR',
|
||||
toAmount: 10,
|
||||
toCurrency: 'EUR',
|
||||
payId: '40000000****0077',
|
||||
cardNumber: '40000000****0077',
|
||||
name: 'John Snow',
|
||||
date: DateTime(2025, 7, 14, 19, 23, 22),
|
||||
comment: 'EUR visa',
|
||||
),
|
||||
OperationItem(
|
||||
status: OperationStatus.success,
|
||||
fileName: null,
|
||||
amount: 10,
|
||||
currency: 'EUR',
|
||||
toAmount: 10,
|
||||
toCurrency: 'EUR',
|
||||
payId: '54133300****0019',
|
||||
cardNumber: '54133300****0019',
|
||||
name: 'Baltasar Gelt',
|
||||
date: DateTime(2025, 7, 14, 19, 23, 21),
|
||||
comment: 'EUR master',
|
||||
),
|
||||
OperationItem(
|
||||
status: OperationStatus.success,
|
||||
fileName: null,
|
||||
amount: 130,
|
||||
currency: 'EUR',
|
||||
toAmount: 130,
|
||||
toCurrency: 'EUR',
|
||||
payId: '54134300****0019',
|
||||
cardNumber: '54153300****0019',
|
||||
name: 'Ivan Brokov',
|
||||
date: DateTime(2025, 7, 15, 19, 23, 21),
|
||||
comment: 'EUR master 2',
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
// Add real API:
|
||||
// Future<List<OperationItem>> fetchOperations() async {
|
||||
// final response = await _httpClient.get('/api/operations');
|
||||
// return (response.data as List)
|
||||
// .map((json) => OperationItem.fromJson(json))
|
||||
// .toList();
|
||||
// }
|
||||
}
|
||||
@@ -33,6 +33,12 @@ class MockPaymentMethodsService implements PaymentMethodsService {
|
||||
),
|
||||
PaymentMethod(
|
||||
id: '4',
|
||||
label: 'Wallet',
|
||||
details: 'WA-76654321',
|
||||
type: PaymentType.wallet,
|
||||
),
|
||||
PaymentMethod(
|
||||
id: '5',
|
||||
label: 'Credit Card',
|
||||
details: '21•• •••• •••• 8901',
|
||||
type: PaymentType.card,
|
||||
|
||||
109
frontend/pweb/lib/services/wallet_transactions.dart
Normal file
109
frontend/pweb/lib/services/wallet_transactions.dart
Normal file
@@ -0,0 +1,109 @@
|
||||
import 'package:pshared/models/payment/status.dart';
|
||||
|
||||
import 'package:pweb/models/currency.dart';
|
||||
import 'package:pweb/models/wallet_transaction.dart';
|
||||
|
||||
|
||||
abstract class WalletTransactionsService {
|
||||
Future<List<WalletTransaction>> fetchHistory({String? walletId});
|
||||
}
|
||||
|
||||
class MockWalletTransactionsService implements WalletTransactionsService {
|
||||
final List<WalletTransaction> _history = [
|
||||
WalletTransaction(
|
||||
id: 'wt-001',
|
||||
walletId: '1124',
|
||||
type: WalletTransactionType.topUp,
|
||||
status: OperationStatus.success,
|
||||
amount: 150000,
|
||||
currency: Currency.rub,
|
||||
date: DateTime(2024, 9, 14, 10, 12),
|
||||
counterparty: 'VISA ••0019',
|
||||
description: 'Top up via corporate card',
|
||||
balanceAfter: 10150000,
|
||||
),
|
||||
WalletTransaction(
|
||||
id: 'wt-002',
|
||||
walletId: '1124',
|
||||
type: WalletTransactionType.payout,
|
||||
status: OperationStatus.processing,
|
||||
amount: 2500,
|
||||
currency: Currency.rub,
|
||||
date: DateTime(2024, 9, 15, 12, 10),
|
||||
counterparty: 'Bank transfer RU239',
|
||||
description: 'Invoice #239 shipping',
|
||||
balanceAfter: 10147500,
|
||||
),
|
||||
WalletTransaction(
|
||||
id: 'wt-003',
|
||||
walletId: '1124',
|
||||
type: WalletTransactionType.payout,
|
||||
status: OperationStatus.error,
|
||||
amount: 1200,
|
||||
currency: Currency.rub,
|
||||
date: DateTime(2024, 9, 13, 16, 40),
|
||||
counterparty: '4000 **** 0077',
|
||||
description: 'Payout to card declined',
|
||||
balanceAfter: 10000000,
|
||||
),
|
||||
WalletTransaction(
|
||||
id: 'wt-004',
|
||||
walletId: '2124',
|
||||
type: WalletTransactionType.topUp,
|
||||
status: OperationStatus.success,
|
||||
amount: 1800,
|
||||
currency: Currency.usd,
|
||||
date: DateTime(2024, 9, 12, 9, 0),
|
||||
counterparty: 'Wire payment 8831',
|
||||
description: 'Top up via USD wire',
|
||||
balanceAfter: 4300.5,
|
||||
),
|
||||
WalletTransaction(
|
||||
id: 'wt-005',
|
||||
walletId: '2124',
|
||||
type: WalletTransactionType.payout,
|
||||
status: OperationStatus.success,
|
||||
amount: 400,
|
||||
currency: Currency.usd,
|
||||
date: DateTime(2024, 9, 16, 14, 30),
|
||||
counterparty: 'IBAN DE09••1122',
|
||||
description: 'Payout to John Snow',
|
||||
balanceAfter: 3900.5,
|
||||
),
|
||||
WalletTransaction(
|
||||
id: 'wt-006',
|
||||
walletId: '1124',
|
||||
type: WalletTransactionType.payout,
|
||||
status: OperationStatus.success,
|
||||
amount: 70000,
|
||||
currency: Currency.rub,
|
||||
date: DateTime(2024, 9, 17, 8, 45),
|
||||
counterparty: 'Payroll batch',
|
||||
description: 'Monthly reimbursements',
|
||||
balanceAfter: 10080000,
|
||||
),
|
||||
WalletTransaction(
|
||||
id: 'wt-007',
|
||||
walletId: '1124',
|
||||
type: WalletTransactionType.topUp,
|
||||
status: OperationStatus.processing,
|
||||
amount: 200000,
|
||||
currency: Currency.rub,
|
||||
date: DateTime(2024, 9, 18, 9, 30),
|
||||
counterparty: 'Bank wire RU511',
|
||||
description: 'Top up pending confirmation',
|
||||
balanceAfter: 10280000,
|
||||
),
|
||||
];
|
||||
|
||||
@override
|
||||
Future<List<WalletTransaction>> fetchHistory({String? walletId}) async {
|
||||
await Future.delayed(const Duration(milliseconds: 350));
|
||||
|
||||
final source = walletId == null
|
||||
? _history
|
||||
: _history.where((tx) => tx.walletId == walletId).toList();
|
||||
|
||||
return List<WalletTransaction>.from(source);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user