Payclave developers
Invoices
Draft, issue, send, remind, collect, and close itemized invoices.
Draft, review, and issue
Create an itemized draft with customer details and line items. Calculate the applicable tax in your application and supply the tax amounts. Review the totals, settlement destination, due date, and customer email before issuing the current version. An amount-only legacy request creates a payable invoice directly instead of an editable itemized draft.
A draft has a version. PATCH replaces the complete editable configuration, so omitted fields may be cleared. Re-read after INVOICE_VERSION_CONFLICT and merge the intended edit with the latest draft. Issued commercial fields are fixed.
Issue and send the invoice
Issue the current draft version to obtain its invoice number and hosted payment information. send:true also queues email to the supplied valid customer address. An email delivery is separate from payment confirmation. Keep the hostedInvoiceUrl from the response instead of constructing it from an internal ID.
Due dates, reminders, and remaining payments
The commercial due date and a checkout session's expiry are different. Read the invoice to find the current collectible remainder. A recovery checkout may reuse an active session and always uses the server-calculated remaining amount. Do not charge the original total again after a partial payment.
Reminder schedules need dueAt and can specify offsets before, on, and after the due date. Email operations have eligibility and cooldown rules. Inspect delivery records when an email fails rather than recreating the invoice.
Close collection without rewriting payment history
Void closes an unpaid invoice. Use void-remaining for an invoice with partial verified credit. Mark-uncollectible records the decision to stop collection. These actions do not reverse onchain transfers or send refunds.
Use the PDF endpoint for an authorized customer download; it returns PDF bytes rather than a JSON response. Use duplicate to create a new draft when commercial terms need to change, and issue that copy separately.
Itemized invoice fields
| Field | Contract |
|---|---|
walletId | Optional explicit active settlement wallet belonging to this merchant and key mode. Omit to use the default. Issued invoices freeze the wallet, token, and chain snapshot. |
lines | Required array of 1-100 items. Each item has description (1-500 UTF-8 bytes), quantity (positive decimal string), unitAmount (non-negative decimal string), and optional id and sku (up to 100 UTF-8 bytes). Numeric strings accept at most 6 fractional digits. |
customer | Object with optional name, email, company and billingAddress (string). A valid email is required to send or remind by email. Name and company are at most 200 UTF-8 bytes, email 320, billingAddress 1000 UTF-8 bytes. |
discount | Optional { type: 'fixed', amount } or { type: 'percentage', percentage }. Percentage is a decimal string between 0 and 100; discount cannot exceed subtotal. Use null to clear on draft replacement. |
taxes | Optional array of up to 100 lines with label, amount (non-negative decimal string), and optional id, jurisdiction, registrationReference. label is required and limited to 120 UTF-8 bytes; jurisdiction and registrationReference have the same limit. Supply calculated tax amounts; Payclave does not calculate jurisdictional tax rates. |
currencyCode | Optional USDC or USDT, defaulting to the mode's settlement token. A different configured token returns CURRENCY_MISMATCH. |
dueAt | Optional RFC 3339 timestamp or null. The invoice due date is separate from each checkout session's expiry. |
checkoutExpiresInMinutes | Optional integer from 5 to 1440, default 30. This is named differently from expiresInMinutes on direct checkout creation. |
paymentTerms, memo, footer, purchaseOrderNumber | Optional strings limited to 4000, 2000, 2000 and 100 UTF-8 bytes respectively. |
externalReference, metadata | Optional externalReference up to 255 UTF-8 bytes. metadata is a JSON object up to 16 KiB. Do not store secrets in metadata. |
successUrl, cancelUrl | Optional absolute HTTP or HTTPS return URLs without credentials, at most 2048 UTF-8 bytes each. Use HTTPS URLs you control. A return to successUrl is not proof of payment. |
reminderSchedule | Optional object: enabled, daysBeforeDue, onDue, daysAfterDue. daysBeforeDue and daysAfterDue are arrays of integer offsets from 1 to 30, with at most six entries combined. Enabled schedules require dueAt. With no timings specified, defaults are 3 days before, on the due date and 7 days after. |
issue, send | HTTP creation only: issue:true immediately issues the draft; send:true sends when issuing. With the server SDK 0.2.0, call createInvoiceDraft and then issueInvoice with send:true. |