refundPayment method
Refund payment
Implementation
Future<LokotroPayOnResponse> refundPayment({
required String orderId,
required String originalTransactionId,
required double amount,
String? currency,
String? reason,
}) async {
try {
final paymentResponse = await _paymentService.refundPayment(
orderId: orderId,
originalTransactionId: originalTransactionId,
amount: amount,
currency: currency ?? config.currency,
reason: reason,
);
return _convertToLokotroResponse(paymentResponse);
} on MastercardException catch (e) {
return LokotroPayOnResponse(
title: 'Refund Failed',
message: e.errorMessage,
paymentStatus: LokotroPaymentStatus.failed,
apiResponseCode: LokotroPayApiResponseCode.lok001,
amount: amount,
currency: currency ?? config.currency,
systemRef: _uuid.v4(),
customRef: orderId,
timestamp: DateTime.now(),
transactionId: null,
);
}
}