+source currency pick fix +fx side propagation
This commit is contained in:
@@ -7,7 +7,9 @@ import 'package:pshared/api/requests/payment/initiate_payments.dart';
|
||||
import 'package:pshared/api/requests/payment/quote.dart';
|
||||
import 'package:pshared/api/responses/payment/quotation.dart';
|
||||
import 'package:pshared/data/dto/money.dart';
|
||||
import 'package:pshared/data/dto/payment/currency_pair.dart';
|
||||
import 'package:pshared/data/dto/payment/endpoint.dart';
|
||||
import 'package:pshared/data/dto/payment/intent/fx.dart';
|
||||
import 'package:pshared/data/dto/payment/intent/payment.dart';
|
||||
import 'package:pshared/data/mapper/payment/payment.dart';
|
||||
import 'package:pshared/models/payment/asset.dart';
|
||||
@@ -76,6 +78,36 @@ void main() {
|
||||
expect(destination['type'], equals('cardToken'));
|
||||
});
|
||||
|
||||
test('quote payment request serializes fx side to backend value', () {
|
||||
final request = QuotePaymentRequest(
|
||||
idempotencyKey: '',
|
||||
previewOnly: true,
|
||||
intent: const PaymentIntentDTO(
|
||||
kind: 'payout',
|
||||
source: PaymentEndpointDTO(
|
||||
type: 'managedWallet',
|
||||
data: {'managed_wallet_ref': 'mw-1'},
|
||||
),
|
||||
destination: PaymentEndpointDTO(
|
||||
type: 'cardToken',
|
||||
data: {'token': 'tok_1', 'masked_pan': '4111'},
|
||||
),
|
||||
amount: MoneyDTO(amount: '10', currency: 'USDT'),
|
||||
settlementMode: 'fix_source',
|
||||
fx: FxIntentDTO(
|
||||
pair: CurrencyPairDTO(base: 'RUB', quote: 'USDT'),
|
||||
side: 'buy_base_sell_quote',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final json =
|
||||
jsonDecode(jsonEncode(request.toJson())) as Map<String, dynamic>;
|
||||
final intent = json['intent'] as Map<String, dynamic>;
|
||||
final fx = intent['fx'] as Map<String, dynamic>;
|
||||
expect(fx['side'], equals('buy_base_sell_quote'));
|
||||
});
|
||||
|
||||
test('quote response parses backend fx quote pricedAtUnixMs', () {
|
||||
final response = PaymentQuoteResponse.fromJson({
|
||||
'accessToken': {'token': 'token', 'expiration': '2026-02-25T00:00:00Z'},
|
||||
|
||||
Reference in New Issue
Block a user