+ quotation provider

This commit is contained in:
Stephan D
2025-12-11 01:13:13 +01:00
parent bdf766075e
commit a4481fb63d
102 changed files with 2242 additions and 246 deletions

View File

@@ -0,0 +1,14 @@
import 'package:pshared/models/payment/chain_network.dart';
class PaymentAsset {
final ChainNetwork chain;
final String tokenSymbol;
final String? contractAddress;
const PaymentAsset({
this.chain = ChainNetwork.unspecified,
required this.tokenSymbol,
this.contractAddress,
});
}

View File

@@ -0,0 +1 @@
enum ChainNetwork { unspecified, ethereumMainnet, arbitrumOne, otherEvm }

View File

@@ -0,0 +1,9 @@
class CurrencyPair {
final String base;
final String quote;
const CurrencyPair({
required this.base,
required this.quote,
});
}

View File

@@ -0,0 +1,18 @@
import 'package:pshared/models/payment/money.dart';
class FeeLine {
final String? ledgerAccountRef;
final Money? amount;
final String? lineType;
final String? side;
final Map<String, String>? meta;
const FeeLine({
required this.ledgerAccountRef,
required this.amount,
required this.lineType,
required this.side,
required this.meta,
});
}

View File

@@ -0,0 +1,12 @@
import 'package:pshared/models/payment/money.dart';
class NetworkFee {
final Money? networkFee;
final String? estimationContext;
const NetworkFee({
required this.networkFee,
required this.estimationContext,
});
}

View File

@@ -0,0 +1,21 @@
import 'package:pshared/models/payment/currency_pair.dart';
import 'package:pshared/models/payment/fx/side.dart';
class FxIntent {
final CurrencyPair? pair;
final FxSide side;
final bool firm;
final int? ttlMs;
final String? preferredProvider;
final int? maxAgeMs;
const FxIntent({
this.pair,
this.side = FxSide.unspecified,
this.firm = false,
this.ttlMs,
this.preferredProvider,
this.maxAgeMs,
});
}

View File

@@ -0,0 +1,30 @@
import 'package:pshared/models/payment/money.dart';
class FxQuote {
final String? quoteRef;
final String? baseCurrency;
final String? quoteCurrency;
final String? side;
final String? price;
final Money? baseAmount;
final Money? quoteAmount;
final int? expiresAtUnixMs;
final String? provider;
final String? rateRef;
final bool firm;
const FxQuote({
required this.quoteRef,
required this.baseCurrency,
required this.quoteCurrency,
required this.side,
required this.price,
required this.baseAmount,
required this.quoteAmount,
required this.expiresAtUnixMs,
required this.provider,
required this.rateRef,
this.firm = false,
});
}

View File

@@ -0,0 +1 @@
enum FxSide { unspecified, buyBaseSellQuote, sellBaseBuyQuote }

View File

@@ -0,0 +1,6 @@
enum InsufficientNetPolicy {
unspecified,
blockPosting,
sweepOrgCash,
invoiceLater
}

View File

@@ -0,0 +1,26 @@
import 'package:pshared/models/payment/fx/intent.dart';
import 'package:pshared/models/payment/kind.dart';
import 'package:pshared/models/payment/methods/data.dart';
import 'package:pshared/models/payment/money.dart';
import 'package:pshared/models/payment/settlement_mode.dart';
class PaymentIntent {
final PaymentKind kind;
final PaymentMethodData? source;
final PaymentMethodData? destination;
final Money? amount;
final FxIntent? fx;
final SettlementMode settlementMode;
final Map<String, String>? attributes;
const PaymentIntent({
this.kind = PaymentKind.unspecified,
this.source,
this.destination,
this.amount,
this.fx,
this.settlementMode = SettlementMode.unspecified,
this.attributes,
});
}

View File

@@ -0,0 +1 @@
enum PaymentKind { unspecified, payout, internalTransfer, fxConversion }

View File

