capturePayment method

Future<LokotroPayOnResponse> capturePayment({
  1. required String orderId,
  2. required String authorizationTransactionId,
  3. required double amount,
  4. String? currency,
})

Capture authorized payment

Implementation

Future<LokotroPayOnResponse> capturePayment({
  required String orderId,
  required String authorizationTransactionId,
  required double amount,
  String? currency,
}) async {
  try {
    final paymentResponse = await _paymentService.capturePayment(
      orderId: orderId,
      authorizationTransactionId: authorizationTransactionId,
      amount: amount,
      currency: currency ?? config.currency,
    );

    return _convertToLokotroResponse(paymentResponse);

  } on MastercardException catch (e) {
    return LokotroPayOnResponse(
      title: 'Capture 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,
    );
  }
}