getInvoice method

Future<Invoice> getInvoice({
  1. String forUserId = "",
  2. required String invoice_id,
  3. required GeneralPaymentAuth generalPaymentAuth,
})

Implementation

Future<Invoice> getInvoice({
  String forUserId = "",
  required String invoice_id,
  required GeneralPaymentAuth generalPaymentAuth,
}) async {
  return await paymentInvokeBuilder(
    generalPaymentAuth: generalPaymentAuth,
    onXendit: (generalPaymentAuth) async {
      final result = await xendit.getInvoice(
        xenditApiKey: generalPaymentAuth.apiKey,
        forUserId: forUserId,
        invoice_id: invoice_id,
      );

      return result.toGeneralPaymentInvoice();
    },
    onMidtrans: (generalPaymentAuth) {
      return Invoice({
        "@type": "error",
        "message": "unimplemented",
      });
    },
    onCoinlox: (generalPaymentAuth) {
      return Invoice({
        "@type": "error",
        "message": "unimplemented",
      });
    },
    onUnknown: (generalPaymentAuth) {
      return Invoice({
        "@type": "error",
        "message": "payment_gateway_auth_type_bad_format",
      });
    },
  );
}