+ quotation provider
This commit is contained in:
14
frontend/pshared/lib/models/payment/asset.dart
Normal file
14
frontend/pshared/lib/models/payment/asset.dart
Normal 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,
|
||||
});
|
||||
}
|
||||
1
frontend/pshared/lib/models/payment/chain_network.dart
Normal file
1
frontend/pshared/lib/models/payment/chain_network.dart
Normal file
@@ -0,0 +1 @@
|
||||
enum ChainNetwork { unspecified, ethereumMainnet, arbitrumOne, otherEvm }
|
||||
9
frontend/pshared/lib/models/payment/currency_pair.dart
Normal file
9
frontend/pshared/lib/models/payment/currency_pair.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
class CurrencyPair {
|
||||
final String base;
|
||||
final String quote;
|
||||
|
||||
const CurrencyPair({
|
||||
required this.base,
|
||||
required this.quote,
|
||||
});
|
||||
}
|
||||
18
frontend/pshared/lib/models/payment/fees/line.dart
Normal file
18
frontend/pshared/lib/models/payment/fees/line.dart
Normal 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,
|
||||
});
|
||||
}
|
||||
12
frontend/pshared/lib/models/payment/fees/network.dart
Normal file
12
frontend/pshared/lib/models/payment/fees/network.dart
Normal 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,
|
||||
});
|
||||
}
|
||||
21
frontend/pshared/lib/models/payment/fx/intent.dart
Normal file
21
frontend/pshared/lib/models/payment/fx/intent.dart
Normal 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,
|
||||
});
|
||||
}
|
||||
30
frontend/pshared/lib/models/payment/fx/quote.dart
Normal file
30
frontend/pshared/lib/models/payment/fx/quote.dart
Normal 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,
|
||||
});
|
||||
}
|
||||
1
frontend/pshared/lib/models/payment/fx/side.dart
Normal file
1
frontend/pshared/lib/models/payment/fx/side.dart
Normal file
@@ -0,0 +1 @@
|
||||
enum FxSide { unspecified, buyBaseSellQuote, sellBaseBuyQuote }
|
||||
@@ -0,0 +1,6 @@
|
||||
enum InsufficientNetPolicy {
|
||||
unspecified,
|
||||
blockPosting,
|
||||
sweepOrgCash,
|
||||
invoiceLater
|
||||
}
|
||||
26
frontend/pshared/lib/models/payment/intent.dart
Normal file
26
frontend/pshared/lib/models/payment/intent.dart
Normal 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,
|
||||
});
|
||||
}
|
||||
1
frontend/pshared/lib/models/payment/kind.dart
Normal file
1
frontend/pshared/lib/models/payment/kind.dart
Normal file
@@ -0,0 +1 @@
|
||||
enum PaymentKind { unspecified, payout, internalTransfer, fxConversion }
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
18
frontend/pshared/lib/models/payment/methods/card_token.dart
Normal file
18
frontend/pshared/lib/models/payment/methods/card_token.dart
Normal 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,
|
||||
});
|
||||
}
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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?>;
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
18
frontend/pshared/lib/models/payment/methods/ledger.dart
Normal file
18
frontend/pshared/lib/models/payment/methods/ledger.dart
Normal 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,
|
||||
});
|
||||
}
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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});
|
||||
}
|
||||
|
||||
9
frontend/pshared/lib/models/payment/money.dart
Normal file
9
frontend/pshared/lib/models/payment/money.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
class Money {
|
||||
final String amount;
|
||||
final String currency;
|
||||
|
||||
const Money({
|
||||
required this.amount,
|
||||
required this.currency,
|
||||
});
|
||||
}
|
||||
20
frontend/pshared/lib/models/payment/payment.dart
Normal file
20
frontend/pshared/lib/models/payment/payment.dart
Normal 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,
|
||||
});
|
||||
}
|
||||
27
frontend/pshared/lib/models/payment/quote.dart
Normal file
27
frontend/pshared/lib/models/payment/quote.dart
Normal 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,
|
||||
});
|
||||
}
|
||||
1
frontend/pshared/lib/models/payment/settlement_mode.dart
Normal file
1
frontend/pshared/lib/models/payment/settlement_mode.dart
Normal file
@@ -0,0 +1 @@
|
||||
enum SettlementMode { unspecified, fixSource, fixReceived }
|
||||
@@ -1,7 +1,10 @@
|
||||
enum PaymentType {
|
||||
ledger,
|
||||
managedWallet,
|
||||
externalChain,
|
||||
bankAccount,
|
||||
iban,
|
||||
wallet,
|
||||
card,
|
||||
cryptoAddress,
|
||||
cardToken,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user