diff --git a/docs/_partials/billing/add-new-payment-method.mdx b/docs/_partials/billing/add-new-payment-method.mdx
index 80e5bde2f6..7a310509e0 100644
--- a/docs/_partials/billing/add-new-payment-method.mdx
+++ b/docs/_partials/billing/add-new-payment-method.mdx
@@ -3,80 +3,162 @@ The following example demonstrates how to create a billing page where a user can
- **`
+ Hello, {userId}! Your current active session is {sessionId}. +
+ ++ Hello, {userId}! Your current active session is {sessionId}. +
+ ++ Hello, {userId}! Your current active session is {sessionId}. +
+ ++ Hello, {userId}! Your current active session is {sessionId}. +
+ + + {data &&{JSON.stringify(data, null, 2)}}
+ + Hello, {userId}! Your current active session is {sessionId}. +
+ ++ Hello, {userId}! Your current active session is {sessionId}. +
+ +[BillingPaymentMethodResource](/docs/reference/javascript/types/billing-payment-method-resource) | null
-
- The payment source being used for the checkout.
-
- ---
-
- - `plan`
- - [BillingPlanResource](/docs/reference/javascript/types/billing-plan-resource) | null
-
- The subscription plan details for the checkout.
-
- ---
-
- - `planPeriod`
- - `'month' | 'annual' | null`
-
- The billing period for the plan.
-
- ---
-
- - `planPeriodStart`
- - `number | undefined`
-
- The start date of the plan period, represented as a Unix timestamp.
-
- ---
-
- - `status`
- - `'needs_initialization' | 'needs_confirmation' | 'completed'`
-
- The current status of the checkout session. The following statuses are possible:
-
- - `needs_initialization`: The checkout hasn't started but the hook is mounted. Call `start()` to continue.
- - `needs_confirmation`: The checkout has been initialized and is awaiting confirmation. Call `confirm()` to continue.
- - `completed`: The checkout has been successfully confirmed. Call `finalize()` to complete the checkout.
-
- ---
-
- - `totals`
- - [`BillingCheckoutTotals`](/docs/reference/javascript/types/billing-checkout-totals)
-
- The total costs, taxes, and other pricing details.
-
- ---
-
- - `isImmediatePlanChange`
- - `boolean`
-
- A boolean that indicates if the plan change will take effect immediately.
-
- ---
-
- - `isStarting`
- - `boolean`
-
- A boolean that indicates if the `start()` method is in progress.
-
- ---
-
- - `isConfirming`
- - `boolean`
-
- A boolean that indicates if the `confirm()` method is in progress.
-
- ---
-
- - `error`
- - [ClerkAPIResponseError](/docs/reference/javascript/types/clerk-api-response-error) | null
-
- Returns an error object if any part of the checkout process fails.
-
- ---
-
- - `fetchStatus`
- - `'idle' | 'fetching' | 'error'`
-
- The data fetching status.
-
- ---
-
- - `start()`
- - `() => Promise<{ data: BillingCheckoutResource; error: null; } | { data: null; error: ClerkAPIResponseError; }>`
-
- A function that initializes the checkout process by creating a checkout resource on the server.
-
- ---
-
- - `confirm()`
- - `(params: ConfirmCheckoutParams) => Promise<{ data: BillingCheckoutResource; error: null; } | { data: null; error: ClerkAPIResponseError; }>`
-
- A function that confirms and finalizes the checkout process, usually after the user has provided and validated payment information.
-
- ---
-
- - `finalize()`
- - `(params?: { navigate?: SetActiveNavigate }) => void`
-
- A function that finalizes the checkout process. Can optionally accept a `navigate()` function to redirect the user after completion.
-
- ---
-
- - `clear()`
- - `() => void`
-
- A function that clears the current checkout state from the cache.
-You are about to subscribe to our monthly plan
-You are about to subscribe to our monthly plan
+You are about to subscribe to our monthly plan
+Error: {error.errors[0].message}
} +Error: {error.errors[0].message}
} -Error: {error.errors[0].message}
} +| Org name | -|
|---|---|
| {inv.emailAddress} | -{inv.publicOrganizationData.name} | -
[BillingPaymentResource](/docs/reference/javascript/types/billing-payment-resource)\[] | null
-
- An array of payment attempts, or `null` if the data hasn't been loaded yet.
-
- ---
-
- - `isLoading`
- - `boolean`
-
- A boolean that is `true` if there is an ongoing request and there is no fetched data.
-
- ---
-
- - `isFetching`
- - `boolean`
-
- A boolean that is `true` if there is an ongoing request or a revalidation.
-
- ---
-
- - `hasNextPage`
- - `boolean`
-
- A boolean that indicates if there are available pages to be fetched.
-
- ---
-
- - `hasPreviousPage`
- - `boolean`
-
- A boolean that indicates if there are available pages to be fetched.
+() => void
-
- A function that triggers the next page to be loaded. This is the same as `fetchPage(page => Math.min(pageCount, page + 1))`.
-
- ---
-
- - `fetchPrevious`
- - () => void
-
- A function that triggers the previous page to be loaded. This is the same as `fetchPage(page => Math.max(0, page - 1))`.
-
- ---
-
- - `pageCount`
- - `number`
-
- The total amount of pages. It is calculated based on `count`, `initialPage`, and `pageSize`.
-
- ---
-
- - `count`
- - `number`
-
- The total number of payment attempts available.
-
- ---
-
- - `error`
- - [ClerkAPIResponseError](/docs/reference/javascript/types/clerk-api-response-error) | null
-
- Returns an error object if any part of the process fails.
-
- ---
+## Examples
- - `fetchPage`
- - `(page: number) => void`
+### Basic usage
- A function that triggers a specific page to be loaded.
+The following example demonstrates how to fetch and display a user's payment attempts.
- ---
+() => Promise\
+ export default function PaymentAttemptsList() {
+ const { data, isLoading } = usePaymentAttempts({
+ for: 'user',
+ pageSize: 10,
+ })
- A function that triggers a revalidation of the current page.
+ if (isLoading) {
+ return | Payment ID | +Amount | +Status | +Date | +Payment Method | +
|---|---|---|---|---|
| {attempt.id} | +{attempt.amount.amountFormatted} | +{attempt.status} | +{attempt.paidAt ? new Date(attempt.paidAt).toLocaleDateString() : '-'} | ++ {attempt.paymentSource.cardType} ****{attempt.paymentSource.last4} + | +
| Payment ID | -Amount | -Status | -Date | -Payment Method | -|||||
|---|---|---|---|---|---|---|---|---|---|
| {attempt.id} | -{attempt.amount.amountFormatted} | -{attempt.status} | -{attempt.paidAt ? new Date(attempt.paidAt).toLocaleDateString() : '-'} | -- {attempt.paymentSource.cardType} ****{attempt.paymentSource.last4} - | + return ( +
| Payment ID | +Amount | +Status | +Date | +Payment Method |
|---|
[BillingPaymentMethodResource](/docs/reference/javascript/types/billing-payment-method-resource)\[] | null
-
- An array of [payment methods](/docs/reference/javascript/types/billing-payment-method-resource), or `null` if the data hasn't been loaded yet.
+[`BillingPlanResource[]`](/docs/reference/javascript/types/billing-plan-resource) | null
-
- An array of [plans](/docs/reference/javascript/types/billing-plan-resource), or `null` if the data hasn't been loaded yet.
-
- ---
-
- - `isLoading`
- - `boolean`
-
- A boolean that indicates whether the initial data is still being fetched.
-
- ---
-
- - `isFetching`
- - `boolean`
-
- A boolean that indicates whether any request is still in flight, including background updates.
-
- ---
-
- - `hasNextPage`
- - `boolean`
-
- A boolean that indicates whether there are more pages available to load.
-
- ---
-
- - `hasPreviousPage`
- - `boolean`
-
- A boolean that indicates whether there are previous pages available to load.
-
- ---
-
- - `fetchNext`
- - `() => Promise{plan.description}
-Is free plan: {!plan.hasBaseFee ? 'Yes' : 'No'}
-- Price per month: {plan.currency} {plan.amountFormatted} -
-- Price per year: {plan.currency} {plan.annualAmountFormatted} equivalent to{' '} - {plan.currency} {plan.annualMonthlyAmountFormatted} per month -
-{plan.description}
+Is free plan: {!plan.hasBaseFee ? 'Yes' : 'No'}
++ Price per month: {plan.currency} {plan.amountFormatted} +
++ Price per year: {plan.currency} {plan.annualAmountFormatted} equivalent to{' '} + {plan.currency} {plan.annualMonthlyAmountFormatted} per month +
+{plan.description}
+Is free plan: {!plan.hasBaseFee ? 'Yes' : 'No'}
++ Price per month: {plan.currency} {plan.amountFormatted} +
++ Price per year: {plan.currency} {plan.annualAmountFormatted} equivalent to{' '} + {plan.currency} {plan.annualMonthlyAmountFormatted} per month +
+{plan.description}
+Is free plan: {!plan.hasBaseFee ? 'Yes' : 'No'}
++ Price per month: {plan.currency} {plan.amountFormatted} +
++ Price per year: {plan.currency} {plan.annualAmountFormatted} equivalent to{' '} + {plan.currency} {plan.annualMonthlyAmountFormatted} per month +
+(\{ complete, cancel, level }: [NeedsReverificationParameters](#needs-reverification-parameters)) => void
-
- Handler for the reverification process. Opts out of using the default UI. Use this to build a custom UI.
-Welcome back. You've been here {sessions.length} times before.
+Welcome back. You've been here {sessions.length} times before.
+Welcome back. You've been here {sessions.length} times before.
+Welcome back. You've been here {sessions.length} times before.
+Welcome back. You've been here {sessions.length} times before.
+This session has been active since {session.lastActiveAt.toLocaleString()}
+This session has been active since {session.lastActiveAt.toLocaleString()}
+This session has been active since {session.lastActiveAt.toLocaleString()}
+This session has been active since {session.lastActiveAt.toLocaleString()}
+This session has been active since {session.lastActiveAt.toLocaleString()}
+[BillingStatementResource](/docs/reference/javascript/types/billing-statement-resource)\[] | null
-
- An array of statements, or `null` if the data hasn't been loaded yet.
-
- ---
-
- - `isLoading`
- - `boolean`
-
- A boolean that is `true` if there is an ongoing request and there is no fetched data.
-
- ---
-
- - `isFetching`
- - `boolean`
-
- A boolean that is `true` if there is an ongoing request or a revalidation.
-
- ---
-
- - `hasNextPage`
- - `boolean`
-
- A boolean that indicates if there are available pages to be fetched.
-
- ---
-
- - `hasPreviousPage`
- - `boolean`
-
- A boolean that indicates if there are available pages to be fetched.
-
- ---
-
- - `fetchNext`
- - () => void
-
- A function that triggers the next page to be loaded. This is the same as `fetchPage(page => Math.min(pageCount, page + 1))`.
-
- ---
-
- - `fetchPrevious`
- - () => void
-
- A function that triggers the previous page to be loaded. This is the same as `fetchPage(page => Math.max(0, page - 1))`.
-
- ---
-
- - `pageCount`
- - `number`
-
- The total amount of pages. It is calculated based on `count`, `initialPage`, and `pageSize`.
-
- ---
-
- - `count`
- - `number`
-
- The total number of statements available.
-
- ---
-
- - `error`
- - [ClerkAPIResponseError](/docs/reference/javascript/types/clerk-api-response-error) | null
-
- Returns an error object if any part of the process fails.
-
- ---
-
- - `fetchPage`
- - `(page: number) => void`
-
- A function that triggers a specific page to be loaded.
-
- ---
-
- - `isError`
- - `boolean`
-
- A boolean that indicates the request failed.
-
- ---
-
- - `page`
- - `number`
-
- The current page.
-
- ---
-
- - `revalidate`
- - () => Promise\
-
- A function that triggers a revalidation of the current page.
-
- ---
-
- - `setData`
- - `(data: any[]) => void`
-
- A function that allows you to set the data manually.
-[`BillingSubscriptionResource`](/docs/reference/javascript/types/billing-subscription-resource) | null
+Active since: {subscription.activeAt.toLocaleDateString()}
+ {subscription.pastDueAt && ( +Past due since: {subscription.pastDueAt.toLocaleDateString()}
+ )} +Amount: {subscription.nextPayment.amount.amountFormatted}
+Due: {subscription.nextPayment.date.toLocaleDateString()}
+{error.message}
+Active since: {subscription.activeAt.toLocaleDateString()}
- {subscription.pastDueAt && ( -Past due since: {subscription.pastDueAt.toLocaleDateString()}
+ return ( +Amount: {subscription.nextPayment.amount.amountFormatted}
-Due: {subscription.nextPayment.date.toLocaleDateString()}
+Active since: {subscription.activeAt.toLocaleDateString()}
+ {subscription.pastDueAt && ( +Past due since: {subscription.pastDueAt.toLocaleDateString()}
+ )} +Amount: {subscription.nextPayment.amount.amountFormatted}
+Due: {subscription.nextPayment.date.toLocaleDateString()}
+{error.message}
+{error.message}
-user.firstName: {user.firstName}
+user.lastName: {user.lastName}
+ > + ) + } + ``` +user.firstName: {user.firstName}
+user.lastName: {user.lastName}
+ > + ) + } + ``` +user.firstName: {user.firstName}
+user.lastName: {user.lastName}
+ > + ) + } + ``` +user.firstName: {user.firstName}
+user.lastName: {user.lastName}
+ > + ) + } + ``` +user.firstName: {user.firstName}
+user.lastName: {user.lastName}
+ > + ) + } + ``` +user role: {user.publicMetadata.role}
+ > + ) + } + ``` +user role: {user.publicMetadata.role}
+ > + ) + } + ``` +user role: {user.publicMetadata.role}
+ > + ) + } + ``` +user role: {user.publicMetadata.role}
+ > + ) + } + ``` +user role: {user.publicMetadata.role}
+ > + ) + } + ``` +