@bunnyapp/components 2.0.0-beta.2 → 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.
@@ -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;
@@ -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;
@@ -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 toasted by the query
7
- * client's global handler.
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
+ };