palbaseDocs

Palbase Payments · API

POST/payments/customers/{customer_id}/invoices

Invoice a payer

Makes an invoice for the payer at the channel's provider — Stripe's own invoice: its number, its page, its PDF and its e-mail are Stripe's — and, unless pay is false, charges it to the card named, or the payer's default card on the channel, with the payer away. Each line's net amount is its quantity times its unit_amount; with automatic_tax (the default) Stripe Tax computes the tax on top, from the payer's billing address. The payer's profile (name, address, tax id) is written on the provider's record first: Stripe copies it onto the invoice as it is finalized; an address or tax id the provider refuses — or, with automatic_tax, an address it cannot place or none at all — is answered with billing_address_invalid or tax_id_invalid, at every asking until the profile is put right, and nothing is made. collection_method send_invoice makes one the payer pays on its page (hosted_url), due days_until_due days later (30); send e-mails it. Answers 201 with the invoice: paid, or open when not charged yet. A card the payer's bank declines answers 402 with the card's decline code (and authentication_required for a card that asks for its holder's own confirmation, which the invoice's page can finish) and the invoice beside the error, still open: pay it again with another card. 409 provider_customer_gone for a payer whose record was deleted at the provider: it is let go of, and asked again a new one is made. 422 invoices_not_supported on a channel whose provider makes no invoice (iyzico); 409 invoice_permission_required when the channel may not write invoices (grant invoice write to its Stripe key, or accept the Stripe app's new permission); 422 method_required for a card's invoice with no card to charge. 503 provider_unavailable when its making was cut short at the provider: it is carried on, and asking again under the same Idempotency-Key answers it — made once, charged once. 409 invoice_in_progress while the same invoice is being made by another asking. A refusal (4xx) is not kept under the Idempotency-Key: asked again under it once what was refused is fixed, the invoice is made.

Called by your server, with the project's secret key.

Path

customer_idstring · requiredThe payer's id: a user id, or any name of 1 to 128 characters the project's server gives a company or a team. Escape it as a path segment.

Request body

channelstring · optionalThe channel to invoice on: the card's channel when `method_id` is named, else the project's routing (currency) and default.
currencystring · requiredISO 4217 currency code.
linesobject[] · required1 to 250 lines: what was sold, a card fee…
method_idstring · optionalThe saved card to charge (a card's invoice): the payer's default card on the channel when left out.
collection_methodstring · optionalcharge_automatically (a saved card is charged: the default) or send_invoice (paid on its page).
days_until_dueinteger · optionalsend_invoice: days after it is made that it is due, 0 to 365 (30).
automatic_taxboolean · optionalStripe Tax computes the tax on top of the lines (true).
payboolean · optionalA card's invoice is charged as it is made (true); false leaves it open, to pay later.
descriptionstring · optionalWhat the invoice is for, shown on it: up to 500 characters.
footerstring · optionalWords at its foot: up to 500 characters.
referencestring · optionalThe project's own reference: up to 255 characters.
metadataobject · optionalUp to 20 keys of the project's own (none starting palbase_), copied onto the provider's invoice.
curl
curl -X POST "https://<your-ref>.palbase.studio/payments/customers/<customer_id>/invoices" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"currency":"string","lines":[{"description":"string","unit_amount":0}]}'

Responses

201Invoice made

defaultStandard Palbase JSON error envelope (`error` and `error_description`).

Operation CreateCustomerInvoice of payments's contract.