Invoicing
Learn how to use Pluto's invoicing system to create requests for payment in the future.
Invoice lifecycle
Invoices start as open
, then can either be marked as void
, paid
, uncollectible
, past_due
.
open
: the invoice can be paidvoid
: the invoice was marked a mistake and is no longer validpaid
: a payment intent associated for the invoice has succeededpast_due
: the invoice has passed its due date, but can still be paiduncollectible
: the customer is unable to pay the invoice and is marked as invalid
Create an invoice
const { Pluto } = require('@plutohq/pluto-node');
const pluto = new Pluto(process.env.PLUTO_SECRET_KEY);
const invoice = await pluto.invoices.create({
price: '{{PRICE_ID}}',
customer: '{{CUSTOMER_ID}}',
line_items: [
{
price_data: {
amount: 1.5,
description: 'Setup cost',
},
},
],
});
Pay an invoice
You can allow users to pay invoices by using one of our client-side libraries, which will handle the creation of a payment intent for you. Since all transactions require a wallet signature, the generated payment intent must be confirmed on the client.
const transaction = await plutoJS.payInvoice('{{INVOICE_ID}}');
Alternatively, you can direct users to Pluto's invoice payment portal to provide this functionality without needing to write any code.
Void an invoice
Invoices can be voided or marked as uncollectible by updating their status. If it is a renewal invoice for a subscription, Pluto's billing engine will ignore the invoice. For more information on how this will impact the subscription, see here.
const { Pluto } = require('@plutohq/pluto-node');
const pluto = new Pluto(process.env.PLUTO_SECRET_KEY);
await pluto.invoices.update('{{INVOICE_ID}}', { status: 'void' });
Send notifications
To send notifications to pay an invoice before it’s due, you can enable the notify field. The customer specified on the invoice will be sent an email notification to pay every 3 days. This will repeat until the invoice’s due date has passed.
Updated 6 months ago