azirid-react 0.9.3 → 0.9.5

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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { CSSProperties, ReactNode, FormEvent } from 'react';
2
+ import { CSSProperties, ReactNode, FormEvent, ReactElement } from 'react';
3
3
  import * as _tanstack_react_query from '@tanstack/react-query';
4
4
  import { UseMutationResult, UseQueryResult } from '@tanstack/react-query';
5
5
  import { z } from 'zod';
@@ -725,7 +725,26 @@ interface PayphoneCallbackProps {
725
725
  className?: string;
726
726
  style?: CSSProperties;
727
727
  }
728
- declare function PayphoneCallback({ onSuccess, onError, className, style, }: PayphoneCallbackProps): react_jsx_runtime.JSX.Element;
728
+ declare function PayphoneCallback({ onSuccess, onError, className, style }: PayphoneCallbackProps): react_jsx_runtime.JSX.Element;
729
+
730
+ declare global {
731
+ interface Window {
732
+ PPaymentButtonBox: new (config: Record<string, unknown>) => {
733
+ render: (containerId: string) => void;
734
+ };
735
+ }
736
+ }
737
+ /**
738
+ * Internal widget renderer — loads Payphone SDK and mounts PPaymentButtonBox.
739
+ * Used by usePayphoneCheckout hook. Not meant to be used directly.
740
+ */
741
+ declare function PayphoneWidgetRenderer({ config, responseUrl, containerId, onReady, onError, }: {
742
+ config: PayphoneWidgetConfig;
743
+ responseUrl: string;
744
+ containerId: string;
745
+ onReady?: () => void;
746
+ onError?: (error: Error) => void;
747
+ }): react_jsx_runtime.JSX.Element;
729
748
 
