intent reference generation + propagation
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
import 'package:pshared/api/requests/payment/base.dart';
|
||||
|
||||
|
||||
class InitiatePaymentsRequest extends PaymentBaseRequest {
|
||||
final String quoteRef;
|
||||
final String? intentRef;
|
||||
final List<String>? intentRefs;
|
||||
|
||||
const InitiatePaymentsRequest({
|
||||
required super.idempotencyKey,
|
||||
super.metadata,
|
||||
required this.quoteRef,
|
||||
this.intentRef,
|
||||
this.intentRefs,
|
||||
});
|
||||
|
||||
factory InitiatePaymentsRequest.fromJson(Map<String, dynamic> json) {
|
||||
@@ -17,6 +20,10 @@ class InitiatePaymentsRequest extends PaymentBaseRequest {
|
||||
(key, value) => MapEntry(key, value as String),
|
||||
),
|
||||
quoteRef: json['quoteRef'] as String,
|
||||
intentRef: json['intentRef'] as String?,
|
||||
intentRefs: (json['intentRefs'] as List<dynamic>?)
|
||||
?.map((value) => value as String)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,6 +33,8 @@ class InitiatePaymentsRequest extends PaymentBaseRequest {
|
||||
'idempotencyKey': idempotencyKey,
|
||||
'metadata': metadata,
|
||||
'quoteRef': quoteRef,
|
||||
if (intentRef != null) 'intentRef': intentRef,
|
||||
if (intentRefs != null) 'intentRefs': intentRefs,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,18 @@ part 'payment_quote.g.dart';
|
||||
@JsonSerializable()
|
||||
class PaymentQuoteDTO {
|
||||
final String? quoteRef;
|
||||
final String? intentRef;
|
||||
final QuoteAmountsDTO? amounts;
|
||||
final QuoteFeesDTO? fees;
|
||||
final FxQuoteDTO? fxQuote;
|
||||
|
||||
const PaymentQuoteDTO({this.quoteRef, this.amounts, this.fees, this.fxQuote});
|
||||
const PaymentQuoteDTO({
|
||||
this.quoteRef,
|
||||
this.intentRef,
|
||||
this.amounts,
|
||||
this.fees,
|
||||
this.fxQuote,
|
||||
});
|
||||
|
||||
factory PaymentQuoteDTO.fromJson(Map<String, dynamic> json) =>
|
||||
_$PaymentQuoteDTOFromJson(json);
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:pshared/models/payment/quote/quote.dart';
|
||||
extension PaymentQuoteDTOMapper on PaymentQuoteDTO {
|
||||
PaymentQuote toDomain({String? idempotencyKey}) => PaymentQuote(
|
||||
quoteRef: quoteRef,
|
||||
intentRef: intentRef,
|
||||
idempotencyKey: idempotencyKey,
|
||||
amounts: amounts?.toDomain(),
|
||||
fees: fees?.toDomain(),
|
||||
@@ -17,6 +18,7 @@ extension PaymentQuoteDTOMapper on PaymentQuoteDTO {
|
||||
extension PaymentQuoteMapper on PaymentQuote {
|
||||
PaymentQuoteDTO toDTO() => PaymentQuoteDTO(
|
||||
quoteRef: quoteRef,
|
||||
intentRef: intentRef,
|
||||
amounts: amounts?.toDTO(),
|
||||
fees: fees?.toDTO(),
|
||||
fxQuote: fxQuote?.toDTO(),
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:pshared/models/payment/quote/fees.dart';
|
||||
|
||||
class PaymentQuote {
|
||||
final String? quoteRef;
|
||||
final String? intentRef;
|
||||
final String? idempotencyKey;
|
||||
final QuoteAmounts? amounts;
|
||||
final QuoteFees? fees;
|
||||
@@ -11,6 +12,7 @@ class PaymentQuote {
|
||||
|
||||
const PaymentQuote({
|
||||
required this.quoteRef,
|
||||
required this.intentRef,
|
||||
required this.idempotencyKey,
|
||||
required this.amounts,
|
||||
required this.fees,
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'package:pshared/provider/resource.dart';
|
||||
import 'package:pshared/service/payment/multiple.dart';
|
||||
import 'package:pshared/utils/exception.dart';
|
||||
|
||||
|
||||
class MultiPaymentProvider extends ChangeNotifier {
|
||||
late OrganizationsProvider _organization;
|
||||
late MultiQuotationProvider _quotation;
|
||||
@@ -31,6 +30,8 @@ class MultiPaymentProvider extends ChangeNotifier {
|
||||
Future<List<Payment>> pay({
|
||||
String? idempotencyKey,
|
||||
Map<String, String>? metadata,
|
||||
String? intentRef,
|
||||
List<String>? intentRefs,
|
||||
}) async {
|
||||
if (!_organization.isOrganizationSet) {
|
||||
throw StateError('Organization is not set');
|
||||
@@ -53,6 +54,8 @@ class MultiPaymentProvider extends ChangeNotifier {
|
||||
quoteRef,
|
||||
idempotencyKey: idempotencyKey,
|
||||
metadata: metadata,
|
||||
intentRef: intentRef,
|
||||
intentRefs: intentRefs,
|
||||
);
|
||||
|
||||
_setResource(
|
||||
|
||||
@@ -13,7 +13,6 @@ import 'package:pshared/models/payment/quote/quotes.dart';
|
||||
import 'package:pshared/service/authorization/service.dart';
|
||||
import 'package:pshared/service/services.dart';
|
||||
|
||||
|
||||
class MultiplePaymentsService {
|
||||
static final _logger = Logger('service.payment.multiple');
|
||||
static const String _objectType = Services.payments;
|
||||
@@ -38,6 +37,8 @@ class MultiplePaymentsService {
|
||||
String quoteRef, {
|
||||
String? idempotencyKey,
|
||||
Map<String, String>? metadata,
|
||||
String? intentRef,
|
||||
List<String>? intentRefs,
|
||||
}) async {
|
||||
_logger.fine(
|
||||
'Executing multiple payments for quote $quoteRef in $organizationRef',
|
||||
@@ -46,6 +47,8 @@ class MultiplePaymentsService {
|
||||
idempotencyKey: idempotencyKey ?? const Uuid().v4(),
|
||||
quoteRef: quoteRef,
|
||||
metadata: metadata,
|
||||
intentRef: intentRef,
|
||||
intentRefs: intentRefs,
|
||||
);
|
||||
|
||||
final response = await AuthorizationService.getPOSTResponse(
|
||||
|
||||
Reference in New Issue
Block a user