unified gateway interfaces

This commit is contained in:
Stephan D
2026-01-04 12:47:43 +01:00
parent 743f683d92
commit 59c83e414a
41 changed files with 927 additions and 186 deletions

View File

@@ -51,25 +51,28 @@ class QuotationProvider extends ChangeNotifier {
recipient: recipients.currentObject,
method: method,
);
final amount = Money(
amount: payment.amount.toString(),
// TODO: adapt to possible other sources
currency: currencyCodeToString(wallets.selectedWallet!.currency),
);
final fxIntent = FxIntent(
pair: CurrencyPair(
base: currencyCodeToString(wallets.selectedWallet!.currency),
quote: 'RUB', // TODO: exentd target currencies
),
side: FxSide.sellBaseBuyQuote,
);
getQuotation(PaymentIntent(
kind: PaymentKind.payout,
amount: Money(
amount: payment.amount.toString(),
// TODO: adapt to possible other sources
currency: currencyCodeToString(wallets.selectedWallet!.currency),
),
amount: amount,
destination: method.data,
source: ManagedWalletPaymentMethod(
managedWalletRef: wallets.selectedWallet!.id,
),
fx: FxIntent(
pair: CurrencyPair(
base: currencyCodeToString(wallets.selectedWallet!.currency),
quote: 'RUB', // TODO: exentd target currencies
),
side: FxSide.sellBaseBuyQuote,
),
fx: fxIntent,
settlementMode: payment.payerCoversFee ? SettlementMode.fixReceived : SettlementMode.fixSource,
settlementCurrency: _resolveSettlementCurrency(amount: amount, fx: fxIntent),
customer: customer,
));
}
@@ -83,6 +86,30 @@ class QuotationProvider extends ChangeNotifier {
Asset? get total => quotation == null ? null : createAsset(quotation!.debitAmount!.currency, quotation!.debitAmount!.amount);
Asset? get recipientGets => quotation == null ? null : createAsset(quotation!.expectedSettlementAmount!.currency, quotation!.expectedSettlementAmount!.amount);
String _resolveSettlementCurrency({
required Money amount,
required FxIntent? fx,
}) {
final pair = fx?.pair;
if (pair != null) {
switch (fx?.side ?? FxSide.unspecified) {
case FxSide.buyBaseSellQuote:
if (pair.base.isNotEmpty) return pair.base;
break;
case FxSide.sellBaseBuyQuote:
if (pair.quote.isNotEmpty) return pair.quote;
break;
case FxSide.unspecified:
break;
}
if (amount.currency == pair.base && pair.quote.isNotEmpty) return pair.quote;
if (amount.currency == pair.quote && pair.base.isNotEmpty) return pair.base;
if (pair.quote.isNotEmpty) return pair.quote;
if (pair.base.isNotEmpty) return pair.base;
}
return amount.currency;
}
Customer _buildCustomer({
required Recipient? recipient,
required PaymentMethod method,