@pontive/pontkit-core 1.43.0 → 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,192 @@
1
+ import { nothing, PropertyDeclarations, PropertyValues, TemplateResult } from 'lit';
2
+ import { HostElement } from '../../core/host-element';
3
+ import { MessagesController } from '../../core/messages';
4
+ import { BrandingController } from '../block/branding';
5
+ import { BillingProblem } from '../checkout/errors';
6
+ import { PaymentFormOptions } from '../checkout/payment';
7
+ import { BillingAccount, BillingContract, BillingCreditNote, BillingInvoice, BillingPaymentMethod, ContractChangePreview } from '../provider/account-billing';
8
+ import { AccountClient } from '../provider/account-client';
9
+ import { AccountController } from '../provider/account-controller';
10
+ export { abilities, chooseAccount, currentContract, seatsSubscription, type PortalAbilities } from './rules';
11
+ /** Detail of every `pont-billing-*` event: the Customer, and what changed. */
12
+ export interface BillingPortalEventDetail {
13
+ customerId: string;
14
+ contractId?: string;
15
+ invoiceId?: string;
16
+ paymentMethodId?: string;
17
+ }
18
+ /** The query parameter the portal puts on Stripe's `return_url`: `invoice:<id>` or `method`. */
19
+ export declare const PORTAL_RETURN_PARAM = "pont_billing_return";
20
+ type Panel = {
21
+ kind: "change";
22
+ } | {
23
+ kind: "seats";
24
+ subscriptionId: string;
25
+ } | {
26
+ kind: "cancel";
27
+ } | {
28
+ kind: "pay";
29
+ invoice: BillingInvoice;
30
+ withNew: boolean;
31
+ } | {
32
+ kind: "add-method";
33
+ } | {
34
+ kind: "remove-method";
35
+ method: BillingPaymentMethod;
36
+ };
37
+ type Confirming = {
38
+ kind: "invoice";
39
+ invoiceId: string;
40
+ } | {
41
+ kind: "method";
42
+ known: string[];
43
+ };
44
+ /**
45
+ * # `<pont-billing-portal>`: manage what the end customer bought (billing-svc docs/m17-design.md, Part 3)
46
+ *
47
+ * ```html
48
+ * <pont-provider app-id="app_123" domain="auth.acme.com" api-base-url="https://api.us.pontive.com"
49
+ * scope="openid email profile offline_access pontive:billing:read pontive:billing:pay">
50
+ * <pont-billing-portal></pont-billing-portal>
51
+ * </pont-provider>
52
+ * ```
53
+ *
54
+ * **Beta: needs the `billing` capability** (P69). For the Customer billing-svc resolves (P37), or
55
+ * the one `subject` names: the plan (package, status, frequency, seats, renewal date, upcoming
56
+ * invoice); changing package or frequency, previewed and confirmed with its `preview_hash`; seats
57
+ * where the package allows; cancel and revoke; invoices and credit notes with their hosted page and
58
+ * PDF; paying an open invoice; payment methods (add, make default, remove). Controls the caller may
59
+ * not use are hidden (R9). A suspended organization's owner sees only the recovery actions, with a
60
+ * notice (P79). Payment steps are in the page, never in a dialog (R10).
61
+ *
62
+ * @tag pont-billing-portal
63
+ * @attr subject - the Customer's subject: `org_...` or `usr_...` (default: as billing-svc resolves it; a suspended organization is reached this way, P79)
64
+ * @attr heading - overrides the title (`msg("billing_portal_title")`)
65
+ * @attr description - overrides the subtitle (`msg("billing_portal_subtitle")`)
66
+ * @prop client - its own `AccountClient` (default: the provider's)
67
+ * @fires pont-billing-contract-changed - `{ customerId, contractId }`
68
+ * @fires pont-billing-contract-cancelled - `{ customerId, contractId }`
69
+ * @fires pont-billing-cancellation-revoked - `{ customerId, contractId }`
70
+ * @fires pont-billing-invoice-paid - `{ customerId, invoiceId }`
71
+ * @fires pont-billing-payment-method-added - `{ customerId, paymentMethodId }`
72
+ * @fires pont-billing-payment-method-default-changed - `{ customerId, paymentMethodId }`
73
+ * @fires pont-billing-payment-method-removed - `{ customerId, paymentMethodId }`
74
+ */
75
+ export declare class BillingPortal extends HostElement {
76
+ static composite: boolean;
77
+ static properties: PropertyDeclarations;
78
+ client: AccountClient | undefined;
79
+ subject: string;
80
+ heading: string;
81
+ description: string;
82
+ protected loading: boolean;
83
+ protected problem: BillingProblem | null;
84
+ protected accounts: BillingAccount[];
85
+ protected account: BillingAccount | null;
86
+ protected scopes: string[];
87
+ protected contract: BillingContract | null;
88
+ protected upcoming: BillingInvoice | null;
89
+ protected invoices: BillingInvoice[];
90
+ protected creditNotes: BillingCreditNote[];
91
+ protected methods: BillingPaymentMethod[];
92
+ protected panel: Panel | null;
93
+ protected busy: boolean;
94
+ protected panelError: string | null;
95
+ protected notice: string | null;
96
+ protected formError: string | null;
97
+ protected confirming: Confirming | null;
98
+ protected slow: boolean;
99
+ protected target: {
100
+ packageId: string;
101
+ frequency: string;
102
+ };
103
+ protected seats: string;
104
+ protected changePreview: ContractChangePreview | null;
105
+ /** For tests and stories: how Stripe.js is reached (default: the page's, loaded from js.stripe.com). */
106
+ paymentFormOptions: PaymentFormOptions;
107
+ protected readonly messages: MessagesController;
108
+ protected readonly branding: BrandingController;
109
+ protected readonly accountController: AccountController;
110
+ private readonly ids;
111
+ private form;
112
+ private stopWatching;
113
+ private loadSeq;
114
+ private loadedBy;
115
+ private loadedOrg;
116
+ /** The account picked in the picker (a subject id), until the session or `subject` changes. */
117
+ private chosen;
118
+ constructor();
119
+ connectedCallback(): void;
120
+ disconnectedCallback(): void;
121
+ /** Everything again. */
122
+ reload(): Promise<void>;
123
+ /** The Customer shown, once read. */
124
+ get customerId(): string | null;
125
+ private get signedIn();
126
+ private whoAmI;
127
+ private tokenOrganization;
128
+ /** The switcher moved the session: the Customer follows the token's organization (P37). */
129
+ private onOrganizationChanged;
130
+ private refresh;
131
+ protected willUpdate(changed: PropertyValues): void;
132
+ protected updated(changed: PropertyValues): void;
133
+ private get api();
134
+ /** The subject every call names: the account shown. */
135
+ private get on();
136
+ private fail;
137
+ private load;
138
+ /** The shown account's contract, upcoming invoice, invoices, credit notes and methods. */
139
+ private loadAccount;
140
+ /** Back from a method that redirected: follow that payment or setup (`PORTAL_RETURN_PARAM`). */
141
+ private followStripeReturn;
142
+ private reloadAccount;
143
+ private emit;
144
+ private openPanel;
145
+ private closePanel;
146
+ private get change();
147
+ private previewChange;
148
+ private confirmChange;
149
+ private cancelPlan;
150
+ private revoke;
151
+ private get defaultMethod();
152
+ private openPay;
153
+ private preparePayNew;
154
+ private prepareForm;
155
+ private pay;
156
+ /** The server's outcome, through Stripe.js where it must confirm or authenticate. */
157
+ private follow;
158
+ private prepareAddMethod;
159
+ private saveMethod;
160
+ private makeDefault;
161
+ private removeMethod;
162
+ private downloadPdf;
163
+ /** Reads the invoice, or the methods, until billing-svc has recorded what Stripe did. */
164
+ private startConfirming;
165
+ render(): TemplateResult<1> | typeof nothing;
166
+ private alert;
167
+ private renderBody;
168
+ private renderAccountPicker;
169
+ private section;
170
+ private renderPlan;
171
+ private renderChange;
172
+ private renderCancel;
173
+ private renderConfirming;
174
+ private renderInvoices;
175
+ private renderPayChoices;
176
+ private renderCreditNotes;
177
+ private renderMethods;
178
+ }
179
+ declare global {
180
+ interface HTMLElementTagNameMap {
181
+ "pont-billing-portal": BillingPortal;
182
+ }
183
+ interface HTMLElementEventMap {
184
+ "pont-billing-contract-changed": CustomEvent<BillingPortalEventDetail>;
185
+ "pont-billing-contract-cancelled": CustomEvent<BillingPortalEventDetail>;
186
+ "pont-billing-cancellation-revoked": CustomEvent<BillingPortalEventDetail>;
187
+ "pont-billing-invoice-paid": CustomEvent<BillingPortalEventDetail>;
188
+ "pont-billing-payment-method-added": CustomEvent<BillingPortalEventDetail>;
189
+ "pont-billing-payment-method-default-changed": CustomEvent<BillingPortalEventDetail>;
190
+ "pont-billing-payment-method-removed": CustomEvent<BillingPortalEventDetail>;
191
+ }
192
+ }
@@ -0,0 +1,36 @@
1
+ import { BillingAccount, BillingContract, BillingSubscription } from '../provider/account-billing';
2
+ /** The contract the portal shows: the one in force, else a scheduled one. */
3
+ export declare function currentContract(contracts: BillingContract[]): BillingContract | null;
4
+ /**
5
+ * Which Customer the portal shows (P37): the `subject` named, else the one chosen in the account
6
+ * picker, else the token's organization's, else the user's own, else the first listed (a suspended
7
+ * organization its owner may recover, P79).
8
+ */
9
+ export declare function chooseAccount(accounts: BillingAccount[], options: {
10
+ subject?: string;
11
+ chosen?: string;
12
+ organizationId?: string;
13
+ }): BillingAccount | null;
14
+ /** What the caller may do on an account, from the token's scopes and `GET .../customers` (R9; P79). */
15
+ export interface PortalAbilities {
16
+ /** Any action at all. */
17
+ act: boolean;
18
+ changePlan: boolean;
19
+ setSeats: boolean;
20
+ cancel: boolean;
21
+ revoke: boolean;
22
+ pay: boolean;
23
+ addMethod: boolean;
24
+ setDefault: boolean;
25
+ removeMethod: boolean;
26
+ creditNotes: boolean;
27
+ }
28
+ /**
29
+ * The controls to show. A recovery account (a suspended organization's owner, P79) gets only the
30
+ * recovery actions: pay, add a method or set the default, change package, revoke a cancellation;
31
+ * no cancel, no removing a method, no seats, no credit notes (R13). billing-svc still decides
32
+ * each route; this only hides what it would refuse.
33
+ */
34
+ export declare function abilities(account: BillingAccount, scopes: string[], contract: BillingContract | null): PortalAbilities;
35
+ /** The seats subscription: a `members` one (follows the organization), or, for editing, a `quantity_only` one. */
36
+ export declare function seatsSubscription(contract: BillingContract, editable?: boolean): BillingSubscription | undefined;
@@ -0,0 +1,78 @@
1
+ import { BillingAccount, BillingContract, BillingInvoice, BillingPackageOption, BillingPaymentMethod, CheckoutSession, PaymentStart } from '../provider/account-billing';
2
+ import { AccountApiError, AccountClient } from '../provider/account-client';
3
+ import { StripeFactory, StripeIntentResult } from './stripe';
4
+ export declare const KEYS: {
5
+ publishable_key: string;
6
+ provider_account: string;
7
+ };
8
+ export declare const PACKAGES: BillingPackageOption[];
9
+ export declare const tokenError: (code: string) => Error & {
10
+ name: string;
11
+ code: string;
12
+ };
13
+ export declare const apiError: (status: number, code: string) => AccountApiError;
14
+ export interface BillingFakeOptions {
15
+ scopes?: string[];
16
+ accounts?: BillingAccount[];
17
+ session?: Partial<CheckoutSession>;
18
+ /** The checkout preview's amount due (a decimal string). Default: the chosen price plus 10% tax. */
19
+ previewDue?: string;
20
+ /** What confirm answers, in order (then the last again). */
21
+ confirm?: Partial<PaymentStart>[];
22
+ /** What paying an invoice answers, in order. */
23
+ pay?: Partial<PaymentStart>[];
24
+ /** How many reads after a payment before the webhook "arrives" (0: the first read sees it). */
25
+ webhookAfterReads?: number;
26
+ /** Per method: what the next calls throw, in order. */
27
+ fail?: Partial<Record<string, unknown[]>>;
28
+ contract?: Partial<BillingContract> | null;
29
+ invoices?: BillingInvoice[];
30
+ methods?: BillingPaymentMethod[];
31
+ requestedScopes?: string[];
32
+ noBilling?: boolean;
33
+ }
34
+ export declare function account(over?: Partial<BillingAccount>): BillingAccount;
35
+ export declare function invoice(id: string, status: string, total: string, over?: Partial<BillingInvoice>): BillingInvoice;
36
+ export declare function contract(over?: Partial<BillingContract>): BillingContract;
37
+ export declare const card: (id: string, last4: string, over?: Partial<BillingPaymentMethod>) => BillingPaymentMethod;
38
+ /** A stand-in account client with the billing part. */
39
+ export declare function fakeBillingClient(opts?: BillingFakeOptions): {
40
+ client: AccountClient;
41
+ log: string[];
42
+ bodies: Record<string, unknown[]>;
43
+ stripeConfirmed: (kind: "checkout" | "invoice" | "method", invoiceId?: string) => void;
44
+ expireSession: () => {
45
+ status: string;
46
+ id: string;
47
+ expires_at?: string;
48
+ contract_id?: string | null;
49
+ collect?: {
50
+ billing_address?: "auto" | "required" | string;
51
+ tax_id?: boolean;
52
+ };
53
+ success_url?: string;
54
+ cancel_url?: string;
55
+ packages: BillingPackageOption[];
56
+ keys: import('..').PaymentKeys | null;
57
+ };
58
+ };
59
+ export interface FakeStripeOptions {
60
+ /** What confirmPayment / confirmSetup answer, in order (then the last again). */
61
+ confirm?: StripeIntentResult[];
62
+ /** What handleNextAction answers. */
63
+ nextAction?: StripeIntentResult;
64
+ /** Called after a confirm or next action that succeeded: the fake client's webhook. */
65
+ onSucceeded?: () => void;
66
+ }
67
+ /** A Stripe.js stand-in: records every call, mounts a placeholder where the Payment Element would be. */
68
+ export declare function fakeStripe(opts?: FakeStripeOptions): {
69
+ factory: StripeFactory;
70
+ loadStripe: () => Promise<StripeFactory>;
71
+ calls: string[];
72
+ elementsOptions: Record<string, unknown>[];
73
+ confirmParams: Record<string, unknown>[];
74
+ created: {
75
+ key: string;
76
+ options?: Record<string, unknown>;
77
+ }[];
78
+ };
@@ -0,0 +1,147 @@
1
+ import { nothing, PropertyDeclarations, PropertyValues, TemplateResult } from 'lit';
2
+ import { HostElement } from '../../core/host-element';
3
+ import { MessagesController } from '../../core/messages';
4
+ import { BrandingController } from '../block/branding';
5
+ import { BillingAddress, CheckoutPreview, CheckoutSession } from '../provider/account-billing';
6
+ import { AccountClient } from '../provider/account-client';
7
+ import { AccountController } from '../provider/account-controller';
8
+ import { BillingProblem } from './errors';
9
+ import { CheckoutPackageRequest } from './packages';
10
+ import { PaymentFormOptions } from './payment';
11
+ export { parsePackages, successUrlFor, type CheckoutPackageRequest } from './packages';
12
+ /** Detail of `pont-checkout-completed`. */
13
+ export interface CheckoutCompletedDetail {
14
+ sessionId: string;
15
+ contractId: string | null;
16
+ /** Where the element goes unless the event is cancelled: `success-url` with `?checkout_session_id=`. */
17
+ url: string | null;
18
+ }
19
+ /** Detail of `pont-checkout-cancelled`. */
20
+ export interface CheckoutCancelledDetail {
21
+ sessionId: string | null;
22
+ url: string | null;
23
+ }
24
+ export type CheckoutPhase = "loading" | "choose" | "review" | "confirming" | "done" | "problem";
25
+ /** The query parameter the element puts on Stripe's `return_url`, to find its session on a return. */
26
+ export declare const CHECKOUT_RETURN_PARAM = "pont_checkout_session";
27
+ declare const ADDRESS_FIELDS: readonly ["country", "line1", "line2", "city", "postal_code", "state"];
28
+ type AddressField = (typeof ADDRESS_FIELDS)[number];
29
+ /**
30
+ * # `<pont-checkout>`: buy a package inside the client's product (billing-svc docs/m17-design.md, Part 3)
31
+ *
32
+ * ```html
33
+ * <pont-provider app-id="app_123" domain="auth.acme.com" api-base-url="https://api.us.pontive.com"
34
+ * scope="openid email profile offline_access pontive:billing:read pontive:billing:pay">
35
+ * <pont-checkout packages="pkg_starter:monthly,annual pkg_pro:monthly,annual" success-url="/welcome" cancel-url="/pricing"></pont-checkout>
36
+ * </pont-provider>
37
+ * ```
38
+ *
39
+ * **Beta: needs the `billing` capability** (P69). Creates a checkout session through `/me` (an
40
+ * element creates sessions only through `/me`, P36), or confirms the server-created one its
41
+ * `session` names. The end customer picks a package and frequency, enters the address and tax id
42
+ * when the session collects them, sees the first invoice with tax and trial before anything is
43
+ * created (P65), then pays in Stripe's Payment Element on the client's connected account. The
44
+ * outcome is followed until billing-svc, told by Stripe's webhook, completes the session; then
45
+ * `pont-checkout-completed` fires and the browser goes to `success-url` with
46
+ * `?checkout_session_id=` unless the event is cancelled. Going back to choose again is allowed until
47
+ * the customer pays (P67). The payment step is in the page, never in a dialog (R10).
48
+ *
49
+ * @tag pont-checkout
50
+ * @attr packages - the packages offered: ids or keys, each with `:` and its frequencies (`pkg_pro:monthly,annual pkg_team`)
51
+ * @attr success-url - where the browser goes once the session completes (default: this page)
52
+ * @attr cancel-url - where "Cancel" goes; no Cancel button without it
53
+ * @attr session - a checkout session the client's server created (`chks_...`); `packages` is then ignored
54
+ * @attr subject - the Customer's subject: `org_...` for an organization, `usr_...` for the user (default: as billing-svc resolves it)
55
+ * @attr heading - overrides the title (`msg("checkout_title")`)
56
+ * @prop client - its own `AccountClient` (default: the provider's)
57
+ * @fires pont-checkout-completed - `{ sessionId, contractId, url }`, cancelable: cancel it to stay on the page
58
+ * @fires pont-checkout-cancelled - `{ sessionId, url }`, cancelable: cancel it to handle Cancel yourself
59
+ */
60
+ export declare class Checkout extends HostElement {
61
+ static composite: boolean;
62
+ static properties: PropertyDeclarations;
63
+ client: AccountClient | undefined;
64
+ packages: string | CheckoutPackageRequest[];
65
+ successUrl: string;
66
+ cancelUrl: string;
67
+ session: string;
68
+ subject: string;
69
+ heading: string;
70
+ protected phase: CheckoutPhase;
71
+ protected problem: (BillingProblem & {
72
+ restart?: boolean;
73
+ }) | null;
74
+ protected checkoutSession: CheckoutSession | null;
75
+ protected packageId: string;
76
+ protected frequency: string;
77
+ protected address: BillingAddress;
78
+ protected taxId: string;
79
+ protected fieldErrors: Partial<Record<AddressField, string>>;
80
+ protected preview: CheckoutPreview | null;
81
+ protected busy: boolean;
82
+ protected actionError: string | null;
83
+ protected formError: string | null;
84
+ protected slow: boolean;
85
+ /** For tests and stories: how Stripe.js is reached (default: the page's, loaded from js.stripe.com). */
86
+ paymentFormOptions: PaymentFormOptions;
87
+ /** For tests and stories: how the element leaves the page (default: `location.assign`). */
88
+ navigate: (url: string) => void;
89
+ protected readonly messages: MessagesController;
90
+ protected readonly branding: BrandingController;
91
+ protected readonly account: AccountController;
92
+ private readonly ids;
93
+ private form;
94
+ private stopWatching;
95
+ private loadSeq;
96
+ private loadedBy;
97
+ constructor();
98
+ disconnectedCallback(): void;
99
+ /** The session acted on, once it is read. */
100
+ get sessionId(): string | null;
101
+ /** Starts again: a new session (or the `session` attribute's, read again). */
102
+ reload(): Promise<void>;
103
+ private whoAmI;
104
+ private refresh;
105
+ protected willUpdate(changed: PropertyValues): void;
106
+ protected updated(changed: PropertyValues): void;
107
+ private get api();
108
+ private get subjectRef();
109
+ private reset;
110
+ private fail;
111
+ private load;
112
+ private showSession;
113
+ private get chosen();
114
+ private pickFrequency;
115
+ private get collectsAddress();
116
+ private get collectsTaxId();
117
+ /** What confirm and preview take (pontive-spec 35, API Surface). No promotion code: coupons are after beta (R6). */
118
+ private choice;
119
+ private validate;
120
+ private review;
121
+ /** The Payment Element for the first invoice: deferred, with its amount, keeping the method for the renewals (R4). */
122
+ private prepareForm;
123
+ private back;
124
+ private pay;
125
+ /** Reads the session until billing-svc, told by the webhook, has completed it (P65). */
126
+ private startConfirming;
127
+ private complete;
128
+ private cancel;
129
+ render(): TemplateResult<1> | typeof nothing;
130
+ private renderBody;
131
+ private renderProblem;
132
+ private alert;
133
+ private renderPrice;
134
+ private renderChoose;
135
+ private renderInput;
136
+ private renderAddress;
137
+ private renderReview;
138
+ }
139
+ declare global {
140
+ interface HTMLElementTagNameMap {
141
+ "pont-checkout": Checkout;
142
+ }
143
+ interface HTMLElementEventMap {
144
+ "pont-checkout-completed": CustomEvent<CheckoutCompletedDetail>;
145
+ "pont-checkout-cancelled": CustomEvent<CheckoutCancelledDetail>;
146
+ }
147
+ }
@@ -0,0 +1,30 @@
1
+ import { BillingInvoice, BillingMoney, BillingPackageOption } from '../provider/account-billing';
2
+ /** "Monthly", "Yearly"; an unknown frequency as it was sent. */
3
+ export declare const frequencyLabel: (frequency: string) => string;
4
+ /** "per month"; empty for an unknown frequency. */
5
+ export declare const perPeriod: (frequency: string) => string;
6
+ /** The price of one period of `option` at `frequency`, if the session sent it. */
7
+ export declare function priceFor(option: BillingPackageOption | undefined, frequency: string): BillingMoney | undefined;
8
+ /** A package's name to show: its name, else its key, else its id. */
9
+ export declare const packageName: (option: {
10
+ name?: string;
11
+ key?: string;
12
+ package_id?: string;
13
+ id?: string;
14
+ } | undefined) => string;
15
+ /** "14 days", in the page's language (`Intl` unit formatting, no message needed). */
16
+ export declare function formatDays(days: number): string;
17
+ /** `amount` formatted; empty for none. */
18
+ export declare const money: (amount: BillingMoney | undefined) => string;
19
+ /** Whether `amount` is zero (a decimal string compared as text, never a float). */
20
+ export declare const isZero: (amount: BillingMoney | undefined) => boolean;
21
+ /**
22
+ * What the Payment Element is created with for an amount: the API's `amount_provider_units` when it
23
+ * sends them (the provider's own units, as the hosted page uses), else the ISO 4217 minor units.
24
+ */
25
+ export declare function providerUnits(amount: BillingMoney | undefined, sent?: number): number | null;
26
+ /** An invoice's lines and totals, as a definition list the element styles with `data-pont-billing-*` hooks. */
27
+ export declare function invoiceSummary(invoice: BillingInvoice, options?: {
28
+ dueLabel?: string;
29
+ amount?: BillingMoney;
30
+ }): import('lit-html').TemplateResult<1>;
@@ -0,0 +1,28 @@
1
+ import { KitMessageCode } from '../../core/messages';
2
+ /**
3
+ * # The billing elements' errors, in the person's words (billing-svc docs/m17-design.md, Part 3, Errors)
4
+ *
5
+ * As member management's (`member-management/errors.ts`): a failure is said, never shown as an
6
+ * empty element. A refused management token comes from `getManagementScopes()` (the SDK's
7
+ * `ManagementTokenError`); a refused route is an `AccountApiError` with the error envelope's code.
8
+ * Pure, unit-tested in `errors.test.ts`. Shared by `<pont-checkout>` and `<pont-billing-portal>`.
9
+ */
10
+ /** What an element shows instead of its content when it cannot show it. */
11
+ export interface BillingProblem {
12
+ message: string;
13
+ /** Whether trying again could help. */
14
+ retry: boolean;
15
+ /** For the app's developer, logged with `console.warn`. */
16
+ hint?: string;
17
+ }
18
+ /** The SDK says the session changed while the token was drawn: ask again, once. */
19
+ export declare function isSessionChanged(error: unknown): boolean;
20
+ /** The error envelope's code of a refused route, or the client's own. */
21
+ export declare const billingErrorCode: (error: unknown) => string | undefined;
22
+ /**
23
+ * Why loading failed, for the person on the page; and, where the cause is the app's setup, a
24
+ * `hint` for its developer. `tag` names the element in the hint.
25
+ */
26
+ export declare function describeBillingLoadError(error: unknown, tag: string, requestedScopes?: string[]): BillingProblem;
27
+ /** Why an action failed, in the person's words; `fallback` when there is no better one. */
28
+ export declare function describeBillingActionError(error: unknown, fallback: KitMessageCode): string;
@@ -0,0 +1,13 @@
1
+ /** The `<pont-checkout>` attributes read as data: pure, unit-tested in `packages.test.ts`. */
2
+ /** One entry of the `packages` attribute: a package id or key, and the frequencies offered. */
3
+ export interface CheckoutPackageRequest {
4
+ package_id: string;
5
+ billing_frequencies?: string[];
6
+ }
7
+ /**
8
+ * The `packages` attribute: entries separated by spaces, each a package id or key with an optional
9
+ * `:` and comma-separated frequencies (`"pkg_pro:monthly,annual starter"`).
10
+ */
11
+ export declare function parsePackages(value: string | CheckoutPackageRequest[] | null | undefined): CheckoutPackageRequest[];
12
+ /** `url` with `?checkout_session_id=` (pontive-spec 35, Checkout, 4); `null` without a URL. */
13
+ export declare function successUrlFor(url: string | undefined, sessionId: string): string | null;