Moved payment data preparation into providers

This commit is contained in:
Arseni
2025-12-25 19:24:45 +03:00
parent b96babdfd4
commit 3ddd7718c2
9 changed files with 126 additions and 156 deletions

View File

@@ -1,7 +1,5 @@
import 'package:flutter/material.dart';
import 'package:collection/collection.dart';
import 'package:uuid/uuid.dart';
import 'package:pshared/api/requests/payment/quote.dart';
@@ -20,7 +18,6 @@ import 'package:pshared/provider/organizations.dart';
import 'package:pshared/provider/payment/amount.dart';
import 'package:pshared/provider/payment/flow.dart';
import 'package:pshared/provider/payment/wallets.dart';
import 'package:pshared/provider/recipient/pmethods.dart';
import 'package:pshared/provider/resource.dart';
import 'package:pshared/service/payment/quotation.dart';
import 'package:pshared/utils/currency.dart';
@@ -36,12 +33,10 @@ class QuotationProvider extends ChangeNotifier {
PaymentAmountProvider payment,
WalletsProvider wallets,
PaymentFlowProvider flow,
PaymentMethodsProvider methods,
) {
_organizations = venue;
final t = flow.selectedType;
final method = methods.methods.firstWhereOrNull((m) => m.type == t);
if ((wallets.selectedWallet != null) && (method != null)) {
final destination = flow.selectedPaymentData;
if ((wallets.selectedWallet != null) && (destination != null)) {
getQuotation(PaymentIntent(
kind: PaymentKind.payout,
amount: Money(
@@ -49,7 +44,7 @@ class QuotationProvider extends ChangeNotifier {
// TODO: adapt to possible other sources
currency: currencyCodeToString(wallets.selectedWallet!.currency),
),
destination: method.data,
destination: destination,
source: ManagedWalletPaymentMethod(
managedWalletRef: wallets.selectedWallet!.id,
),