@@ -2,17 +2,25 @@ import 'package:pshared/models/payment/methods/data.dart';
import 'package:pshared/models/payment/type.dart';
class CardPaymentMethod extends PaymentMethodData {
class CardPaymentMethod implements PaymentMethodData {
@override
final PaymentType type = PaymentType.card;
final String pan;
final String firstName;
final String lastName;
final int? expMonth;
final int? expYear;
final String? country;
@override
final Map<String, String>? metadata;
CardPaymentMethod({
const CardPaymentMethod({
required this.pan,
this.expMonth,
this.expYear,
required this.firstName,
required this.lastName,
this.country,
this.metadata,
});
}
}

View File

@@ -0,0 +1,18 @@
import 'package:pshared/models/payment/methods/data.dart';
import 'package:pshared/models/payment/type.dart';
class CardTokenPaymentMethod implements PaymentMethodData {
@override
final PaymentType type = PaymentType.cardToken;
final String token;
final String maskedPan;
@override
final Map<String, String>? metadata;
const CardTokenPaymentMethod({
required this.token,
required this.maskedPan,
this.metadata,
});
}

View File

@@ -1,18 +1,21 @@
import 'package:pshared/models/payment/methods/data.dart';
import 'package:pshared/models/payment/asset.dart';
import 'package:pshared/models/payment/type.dart';
class CryptoAddressPaymentMethod extends PaymentMethodData {
class CryptoAddressPaymentMethod implements PaymentMethodData {
@override
final PaymentType type = PaymentType.cryptoAddress;
final PaymentType type = PaymentType.externalChain;
final PaymentAsset? asset;
final String address;
final String network;
final String? destinationTag;
final String? memo;
@override
final Map<String, String>? metadata;
CryptoAddressPaymentMethod({
const CryptoAddressPaymentMethod({
this.asset,
required this.address,
required this.network,
this.destinationTag,
this.memo,
this.metadata,
});
}

View File

@@ -3,6 +3,7 @@ import 'package:pshared/models/payment/type.dart';
abstract class PaymentMethodData {
PaymentType get type;
Map<String, String>? get metadata;
}
typedef MethodMap = Map<PaymentType, PaymentMethodData?>;

View File

@@ -2,7 +2,7 @@ import 'package:pshared/models/payment/methods/data.dart';
import 'package:pshared/models/payment/type.dart';
class IbanPaymentMethod extends PaymentMethodData {
class IbanPaymentMethod implements PaymentMethodData {
@override
final PaymentType type = PaymentType.iban;
@@ -10,11 +10,14 @@ class IbanPaymentMethod extends PaymentMethodData {
final String accountHolder; // Full name of the recipient
final String? bic; // Optional: for cross-border transfers
final String? bankName; // Optional: for UI clarity
@override
final Map<String, String>? metadata;
IbanPaymentMethod({
const IbanPaymentMethod({
required this.iban,
required this.accountHolder,
this.bic,
this.bankName,
this.metadata,
});
}

View File

@@ -0,0 +1,18 @@
import 'package:pshared/models/payment/methods/data.dart';
import 'package:pshared/models/payment/type.dart';
class LedgerPaymentMethod implements PaymentMethodData {
@override
final PaymentType type = PaymentType.ledger;
final String ledgerAccountRef;
final String? contraLedgerAccountRef;
@override
final Map<String, String>? metadata;
const LedgerPaymentMethod({
required this.ledgerAccountRef,
this.contraLedgerAccountRef,
this.metadata,
});
}

View File

@@ -0,0 +1,19 @@
import 'package:pshared/models/payment/methods/data.dart';
import 'package:pshared/models/payment/asset.dart';
import 'package:pshared/models/payment/type.dart';
class ManagedWalletPaymentMethod implements PaymentMethodData {
@override
final PaymentType type = PaymentType.managedWallet;
final String managedWalletRef;
final PaymentAsset? asset;
@override
final Map<String, String>? metadata;
const ManagedWalletPaymentMethod({
required this.managedWalletRef,
this.asset,
this.metadata,
});
}

View File

@@ -2,7 +2,7 @@ import 'package:pshared/models/payment/methods/data.dart';
import 'package:pshared/models/payment/type.dart';
class RussianBankAccountPaymentMethod extends PaymentMethodData {
class RussianBankAccountPaymentMethod implements PaymentMethodData {
@override
final PaymentType type = PaymentType.bankAccount;
@@ -13,8 +13,10 @@ class RussianBankAccountPaymentMethod extends PaymentMethodData {
final String bik;
final String accountNumber;
final String correspondentAccount;
@override
final Map<String, String>? metadata;
RussianBankAccountPaymentMethod({
const RussianBankAccountPaymentMethod({
required this.recipientName,
required this.inn,
required this.kpp,
@@ -22,5 +24,6 @@ class RussianBankAccountPaymentMethod extends PaymentMethodData {
required this.bik,
required this.accountNumber,
required this.correspondentAccount,
this.metadata,
});
}

View File

@@ -2,11 +2,14 @@ import 'package:pshared/models/payment/methods/data.dart';
import 'package:pshared/models/payment/type.dart';
class WalletPaymentMethod extends PaymentMethodData {
class WalletPaymentMethod implements PaymentMethodData {
@override
final PaymentType type = PaymentType.wallet;
final String walletId;
WalletPaymentMethod({required this.walletId});
@override
final Map<String, String>? metadata;
WalletPaymentMethod({required this.walletId, this.metadata});
}

View File

@@ -0,0 +1,9 @@
class Money {
final String amount;
final String currency;
const Money({
required this.amount,
required this.currency,
});
}

View File

@@ -0,0 +1,20 @@
import 'package:pshared/models/payment/quote.dart';
class Payment {
final String? paymentRef;
final String? idempotencyKey;
final String? state;
final String? failureCode;
final String? failureReason;
final PaymentQuote? lastQuote;
const Payment({
required this.paymentRef,
required this.idempotencyKey,
required this.state,
required this.failureCode,
required this.failureReason,
required this.lastQuote,
});
}

View File

@@ -0,0 +1,27 @@
import 'package:pshared/models/payment/fees/line.dart';
import 'package:pshared/models/payment/fx/quote.dart';
import 'package:pshared/models/payment/money.dart';
import 'package:pshared/models/payment/fees/network.dart';
class PaymentQuote {
final String? quoteRef;
final Money? debitAmount;
final Money? expectedSettlementAmount;
final Money? expectedFeeTotal;
final String? feeQuoteToken;
final List<FeeLine>? feeLines;
final NetworkFee? networkFee;
final FxQuote? fxQuote;
const PaymentQuote({
required this.quoteRef,
required this.debitAmount,
required this.expectedSettlementAmount,
required this.expectedFeeTotal,
required this.feeQuoteToken,
required this.feeLines,
required this.networkFee,
required this.fxQuote,
});
}

View File

@@ -0,0 +1 @@
enum SettlementMode { unspecified, fixSource, fixReceived }

View File

@@ -1,7 +1,10 @@
enum PaymentType {
ledger,
managedWallet,
externalChain,
bankAccount,
iban,
wallet,
card,
cryptoAddress,
cardToken,
}