Separated request idempotency from intent identity #330

Closed
protuberanets wants to merge 1 commits from SEND035 into main
2 changed files with 4 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ part 'quote.g.dart';
@JsonSerializable() @JsonSerializable()
class QuotePaymentRequest extends PaymentBaseRequest { class QuotePaymentRequest extends PaymentBaseRequest {
final PaymentIntentDTO intent; final PaymentIntentDTO intent;
final String? intentKey;
@JsonKey(defaultValue: false) @JsonKey(defaultValue: false)
final bool previewOnly; final bool previewOnly;
@@ -17,6 +18,7 @@ class QuotePaymentRequest extends PaymentBaseRequest {
required super.idempotencyKey, required super.idempotencyKey,
super.metadata, super.metadata,
required this.intent, required this.intent,
this.intentKey,
this.previewOnly = false, this.previewOnly = false,
}); });

View File

@@ -91,12 +91,14 @@ class QuotationProvider extends ChangeNotifier {
if (!_organizations.isOrganizationSet) throw StateError('Organization is not set'); if (!_organizations.isOrganizationSet) throw StateError('Organization is not set');
_lastIntent = intent; _lastIntent = intent;
try { try {
final intentKey = _buildIntentKey(intent);
_setResource(_quotation.copyWith(isLoading: true, error: null)); _setResource(_quotation.copyWith(isLoading: true, error: null));
final response = await QuotationService.getQuotation( final response = await QuotationService.getQuotation(
_organizations.current.id, _organizations.current.id,
QuotePaymentRequest( QuotePaymentRequest(
idempotencyKey: Uuid().v4(), idempotencyKey: Uuid().v4(),
intent: intent.toDTO(), intent: intent.toDTO(),
intentKey: intentKey,
), ),
); );
_isLoaded = true; _isLoaded = true;