@bunnyapp/components 2.0.0-beta.1 → 2.0.0-beta.3
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.
- package/README.md +2 -0
- package/dist/cjs/index.js +6 -6
- package/dist/cjs/types/src/components/BunnyProvider/BunnyProvider.d.ts +6 -0
- package/dist/cjs/types/src/components/Checkout/Checkout.stories.d.ts +1 -0
- package/dist/cjs/types/src/components/CheckoutShared/components/CheckoutForm/PayButton.d.ts +2 -1
- package/dist/cjs/types/src/components/CheckoutShared/components/CheckoutRoot.d.ts +3 -1
- package/dist/cjs/types/src/components/CheckoutShared/components/CheckoutScreen.d.ts +3 -1
- package/dist/cjs/types/src/components/CheckoutShared/contexts/CheckoutConfigContext.d.ts +2 -0
- package/dist/cjs/types/src/components/CheckoutShared/hooks/useCheckoutFormSubmit.d.ts +3 -2
- package/dist/cjs/types/src/components/PaymentMethods/components/StripeElements.d.ts +7 -1
- package/dist/cjs/types/src/components/PaymentMethods/utils/stripeErrors.d.ts +17 -0
- package/dist/cjs/types/src/components/Signup/Signup.stories.d.ts +1 -0
- package/dist/esm/index.js +6 -6
- package/dist/esm/types/src/components/BunnyProvider/BunnyProvider.d.ts +6 -0
- package/dist/esm/types/src/components/Checkout/Checkout.stories.d.ts +1 -0
- package/dist/esm/types/src/components/CheckoutShared/components/CheckoutForm/PayButton.d.ts +2 -1
- package/dist/esm/types/src/components/CheckoutShared/components/CheckoutRoot.d.ts +3 -1
- package/dist/esm/types/src/components/CheckoutShared/components/CheckoutScreen.d.ts +3 -1
- package/dist/esm/types/src/components/CheckoutShared/contexts/CheckoutConfigContext.d.ts +2 -0
- package/dist/esm/types/src/components/CheckoutShared/hooks/useCheckoutFormSubmit.d.ts +3 -2
- package/dist/esm/types/src/components/PaymentMethods/components/StripeElements.d.ts +7 -1
- package/dist/esm/types/src/components/PaymentMethods/utils/stripeErrors.d.ts +17 -0
- package/dist/esm/types/src/components/Signup/Signup.stories.d.ts +1 -0
- package/dist/index.d.ts +8 -0
- package/package.json +1 -1
- package/skills/bunny-components/SKILL.md +1 -0
|
@@ -8,6 +8,12 @@ export type BunnyContextValues = {
|
|
|
8
8
|
export declare const BunnyContext: import("react").Context<BunnyContextValues>;
|
|
9
9
|
declare function BunnyProvider({ children, queryClient, apiHost, token, onTokenExpired, onUserUnavailable, onInvalidOrMissingAuthorization, suppressUserUnavailableErrorNotification, disableErrorNotifications, appearance, }: {
|
|
10
10
|
children: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Your own TanStack Query client, if your app already has one. It replaces Bunny's default client
|
|
13
|
+
* entirely, so Bunny's error notifications and Sentry reporting for failed requests no longer run:
|
|
14
|
+
* show errors yourself with an `onError` on the client's `MutationCache` / `QueryCache` (or in
|
|
15
|
+
* `defaultOptions.mutations.onError`). Payment setup errors are still reported to your page's Sentry.
|
|
16
|
+
*/
|
|
11
17
|
queryClient?: QueryClient;
|
|
12
18
|
apiHost: string;
|
|
13
19
|
token?: string;
|
|
@@ -4,6 +4,7 @@ declare const meta: Meta<typeof Checkout>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof meta>;
|
|
6
6
|
export declare const Default: Story;
|
|
7
|
+
export declare const Preview: Story;
|
|
7
8
|
export declare const DisabledFields: Story;
|
|
8
9
|
export declare const WithDocumentTemplate: Story;
|
|
9
10
|
export declare const StoredPaymentMethod: Story;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* "Pay $50.00" with the amount due (or "Start trial" on a trial, "Complete order" when nothing is due), with the authorization text
|
|
3
3
|
* under it. Disabled only until the amount due first resolves and while a recalculation (e.g. taxes)
|
|
4
|
-
* is in flight; an incomplete form stays submittable so that submitting shows what is missing.
|
|
4
|
+
* is in flight; an incomplete form stays submittable so that submitting shows what is missing. Always disabled in a
|
|
5
|
+
* preview.
|
|
5
6
|
*/
|
|
6
7
|
export default function PayButton({ isProcessing }: {
|
|
7
8
|
isProcessing: boolean;
|
|
@@ -21,8 +21,10 @@ export type CheckoutFlowProps = {
|
|
|
21
21
|
defaultCouponCode?: string;
|
|
22
22
|
/** Callbacks fired at key lifecycle events */
|
|
23
23
|
callbacks?: CheckoutCallbacks;
|
|
24
|
+
/** Renders the flow with pricing and fields working but never submits it, e.g. to preview it inside an admin screen */
|
|
25
|
+
preview?: boolean;
|
|
24
26
|
};
|
|
25
27
|
/** The providers both flows mount, in one order: config, form instance, result, then the appearance. */
|
|
26
|
-
export default function CheckoutRoot({ priceListCode, enableTrial, form, defaultCouponCode, callbacks, appearance, children, }: Omit<CheckoutFlowProps, 'style'> & {
|
|
28
|
+
export default function CheckoutRoot({ priceListCode, enableTrial, form, defaultCouponCode, callbacks, appearance, preview, children, }: Omit<CheckoutFlowProps, 'style'> & {
|
|
27
29
|
children: ReactNode;
|
|
28
30
|
}): import("react").JSX.Element;
|
|
@@ -13,7 +13,7 @@ import { CheckoutQuoteDocument_QuoteFragment } from '../graphql/fragments/Checko
|
|
|
13
13
|
* document template is configured it goes under the summary: the composed quote before the checkout,
|
|
14
14
|
* and the checked-out quote under the receipt afterwards.
|
|
15
15
|
*/
|
|
16
|
-
export default function CheckoutScreen({ style, form, savedPaymentMethods, isFlowReady, showQuoteDocument, quote: pendingQuote, }: {
|
|
16
|
+
export default function CheckoutScreen({ style, form, savedPaymentMethods, isFlowReady, showQuoteDocument, quote: pendingQuote, paymentMethodTypes, }: {
|
|
17
17
|
style?: React.CSSProperties;
|
|
18
18
|
form: ReactNode;
|
|
19
19
|
/** Payment methods already stored on the account, if the flow has one. */
|
|
@@ -24,4 +24,6 @@ export default function CheckoutScreen({ style, form, savedPaymentMethods, isFlo
|
|
|
24
24
|
showQuoteDocument?: boolean;
|
|
25
25
|
/** The quote the flow will check out, if it exists before paying. Its PDF is shown under the summary. */
|
|
26
26
|
quote?: FragmentOf<typeof CheckoutQuoteDocument_QuoteFragment>;
|
|
27
|
+
/** The Stripe payment method types the flow's SetupIntent is limited to, if it is (see `StripeElements`). */
|
|
28
|
+
paymentMethodTypes?: readonly string[];
|
|
27
29
|
}): import("react").JSX.Element;
|
|
@@ -62,6 +62,8 @@ export type CheckoutConfig = {
|
|
|
62
62
|
defaultCouponCode: string | undefined;
|
|
63
63
|
form: CheckoutFormOptions;
|
|
64
64
|
callbacks: CheckoutCallbacks;
|
|
65
|
+
/** The flow renders but never submits. */
|
|
66
|
+
preview: boolean;
|
|
65
67
|
};
|
|
66
68
|
export declare const CheckoutConfigProvider: ({ value, children }: {
|
|
67
69
|
value: CheckoutConfig;
|
|
@@ -3,8 +3,9 @@ import { CheckoutResult } from '../contexts/CheckoutResultContext';
|
|
|
3
3
|
/**
|
|
4
4
|
* What submitting the checkout form has in common across the flows, once antd has validated it:
|
|
5
5
|
* layer the consumer's defaults under the entered values (fields that aren't shown still describe
|
|
6
|
-
* the account), run the flow's checkout and publish its result. Errors are
|
|
7
|
-
* client's
|
|
6
|
+
* the account), run the flow's checkout and publish its result. Errors are shown by the query
|
|
7
|
+
* client's own handlers (the default client toasts them), so the flow's `onError` goes on the
|
|
8
|
+
* `mutate` call: as a `useMutation` option it would replace a consumer client's default `onError`.
|
|
8
9
|
*/
|
|
9
10
|
export declare function useCheckoutFormSubmit({ mutationKey, checkout, onError, }: {
|
|
10
11
|
mutationKey: readonly string[];
|
|
@@ -7,8 +7,14 @@ import { ReactNode } from 'react';
|
|
|
7
7
|
* Element render before any intent exists. Such a group needs its currency from the start, so Stripe
|
|
8
8
|
* is held back until there is one. Changes to the appearance or currency reach the mounted elements;
|
|
9
9
|
* `fonts` can't change after the group is created, so new fonts remount it.
|
|
10
|
+
*
|
|
11
|
+
* Stripe only confirms a SetupIntent that offers payment methods the same way the group does. Without
|
|
12
|
+
* `paymentMethodTypes` the group uses the Stripe account's automatic payment methods, which is what
|
|
13
|
+
* the API's intent for an existing account uses too; a flow whose intent lists its types has to pass
|
|
14
|
+
* the same list here.
|
|
10
15
|
*/
|
|
11
|
-
export default function StripeElements({ currency, children }: {
|
|
16
|
+
export default function StripeElements({ currency, paymentMethodTypes, children, }: {
|
|
12
17
|
currency: string | undefined;
|
|
18
|
+
paymentMethodTypes?: readonly string[];
|
|
13
19
|
children: ReactNode;
|
|
14
20
|
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StripeError } from '@stripe/stripe-js';
|
|
2
|
+
/** Errors this module already sent to Sentry, so the default query client's handler skips them. */
|
|
3
|
+
export declare const reportedPaymentErrors: WeakSet<object>;
|
|
4
|
+
/**
|
|
5
|
+
* Reports a failed payment setup to the host page's Sentry, whatever query client is in use: the
|
|
6
|
+
* client's handler is the consumer's when they pass their own. Validation errors are the customer's
|
|
7
|
+
* input, shown by the Payment Element itself, so they aren't reported.
|
|
8
|
+
*/
|
|
9
|
+
export declare function reportPaymentError(error: Error, extra: Record<string, unknown>): void;
|
|
10
|
+
/**
|
|
11
|
+
* Turns a Stripe error into one the customer can read. Card and validation errors already are
|
|
12
|
+
* ("Your card has been declined."); anything else is a setup problem whose text is meant for
|
|
13
|
+
* developers, so the customer gets a generic message and the original goes along as `cause`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function toStripeUserError(stripeError: StripeError, extra: Record<string, unknown>): Error & {
|
|
16
|
+
cause: StripeError;
|
|
17
|
+
};
|
|
@@ -4,6 +4,7 @@ declare const meta: Meta<typeof Signup>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof meta>;
|
|
6
6
|
export declare const Default: Story;
|
|
7
|
+
export declare const Preview: Story;
|
|
7
8
|
export declare const DisabledFields: Story;
|
|
8
9
|
export declare const Mobile: Story;
|
|
9
10
|
export declare const Ledger: Story;
|
package/dist/index.d.ts
CHANGED
|
@@ -2218,6 +2218,8 @@ type CheckoutFlowProps = {
|
|
|
2218
2218
|
defaultCouponCode?: string;
|
|
2219
2219
|
/** Callbacks fired at key lifecycle events */
|
|
2220
2220
|
callbacks?: CheckoutCallbacks;
|
|
2221
|
+
/** Renders the flow with pricing and fields working but never submits it, e.g. to preview it inside an admin screen */
|
|
2222
|
+
preview?: boolean;
|
|
2221
2223
|
};
|
|
2222
2224
|
|
|
2223
2225
|
type SignupProps = CheckoutFlowProps;
|
|
@@ -2240,6 +2242,12 @@ type RuleProperty = RuleProperty$1;
|
|
|
2240
2242
|
|
|
2241
2243
|
declare function BunnyProvider({ children, queryClient, apiHost, token, onTokenExpired, onUserUnavailable, onInvalidOrMissingAuthorization, suppressUserUnavailableErrorNotification, disableErrorNotifications, appearance, }: {
|
|
2242
2244
|
children: React.ReactNode;
|
|
2245
|
+
/**
|
|
2246
|
+
* Your own TanStack Query client, if your app already has one. It replaces Bunny's default client
|
|
2247
|
+
* entirely, so Bunny's error notifications and Sentry reporting for failed requests no longer run:
|
|
2248
|
+
* show errors yourself with an `onError` on the client's `MutationCache` / `QueryCache` (or in
|
|
2249
|
+
* `defaultOptions.mutations.onError`). Payment setup errors are still reported to your page's Sentry.
|
|
2250
|
+
*/
|
|
2243
2251
|
queryClient?: QueryClient;
|
|
2244
2252
|
apiHost: string;
|
|
2245
2253
|
token?: string;
|
package/package.json
CHANGED
|
@@ -133,6 +133,7 @@ token.
|
|
|
133
133
|
| Result | A subscription on the existing account | A new account and its first subscription |
|
|
134
134
|
| Form defaults | Merged from the account (yours win) | Yours only |
|
|
135
135
|
| `documentTemplateId` | Yes: shows the quote PDF under the summary | No |
|
|
136
|
+
| Payment methods | Every method enabled in the Stripe account, including SEPA Direct Debit | Cards only (also Link), as signup charges immediately; bank debits such as SEPA and ACH settle over days. Customers who need SEPA sign up with a card and switch later, or use Checkout |
|
|
136
137
|
|
|
137
138
|
`<Signup />` calls the signup mutations that only the
|
|
138
139
|
`signup:read` / `signup:write` scopes cover; a portal session token is
|