processDirectPayment method
Future<LokotroPayOnResponse>
processDirectPayment({
- required MastercardPaymentRequest paymentRequest,
Process direct payment (without 3DS)
Implementation
Future<LokotroPayOnResponse> processDirectPayment({
required MastercardPaymentRequest paymentRequest,
}) async {
try {
final paymentResponse = await _paymentService.processPayment(
orderId: paymentRequest.orderId,
cardDetails: paymentRequest.cardDetails,
amount: paymentRequest.amount,
currency: paymentRequest.currency,
billingAddress: paymentRequest.billingAddress?.toJson(),
customerInfo: paymentRequest.customer?.toJson(),
description: paymentRequest.description,
);
return _convertToLokotroResponse(paymentResponse);
} on MastercardException catch (e) {
return LokotroPayOnResponse(
title: 'Payment Failed',
message: e.errorMessage,
paymentStatus: LokotroPaymentStatus.failed,
apiResponseCode: LokotroPayApiResponseCode.lok001,
amount: paymentRequest.amount,
currency: paymentRequest.currency,
systemRef: _uuid.v4(),
customRef: paymentRequest.orderId,
timestamp: DateTime.now(),
transactionId: null,
);
} catch (e) {
return LokotroPayOnResponse(
title: 'System Error',
message: 'Payment processing failed: $e',
paymentStatus: LokotroPaymentStatus.failed,
apiResponseCode: LokotroPayApiResponseCode.lok007,
amount: paymentRequest.amount,
currency: paymentRequest.currency,
systemRef: _uuid.v4(),
customRef: paymentRequest.orderId,
timestamp: DateTime.now(),
transactionId: null,
);
}
}