small fixes for single payout and big chunck for multiple payouts

This commit is contained in:
Arseni
2026-02-05 21:58:37 +03:00
parent 8034847e46
commit b9748b8ab2
37 changed files with 1708 additions and 224 deletions

View File

@@ -0,0 +1,71 @@
import 'package:flutter/foundation.dart';
import 'package:pshared/provider/payment/flow.dart';
import 'package:pshared/provider/payment/provider.dart';
import 'package:pshared/provider/payment/quotation/quotation.dart';
import 'package:pshared/provider/recipient/provider.dart';
class PaymentPageController extends ChangeNotifier {
PaymentProvider? _payment;
QuotationProvider? _quotation;
PaymentFlowProvider? _flow;
RecipientsProvider? _recipients;
bool _isSending = false;
Exception? _error;
bool get isSending => _isSending;
Exception? get error => _error;
void update(
PaymentProvider payment,
QuotationProvider quotation,
PaymentFlowProvider flow,
RecipientsProvider recipients,
) {
_payment = payment;
_quotation = quotation;
_flow = flow;
_recipients = recipients;
}
Future<bool> sendPayment() async {
if (_isSending) return false;
final payment = _payment;
if (payment == null) {
_setError(StateError('Payment provider is not ready'));
return false;
}
try {
_setSending(true);
_error = null;
final result = await payment.pay();
return result != null && payment.error == null;
} catch (e) {
_setError(e);
return false;
} finally {
_setSending(false);
}
}
void resetAfterSuccess() {
_quotation?.reset();
_payment?.reset();
_flow?.setManualPaymentData(null);
_recipients?.setCurrentObject(null);
}
void _setSending(bool value) {
if (_isSending == value) return;
_isSending = value;
notifyListeners();
}
void _setError(Object error) {
_error = error is Exception ? error : Exception(error.toString());
notifyListeners();
}
}