From 636afe5d25266640aac87c4b5775f5eac1aed9cf Mon Sep 17 00:00:00 2001 From: Arseni Date: Thu, 22 Jan 2026 00:00:42 +0300 Subject: [PATCH] Fix --- .../lib/data/mapper/payment/quote/quotes.dart | 3 ++- .../lib/models/payment/quote/quotes.dart | 2 ++ .../payment/quotation/intent_builder.dart | 23 ++++++------------- .../lib/service/payment/quotation.dart | 4 +++- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/frontend/pshared/lib/data/mapper/payment/quote/quotes.dart b/frontend/pshared/lib/data/mapper/payment/quote/quotes.dart index 75015ebd..51117a2d 100644 --- a/frontend/pshared/lib/data/mapper/payment/quote/quotes.dart +++ b/frontend/pshared/lib/data/mapper/payment/quote/quotes.dart @@ -5,8 +5,9 @@ import 'package:pshared/models/payment/quote/quotes.dart'; extension PaymentQuotesDTOMapper on PaymentQuotesDTO { - PaymentQuotes toDomain() => PaymentQuotes( + PaymentQuotes toDomain({String? idempotencyKey}) => PaymentQuotes( quoteRef: quoteRef, + idempotencyKey: idempotencyKey, aggregate: aggregate?.toDomain(), quotes: quotes?.map((quote) => quote.toDomain()).toList(), ); diff --git a/frontend/pshared/lib/models/payment/quote/quotes.dart b/frontend/pshared/lib/models/payment/quote/quotes.dart index e4bc7e5e..15fca09c 100644 --- a/frontend/pshared/lib/models/payment/quote/quotes.dart +++ b/frontend/pshared/lib/models/payment/quote/quotes.dart @@ -4,11 +4,13 @@ import 'package:pshared/models/payment/quote/aggregate.dart'; class PaymentQuotes { final String quoteRef; + final String? idempotencyKey; final PaymentQuoteAggregate? aggregate; final List? quotes; const PaymentQuotes({ required this.quoteRef, + required this.idempotencyKey, required this.aggregate, required this.quotes, }); diff --git a/frontend/pshared/lib/provider/payment/quotation/intent_builder.dart b/frontend/pshared/lib/provider/payment/quotation/intent_builder.dart index ec242cd7..def7d899 100644 --- a/frontend/pshared/lib/provider/payment/quotation/intent_builder.dart +++ b/frontend/pshared/lib/provider/payment/quotation/intent_builder.dart @@ -90,22 +90,13 @@ class QuotationIntentBuilder { required PaymentMethod method, }) { final name = _resolveCustomerName(method, recipient); - String? firstName; - String? middleName; - String? lastName; - - if (name != null && name.isNotEmpty) { - final parts = name.split(RegExp(r'\s+')); - if (parts.isNotEmpty) { - firstName = parts.first; - } - if (parts.length == 2) { - lastName = parts.last; - } else if (parts.length > 2) { - lastName = parts.last; - middleName = parts.sublist(1, parts.length - 1).join(' '); - } - } + final parts = name == null || name.trim().isEmpty + ? const [] + : name.trim().split(RegExp(r'\s+')); + final firstName = parts.isNotEmpty ? parts.first : null; + final lastName = parts.length >= 2 ? parts.last : null; + final middleName = + parts.length > 2 ? parts.sublist(1, parts.length - 1).join(' ') : null; return Customer( id: recipient?.id ?? method.recipientRef, diff --git a/frontend/pshared/lib/service/payment/quotation.dart b/frontend/pshared/lib/service/payment/quotation.dart index 62b874f9..7055fc8a 100644 --- a/frontend/pshared/lib/service/payment/quotation.dart +++ b/frontend/pshared/lib/service/payment/quotation.dart @@ -34,6 +34,8 @@ class QuotationService { '/multiquote/$organizationRef', request.toJson(), ); - return PaymentQuotesResponse.fromJson(response).quote.toDomain(); + final parsed = PaymentQuotesResponse.fromJson(response); + final idempotencyKey = response['idempotencyKey'] as String?; + return parsed.quote.toDomain(idempotencyKey: idempotencyKey); } }