Collect Invoice
Authentication
Bearer authentication of the form Bearer <token>, where token is your auth token.
Bearer authentication of the form Bearer <token>, where token is your auth token.
Collect payment on an invoice.
Called by the Restate workflow handler for:
Handles invoices in DRAFT, OPEN, or PAST_DUE state. DRAFT invoices are finalized before processor attempt.
Requirements:
Headers:
Returns (200 OK - Payment Succeeded):
Returns (402 Payment Required - Payment Failed):
invoice_id: ID of the invoice
invoice_status: “past_due” or “open” (invoice not paid)
subscription_id: ID of linked subscription (if any)
payment_status: “failed”, “requires_action”, “no_payment_method”, “skipped”, “on_session_checkout_invoice”, “hard_cap_exceeded”, or “subscription_cancelled”
The last three answer 402 because nothing was collected:
payment_error: Detailed processor decline reason (e.g., “Insufficient funds”, “Card declined”)
error_message: Same as payment_error (deprecated, kept for backward compatibility)
orchestrator_summary: High-level summary (e.g., “All payment methods exhausted”)
is_dunning: Whether this was a dunning retry attempt
dunning_attempt: Dunning attempt number (0 = first attempt)
Returns (200 OK - Collection Deferred, payment_status “au_deferred”):
Returns (200 OK - Collection Suppressed, payment_status “duplicate_suppressed”):
CRITICAL for one-time product purchases:
Only grant product access/credits when payment_status is “paid” or
“processing”. HTTP 200 alone is not enough: “au_deferred”, “too_early”,
“stale_trigger” and “duplicate_suppressed” all return 200 and all mean no money
moved. Never grant access on HTTP 402 (payment failed).