Files
sendico/frontend/pshared/lib/models/payment/payment.dart

42 lines
1.2 KiB
Dart

import 'package:pshared/models/payment/execution_operation.dart';
import 'package:pshared/models/payment/intent.dart';
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 PaymentIntent? intent;
final List<PaymentExecutionOperation> operations;
final PaymentQuote? lastQuote;
final Map<String, String>? metadata;
final DateTime? createdAt;
const Payment({
required this.paymentRef,
required this.idempotencyKey,
required this.state,
required this.orchestrationState,
required this.failureCode,
required this.failureReason,
this.intent,
required this.operations,
required this.lastQuote,
required this.metadata,
required this.createdAt,
});
bool get isPending => orchestrationState.isPending;
bool get isTerminal => orchestrationState.isTerminal;
bool get isFailure {
if ((failureCode ?? '').trim().isNotEmpty) return true;
return orchestrationState == PaymentOrchestrationState.failed;
}
}