fixed idempotency key
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import 'package:json_annotation/json_annotation.dart';
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
import 'package:pshared/api/requests/payment/base.dart';
|
|
||||||
|
|
||||||
|
import 'package:pshared/api/requests/payment/base.dart';
|
||||||
import 'package:pshared/data/dto/payment/intent/payment.dart';
|
import 'package:pshared/data/dto/payment/intent/payment.dart';
|
||||||
|
|
||||||
part 'quote.g.dart';
|
part 'quote.g.dart';
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class QuotationProvider extends ChangeNotifier {
|
|||||||
final intentKey = _buildIntentKey(intent);
|
final intentKey = _buildIntentKey(intent);
|
||||||
final lastIntent = _lastIntent;
|
final lastIntent = _lastIntent;
|
||||||
if (lastIntent != null && intentKey == _buildIntentKey(lastIntent)) return;
|
if (lastIntent != null && intentKey == _buildIntentKey(lastIntent)) return;
|
||||||
getQuotation(intent, idempotencyKey: intentKey);
|
getQuotation(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
PaymentQuote? get quotation => _quotation.data;
|
PaymentQuote? get quotation => _quotation.data;
|
||||||
@@ -84,19 +84,18 @@ class QuotationProvider extends ChangeNotifier {
|
|||||||
Future<PaymentQuote?> refreshQuotation() async {
|
Future<PaymentQuote?> refreshQuotation() async {
|
||||||
final intent = _lastIntent;
|
final intent = _lastIntent;
|
||||||
if (intent == null) return null;
|
if (intent == null) return null;
|
||||||
return getQuotation(intent, idempotencyKey: _buildIntentKey(intent));
|
return getQuotation(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<PaymentQuote?> getQuotation(PaymentIntent intent, {String? idempotencyKey}) async {
|
Future<PaymentQuote?> getQuotation(PaymentIntent intent) async {
|
||||||
if (!_organizations.isOrganizationSet) throw StateError('Organization is not set');
|
if (!_organizations.isOrganizationSet) throw StateError('Organization is not set');
|
||||||
_lastIntent = intent;
|
_lastIntent = intent;
|
||||||
final intentKey = idempotencyKey ?? _buildIntentKey(intent);
|
|
||||||
try {
|
try {
|
||||||
_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: intentKey,
|
idempotencyKey: Uuid().v4(),
|
||||||
intent: intent.toDTO(),
|
intent: intent.toDTO(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user