Shell Python Node PHP C# Ruby

Create an Invoice


curl "https://api.payload.co/invoices/" \
    -u secret_key_3bW9JMZtPVDOfFNzwRdfE: \
    -d "type=bill" \
    -d "due_date=2020-01-01" \
    -d "processing_id=acct_3bW9JMapnT7sw7neax7ui" \
    -d "items[0][type]=item1" \
    -d "items[0][amount]=29.99" \
    -d "items[0][entry_type]=charge" \
    -d "customer_id=acct_3bW9JMoGYQul5fCIa9f8q"
invoice = pl.Invoice.create(
    items=[pl.ChargeItem(entry_type='charge', amount=100)],
    due_date='2020-01-01',
    customer_id='acct_3bsVUMvAUV8AdvbFWVSWD',
    processing_id='acct_3bz0zU99AX06SJwfMmfn0',
)
invoice = Payload::Invoice.create(
    type: 'bill',
    processing_id: 'acct_3bz0zU99AX06SJwfMmfn0',
    due_date: '2020-01-01',
    items: [
        Payload::ChargeItem.new(
            type: 'item1',
            amount: 29.99
        )
    ],
    customer_id: 'acct_3bW9JMoGYQul5fCIa9f8q'
)
<?php
$invoice = Payload\Invoice::create(array(
    'type' => 'bill',
    'processing_id' => 'acct_3c0EVDZYsO4lVTVGwoX89',
    'due_date' => '2020-01-01',
    'items' => array(
        new Payload\LineItem(array(
            'entry_type' => 'charge',
            'amount' => 29.99
        ))
    ),
    'customer_id' => 'acct_3bzs0vKOQllhhooaG0omz'
));
?>
const inv = await pl.Invoice.create({
    type: 'bill',
    processing_id: 'acct_3bW9JMapnT7sw7neax7ui',
    due_date: '2020-01-01',
    items: [
        new pl.ChargeItem({
            type: 'item1',
            amount: 29.99
        })
    ],
    customer_id: 'acct_3bW9JMoGYQul5fCIa9f8q'
})
var invoice = await pl.Invoice.CreateAsync(new {
    type = "bill",
    processing_id = "acct_3bW9JMapnT7sw7neax7ui",
    due_date = "2020-01-01",
    items = new[] {
        new pl.ChargeItem(new{
            type="item1",
            amount=29.99
        })
    },
    customer_id = "acct_3bW9JMoGYQul5fCIa9f8q"
});

Invoicing is a simple way to create and track orders, and send payment requests. At the core, an invoice has a due date, an associated processing account for routing funds, line item charges, and an associated customer.

Draft mode

New invoices will have a default initial status of unpaid and be able to accept a payment but you can also create an invoice in draft mode by initializing the invoice with a status of draft. An invoice in draft mode will prevent any payment attempts until it's been finalized. Once an invoice in draft mode is ready for payment, update the status to open to take the invoice out of draft mode.

Line items

Line items can be positive or negative values. The entry_type of a line item can be either a charge or a payment. There are separate type and description fields which can be used to identify the line item.

Line items can accept a variable quantity with the qty attribute. This defaults to 1 if no qty is specified.

For a complete list of all available attributes, see the Line Item API reference.

Charge type

An entry_type of charge refers to an incurred amount or discount by the biller. This is a standard line item type used when creating an invoice to specify the items and amounts owed.

Payment type

An entry_type of payment is reserved for payments from a customer and is associated with a transaction. To learn how to associate a payment to an invoice, see the next section pay an invoice.