payment quotation v2 + payment orchestration v2 draft
This commit is contained in:
@@ -12,7 +12,6 @@ import 'package:pshared/service/authorization/service.dart';
|
||||
import 'package:pshared/service/services.dart';
|
||||
import 'package:pshared/utils/http/params.dart';
|
||||
|
||||
|
||||
class PaymentService {
|
||||
static final _logger = Logger('service.payment');
|
||||
static const String _objectType = Services.payments;
|
||||
@@ -21,17 +20,21 @@ class PaymentService {
|
||||
String organizationRef, {
|
||||
int? limit,
|
||||
String? cursor,
|
||||
String? sourceRef,
|
||||
String? destinationRef,
|
||||
String? quotationRef,
|
||||
DateTime? createdFrom,
|
||||
DateTime? createdTo,
|
||||
List<String>? states,
|
||||
}) async {
|
||||
_logger.fine('Listing payments for organization $organizationRef');
|
||||
final queryParams = <String, String>{};
|
||||
if (sourceRef != null && sourceRef.isNotEmpty) {
|
||||
queryParams['source_ref'] = sourceRef;
|
||||
if (quotationRef != null && quotationRef.isNotEmpty) {
|
||||
queryParams['quotation_ref'] = quotationRef;
|
||||
}
|
||||
if (destinationRef != null && destinationRef.isNotEmpty) {
|
||||
queryParams['destination_ref'] = destinationRef;
|
||||
if (createdFrom != null) {
|
||||
queryParams['created_from'] = createdFrom.toUtc().toIso8601String();
|
||||
}
|
||||
if (createdTo != null) {
|
||||
queryParams['created_to'] = createdTo.toUtc().toIso8601String();
|
||||
}
|
||||
if (states != null && states.isNotEmpty) {
|
||||
queryParams['state'] = states.join(',');
|
||||
@@ -43,9 +46,14 @@ class PaymentService {
|
||||
cursor: cursor,
|
||||
queryParams: queryParams,
|
||||
);
|
||||
final response = await AuthorizationService.getGETResponse(_objectType, url);
|
||||
final response = await AuthorizationService.getGETResponse(
|
||||
_objectType,
|
||||
url,
|
||||
);
|
||||
final parsed = PaymentsResponse.fromJson(response);
|
||||
final payments = parsed.payments.map((payment) => payment.toDomain()).toList();
|
||||
final payments = parsed.payments
|
||||
.map((payment) => payment.toDomain())
|
||||
.toList();
|
||||
return PaymentPage(items: payments, nextCursor: parsed.nextCursor);
|
||||
}
|
||||
|
||||
@@ -53,16 +61,18 @@ class PaymentService {
|
||||
String organizationRef, {
|
||||
int? limit,
|
||||
String? cursor,
|
||||
String? sourceRef,
|
||||
String? destinationRef,
|
||||
String? quotationRef,
|
||||
DateTime? createdFrom,
|
||||
DateTime? createdTo,
|
||||
List<String>? states,
|
||||
}) async {
|
||||
final page = await listPage(
|
||||
organizationRef,
|
||||
limit: limit,
|
||||
cursor: cursor,
|
||||
sourceRef: sourceRef,
|
||||
destinationRef: destinationRef,
|
||||
quotationRef: quotationRef,
|
||||
createdFrom: createdFrom,
|
||||
createdTo: createdTo,
|
||||
states: states,
|
||||
);
|
||||
return page.items;
|
||||
@@ -74,7 +84,9 @@ class PaymentService {
|
||||
String? idempotencyKey,
|
||||
Map<String, String>? metadata,
|
||||
}) async {
|
||||
_logger.fine('Executing payment for quotation $quotationRef in $organizationRef');
|
||||
_logger.fine(
|
||||
'Executing payment for quotation $quotationRef in $organizationRef',
|
||||
);
|
||||
final request = InitiatePaymentRequest(
|
||||
idempotencyKey: idempotencyKey ?? Uuid().v4(),
|
||||
quoteRef: quotationRef,
|
||||
@@ -87,5 +99,4 @@ class PaymentService {
|
||||
);
|
||||
return PaymentResponse.fromJson(response).payment.toDomain();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user