Billing
Hosted Billing Page
Give your customers a branded portal to view their invoices, payment history, and subscriptions, with no login required.
Overview
The Hosted Billing Page gives each customer a secure, tokenized URL. When the customer visits the link, they see a page branded with your business name, logo, and color, with four tabs: Overview, Invoices, Payments, and Subscriptions. No account or login is needed. The same token also authorizes two customer actions through the API: changing a subscription plan and exporting payment history.
Token-based access
256-bit tokens with the hbp_ prefix
Merchant branding
Logo, brand color, business name
Customer portal
Invoices, payments, subscriptions, plan change, export
Generate a token
curl -X POST https://paymenthooks.com/api/v1/billing-page/tokens \
-H "Authorization: Bearer phk_live_..." \
-H "Content-Type: application/json" \
-d '{"customerId": "ph_cus_8d2f6a1c3e5b7d9f0a2c4e6b8d1f3a5c"}'Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| customerId | string | Yes | The customer the billing page is for. Must exist. |
| expiresAt | string | No | ISO 8601 expiry. Omit or pass null for a token that never expires. |
| businessEntityId | string | No | The business the page shows and sells under. Plan changes offer only that business's products. With an API key that belongs to a business, that business is used (another one returns 422 BUSINESS_MISMATCH). Omit with an account-wide key to use the business of the customer's purchases. |
| returnUrl | string | No | Where the page's Back link goes: your page the customer came from (absolute https URL). Without it, Back goes to the referring site, else the business's website. 400 VALIDATION_ERROR when it is not https. |
Billing page URL
Create and list responses include billingPageUrl. Send it to the customer as-is:
https://paymenthooks.com/billing/{token}The page loads its data from GET /v1/billing-page/resolve?token=.... If the token is unknown, revoked, or expired, the page shows the corresponding error message instead of billing data.
Back button
The page shows a Back to {site} link above the business header. Its destination is, in this order:
returnUrlsent when the token was created (your account page, for example). Must be an absolutehttpsURL; anything else returns400 VALIDATION_ERROR.- The site the customer arrived from (the browser's referrer), when it is another https site. It is kept for the browser tab, so it survives a refresh or a visit to a receipt. Browsers send only the origin across sites by default, so the link usually returns to your site's home page.
- The business's website (Settings > Businesses), or your account's when the page has no business.
When none of these is available, no Back link is shown. A receipt opened from the Payments tab has its own Back to billing link to the billing page.
curl https://paymenthooks.com/api/v1/billing-page/tokens -H "Authorization: Bearer phk_live_..." -H "Content-Type: application/json" -d '{"customerId": "ph_cus_8d2f6a1c3e5b7d9f0a2c4e6b8d1f3a5c", "returnUrl": "https://example.com/account/billing"}'Endpoints & Responses
Token management endpoints use your secret key (Authorization: Bearer phk_live_...). Resolve, change-plan, and export are public and authenticated by the billing token. All responses use the { data, error } envelope except the CSV export.
/v1/billing-page/tokensCreate a billing page token for a customer. Returns 201. 400 VALIDATION_ERROR if customerId is missing; 404 NOT_FOUND if the customer does not exist.{
"customerId": "ph_cus_8d2f6a1c3e5b7d9f0a2c4e6b8d1f3a5c",
"expiresAt": "2026-06-16T00:00:00.000Z"
}{
"data": {
"id": "ph_bpt_1a2b3c4d5e6f708192a3b4c5d6e7f809",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"customerId": "ph_cus_8d2f6a1c3e5b7d9f0a2c4e6b8d1f3a5c",
"token": "hbp_3f9a1c7e5b2d4f6a8c0e1b3d5f7a9c1e3b5d7f9a1c3e5b7d9f1a3c5e7b9d1f3a",
"status": "active",
"expiresAt": "2026-06-16T00:00:00.000Z",
"lastAccessedAt": null,
"accessCount": 0,
"createdAt": "2026-05-16T10:30:00.000Z",
"updatedAt": "2026-05-16T10:30:00.000Z",
"billingPageUrl": "https://paymenthooks.com/billing/hbp_3f9a1c7e5b2d4f6a8c0e1b3d5f7a9c1e3b5d7f9a1c3e5b7d9f1a3c5e7b9d1f3a"
},
"error": null
}/v1/billing-page/tokens?customerId=ph_cus_8d2f6a1c3e5b7d9f0a2c4e6b8d1f3a5cList all of your tokens, newest first, including revoked and expired ones. Optional filter: customerId. Not paginated.{
"data": {
"items": [
{
"id": "ph_bpt_1a2b3c4d5e6f708192a3b4c5d6e7f809",
"customerId": "ph_cus_8d2f6a1c3e5b7d9f0a2c4e6b8d1f3a5c",
"token": "hbp_3f9a1c7e5b2d4f6a8c0e1b3d5f7a9c1e3b5d7f9a1c3e5b7d9f1a3c5e7b9d1f3a",
"status": "active",
"expiresAt": "2026-06-16T00:00:00.000Z",
"lastAccessedAt": "2026-05-15T14:22:00.000Z",
"accessCount": 5,
"createdAt": "2026-05-16T10:30:00.000Z",
"billingPageUrl": "https://paymenthooks.com/billing/hbp_3f9a1c7e5b2d4f6a8c0e1b3d5f7a9c1e3b5d7f9a1c3e5b7d9f1a3c5e7b9d1f3a"
}
],
"total": 1
},
"error": null
}/v1/billing-page/tokens/:idRevoke a token by its id (not the token string). The token status becomes revoked and the link stops working immediately.{
"data": { "revoked": true },
"error": null
}/v1/billing-page/resolve?token=hbp_...Public, no auth; the token is the credential. Each successful call increments accessCount and sets lastAccessedAt. Up to 100 most recent invoices, payments, and subscriptions are returned. Errors: 404 TOKEN_INVALID (unknown), 410 TOKEN_INVALID (revoked or expired).{
"data": {
"merchant": {
"businessName": "Acme Corp",
"logoUrl": "/api/v1/brand-assets/ph_bra_9e3b7d1f5a2c6e0b4d8f2a6c0e4b8d1f?v=3f1a2c",
"brandColor": "#4D5AFF",
"logoDisplay": "logo_and_name"
},
"customer": {
"id": "ph_cus_8d2f6a1c3e5b7d9f0a2c4e6b8d1f3a5c",
"name": "Jane Doe",
"email": "[email protected]"
},
"invoices": [
{
"id": "ph_inv_2b4d6f8a0c1e3b5d7f9a2c4e6b8d0f1a",
"invoiceNumber": "INV-0042",
"status": "paid",
"itemLocalCurrencyAmount": 2990,
"itemLocalCurrency": "USD",
"dueDate": "2026-05-01T00:00:00.000Z",
"paidAt": "2026-04-28T10:00:00.000Z",
"createdAt": "2026-04-20T09:00:00.000Z"
}
],
"payments": [
{
"id": "ph_pay_0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f",
"transactionLocalCurrencyAmount": 2990,
"transactionLocalCurrency": "USD",
"status": "success",
"description": "Pro Plan",
"gateway": "gw_stripe",
"createdAt": "2026-04-28T10:00:00.000Z"
}
],
"subscriptions": [
{
"id": "ph_sub_6e8a2c4f0b1d3e5a7c9b2d4f6a8c0e1b",
"productName": "Pro Plan",
"status": "active",
"itemLocalCurrencyAmount": 2990,
"itemLocalCurrency": "USD",
"interval": "month",
"currentPeriodEnd": "2026-06-01T00:00:00.000Z",
"createdAt": "2026-04-01T00:00:00.000Z"
}
],
"summary": {
"totalSpendAmountUsdCents": 2990,
"openInvoices": 0,
"activeSubscriptions": 1
}
},
"error": null
}/v1/billing-page/change-planPublic, token-authenticated. Switches one of the customer's active or trialing subscriptions to another of your recurring prices in the same currency, with real proration measured on the exact remaining fraction of the current period. A changed interval or intervalCount resets the billing anchor: the unused old-plan time is credited and a full new period is billed from now. Downgrade (net < 0): the plan switches immediately (status "switched"), a credit note for the net credit is issued (itemLocalCurrencyAmount in the subscription's itemLocalCurrency, with itemAmountUsdCents) and the credit is added to the subscription's credit balance, which the next renewals use up before the gateway is charged (a renewal fully covered by credit is not charged at all). Upgrade (net > 0): an invoice for the prorated difference is created in the subscription's itemLocalCurrency. If the subscription has an off-session mandate (CCAvenue SI) the difference is charged now and the plan switches only when the charge succeeds; a declined charge voids the invoice, leaves the plan unchanged and returns 402 PAYMENT_FAILED. Otherwise the call returns 202 with status "payment_required", invoiceId, prorationNetLocalCurrencyAmount and a hosted paymentUrl (/checkout/{sessionId}) for the exact amount, with prorationApplied: false; the plan switches when that checkout is paid. Repeating the request for the same price while payment is pending returns the same invoice and paymentUrl (idempotent); an expired pending checkout is voided automatically. Trialing subscriptions switch without proration. Errors: 400 VALIDATION_ERROR (missing fields or same price), 401 TOKEN_INVALID, 402 PAYMENT_FAILED, 404 NOT_FOUND, 409 CONFLICT (changed concurrently) or PLAN_CHANGE_PENDING (another change awaits payment), 422 INVALID_STATE (subscription not active or trialing, price not recurring, different currency, or unsupported interval), 502 SCHEDULING_FAILED (billing could not be rescheduled; the plan is not changed).{
"token": "hbp_...",
"subscriptionId": "ph_sub_6e8a2c4f0b1d3e5a7c9b2d4f6a8c0e1b",
"newPriceId": "ph_pri_9c1e5a3d7b0f2c4e6a8d1b3f5c7e9a2d"
}{
"data": {
"status": "switched",
"subscriptionId": "ph_sub_6e8a2c4f0b1d3e5a7c9b2d4f6a8c0e1b",
"previousPriceId": "ph_pri_9c1e5a3d7b0f2c4e6a8d1b3f5c7e9a2d",
"newPriceId": "ph_pri_3a9e5c7b1d2f4a6c8e0b2d4f6a8c1e3b",
"newProductName": "Starter Plan",
"prorationCreditLocalCurrencyAmount": 2500,
"prorationDebitLocalCurrencyAmount": 1000,
"prorationNetLocalCurrencyAmount": -1500,
"itemLocalCurrency": "USD",
"itemLocalCurrencyAmount": 2000,
"itemAmountUsdCents": 2000,
"itemUsdToLocalCurrencyRate": 1,
"interval": "month",
"intervalCount": 1,
"billingAnchorReset": false,
"effectiveAt": "2026-05-16T12:00:00.000Z",
"prorationApplied": true,
"invoiceId": "ph_inv_51c0a3e7b9d2f4c6a8e0b1d3f5a7c9e2",
"creditNote": { "id": "ph_crn_8d2f4b6a0c3e5f7a9b1d2c4e6f8a0b3d", "creditNoteNumber": "CN-MB7K2-X9QD", "itemAmountUsdCents": 1500 },
"creditBalance": 1500
},
"error": null
}/v1/billing-page/plan-options?token=hbp_...&subscriptionId=ph_sub_6e8a2c4f0b1d3e5a7c9b2d4f6a8c0e1bPublic, token-authenticated. The prices the customer may switch an active or trialing subscription to (your active, licensed, recurring prices of active products in the subscription's itemLocalCurrency, other than the current one), each with a proration preview for a change made now, computed exactly as change-plan bills it. Amounts are in itemLocalCurrency, smallest unit. prorationDueLocalCurrencyAmount includes the subscription's tax: positive is charged before the switch, negative is credited, 0 switches with nothing billed. pendingPayment marks an upgrade already awaiting payment. Errors: 400 VALIDATION_ERROR, 401 TOKEN_INVALID, 404 NOT_FOUND, 422 INVALID_STATE (subscription not active or trialing).{
"data": {
"subscriptionId": "ph_sub_6e8a2c4f0b1d3e5a7c9b2d4f6a8c0e1b",
"options": [{
"priceId": "ph_pri_3a9e5c7b1d2f4a6c8e0b2d4f6a8c1e3b",
"productName": "Pro Plan",
"priceLabel": "Monthly",
"itemLocalCurrency": "USD",
"itemLocalCurrencyAmount": 4900,
"interval": "month",
"intervalCount": 1,
"prorationCreditLocalCurrencyAmount": 1000,
"prorationDebitLocalCurrencyAmount": 2450,
"prorationNetLocalCurrencyAmount": 1450,
"prorationDueLocalCurrencyAmount": 1450,
"billingAnchorReset": false,
"pendingPayment": false
}]
},
"error": null
}/v1/billing-page/cancelPublic, token-authenticated. Cancels one of the customer's subscriptions. cancelAtPeriodEnd defaults to true: the subscription stays active until currentPeriodEnd and is not renewed. false cancels now: renewals stop, the automatic-payment authorisation is cancelled and, when Settings > Subscriptions > Prorate on change is on, the unused time is credited (cancellationCredit). Sends subscription.cancelled and the customer's cancellation email, like the subscriptions cancel API. Refused with 403 FORBIDDEN when Settings > Subscriptions > Allow self-cancellation is off; resolve returns selfService.cancelAllowed so the page can hide the action. Errors: 400 VALIDATION_ERROR, 401 TOKEN_INVALID, 403 FORBIDDEN, 404 NOT_FOUND, 422 INVALID_STATE (already cancelled, or already ending at period end).{
"token": "hbp_...",
"subscriptionId": "ph_sub_6e8a2c4f0b1d3e5a7c9b2d4f6a8c0e1b",
"cancelAtPeriodEnd": true
}{
"data": {
"subscriptionId": "ph_sub_6e8a2c4f0b1d3e5a7c9b2d4f6a8c0e1b",
"status": "active",
"cancelAtPeriodEnd": true,
"currentPeriodEnd": "2026-12-01T00:00:00.000Z",
"cancelledAt": null
},
"error": null
}/v1/billing-page/export?token=hbp_...&format=csvPublic, token-authenticated. Downloads the customer's payment history as an attachment. format is csv (default) or json. Every payment is included (not capped at 100). Each row has Amount and Currency (what the customer was charged, in major units of that currency, e.g. 29.90 USD; zero-decimal currencies such as JPY have no decimals) and Amount (USD), the same charge in US dollars. Errors as for resolve, plus 400 VALIDATION_ERROR for an invalid format.Date,Description,Amount,Currency,Amount (USD),Status,Reference 2026-04-28T10:00:00.000Z,Pro Plan,29.90,USD,29.90,success,ph_pay_0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f
Customer view
The billing page renders your branding and four read-only tabs:
OverviewSummary metrics (total spent: payments net of refunds, in USD; open invoices; active subscriptions) plus recent invoices and paymentsInvoicesIssued invoices (drafts are never shown) with number, status, total, due date, and paid date; Pay invoice on an open Pay once renewal invoicePaymentsPayment history with description, gateway, amount, and status, a receipt link for every captured payment (a refunded or charged-back payment's receipt is marked with the amount and date returned), and an Export CSV buttonSubscriptionsSubscriptions with product name, amount, interval, current period end and payment method, with Change plan (proration shown before confirming), Set up automatic payments or Update payment method when needed, Pause / Resume when you allow pause, and Cancel subscription (at period end or now) when you allow self-cancellationCreditCredit balance per currency and the customer's credit notesRevoke a token
Call DELETE /v1/billing-page/tokens/:id with the token's id (ph_bpt_...), not the hbp_ token string. A revoked token is deleted: it no longer appears in the list, and the page and every billing page action answer it as an unknown token. Creating a new token for the same customer also replaces (deletes) their previous one. Issuing and revoking are recorded in the API request log.
curl -X DELETE https://paymenthooks.com/api/v1/billing-page/tokens/ph_bpt_1a2b3c4d5e6f708192a3b4c5d6e7f809 \
-H "Authorization: Bearer phk_live_..."Payment reminders
Payment reminder, subscription renewal reminder, and dunning emails sent by PaymentHooks carry a billing page link for the customer. PaymentHooks reuses the customer's newest active, unexpired token, or creates a new non-expiring token if none exists. Those tokens appear in the list endpoint and can be revoked like any other.
Hosted invoice page
Every invoice that has been sent has its own page where the customer views it, downloads the PDF and pays it, with no login. The link is signed for that one invoice and cannot be derived from the invoice id. The page always shows the invoice as it is stored now, so a paid or voided invoice can never be paid again. It is served on your business's custom domain when you have one.
https://paymenthooks.com/invoice/{invoiceId}-{signature}- Invoice webhooks carry it as
hosted_invoice_urland the PDF asinvoice_pdf(bothnullfor a draft). GET /v1/invoices/:idreturns it ashostedInvoiceUrl; the dashboard shows it on the invoice with Copy and Open.- The invoice, reminder and overdue emails link to it with a "View and pay invoice" button.
Revoking a link. The link does not expire. If it reached the wrong person, use Revoke link on the invoice in the dashboard, or DELETE /v1/invoices/:id/hosted-link (scope invoices:write). Every link sent so far, including its PDF link, then opens "Invoice unavailable" (404), and the response returns the new link. From then on the emails, hosted_invoice_url / invoice_pdf on webhooks and hostedInvoiceUrl carry the new link; send it to the customer again yourself if they still need it. A revoke cannot be undone and is recorded in the activity log as invoice.hosted_link_revoked. GET /v1/invoices/:id/hosted-link (scope invoices:read) returns the current link. A draft has no link (404).
Payopens the hosted checkout for the amount due. The checkout picks the charge currency like any other: the customer's regional currency when the payment method supports it, else USD, else the invoice currency. The invoice is marked paid when the payment succeeds, and invoice.paid is sent.
An invoice counts one payment. A payment that arrives after the invoice was already paid (by another payment, by customer credit or with Mark as Paid) or voided, for example from a checkout left open in a second tab, is refunded in full automatically through the gateway that took it, the same way as POST /v1/payments/:id/refund: the customer gets the refund confirmation, you get a dashboard notice and an email, and payment.refundedis sent with the payment's metadata below. The same applies to Pay once renewal invoices and plan-change upgrade invoices. The payment's metadata records duplicateOfInvoiceId, duplicateOfInvoiceNumber, duplicateReason (invoice_already_paid, invoice_void or invoice_cancelled), duplicateOfPaymentId when another payment paid it, and duplicateRefund (pending until the refund succeeds, then refunded). If the gateway refuses the refund you are alerted once, the payment keeps refundRequired: "true" and duplicateRefundError, and the refund is retried automatically. The payment is refunded once, however many times its confirmation arrives.
GET /v1/hosted-invoices/{token}The invoice as the page shows it: lines, tax rows, total, customer credit applied, amount due (itemLocalCurrency), due date, state (open, overdue, paid, void). 404 for a draft, a forged token or a revoked link.GET /v1/hosted-invoices/{token}/pdfThe invoice PDF, the same document invoice emails attach.POST /v1/hosted-invoices/{token}/paySpends customer credit first, then returns { kind: "checkout", checkoutUrl } for the amount still due, or { kind: "paid" } when credit covered it. 409 INVALID_STATE for a paid or voided invoice.Invoice settings and customer credit
GET/PUT /v1/invoice-settings(scopesinvoices:read/invoices:write):numberPrefix,nextNumber(forward only),defaultDueDays,defaultNotes,footer,attachPdf,autoApplyCredit. The response addsnextInvoiceNumber.POST /v1/invoices:dueDateis optional (issue date +defaultDueDays);notesdefault todefaultNotes.- Customer credit in the invoice currency is recorded on the invoice as
itemCustomerBalanceLocalCurrencyAmount/itemCustomerBalanceAmountUsdCents. WithautoApplyCreditit is spent when the invoice is sent and when it is paid on the hosted page; credit that covers the invoice pays it. POST /v1/invoices/:id/apply-creditapplies it on demand (409 for a settled or renewal invoice). Webhookamount_dueis net of credit andstarting_balanceis the credit as a negative amount.