Skip to main content

Creating an Invoice

HashMap<String, Object> invoiceData = new HashMap<>();
invoiceData.put("customer_id", 29); // Customer ID
invoiceData.put("date", "2024-01-15"); // Invoice date
invoiceData.put("line_items", Arrays.asList(
new HashMap<String, Object>() {{
put("item_name", "Consulting Service");
put("item_price", 200.00);
put("quantity", 5);
}}
));

int invoiceId = co.create(ChargeOver.Target.INVOICE, invoiceData);
if (invoiceId < 0) {
System.out.println(co.getLastError());
} else {
System.out.println("Created Invoice ID: " + invoiceId);
}