createInvoice method

Future<Invoice> createInvoice({
  1. String forUserId = "",
  2. String withFeeRule = "",
  3. required String external_id,
  4. required int amount,
  5. String? description,
  6. String? payer_email,
  7. Map? customer,
  8. Map? customer_notification_preference,
  9. int? invoice_duration,
  10. String? success_redirect_url,
  11. String? failure_redirect_url,
  12. List<String>? payment_methods,
  13. String? currency,
  14. bool? fixed_va,
  15. String? callback_virtual_account_id,
  16. String? mid_label,
  17. String? reminder_time_unit,
  18. int? reminder_time,
  19. String? locale,
  20. List? items,
  21. List? fees,
  22. bool? should_authenticate_credit_card,
  23. Map<String, String>? headers,
  24. required GeneralPaymentAuth generalPaymentAuth,
})

Implementation

Future<Invoice> createInvoice({
  String forUserId = "",
  String withFeeRule = "",
  required String external_id,
  required int amount,
  String? description,
  String? payer_email,
  Map<dynamic, dynamic>? customer,
  Map<dynamic, dynamic>? customer_notification_preference,
  int? invoice_duration,
  String? success_redirect_url,
  String? failure_redirect_url,
  List<String>? payment_methods,
  String? currency,
  bool? fixed_va,
  String? callback_virtual_account_id,
  String? mid_label,
  String? reminder_time_unit,
  int? reminder_time,
  String? locale,
  List<dynamic>? items,
  List<dynamic>? fees,
  bool? should_authenticate_credit_card,
  Map<String, String>? headers,
  required GeneralPaymentAuth generalPaymentAuth,
}) async {
  return await paymentInvokeBuilder(
    generalPaymentAuth: generalPaymentAuth,
    onXendit: (generalPaymentAuth) async {
      final result = await xendit.createInvoice(
        xenditApiKey: generalPaymentAuth.apiKey,
        external_id: external_id,
        amount: amount,
        forUserId: forUserId,
        failure_redirect_url: failure_redirect_url,
        fees: fees,
        fixed_va: fixed_va,
        withFeeRule: withFeeRule,
        payer_email: payer_email,
        reminder_time: reminder_time,
        reminder_time_unit: reminder_time_unit,
        success_redirect_url: success_redirect_url,
        invoice_duration: invoice_duration,
        items: items,
        payment_methods: payment_methods,
        customer_notification_preference: customer_notification_preference,
        should_authenticate_credit_card: should_authenticate_credit_card,
        callback_virtual_account_id: callback_virtual_account_id,
        description: description,
        headers: headers,
        locale: locale,
        mid_label: mid_label,
        currency: currency,
        customer: customer,
      );

      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",
      });
    },
  );
}