payment quotation v2 + payment orchestration v2 draft
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import 'package:pshared/models/payment/quote/quote.dart';
|
||||
|
||||
import 'package:pshared/models/payment/state.dart';
|
||||
|
||||
class Payment {
|
||||
final String? paymentRef;
|
||||
final String? idempotencyKey;
|
||||
final String? state;
|
||||
final PaymentOrchestrationState orchestrationState;
|
||||
final String? failureCode;
|
||||
final String? failureReason;
|
||||
final PaymentQuote? lastQuote;
|
||||
@@ -15,6 +16,7 @@ class Payment {
|
||||
required this.paymentRef,
|
||||
required this.idempotencyKey,
|
||||
required this.state,
|
||||
required this.orchestrationState,
|
||||
required this.failureCode,
|
||||
required this.failureReason,
|
||||
required this.lastQuote,
|
||||
@@ -22,9 +24,12 @@ class Payment {
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
bool get isPending => orchestrationState.isPending;
|
||||
|
||||
bool get isTerminal => orchestrationState.isTerminal;
|
||||
|
||||
bool get isFailure {
|
||||
if ((failureCode ?? '').trim().isNotEmpty) return true;
|
||||
final normalized = (state ?? '').trim().toLowerCase();
|
||||
return normalized.contains('fail') || normalized.contains('cancel');
|
||||
return orchestrationState == PaymentOrchestrationState.failed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user