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

@@ -20,6 +20,9 @@ class PaymentIntentDTO {
@JsonKey(name: 'settlement_mode')
final String? settlementMode;
@JsonKey(name: 'settlement_currency')
final String? settlementCurrency;
final Map<String, String>? attributes;
final CustomerDTO? customer;
@@ -30,6 +33,7 @@ class PaymentIntentDTO {
this.amount,
this.fx,
this.settlementMode,
this.settlementCurrency,
this.attributes,
this.customer,
});

View File

@@ -15,6 +15,7 @@ extension PaymentIntentMapper on PaymentIntent {
amount: amount?.toDTO(),
fx: fx?.toDTO(),
settlementMode: settlementModeToValue(settlementMode),
settlementCurrency: settlementCurrency,
attributes: attributes,
customer: customer?.toDTO(),
);
@@ -28,6 +29,7 @@ extension PaymentIntentDTOMapper on PaymentIntentDTO {
amount: amount?.toDomain(),
fx: fx?.toDomain(),
settlementMode: settlementModeFromValue(settlementMode),
settlementCurrency: settlementCurrency,
attributes: attributes,
customer: customer?.toDomain(),
);

View File

@@ -13,6 +13,7 @@ class PaymentIntent {
final Money? amount;
final FxIntent? fx;
final SettlementMode settlementMode;
final String? settlementCurrency;
final Map<String, String>? attributes;
final Customer? customer;
@@ -23,6 +24,7 @@ class PaymentIntent {
this.amount,
this.fx,
this.settlementMode = SettlementMode.unspecified,
this.settlementCurrency,
this.attributes,
this.customer,
});

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,