730
749
  interface SubscriptionBadgeProps {
731
750
  className?: string;
@@ -1559,6 +1578,20 @@ interface UsePayphoneConfirmOptions {
1559
1578
  }
1560
1579
  declare function usePayphoneConfirm(options?: UsePayphoneConfirmOptions): _tanstack_react_query.UseMutationResult<PayphoneConfirmResult, Error, PayphoneConfirmParams, unknown>;
1561
1580
 
1581
+ type PayphoneCheckoutStatus = 'idle' | 'loading' | 'ready' | 'confirming' | 'confirmed' | 'cancelled' | 'error';
1582
+ interface UsePayphoneCheckoutOptions {
1583
+ intentId: string;
1584
+ onSuccess?: (data: PayphoneConfirmResult) => void;
1585
+ onError?: (error: Error) => void;
1586
+ }
1587
+ interface UsePayphoneCheckoutReturn {
1588
+ PayphoneWidget: () => ReactElement | null;
1589
+ status: PayphoneCheckoutStatus;
1590
+ intentId: string;
1591
+ error: Error | null;
1592
+ }
1593
+ declare function usePayphoneCheckout({ intentId, onSuccess, onError, }: UsePayphoneCheckoutOptions): UsePayphoneCheckoutReturn;
1594
+
1562
1595
  declare function useTenants(): _tanstack_react_query.UseQueryResult<TenantWithRole[], Error>;
1563
1596
  declare function useTenantMembers(tenantId: string): _tanstack_react_query.UseQueryResult<TenantMemberInfo[], Error>;
1564
1597
  declare function useSwitchTenant(): {
@@ -1895,4 +1928,4 @@ interface SessionSyncOptions {
1895
1928
 
1896
1929
  declare const SDK_VERSION: string;
1897
1930
 
1898
- export { type AccessClient, type AccessClientConfig, type AccessMessages, type ApiError, type AppBranding, AuthForm, type AuthFormProps, type AuthPaths, type AuthState, type AuthSuccessResponse, type AuthUser, type AuthView, type AvailableProvider, type AziridContextValue, AziridProvider, type AziridProviderProps, BASE_PATHS, type BillingInvoice, type BillingPlan, type BootstrapResponse, type ChangePasswordData, type ChangePasswordInput, CheckoutButton, type CheckoutButtonProps, type CheckoutParams, type CheckoutResponse, type CreateTenantData, type FieldError, ForgotPasswordForm, type ForgotPasswordFormProps, type ForgotPasswordInput, InvoiceList, type InvoiceListProps, type LoginData, LoginForm, type LoginFormProps, type LoginInput, type MagicLinkRequestData, type MagicLinkRequestInput, type MagicLinkVerifyData, type MagicLinkVerifyInput, type MutationHookConfig, PATHS, type PasskeyItem, type PasskeyLoginData, type PasskeyLoginStartData, type PasskeyLoginStartResponse, type PasskeyLoginVerifyData, type PasskeyRegisterStartData, type PasskeyRegisterStartInput, type PasskeyRegisterStartResponse, type PasskeyRegisterVerifyData, type PasswordResetConfirmData, type PasswordResetRequestData, PayButton, type PayButtonProps, type PaymentIntent, type PaymentProviderType, PayphoneCallback, type PayphoneCallbackProps, type PayphoneConfirmParams, type PayphoneConfirmResult, type PayphoneModalProps, type PayphoneWidgetConfig, type PricingCardProps, type PricingFeatureListProps, PricingTable, type PricingTableProps, type ProviderModalProps, ReferralCard, type ReferralCardProps, type ReferralInfo, type ReferralItem, ReferralStats, type ReferralStatsData, type ReferralStatsProps, type RegisterPasskeyData, type ResetPasswordConfirmInput, ResetPasswordForm, type ResetPasswordFormProps, SDK_VERSION, type SessionSyncOptions, type SignupData, SignupForm, type SignupFormProps, type SignupInput, type SimpleMutationOptions, type SocialLoginData, type SocialLoginInput, type SubmitTransferProofData, SubscriptionBadge, type SubscriptionBadgeProps, type SupportedLocale, type TenantMemberInfo, type TenantWithRole, type TransferModalProps, type TransferProof, type UseBootstrapOptions, type UseBootstrapReturn, type UseChangePasswordOptions, type UseChangePasswordReturn, type UseCheckoutOptions, type UseFormReturn, type UseLoginOptions, type UseLoginReturn, type UseLogoutOptions, type UseLogoutReturn, type UseMagicLinkOptions, type UseMagicLinkReturn, type UsePasskeysOptions, type UsePasskeysReturn, type UsePasswordResetOptions, type UsePasswordResetReturn, type UsePayphoneConfirmOptions, type UseRefreshOptions, type UseRefreshReturn, type UseSessionOptions, type UseSessionReturn, type UseSignupOptions, type UseSignupReturn, type UseSocialLoginOptions, type UseSocialLoginReturn, type UserSubscription, buildPaths, changePasswordSchema, cn, createAccessClient, createForgotPasswordSchema, createLoginSchema, createMutationHook, createResetPasswordConfirmSchema, createSignupSchema, en, es, forgotPasswordSchema, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resetPasswordConfirmSchema, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordReset, usePasswordToggle, usePaymentProviders, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferProofs };
1931
+ export { type AccessClient, type AccessClientConfig, type AccessMessages, type ApiError, type AppBranding, AuthForm, type AuthFormProps, type AuthPaths, type AuthState, type AuthSuccessResponse, type AuthUser, type AuthView, type AvailableProvider, type AziridContextValue, AziridProvider, type AziridProviderProps, BASE_PATHS, type BillingInvoice, type BillingPlan, type BootstrapResponse, type ChangePasswordData, type ChangePasswordInput, CheckoutButton, type CheckoutButtonProps, type CheckoutParams, type CheckoutResponse, type CreateTenantData, type FieldError, ForgotPasswordForm, type ForgotPasswordFormProps, type ForgotPasswordInput, InvoiceList, type InvoiceListProps, type LoginData, LoginForm, type LoginFormProps, type LoginInput, type MagicLinkRequestData, type MagicLinkRequestInput, type MagicLinkVerifyData, type MagicLinkVerifyInput, type MutationHookConfig, PATHS, type PasskeyItem, type PasskeyLoginData, type PasskeyLoginStartData, type PasskeyLoginStartResponse, type PasskeyLoginVerifyData, type PasskeyRegisterStartData, type PasskeyRegisterStartInput, type PasskeyRegisterStartResponse, type PasskeyRegisterVerifyData, type PasswordResetConfirmData, type PasswordResetRequestData, PayButton, type PayButtonProps, type PaymentIntent, type PaymentProviderType, PayphoneCallback, type PayphoneCallbackProps, type PayphoneCheckoutStatus, type PayphoneConfirmParams, type PayphoneConfirmResult, type PayphoneModalProps, type PayphoneWidgetConfig, PayphoneWidgetRenderer, type PricingCardProps, type PricingFeatureListProps, PricingTable, type PricingTableProps, type ProviderModalProps, ReferralCard, type ReferralCardProps, type ReferralInfo, type ReferralItem, ReferralStats, type ReferralStatsData, type ReferralStatsProps, type RegisterPasskeyData, type ResetPasswordConfirmInput, ResetPasswordForm, type ResetPasswordFormProps, SDK_VERSION, type SessionSyncOptions, type SignupData, SignupForm, type SignupFormProps, type SignupInput, type SimpleMutationOptions, type SocialLoginData, type SocialLoginInput, type SubmitTransferProofData, SubscriptionBadge, type SubscriptionBadgeProps, type SupportedLocale, type TenantMemberInfo, type TenantWithRole, type TransferModalProps, type TransferProof, type UseBootstrapOptions, type UseBootstrapReturn, type UseChangePasswordOptions, type UseChangePasswordReturn, type UseCheckoutOptions, type UseFormReturn, type UseLoginOptions, type UseLoginReturn, type UseLogoutOptions, type UseLogoutReturn, type UseMagicLinkOptions, type UseMagicLinkReturn, type UsePasskeysOptions, type UsePasskeysReturn, type UsePasswordResetOptions, type UsePasswordResetReturn, type UsePayphoneCheckoutOptions, type UsePayphoneCheckoutReturn, type UsePayphoneConfirmOptions, type UseRefreshOptions, type UseRefreshReturn, type UseSessionOptions, type UseSessionReturn, type UseSignupOptions, type UseSignupReturn, type UseSocialLoginOptions, type UseSocialLoginReturn, type UserSubscription, buildPaths, changePasswordSchema, cn, createAccessClient, createForgotPasswordSchema, createLoginSchema, createMutationHook, createResetPasswordConfirmSchema, createSignupSchema, en, es, forgotPasswordSchema, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resetPasswordConfirmSchema, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordReset, usePasswordToggle, usePaymentProviders, usePayphoneCheckout, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferProofs };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { CSSProperties, ReactNode, FormEvent } from 'react';
2
+ import { CSSProperties, ReactNode, FormEvent, ReactElement } from 'react';
3
3
  import * as _tanstack_react_query from '@tanstack/react-query';
4
4
  import { UseMutationResult, UseQueryResult } from '@tanstack/react-query';
5
5
  import { z } from 'zod';
@@ -725,7 +725,26 @@ interface PayphoneCallbackProps {
725
725
  className?: string;
726
726
  style?: CSSProperties;
727
727
  }
728
- declare function PayphoneCallback({ onSuccess, onError, className, style, }: PayphoneCallbackProps): react_jsx_runtime.JSX.Element;
728
+ declare function PayphoneCallback({ onSuccess, onError, className, style }: PayphoneCallbackProps): react_jsx_runtime.JSX.Element;
729
+
730
+ declare global {
731
+ interface Window {
732
+ PPaymentButtonBox: new (config: Record<string, unknown>) => {
733
+ render: (containerId: string) => void;
734
+ };
735
+ }
736
+ }
737
+ /**
738
+ * Internal widget renderer — loads Payphone SDK and mounts PPaymentButtonBox.
739
+ * Used by usePayphoneCheckout hook. Not meant to be used directly.
740
+ */
741
+ declare function PayphoneWidgetRenderer({ config, responseUrl, containerId, onReady, onError, }: {
742
+ config: PayphoneWidgetConfig;
743
+ responseUrl: string;
744
+ containerId: string;
745
+ onReady?: () => void;
746
+ onError?: (error: Error) => void;
747
+ }): react_jsx_runtime.JSX.Element;
729
748
 
730
749
  interface SubscriptionBadgeProps {
731
750
  className?: string;
@@ -1559,6 +1578,20 @@ interface UsePayphoneConfirmOptions {
1559
1578
  }
1560
1579
  declare function usePayphoneConfirm(options?: UsePayphoneConfirmOptions): _tanstack_react_query.UseMutationResult<PayphoneConfirmResult, Error, PayphoneConfirmParams, unknown>;
1561
1580
 
1581
+ type PayphoneCheckoutStatus = 'idle' | 'loading' | 'ready' | 'confirming' | 'confirmed' | 'cancelled' | 'error';
1582
+ interface UsePayphoneCheckoutOptions {
1583
+ intentId: string;
1584
+ onSuccess?: (data: PayphoneConfirmResult) => void;
1585
+ onError?: (error: Error) => void;
1586
+ }
1587
+ interface UsePayphoneCheckoutReturn {
1588
+ PayphoneWidget: () => ReactElement | null;
1589
+ status: PayphoneCheckoutStatus;
1590
+ intentId: string;
1591
+ error: Error | null;
1592
+ }
1593
+ declare function usePayphoneCheckout({ intentId, onSuccess, onError, }: UsePayphoneCheckoutOptions): UsePayphoneCheckoutReturn;
1594
+
1562
1595
  declare function useTenants(): _tanstack_react_query.UseQueryResult<TenantWithRole[], Error>;
1563
1596
  declare function useTenantMembers(tenantId: string): _tanstack_react_query.UseQueryResult<TenantMemberInfo[], Error>;
1564
1597
  declare function useSwitchTenant(): {
@@ -1895,4 +1928,4 @@ interface SessionSyncOptions {
1895
1928
 
1896
1929
  declare const SDK_VERSION: string;
1897
1930
 
1898
- export { type AccessClient, type AccessClientConfig, type AccessMessages, type ApiError, type AppBranding, AuthForm, type AuthFormProps, type AuthPaths, type AuthState, type AuthSuccessResponse, type AuthUser, type AuthView, type AvailableProvider, type AziridContextValue, AziridProvider, type AziridProviderProps, BASE_PATHS, type BillingInvoice, type BillingPlan, type BootstrapResponse, type ChangePasswordData, type ChangePasswordInput, CheckoutButton, type CheckoutButtonProps, type CheckoutParams, type CheckoutResponse, type CreateTenantData, type FieldError, ForgotPasswordForm, type ForgotPasswordFormProps, type ForgotPasswordInput, InvoiceList, type InvoiceListProps, type LoginData, LoginForm, type LoginFormProps, type LoginInput, type MagicLinkRequestData, type MagicLinkRequestInput, type MagicLinkVerifyData, type MagicLinkVerifyInput, type MutationHookConfig, PATHS, type PasskeyItem, type PasskeyLoginData, type PasskeyLoginStartData, type PasskeyLoginStartResponse, type PasskeyLoginVerifyData, type PasskeyRegisterStartData, type PasskeyRegisterStartInput, type PasskeyRegisterStartResponse, type PasskeyRegisterVerifyData, type PasswordResetConfirmData, type PasswordResetRequestData, PayButton, type PayButtonProps, type PaymentIntent, type PaymentProviderType, PayphoneCallback, type PayphoneCallbackProps, type PayphoneConfirmParams, type PayphoneConfirmResult, type PayphoneModalProps, type PayphoneWidgetConfig, type PricingCardProps, type PricingFeatureListProps, PricingTable, type PricingTableProps, type ProviderModalProps, ReferralCard, type ReferralCardProps, type ReferralInfo, type ReferralItem, ReferralStats, type ReferralStatsData, type ReferralStatsProps, type RegisterPasskeyData, type ResetPasswordConfirmInput, ResetPasswordForm, type ResetPasswordFormProps, SDK_VERSION, type SessionSyncOptions, type SignupData, SignupForm, type SignupFormProps, type SignupInput, type SimpleMutationOptions, type SocialLoginData, type SocialLoginInput, type SubmitTransferProofData, SubscriptionBadge, type SubscriptionBadgeProps, type SupportedLocale, type TenantMemberInfo, type TenantWithRole, type TransferModalProps, type TransferProof, type UseBootstrapOptions, type UseBootstrapReturn, type UseChangePasswordOptions, type UseChangePasswordReturn, type UseCheckoutOptions, type UseFormReturn, type UseLoginOptions, type UseLoginReturn, type UseLogoutOptions, type UseLogoutReturn, type UseMagicLinkOptions, type UseMagicLinkReturn, type UsePasskeysOptions, type UsePasskeysReturn, type UsePasswordResetOptions, type UsePasswordResetReturn, type UsePayphoneConfirmOptions, type UseRefreshOptions, type UseRefreshReturn, type UseSessionOptions, type UseSessionReturn, type UseSignupOptions, type UseSignupReturn, type UseSocialLoginOptions, type UseSocialLoginReturn, type UserSubscription, buildPaths, changePasswordSchema, cn, createAccessClient, createForgotPasswordSchema, createLoginSchema, createMutationHook, createResetPasswordConfirmSchema, createSignupSchema, en, es, forgotPasswordSchema, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resetPasswordConfirmSchema, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordReset, usePasswordToggle, usePaymentProviders, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferProofs };
1931
+ export { type AccessClient, type AccessClientConfig, type AccessMessages, type ApiError, type AppBranding, AuthForm, type AuthFormProps, type AuthPaths, type AuthState, type AuthSuccessResponse, type AuthUser, type AuthView, type AvailableProvider, type AziridContextValue, AziridProvider, type AziridProviderProps, BASE_PATHS, type BillingInvoice, type BillingPlan, type BootstrapResponse, type ChangePasswordData, type ChangePasswordInput, CheckoutButton, type CheckoutButtonProps, type CheckoutParams, type CheckoutResponse, type CreateTenantData, type FieldError, ForgotPasswordForm, type ForgotPasswordFormProps, type ForgotPasswordInput, InvoiceList, type InvoiceListProps, type LoginData, LoginForm, type LoginFormProps, type LoginInput, type MagicLinkRequestData, type MagicLinkRequestInput, type MagicLinkVerifyData, type MagicLinkVerifyInput, type MutationHookConfig, PATHS, type PasskeyItem, type PasskeyLoginData, type PasskeyLoginStartData, type PasskeyLoginStartResponse, type PasskeyLoginVerifyData, type PasskeyRegisterStartData, type PasskeyRegisterStartInput, type PasskeyRegisterStartResponse, type PasskeyRegisterVerifyData, type PasswordResetConfirmData, type PasswordResetRequestData, PayButton, type PayButtonProps, type PaymentIntent, type PaymentProviderType, PayphoneCallback, type PayphoneCallbackProps, type PayphoneCheckoutStatus, type PayphoneConfirmParams, type PayphoneConfirmResult, type PayphoneModalProps, type PayphoneWidgetConfig, PayphoneWidgetRenderer, type PricingCardProps, type PricingFeatureListProps, PricingTable, type PricingTableProps, type ProviderModalProps, ReferralCard, type ReferralCardProps, type ReferralInfo, type ReferralItem, ReferralStats, type ReferralStatsData, type ReferralStatsProps, type RegisterPasskeyData, type ResetPasswordConfirmInput, ResetPasswordForm, type ResetPasswordFormProps, SDK_VERSION, type SessionSyncOptions, type SignupData, SignupForm, type SignupFormProps, type SignupInput, type SimpleMutationOptions, type SocialLoginData, type SocialLoginInput, type SubmitTransferProofData, SubscriptionBadge, type SubscriptionBadgeProps, type SupportedLocale, type TenantMemberInfo, type TenantWithRole, type TransferModalProps, type TransferProof, type UseBootstrapOptions, type UseBootstrapReturn, type UseChangePasswordOptions, type UseChangePasswordReturn, type UseCheckoutOptions, type UseFormReturn, type UseLoginOptions, type UseLoginReturn, type UseLogoutOptions, type UseLogoutReturn, type UseMagicLinkOptions, type UseMagicLinkReturn, type UsePasskeysOptions, type UsePasskeysReturn, type UsePasswordResetOptions, type UsePasswordResetReturn, type UsePayphoneCheckoutOptions, type UsePayphoneCheckoutReturn, type UsePayphoneConfirmOptions, type UseRefreshOptions, type UseRefreshReturn, type UseSessionOptions, type UseSessionReturn, type UseSignupOptions, type UseSignupReturn, type UseSocialLoginOptions, type UseSocialLoginReturn, type UserSubscription, buildPaths, changePasswordSchema, cn, createAccessClient, createForgotPasswordSchema, createLoginSchema, createMutationHook, createResetPasswordConfirmSchema, createSignupSchema, en, es, forgotPasswordSchema, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resetPasswordConfirmSchema, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordReset, usePasswordToggle, usePaymentProviders, usePayphoneCheckout, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferProofs };
package/dist/index.js CHANGED
@@ -677,10 +677,7 @@ function AziridProviderInner({
677
677
  () => resolveMessages(props.locale ?? "es", props.messages),
678
678
  [props.locale, props.messages]
679
679
  );
680
- const brandingValue = useMemo(
681
- () => ({ branding, messages }),
682
- [branding, messages]
683
- );
680
+ const brandingValue = useMemo(() => ({ branding, messages }), [branding, messages]);
684
681
  const isProxyMode = !props.apiUrl;
685
682
  const syncUrl = useMemo(() => {
686
683
  if (props.sessionSyncUrl === false) return null;
@@ -805,13 +802,7 @@ function AziridProviderInner({
805
802
  (data) => data.at ?? data.accessToken,
806
803
  []
807
804
  );
808
- const {
809
- loginMutation,
810
- signupMutation,
811
- logoutMutation,
812
- refreshFn,
813
- switchTenantFn
814
- } = useAuthMutations({
805
+ const { loginMutation, signupMutation, logoutMutation, refreshFn, switchTenantFn } = useAuthMutations({
815
806
  client,
816
807
  props,
817
808
  setUser,
@@ -1872,10 +1863,7 @@ function useReferral() {
1872
1863
  }
1873
1864
  return false;
1874
1865
  }, [query.data?.referralUrl]);
1875
- return useMemo(
1876
- () => ({ ...query, copyToClipboard }),
1877
- [query, copyToClipboard]
1878
- );
1866
+ return useMemo(() => ({ ...query, copyToClipboard }), [query, copyToClipboard]);
1879
1867
  }
1880
1868
  var styles = {
1881
1869
  card: {
@@ -2266,8 +2254,9 @@ function usePaymentProviders() {
2266
2254
  }
2267
2255
 
2268
2256
  // src/utils/payphone-loader.ts
2269
- var PAYPHONE_CSS_URL = "https://cdn.payphonetodoesposible.com/box/v1.1/payphone-payment-box.css";
2270
- var PAYPHONE_JS_URL = "https://cdn.payphonetodoesposible.com/box/v1.1/payphone-payment-box.js";
2257
+ var PAYPHONE_CDN = "https://cdn.payphonetodoesposible.com";
2258
+ var PAYPHONE_CSS_URL = `${PAYPHONE_CDN}/box/v1.1/payphone-payment-box.css`;
2259
+ var PAYPHONE_JS_URL = `${PAYPHONE_CDN}/box/v1.1/payphone-payment-box.js`;
2271
2260
  var loadPromise = null;
2272
2261
  function loadCss(href) {
2273
2262
  if (document.querySelector(`link[href="${href}"]`)) return;
@@ -2285,7 +2274,11 @@ function loadScript(src) {
2285
2274
  const script = document.createElement("script");
2286
2275
  script.src = src;
2287
2276
  script.onload = () => resolve();
2288
- script.onerror = () => reject(new Error(`Failed to load Payphone SDK: ${src}`));
2277
+ script.onerror = () => reject(
2278
+ new Error(
2279
+ `Failed to load Payphone SDK from ${src}. If your app uses a Content-Security-Policy, add "${PAYPHONE_CDN}" to both script-src and style-src directives.`
2280
+ )
2281
+ );
2289
2282
  document.head.appendChild(script);
2290
2283
  });
2291
2284
  }
@@ -2294,7 +2287,10 @@ function loadPayphoneSdk() {
2294
2287
  loadPromise = (async () => {
2295
2288
  loadCss(PAYPHONE_CSS_URL);
2296
2289
  await loadScript(PAYPHONE_JS_URL);
2297
- })();
2290
+ })().catch((err) => {
2291
+ loadPromise = null;
2292
+ throw err;
2293
+ });
2298
2294
  return loadPromise;
2299
2295
  }
2300
2296
  function PayphoneModal({ config, successUrl, onClose }) {
@@ -2662,16 +2658,12 @@ var intervalLabels2 = {
2662
2658
  YEARLY: "/yr",
2663
2659
  ONE_TIME: ""
2664
2660
  };
2665
- function TransferModal({
2666
- data,
2667
- onClose
2668
- }) {
2661
+ function TransferModal({ data, onClose }) {
2669
2662
  const bankDetails = data.bankDetails;
2670
2663
  return /* @__PURE__ */ jsx("div", { style: styles5.overlay, onClick: onClose, children: /* @__PURE__ */ jsxs("div", { style: styles5.modal, onClick: (e) => e.stopPropagation(), children: [
2671
2664
  /* @__PURE__ */ jsx("h2", { style: styles5.modalTitle, children: "Manual Transfer" }),
2672
2665
  /* @__PURE__ */ jsxs("p", { style: styles5.modalSubtitle, children: [
2673
- "Transfer the amount below to subscribe to",
2674
- " ",
2666
+ "Transfer the amount below to subscribe to ",
2675
2667
  /* @__PURE__ */ jsx("strong", { children: data.plan?.name })
2676
2668
  ] }),
2677
2669
  /* @__PURE__ */ jsxs(
@@ -2734,9 +2726,7 @@ function PricingTable({
2734
2726
  const { data: plans, isLoading: plansLoading } = usePlans();
2735
2727
  const { data: subscription } = useSubscription();
2736
2728
  const { data: providers } = usePaymentProviders();
2737
- const [transferData, setTransferData] = useState(
2738
- null
2739
- );
2729
+ const [transferData, setTransferData] = useState(null);
2740
2730
  const [payphoneData, setPayphoneData] = useState(null);
2741
2731
  const [pendingPlan, setPendingPlan] = useState(null);
2742
2732
  const [showProviderModal, setShowProviderModal] = useState(false);
@@ -2756,8 +2746,7 @@ function PricingTable({
2756
2746
  checkout({ planId, provider, successUrl, cancelUrl });
2757
2747
  };
2758
2748
  const handleSelect = (plan) => {
2759
- if (subscription?.planId === plan.id && subscription.status === "ACTIVE")
2760
- return;
2749
+ if (subscription?.planId === plan.id && subscription.status === "ACTIVE") return;
2761
2750
  if (onPlanSelect) {
2762
2751
  onPlanSelect(plan);
2763
2752
  return;
@@ -2829,26 +2818,19 @@ function PricingTable({
2829
2818
  }
2830
2819
  const sortedPlans = plans ? [...plans].sort((a, b) => a.sortOrder - b.sortOrder) : [];
2831
2820
  return /* @__PURE__ */ jsxs(Fragment, { children: [
2832
- /* @__PURE__ */ jsx(
2833
- "div",
2834
- {
2835
- className,
2836
- style: { ...styles5.grid(columns), ...style },
2837
- children: sortedPlans.map((plan) => {
2838
- const isCurrentPlan = subscription?.planId === plan.id && subscription.status === "ACTIVE";
2839
- return /* @__PURE__ */ jsx(
2840
- PricingCard,
2841
- {
2842
- plan,
2843
- isCurrentPlan,
2844
- isCheckoutPending: checkoutPending,
2845
- onSelect: handleSelect
2846
- },
2847
- plan.id
2848
- );
2849
- })
2850
- }
2851
- ),
2821
+ /* @__PURE__ */ jsx("div", { className, style: { ...styles5.grid(columns), ...style }, children: sortedPlans.map((plan) => {
2822
+ const isCurrentPlan = subscription?.planId === plan.id && subscription.status === "ACTIVE";
2823
+ return /* @__PURE__ */ jsx(
2824
+ PricingCard,
2825
+ {
2826
+ plan,
2827
+ isCurrentPlan,
2828
+ isCheckoutPending: checkoutPending,
2829
+ onSelect: handleSelect
2830
+ },
2831
+ plan.id
2832
+ );
2833
+ }) }),
2852
2834
  showProviderModal && pendingPlan && providers && providers.length > 1 && /* @__PURE__ */ jsx(
2853
2835
  ProviderSelectModal,
2854
2836
  {
@@ -2861,13 +2843,7 @@ function PricingTable({
2861
2843
  }
2862
2844
  }
2863
2845
  ),
2864
- transferData && /* @__PURE__ */ jsx(
2865
- TransferModal,
2866
- {
2867
- data: transferData,
2868
- onClose: () => setTransferData(null)
2869
- }
2870
- ),
2846
+ transferData && /* @__PURE__ */ jsx(TransferModal, { data: transferData, onClose: () => setTransferData(null) }),
2871
2847
  payphoneData?.widgetConfig && /* @__PURE__ */ jsx(
2872
2848
  PayphoneModal,
2873
2849
  {
@@ -3016,11 +2992,7 @@ function ProviderModal({
3016
2992
  /* @__PURE__ */ jsx("button", { type: "button", style: modalStyles.cancelButton, onClick: onClose, children: labels?.cancel ?? "Cancel" })
3017
2993
  ] }) });
3018
2994
  }
3019
- function TransferModal2({
3020
- data,
3021
- onClose,
3022
- labels
3023
- }) {
2995
+ function TransferModal2({ data, onClose, labels }) {
3024
2996
  const bankDetails = data.bankDetails;
3025
2997
  const plan = data.plan;
3026
2998
  const intent = data.intent;
@@ -3131,9 +3103,12 @@ function PayButton({
3131
3103
  setTransferData(data);
3132
3104
  setShowTransferModal(true);
3133
3105
  setShowProviderModal(false);
3134
- } else if (data.provider === "PAYPHONE" && data.widgetConfig) {
3106
+ return;
3107
+ }
3108
+ if (data.provider === "PAYPHONE" && data.widgetConfig) {
3135
3109
  setPayphoneData(data);
3136
3110
  setShowProviderModal(false);
3111
+ return;
3137
3112
  }
3138
3113
  onSuccess?.(data);
3139
3114
  },
@@ -3178,7 +3153,7 @@ function PayButton({
3178
3153
  },
3179
3154
  onClick: handleClick,
3180
3155
  disabled: isDisabled,
3181
- children: isPending ? billing?.processing ?? "Processing..." : children ?? (billing?.pay ?? "Pay")
3156
+ children: isPending ? billing?.processing ?? "Processing..." : children ?? billing?.pay ?? "Pay"
3182
3157
  }
3183
3158
  ),
3184
3159
  showProviderModal && providers && providers.length > 1 && /* @__PURE__ */ jsx(
@@ -3197,6 +3172,7 @@ function PayButton({
3197
3172
  data: transferData,
3198
3173
  onClose: () => {
3199
3174
  setShowTransferModal(false);
3175
+ onSuccess?.(transferData);
3200
3176
  setTransferData(null);
3201
3177
  },
3202
3178
  labels: billing
@@ -3207,7 +3183,10 @@ function PayButton({
3207
3183
  {
3208
3184
  config: payphoneData.widgetConfig,
3209
3185
  successUrl,
3210
- onClose: () => setPayphoneData(null)
3186
+ onClose: () => {
3187
+ onSuccess?.(payphoneData);
3188
+ setPayphoneData(null);
3189
+ }
3211
3190
  }
3212
3191
  )
3213
3192
  ] });
@@ -3220,12 +3199,7 @@ function usePayphoneConfirm(options) {
3220
3199
  onError: options?.onError
3221
3200
  });
3222
3201
  }
3223
- function PayphoneCallback({
3224
- onSuccess,
3225
- onError,
3226
- className,
3227
- style
3228
- }) {
3202
+ function PayphoneCallback({ onSuccess, onError, className, style }) {
3229
3203
  const { mutate, isPending, isSuccess, isError, error, data } = usePayphoneConfirm({
3230
3204
  onSuccess,
3231
3205
  onError
@@ -3269,6 +3243,41 @@ var subtextStyle = {
3269
3243
  color: "#6b7280",
3270
3244
  margin: 0
3271
3245
  };
3246
+ function PayphoneWidgetRenderer({
3247
+ config,
3248
+ responseUrl,
3249
+ containerId,
3250
+ onReady,
3251
+ onError
3252
+ }) {
3253
+ const initialized = useRef(false);
3254
+ useEffect(() => {
3255
+ if (initialized.current) return;
3256
+ initialized.current = true;
3257
+ loadPayphoneSdk().then(() => {
3258
+ requestAnimationFrame(() => {
3259
+ if (typeof window.PPaymentButtonBox === "undefined") {
3260
+ onError?.(new Error("Payphone SDK failed to initialize"));
3261
+ return;
3262
+ }
3263
+ new window.PPaymentButtonBox({
3264
+ token: config.token,
3265
+ clientTransactionId: config.clientTransactionId,
3266
+ amount: config.amount,
3267
+ amountWithoutTax: config.amountWithoutTax,
3268
+ currency: config.currency,
3269
+ storeId: config.storeId,
3270
+ reference: config.reference,
3271
+ responseUrl
3272
+ }).render(containerId);
3273
+ onReady?.();
3274
+ });
3275
+ }).catch((err) => {
3276
+ onError?.(new Error(err instanceof Error ? err.message : "Failed to load Payphone SDK"));
3277
+ });
3278
+ }, [config, responseUrl, containerId, onReady, onError]);
3279
+ return /* @__PURE__ */ jsx("div", { id: containerId });
3280
+ }
3272
3281
  var statusConfig = {
3273
3282
  ACTIVE: { bg: "#d1fae5", color: "#065f46", label: "Active" },
3274
3283
  TRIALING: { bg: "#dbeafe", color: "#1e40af", label: "Trial" },
@@ -3730,6 +3739,85 @@ function useTransferProofs() {
3730
3739
  queryFn: () => client.get(client.paths.transferProofs)
3731
3740
  });
3732
3741
  }
3742
+ var CONTAINER_ID = "pp-checkout-azirid";
3743
+ function usePayphoneCheckout({
3744
+ intentId,
3745
+ onSuccess,
3746
+ onError
3747
+ }) {
3748
+ const [status, setStatus] = useState("idle");
3749
+ const [widgetConfig, setWidgetConfig] = useState(null);
3750
+ const [currentError, setCurrentError] = useState(null);
3751
+ const checkoutTriggered = useRef(false);
3752
+ const confirmTriggered = useRef(false);
3753
+ const responseUrl = typeof window !== "undefined" ? window.location.href.split("?")[0] : "";
3754
+ const params = typeof window !== "undefined" ? new URLSearchParams(window.location.search) : new URLSearchParams();
3755
+ const callbackId = params.get("id");
3756
+ const callbackClientTxId = params.get("clientTransactionId");
3757
+ const isCallback = !!(callbackId && callbackClientTxId);
3758
+ const { checkout } = useCheckout({
3759
+ redirectOnSuccess: false,
3760
+ onSuccess: (data) => {
3761
+ if (data.provider === "PAYPHONE" && data.widgetConfig) {
3762
+ setWidgetConfig(data.widgetConfig);
3763
+ setStatus("ready");
3764
+ }
3765
+ },
3766
+ onError: (err) => {
3767
+ setCurrentError(err);
3768
+ setStatus("error");
3769
+ onError?.(err);
3770
+ }
3771
+ });
3772
+ useEffect(() => {
3773
+ if (isCallback || checkoutTriggered.current) return;
3774
+ checkoutTriggered.current = true;
3775
+ setStatus("loading");
3776
+ checkout({
3777
+ intentId,
3778
+ provider: "PAYPHONE",
3779
+ successUrl: responseUrl,
3780
+ cancelUrl: responseUrl
3781
+ });
3782
+ }, [checkout, intentId, responseUrl, isCallback]);
3783
+ const { mutate: confirm } = usePayphoneConfirm({
3784
+ onSuccess: (data) => {
3785
+ setStatus(data.status === "confirmed" || data.status === "already_confirmed" ? "confirmed" : "cancelled");
3786
+ onSuccess?.(data);
3787
+ },
3788
+ onError: (err) => {
3789
+ setCurrentError(err);
3790
+ setStatus("error");
3791
+ onError?.(err);
3792
+ }
3793
+ });
3794
+ useEffect(() => {
3795
+ if (!isCallback || confirmTriggered.current) return;
3796
+ confirmTriggered.current = true;
3797
+ setStatus("confirming");
3798
+ confirm({ id: Number(callbackId), clientTransactionId: callbackClientTxId });
3799
+ }, [isCallback, callbackId, callbackClientTxId, confirm]);
3800
+ const handleSdkError = useCallback(
3801
+ (err) => {
3802
+ setCurrentError(err);
3803
+ setStatus("error");
3804
+ onError?.(err);
3805
+ },
3806
+ [onError]
3807
+ );
3808
+ const PayphoneWidget = useMemo(() => {
3809
+ return function PayphoneWidgetInner() {
3810
+ if (!widgetConfig || isCallback) return null;
3811
+ return PayphoneWidgetRenderer({
3812
+ config: widgetConfig,
3813
+ responseUrl,
3814
+ containerId: CONTAINER_ID,
3815
+ onError: handleSdkError
3816
+ });
3817
+ };
3818
+ }, [widgetConfig, responseUrl, isCallback, handleSdkError]);
3819
+ return { PayphoneWidget, status, intentId, error: currentError };
3820
+ }
3733
3821
  function useTenants() {
3734
3822
  const client = useAccessClient();
3735
3823
  return useQuery({
@@ -3822,8 +3910,8 @@ function usePasswordToggle() {
3822
3910
  }
3823
3911
 
3824
3912
  // src/index.ts
3825
- var SDK_VERSION = "0.9.3";
3913
+ var SDK_VERSION = "0.9.5";
3826
3914
 
3827
- export { AuthForm, AziridProvider, BASE_PATHS, CheckoutButton, ForgotPasswordForm, InvoiceList, LoginForm, PATHS, PayButton, PayphoneCallback, PricingTable, ReferralCard, ReferralStats, ResetPasswordForm, SDK_VERSION, SignupForm, SubscriptionBadge, buildPaths, changePasswordSchema, cn, createAccessClient, createForgotPasswordSchema, createLoginSchema, createMutationHook, createResetPasswordConfirmSchema, createSignupSchema, en, es, forgotPasswordSchema, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resetPasswordConfirmSchema, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordReset, usePasswordToggle, usePaymentProviders, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferProofs };
3915
+ export { AuthForm, AziridProvider, BASE_PATHS, CheckoutButton, ForgotPasswordForm, InvoiceList, LoginForm, PATHS, PayButton, PayphoneCallback, PayphoneWidgetRenderer, PricingTable, ReferralCard, ReferralStats, ResetPasswordForm, SDK_VERSION, SignupForm, SubscriptionBadge, buildPaths, changePasswordSchema, cn, createAccessClient, createForgotPasswordSchema, createLoginSchema, createMutationHook, createResetPasswordConfirmSchema, createSignupSchema, en, es, forgotPasswordSchema, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resetPasswordConfirmSchema, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordReset, usePasswordToggle, usePaymentProviders, usePayphoneCheckout, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferProofs };
3828
3916
  //# sourceMappingURL=index.js.map
3829
3917
  //# sourceMappingURL=index.js.map