updated document upload according to fresh api

This commit is contained in:
Arseni
2026-03-04 18:07:08 +03:00
parent aff804ec58
commit c59538869b
12 changed files with 122 additions and 53 deletions

View File

@@ -1,6 +1,7 @@
class PaymentOperationDTO {
final String? stepRef;
final String? operationRef;
final String? gateway;
final String? code;
final String? state;
final String? label;
@@ -12,6 +13,7 @@ class PaymentOperationDTO {
const PaymentOperationDTO({
this.stepRef,
this.operationRef,
this.gateway,
this.code,
this.state,
this.label,
@@ -25,6 +27,7 @@ class PaymentOperationDTO {
PaymentOperationDTO(
stepRef: _asString(json['stepRef'] ?? json['step_ref']),
operationRef: _asString(json['operationRef'] ?? json['operation_ref']),
gateway: _asString(json['gateway']),
code: _asString(json['code']),
state: _asString(json['state']),
label: _asString(json['label']),
@@ -39,6 +42,7 @@ class PaymentOperationDTO {
Map<String, dynamic> toJson() => <String, dynamic>{
'stepRef': stepRef,
'operationRef': operationRef,
'gateway': gateway,
'code': code,
'state': state,
'label': label,

View File

@@ -1,11 +1,11 @@
import 'package:pshared/data/dto/payment/operation.dart';
import 'package:pshared/models/payment/execution_operation.dart';
extension PaymentOperationDTOMapper on PaymentOperationDTO {
PaymentExecutionOperation toDomain() => PaymentExecutionOperation(
stepRef: stepRef,
operationRef: operationRef,
gateway: gateway,
code: code,
state: state,
label: label,
@@ -20,6 +20,7 @@ extension PaymentExecutionOperationMapper on PaymentExecutionOperation {
PaymentOperationDTO toDTO() => PaymentOperationDTO(
stepRef: stepRef,
operationRef: operationRef,
gateway: gateway,
code: code,
state: state,
label: label,

View File

@@ -1,6 +1,7 @@
class PaymentExecutionOperation {
final String? stepRef;
final String? operationRef;
final String? gateway;
final String? code;
final String? state;
final String? label;
@@ -12,6 +13,7 @@ class PaymentExecutionOperation {
const PaymentExecutionOperation({
required this.stepRef,
required this.operationRef,
required this.gateway,
required this.code,
required this.state,
required this.label,

View File

@@ -1,7 +1,6 @@
import 'package:pshared/models/payment/methods/type.dart';
import 'package:pshared/models/payment/status.dart';
class OperationItem {
final OperationStatus status;
final String? fileName;
@@ -11,6 +10,8 @@ class OperationItem {
final String toCurrency;
final String payId;
final String? paymentRef;
final String? operationRef;
final String? gatewayService;
final String? cardNumber;
final PaymentMethod? paymentMethod;
final String name;
@@ -26,6 +27,8 @@ class OperationItem {
required this.toCurrency,
required this.payId,
this.paymentRef,
this.operationRef,
this.gatewayService,
this.cardNumber,
this.paymentMethod,
required this.name,

View File

@@ -8,27 +8,27 @@ class PaymentDocumentsService {
static final _logger = Logger('service.payment_documents');
static const String _objectType = Services.payments;
static Future<DownloadedFile> getAct(
static Future<DownloadedFile> getOperationDocument(
String organizationRef,
String paymentRef, {
String? operationRef,
}) async {
final query = <String, String>{'payment_ref': paymentRef};
final operationRefValue = operationRef;
if (operationRefValue != null && operationRefValue.isNotEmpty) {
query['operation_ref'] = operationRefValue;
query['operationRef'] = operationRefValue;
}
String gatewayService,
String operationRef,
) async {
final query = <String, String>{
'gateway_service': gatewayService,
'operation_ref': operationRef,
};
final queryString = Uri(queryParameters: query).query;
final url = '/documents/act/$organizationRef?$queryString';
_logger.fine('Downloading act document for payment $paymentRef');
final url = '/documents/operation/$organizationRef?$queryString';
_logger.fine(
'Downloading operation document for operation $operationRef in gateway $gatewayService',
);
final response = await AuthorizationService.getGETBinaryResponse(
_objectType,
url,
);
final filename =
_filenameFromDisposition(response.header('content-disposition')) ??
'act_$paymentRef.pdf';
'operation_$operationRef.pdf';
final mimeType = response.header('content-type') ?? 'application/pdf';
return DownloadedFile(
bytes: response.bytes,