@b3dotfun/sdk 0.1.68 → 0.1.69-alpha.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.
- package/dist/cjs/anyspend/platform/client.d.ts +35 -0
- package/dist/cjs/anyspend/platform/client.js +158 -0
- package/dist/cjs/anyspend/platform/errors.d.ts +38 -0
- package/dist/cjs/anyspend/platform/errors.js +77 -0
- package/dist/cjs/anyspend/platform/index.d.ts +87 -0
- package/dist/cjs/anyspend/platform/index.js +85 -0
- package/dist/cjs/anyspend/platform/resources/analytics.d.ts +7 -0
- package/dist/cjs/anyspend/platform/resources/analytics.js +12 -0
- package/dist/cjs/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
- package/dist/cjs/anyspend/platform/resources/checkout-sessions.js +27 -0
- package/dist/cjs/anyspend/platform/resources/customers.d.ts +19 -0
- package/dist/cjs/anyspend/platform/resources/customers.js +34 -0
- package/dist/cjs/anyspend/platform/resources/discount-codes.d.ts +29 -0
- package/dist/cjs/anyspend/platform/resources/discount-codes.js +31 -0
- package/dist/cjs/anyspend/platform/resources/events.d.ts +14 -0
- package/dist/cjs/anyspend/platform/resources/events.js +16 -0
- package/dist/cjs/anyspend/platform/resources/notifications.d.ts +18 -0
- package/dist/cjs/anyspend/platform/resources/notifications.js +27 -0
- package/dist/cjs/anyspend/platform/resources/organization.d.ts +17 -0
- package/dist/cjs/anyspend/platform/resources/organization.js +15 -0
- package/dist/cjs/anyspend/platform/resources/payment-links.d.ts +21 -0
- package/dist/cjs/anyspend/platform/resources/payment-links.js +49 -0
- package/dist/cjs/anyspend/platform/resources/products.d.ts +27 -0
- package/dist/cjs/anyspend/platform/resources/products.js +31 -0
- package/dist/cjs/anyspend/platform/resources/transactions.d.ts +11 -0
- package/dist/cjs/anyspend/platform/resources/transactions.js +25 -0
- package/dist/cjs/anyspend/platform/resources/webhooks.d.ts +14 -0
- package/dist/cjs/anyspend/platform/resources/webhooks.js +33 -0
- package/dist/cjs/anyspend/platform/resources/widgets.d.ts +38 -0
- package/dist/cjs/anyspend/platform/resources/widgets.js +31 -0
- package/dist/cjs/anyspend/platform/types.d.ts +478 -0
- package/dist/cjs/anyspend/platform/types.js +5 -0
- package/dist/cjs/anyspend/platform/utils/idempotency.d.ts +4 -0
- package/dist/cjs/anyspend/platform/utils/idempotency.js +17 -0
- package/dist/cjs/anyspend/platform/utils/pagination.d.ts +12 -0
- package/dist/cjs/anyspend/platform/utils/pagination.js +22 -0
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +127 -16
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +4 -4
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +55 -8
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +48 -16
- package/dist/cjs/anyspend/react/components/checkout/KycGate.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/checkout/KycGate.js +203 -0
- package/dist/cjs/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
- package/dist/cjs/anyspend/react/components/checkout/VariablePricingInput.js +145 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +1 -1
- package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/cjs/anyspend/react/components/index.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/index.js +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -0
- package/dist/cjs/anyspend/react/hooks/useKycStatus.d.ts +47 -0
- package/dist/cjs/anyspend/react/hooks/useKycStatus.js +124 -0
- package/dist/cjs/anyspend/services/anyspend.d.ts +4 -1
- package/dist/cjs/anyspend/services/anyspend.js +3 -1
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/BottomNavigation.js +3 -3
- package/dist/cjs/global-account/react/components/ManageAccount/HomeActions.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -5
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +21 -24
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
- package/dist/cjs/global-account/react/hooks/useAuth.js +1 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +3 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +94 -24
- package/dist/cjs/global-account/react/hooks/useGetAllTWSigners.js +2 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/cjs/global-account/react/stores/useModalStore.js +2 -0
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +18 -0
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +17 -0
- package/dist/esm/anyspend/platform/client.d.ts +35 -0
- package/dist/esm/anyspend/platform/client.js +153 -0
- package/dist/esm/anyspend/platform/errors.d.ts +38 -0
- package/dist/esm/anyspend/platform/errors.js +67 -0
- package/dist/esm/anyspend/platform/index.d.ts +87 -0
- package/dist/esm/anyspend/platform/index.js +75 -0
- package/dist/esm/anyspend/platform/resources/analytics.d.ts +7 -0
- package/dist/esm/anyspend/platform/resources/analytics.js +8 -0
- package/dist/esm/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
- package/dist/esm/anyspend/platform/resources/checkout-sessions.js +23 -0
- package/dist/esm/anyspend/platform/resources/customers.d.ts +19 -0
- package/dist/esm/anyspend/platform/resources/customers.js +30 -0
- package/dist/esm/anyspend/platform/resources/discount-codes.d.ts +29 -0
- package/dist/esm/anyspend/platform/resources/discount-codes.js +27 -0
- package/dist/esm/anyspend/platform/resources/events.d.ts +14 -0
- package/dist/esm/anyspend/platform/resources/events.js +12 -0
- package/dist/esm/anyspend/platform/resources/notifications.d.ts +18 -0
- package/dist/esm/anyspend/platform/resources/notifications.js +23 -0
- package/dist/esm/anyspend/platform/resources/organization.d.ts +17 -0
- package/dist/esm/anyspend/platform/resources/organization.js +11 -0
- package/dist/esm/anyspend/platform/resources/payment-links.d.ts +21 -0
- package/dist/esm/anyspend/platform/resources/payment-links.js +45 -0
- package/dist/esm/anyspend/platform/resources/products.d.ts +27 -0
- package/dist/esm/anyspend/platform/resources/products.js +27 -0
- package/dist/esm/anyspend/platform/resources/transactions.d.ts +11 -0
- package/dist/esm/anyspend/platform/resources/transactions.js +21 -0
- package/dist/esm/anyspend/platform/resources/webhooks.d.ts +14 -0
- package/dist/esm/anyspend/platform/resources/webhooks.js +29 -0
- package/dist/esm/anyspend/platform/resources/widgets.d.ts +38 -0
- package/dist/esm/anyspend/platform/resources/widgets.js +27 -0
- package/dist/esm/anyspend/platform/types.d.ts +478 -0
- package/dist/esm/anyspend/platform/types.js +4 -0
- package/dist/esm/anyspend/platform/utils/idempotency.d.ts +4 -0
- package/dist/esm/anyspend/platform/utils/idempotency.js +14 -0
- package/dist/esm/anyspend/platform/utils/pagination.d.ts +12 -0
- package/dist/esm/anyspend/platform/utils/pagination.js +19 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +5 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +128 -17
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +4 -4
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +55 -8
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +1 -1
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +50 -18
- package/dist/esm/anyspend/react/components/checkout/KycGate.d.ts +11 -0
- package/dist/esm/anyspend/react/components/checkout/KycGate.js +167 -0
- package/dist/esm/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
- package/dist/esm/anyspend/react/components/checkout/VariablePricingInput.js +142 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +1 -1
- package/dist/esm/anyspend/react/components/common/FeeDetailPanel.js +1 -1
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +1 -1
- package/dist/esm/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/esm/anyspend/react/components/index.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -0
- package/dist/esm/anyspend/react/hooks/useKycStatus.d.ts +47 -0
- package/dist/esm/anyspend/react/hooks/useKycStatus.js +117 -0
- package/dist/esm/anyspend/services/anyspend.d.ts +4 -1
- package/dist/esm/anyspend/services/anyspend.js +3 -1
- package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/esm/global-account/react/components/ManageAccount/BottomNavigation.js +3 -3
- package/dist/esm/global-account/react/components/ManageAccount/HomeActions.js +1 -1
- package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -5
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +21 -24
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
- package/dist/esm/global-account/react/hooks/useAuth.js +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +3 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.js +94 -24
- package/dist/esm/global-account/react/hooks/useGetAllTWSigners.js +2 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/esm/global-account/react/stores/useModalStore.js +2 -0
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +18 -0
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +16 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/platform/client.d.ts +35 -0
- package/dist/types/anyspend/platform/errors.d.ts +38 -0
- package/dist/types/anyspend/platform/index.d.ts +87 -0
- package/dist/types/anyspend/platform/resources/analytics.d.ts +7 -0
- package/dist/types/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
- package/dist/types/anyspend/platform/resources/customers.d.ts +19 -0
- package/dist/types/anyspend/platform/resources/discount-codes.d.ts +29 -0
- package/dist/types/anyspend/platform/resources/events.d.ts +14 -0
- package/dist/types/anyspend/platform/resources/notifications.d.ts +18 -0
- package/dist/types/anyspend/platform/resources/organization.d.ts +17 -0
- package/dist/types/anyspend/platform/resources/payment-links.d.ts +21 -0
- package/dist/types/anyspend/platform/resources/products.d.ts +27 -0
- package/dist/types/anyspend/platform/resources/transactions.d.ts +11 -0
- package/dist/types/anyspend/platform/resources/webhooks.d.ts +14 -0
- package/dist/types/anyspend/platform/resources/widgets.d.ts +38 -0
- package/dist/types/anyspend/platform/types.d.ts +478 -0
- package/dist/types/anyspend/platform/utils/idempotency.d.ts +4 -0
- package/dist/types/anyspend/platform/utils/pagination.d.ts +12 -0
- package/dist/types/anyspend/react/components/AnySpend.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/KycGate.d.ts +11 -0
- package/dist/types/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
- package/dist/types/anyspend/react/components/index.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useKycStatus.d.ts +47 -0
- package/dist/types/anyspend/services/anyspend.d.ts +4 -1
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +3 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +18 -0
- package/package.json +7 -1
- package/src/anyspend/docs/checkout-sessions.md +20 -3
- package/src/anyspend/platform/client.ts +198 -0
- package/src/anyspend/platform/errors.ts +92 -0
- package/src/anyspend/platform/index.ts +129 -0
- package/src/anyspend/platform/resources/analytics.ts +10 -0
- package/src/anyspend/platform/resources/checkout-sessions.ts +36 -0
- package/src/anyspend/platform/resources/customers.ts +54 -0
- package/src/anyspend/platform/resources/discount-codes.ts +63 -0
- package/src/anyspend/platform/resources/events.ts +22 -0
- package/src/anyspend/platform/resources/notifications.ts +37 -0
- package/src/anyspend/platform/resources/organization.ts +24 -0
- package/src/anyspend/platform/resources/payment-links.ts +74 -0
- package/src/anyspend/platform/resources/products.ts +59 -0
- package/src/anyspend/platform/resources/transactions.ts +33 -0
- package/src/anyspend/platform/resources/webhooks.ts +47 -0
- package/src/anyspend/platform/resources/widgets.ts +63 -0
- package/src/anyspend/platform/types.ts +532 -0
- package/src/anyspend/platform/utils/idempotency.ts +15 -0
- package/src/anyspend/platform/utils/pagination.ts +32 -0
- package/src/anyspend/react/components/AnySpend.tsx +152 -18
- package/src/anyspend/react/components/AnySpendCustom.tsx +4 -4
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +2 -2
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +81 -18
- package/src/anyspend/react/components/checkout/AnySpendCheckoutTrigger.tsx +4 -0
- package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +8 -0
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +4 -13
- package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +86 -17
- package/src/anyspend/react/components/checkout/KycGate.tsx +387 -0
- package/src/anyspend/react/components/checkout/VariablePricingInput.tsx +247 -0
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +1 -1
- package/src/anyspend/react/components/common/FeeDetailPanel.tsx +1 -1
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +1 -1
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +1 -1
- package/src/anyspend/react/components/common/RecipientSelection.tsx +1 -1
- package/src/anyspend/react/components/index.ts +1 -0
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +17 -0
- package/src/anyspend/react/hooks/useKycStatus.ts +150 -0
- package/src/anyspend/services/anyspend.ts +7 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +0 -2
- package/src/global-account/react/components/ManageAccount/BottomNavigation.tsx +7 -7
- package/src/global-account/react/components/ManageAccount/HomeActions.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +7 -7
- package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -5
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +35 -25
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +1 -1
- package/src/global-account/react/hooks/useAuth.ts +2 -2
- package/src/global-account/react/hooks/useAuthentication.ts +92 -27
- package/src/global-account/react/hooks/useGetAllTWSigners.tsx +2 -1
- package/src/global-account/react/stores/useModalStore.ts +6 -0
- package/src/global-account/react/utils/createWagmiConfig.tsx +18 -0
|
@@ -10,13 +10,16 @@ import { USDC_BASE } from "@b3dotfun/sdk/anyspend/constants";
|
|
|
10
10
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
11
11
|
import { formatUnits } from "@b3dotfun/sdk/shared/utils/number";
|
|
12
12
|
import { getStripePromise } from "@b3dotfun/sdk/shared/utils/payment.utils";
|
|
13
|
-
import { ShinyButton, TextShimmer, useB3Config, useTokenData } from "@b3dotfun/sdk/global-account/react";
|
|
13
|
+
import { ShinyButton, TextShimmer, useB3Config, useModalStore, useTokenData } from "@b3dotfun/sdk/global-account/react";
|
|
14
|
+
import { thirdwebB3Chain } from "@b3dotfun/sdk/shared/constants/chains/b3Chain";
|
|
14
15
|
import { AddressElement, Elements, PaymentElement, useElements, useStripe } from "@stripe/react-stripe-js";
|
|
15
16
|
import type { PaymentIntentResult, StripePaymentElementOptions } from "@stripe/stripe-js";
|
|
16
|
-
import { Loader2, Lock } from "lucide-react";
|
|
17
|
+
import { Loader2, Lock, Wallet } from "lucide-react";
|
|
17
18
|
import { AnimatePresence, motion } from "motion/react";
|
|
18
19
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
20
|
+
import { useAccount } from "wagmi";
|
|
19
21
|
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
22
|
+
import { KycGate } from "./KycGate";
|
|
20
23
|
|
|
21
24
|
interface FiatCheckoutPanelProps {
|
|
22
25
|
recipientAddress: string;
|
|
@@ -31,6 +34,10 @@ interface FiatCheckoutPanelProps {
|
|
|
31
34
|
onError?: (error: Error) => void;
|
|
32
35
|
callbackMetadata?: Record<string, unknown>;
|
|
33
36
|
classes?: AnySpendCheckoutClasses;
|
|
37
|
+
/** When true, fees are added on top (payer pays more, receiver gets exact amount) */
|
|
38
|
+
feeOnTop?: boolean;
|
|
39
|
+
/** When true, identity verification is required before card payment. Defaults to false. */
|
|
40
|
+
kycEnabled?: boolean;
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
export function FiatCheckoutPanel({
|
|
@@ -44,13 +51,24 @@ export function FiatCheckoutPanel({
|
|
|
44
51
|
onError,
|
|
45
52
|
callbackMetadata,
|
|
46
53
|
classes,
|
|
54
|
+
feeOnTop,
|
|
55
|
+
kycEnabled = false,
|
|
47
56
|
}: FiatCheckoutPanelProps) {
|
|
48
57
|
// Stable refs for callback props to avoid re-triggering effects
|
|
49
58
|
const onErrorRef = useRef(onError);
|
|
50
59
|
onErrorRef.current = onError;
|
|
51
60
|
|
|
61
|
+
const { address } = useAccount();
|
|
62
|
+
const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
|
|
63
|
+
const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
|
|
64
|
+
|
|
52
65
|
const { data: tokenData } = useTokenData(destinationTokenChainId, destinationTokenAddress);
|
|
53
|
-
const { theme, stripePublishableKey } = useB3Config();
|
|
66
|
+
const { theme, stripePublishableKey, partnerId } = useB3Config();
|
|
67
|
+
|
|
68
|
+
const handleConnectWallet = useCallback(() => {
|
|
69
|
+
setB3ModalContentType({ type: "signInWithB3", showBackButton: false, chain: thirdwebB3Chain, partnerId });
|
|
70
|
+
setB3ModalOpen(true);
|
|
71
|
+
}, [setB3ModalContentType, setB3ModalOpen, partnerId]);
|
|
54
72
|
|
|
55
73
|
// Clean decimal string for API calls (no commas, no subscripts)
|
|
56
74
|
const formattedAmount = useMemo(() => {
|
|
@@ -86,18 +104,6 @@ export function FiatCheckoutPanel({
|
|
|
86
104
|
return parseFloat(raw).toFixed(2);
|
|
87
105
|
}, [isStablecoin, formattedAmount, anyspendQuote]);
|
|
88
106
|
|
|
89
|
-
// Debug: log computed values for Stripe flow diagnostics
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
console.log("@@fiat-checkout:debug", {
|
|
92
|
-
totalAmount,
|
|
93
|
-
formattedAmount,
|
|
94
|
-
isStablecoin,
|
|
95
|
-
isLoadingAnyspendQuote,
|
|
96
|
-
quoteAmount: anyspendQuote?.data?.currencyIn?.amount,
|
|
97
|
-
usdAmount,
|
|
98
|
-
});
|
|
99
|
-
}, [totalAmount, formattedAmount, isStablecoin, isLoadingAnyspendQuote, anyspendQuote, usdAmount]);
|
|
100
|
-
|
|
101
107
|
const {
|
|
102
108
|
geoData,
|
|
103
109
|
stripeOnrampSupport,
|
|
@@ -105,6 +111,13 @@ export function FiatCheckoutPanel({
|
|
|
105
111
|
isLoading: isLoadingGeo,
|
|
106
112
|
} = useGeoOnrampOptions(usdAmount || "0");
|
|
107
113
|
|
|
114
|
+
// KYC state — pre-approved when kycEnabled is false (feature flag off)
|
|
115
|
+
const [kycApproved, setKycApproved] = useState(() => !kycEnabled);
|
|
116
|
+
|
|
117
|
+
const handleKycResolved = useCallback((approved: boolean) => {
|
|
118
|
+
setKycApproved(approved);
|
|
119
|
+
}, []);
|
|
120
|
+
|
|
108
121
|
// Order state
|
|
109
122
|
const [orderId, setOrderId] = useState<string | null>(null);
|
|
110
123
|
const [stripePaymentIntentId, setStripePaymentIntentId] = useState<string | null>(null);
|
|
@@ -123,19 +136,35 @@ export function FiatCheckoutPanel({
|
|
|
123
136
|
}
|
|
124
137
|
},
|
|
125
138
|
onError: (error: Error) => {
|
|
126
|
-
|
|
139
|
+
// Backend requires KYC even when kycEnabled=false — reset to show KycGate
|
|
140
|
+
if (error.message?.includes("KYC verification required")) {
|
|
141
|
+
setKycApproved(false);
|
|
142
|
+
orderCreatedRef.current = false;
|
|
143
|
+
} else {
|
|
144
|
+
setOrderError(error.message || "Failed to create payment order.");
|
|
145
|
+
}
|
|
127
146
|
onErrorRef.current?.(error);
|
|
128
147
|
},
|
|
129
148
|
});
|
|
130
149
|
|
|
131
|
-
//
|
|
150
|
+
// Reset order error when wallet connects so the user gets a clean state
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (address && orderError) {
|
|
153
|
+
setOrderError(null);
|
|
154
|
+
orderCreatedRef.current = false;
|
|
155
|
+
}
|
|
156
|
+
}, [address]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
157
|
+
|
|
158
|
+
// Auto-create onramp order when Stripe Web2 is supported, KYC approved, and all data is ready
|
|
132
159
|
useEffect(() => {
|
|
133
160
|
if (
|
|
161
|
+
address &&
|
|
134
162
|
!isLoadingGeo &&
|
|
135
163
|
(!isStablecoin ? !isLoadingAnyspendQuote : true) &&
|
|
136
164
|
usdAmount &&
|
|
137
165
|
parseFloat(usdAmount) > 0 &&
|
|
138
166
|
stripeWeb2Support?.isSupport &&
|
|
167
|
+
kycApproved &&
|
|
139
168
|
!orderCreatedRef.current &&
|
|
140
169
|
!orderId &&
|
|
141
170
|
!isCreatingOrder &&
|
|
@@ -170,14 +199,17 @@ export function FiatCheckoutPanel({
|
|
|
170
199
|
},
|
|
171
200
|
expectedDstAmount: totalAmount,
|
|
172
201
|
callbackMetadata,
|
|
202
|
+
feeOnTop,
|
|
173
203
|
});
|
|
174
204
|
}
|
|
175
205
|
}, [
|
|
206
|
+
address,
|
|
176
207
|
isLoadingGeo,
|
|
177
208
|
isStablecoin,
|
|
178
209
|
isLoadingAnyspendQuote,
|
|
179
210
|
usdAmount,
|
|
180
211
|
stripeWeb2Support,
|
|
212
|
+
kycApproved,
|
|
181
213
|
orderId,
|
|
182
214
|
isCreatingOrder,
|
|
183
215
|
orderError,
|
|
@@ -189,6 +221,7 @@ export function FiatCheckoutPanel({
|
|
|
189
221
|
geoData,
|
|
190
222
|
callbackMetadata,
|
|
191
223
|
createOrder,
|
|
224
|
+
feeOnTop,
|
|
192
225
|
]);
|
|
193
226
|
|
|
194
227
|
// Loading geo/stripe support check (and quote for non-stablecoins)
|
|
@@ -227,6 +260,42 @@ export function FiatCheckoutPanel({
|
|
|
227
260
|
);
|
|
228
261
|
}
|
|
229
262
|
|
|
263
|
+
// KYC gate — shown before order creation when verification is needed
|
|
264
|
+
if (!kycApproved) {
|
|
265
|
+
return <KycGate themeColor={themeColor} classes={classes} enabled onStatusResolved={handleKycResolved} />;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// No wallet connected — prompt to connect before attempting card payment
|
|
269
|
+
if (!address) {
|
|
270
|
+
return (
|
|
271
|
+
<motion.div
|
|
272
|
+
initial={{ opacity: 0, y: 8 }}
|
|
273
|
+
animate={{ opacity: 1, y: 0 }}
|
|
274
|
+
transition={{ duration: 0.25, ease: "easeOut" }}
|
|
275
|
+
className={cn("anyspend-fiat-connect flex flex-col items-center gap-4 py-2", classes?.fiatPanel)}
|
|
276
|
+
>
|
|
277
|
+
<Wallet className="h-8 w-8 text-gray-400" />
|
|
278
|
+
<div className="text-center">
|
|
279
|
+
<p className="text-sm font-medium text-gray-900 dark:text-gray-100">Connect wallet to pay with card</p>
|
|
280
|
+
<p className="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
|
281
|
+
A wallet connection is required to complete card payment.
|
|
282
|
+
</p>
|
|
283
|
+
</div>
|
|
284
|
+
<ShinyButton
|
|
285
|
+
accentColor={themeColor || "hsl(var(--as-brand))"}
|
|
286
|
+
className="w-full"
|
|
287
|
+
textClassName="text-white"
|
|
288
|
+
onClick={handleConnectWallet}
|
|
289
|
+
>
|
|
290
|
+
<span className="flex items-center justify-center gap-2">
|
|
291
|
+
<Wallet className="h-4 w-4" />
|
|
292
|
+
Connect Wallet
|
|
293
|
+
</span>
|
|
294
|
+
</ShinyButton>
|
|
295
|
+
</motion.div>
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
230
299
|
// Order creation error - show with retry
|
|
231
300
|
if (orderError) {
|
|
232
301
|
return (
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
4
|
+
import { ShinyButton, TextShimmer, useB3Config, useModalStore } from "@b3dotfun/sdk/global-account/react";
|
|
5
|
+
import { thirdwebB3Chain } from "@b3dotfun/sdk/shared/constants/chains/b3Chain";
|
|
6
|
+
import { Loader2, ShieldCheck, AlertTriangle, Clock, Wallet } from "lucide-react";
|
|
7
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
8
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
9
|
+
import { useAccount } from "wagmi";
|
|
10
|
+
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
11
|
+
import { useCreateKycInquiry, useKycStatus, useVerifyKyc, useWalletAuthHeaders } from "../../hooks/useKycStatus";
|
|
12
|
+
|
|
13
|
+
interface KycGateProps {
|
|
14
|
+
themeColor?: string;
|
|
15
|
+
classes?: AnySpendCheckoutClasses;
|
|
16
|
+
/** Only fetch KYC status (and prompt wallet signature) when true. */
|
|
17
|
+
enabled?: boolean;
|
|
18
|
+
/** Called when KYC status is resolved (approved or not required) */
|
|
19
|
+
onStatusResolved: (approved: boolean) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function KycGate({ themeColor, classes, enabled = false, onStatusResolved }: KycGateProps) {
|
|
23
|
+
const { address } = useAccount();
|
|
24
|
+
const { partnerId } = useB3Config();
|
|
25
|
+
// Gate the status fetch behind explicit user consent so the wallet
|
|
26
|
+
// signature prompt doesn't fire automatically on tab open.
|
|
27
|
+
const [userInitiated, setUserInitiated] = useState(false);
|
|
28
|
+
const { getHeaders: preCacheKycHeaders } = useWalletAuthHeaders();
|
|
29
|
+
const { kycStatus, isLoadingKycStatus, refetchKycStatus } = useKycStatus(enabled && userInitiated);
|
|
30
|
+
const { createInquiry, isCreatingInquiry } = useCreateKycInquiry();
|
|
31
|
+
const { verifyKyc, isVerifying } = useVerifyKyc();
|
|
32
|
+
const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
|
|
33
|
+
const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
|
|
34
|
+
|
|
35
|
+
const [personaOpen, setPersonaOpen] = useState(false);
|
|
36
|
+
const [personaError, setPersonaError] = useState<string | null>(null);
|
|
37
|
+
const [personaCancelled, setPersonaCancelled] = useState(false);
|
|
38
|
+
const prevStatusRef = useRef<string | null>(null);
|
|
39
|
+
|
|
40
|
+
// Reset consent gate when wallet changes so the signature prompt isn't
|
|
41
|
+
// skipped for a different (or reconnected) wallet with no cached headers.
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
setUserInitiated(false);
|
|
44
|
+
}, [address]);
|
|
45
|
+
|
|
46
|
+
// Notify parent when status resolves
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!kycStatus) return;
|
|
49
|
+
|
|
50
|
+
const currentStatus = kycStatus.status;
|
|
51
|
+
if (currentStatus === prevStatusRef.current) return;
|
|
52
|
+
prevStatusRef.current = currentStatus;
|
|
53
|
+
|
|
54
|
+
if (!kycStatus.kycRequired || currentStatus === "approved") {
|
|
55
|
+
onStatusResolved(true);
|
|
56
|
+
}
|
|
57
|
+
}, [kycStatus, onStatusResolved]);
|
|
58
|
+
|
|
59
|
+
const openPersonaFlow = useCallback(
|
|
60
|
+
async (config: { inquiryId: string; sessionToken: string; environment?: string }) => {
|
|
61
|
+
setPersonaOpen(true);
|
|
62
|
+
try {
|
|
63
|
+
// Dynamic import to keep bundle small
|
|
64
|
+
const { Client } = await import("persona");
|
|
65
|
+
const client = new Client({
|
|
66
|
+
inquiryId: config.inquiryId,
|
|
67
|
+
sessionToken: config.sessionToken,
|
|
68
|
+
environment: config.environment === "production" ? "production" : "sandbox",
|
|
69
|
+
onComplete: async ({ inquiryId }) => {
|
|
70
|
+
// Reopen the modal first so the user lands back in the checkout flow
|
|
71
|
+
setB3ModalOpen(true);
|
|
72
|
+
setPersonaOpen(false);
|
|
73
|
+
if (inquiryId) {
|
|
74
|
+
try {
|
|
75
|
+
const result = await verifyKyc(inquiryId);
|
|
76
|
+
if (result.status === "approved") {
|
|
77
|
+
onStatusResolved(true);
|
|
78
|
+
}
|
|
79
|
+
} catch (err) {
|
|
80
|
+
setPersonaError(err instanceof Error ? err.message : "Verification check failed — please retry.");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
refetchKycStatus();
|
|
84
|
+
},
|
|
85
|
+
onCancel: () => {
|
|
86
|
+
// Reopen the modal so the user can retry or cancel the purchase
|
|
87
|
+
setB3ModalOpen(true);
|
|
88
|
+
setPersonaOpen(false);
|
|
89
|
+
setPersonaCancelled(true);
|
|
90
|
+
},
|
|
91
|
+
onError: error => {
|
|
92
|
+
// Reopen the modal so the user sees the error and can retry
|
|
93
|
+
setB3ModalOpen(true);
|
|
94
|
+
setPersonaOpen(false);
|
|
95
|
+
setPersonaError(error?.message || "Verification encountered an error");
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
// Close the modal before opening Persona so its overlay is fully
|
|
99
|
+
// interactive — no Radix Dialog backdrop or z-index conflicts.
|
|
100
|
+
// The modal's contentType is preserved in Zustand and restored on reopen.
|
|
101
|
+
setB3ModalOpen(false);
|
|
102
|
+
client.open();
|
|
103
|
+
} catch (error) {
|
|
104
|
+
setPersonaOpen(false);
|
|
105
|
+
setB3ModalOpen(true);
|
|
106
|
+
setPersonaError("Failed to load verification module");
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
[verifyKyc, onStatusResolved, refetchKycStatus, setB3ModalOpen],
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const handleStartVerification = useCallback(async () => {
|
|
113
|
+
setPersonaError(null);
|
|
114
|
+
setPersonaCancelled(false);
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
const { inquiryId, sessionToken } = await createInquiry();
|
|
118
|
+
openPersonaFlow({
|
|
119
|
+
inquiryId,
|
|
120
|
+
sessionToken,
|
|
121
|
+
environment: kycStatus?.config?.environment,
|
|
122
|
+
});
|
|
123
|
+
} catch (error) {
|
|
124
|
+
setPersonaError(error instanceof Error ? error.message : "Failed to start verification");
|
|
125
|
+
}
|
|
126
|
+
}, [createInquiry, kycStatus, openPersonaFlow]);
|
|
127
|
+
|
|
128
|
+
const handleConnectWallet = useCallback(() => {
|
|
129
|
+
setB3ModalContentType({ type: "signInWithB3", showBackButton: false, chain: thirdwebB3Chain, partnerId });
|
|
130
|
+
setB3ModalOpen(true);
|
|
131
|
+
}, [setB3ModalContentType, setB3ModalOpen, partnerId]);
|
|
132
|
+
|
|
133
|
+
const handleResumeVerification = useCallback(() => {
|
|
134
|
+
if (!kycStatus?.inquiry) return;
|
|
135
|
+
|
|
136
|
+
setPersonaError(null);
|
|
137
|
+
setPersonaCancelled(false);
|
|
138
|
+
|
|
139
|
+
openPersonaFlow({
|
|
140
|
+
inquiryId: kycStatus.inquiry.inquiryId,
|
|
141
|
+
sessionToken: kycStatus.inquiry.sessionToken,
|
|
142
|
+
environment: kycStatus.config?.environment,
|
|
143
|
+
});
|
|
144
|
+
}, [kycStatus, openPersonaFlow]);
|
|
145
|
+
|
|
146
|
+
// No wallet connected — prompt to connect wallet (same pattern as crypto tab)
|
|
147
|
+
if (!address) {
|
|
148
|
+
return (
|
|
149
|
+
<motion.div
|
|
150
|
+
initial={{ opacity: 0, y: 8 }}
|
|
151
|
+
animate={{ opacity: 1, y: 0 }}
|
|
152
|
+
transition={{ duration: 0.25, ease: "easeOut" }}
|
|
153
|
+
className={cn("anyspend-kyc-auth flex flex-col items-center gap-4 py-2", classes?.fiatPanel)}
|
|
154
|
+
>
|
|
155
|
+
<ShieldCheck className="h-8 w-8 text-gray-400" />
|
|
156
|
+
<div className="text-center">
|
|
157
|
+
<p className="text-sm font-medium text-gray-900 dark:text-gray-100">Connect wallet to pay with card</p>
|
|
158
|
+
<p className="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
|
159
|
+
A wallet connection is required to complete identity verification.
|
|
160
|
+
</p>
|
|
161
|
+
</div>
|
|
162
|
+
<ShinyButton
|
|
163
|
+
accentColor={themeColor || "hsl(var(--as-brand))"}
|
|
164
|
+
className="w-full"
|
|
165
|
+
textClassName="text-white"
|
|
166
|
+
onClick={handleConnectWallet}
|
|
167
|
+
>
|
|
168
|
+
<span className="flex items-center justify-center gap-2">
|
|
169
|
+
<Wallet className="h-4 w-4" />
|
|
170
|
+
Connect Wallet
|
|
171
|
+
</span>
|
|
172
|
+
</ShinyButton>
|
|
173
|
+
</motion.div>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Wallet connected but user hasn't kicked off the KYC check yet
|
|
178
|
+
if (!userInitiated) {
|
|
179
|
+
return (
|
|
180
|
+
<motion.div
|
|
181
|
+
initial={{ opacity: 0, y: 8 }}
|
|
182
|
+
animate={{ opacity: 1, y: 0 }}
|
|
183
|
+
transition={{ duration: 0.25, ease: "easeOut" }}
|
|
184
|
+
className={cn("anyspend-kyc-prompt flex flex-col items-center gap-4 py-2", classes?.fiatPanel)}
|
|
185
|
+
>
|
|
186
|
+
<ShieldCheck className="h-8 w-8 text-blue-500" />
|
|
187
|
+
<div className="text-center">
|
|
188
|
+
<p className="text-sm font-medium text-gray-900 dark:text-gray-100">Identity verification required</p>
|
|
189
|
+
<p className="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
|
190
|
+
Card payments require a one-time identity check. This takes about 2 minutes.
|
|
191
|
+
</p>
|
|
192
|
+
</div>
|
|
193
|
+
<ShinyButton
|
|
194
|
+
accentColor={themeColor || "hsl(var(--as-brand))"}
|
|
195
|
+
className="w-full"
|
|
196
|
+
textClassName="text-white"
|
|
197
|
+
onClick={async () => {
|
|
198
|
+
// Pre-sign in user-gesture context so React Query's queryFn
|
|
199
|
+
// can reuse the cached headers without a second popup.
|
|
200
|
+
// Only enable the query on success — if the user rejects the
|
|
201
|
+
// signature, leave userInitiated=false and stay on this screen.
|
|
202
|
+
try {
|
|
203
|
+
await preCacheKycHeaders();
|
|
204
|
+
setUserInitiated(true);
|
|
205
|
+
} catch {
|
|
206
|
+
// User rejected signature — stay on consent screen
|
|
207
|
+
}
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
210
|
+
<span className="flex items-center justify-center gap-2">
|
|
211
|
+
<ShieldCheck className="h-4 w-4" />
|
|
212
|
+
Continue to Verify
|
|
213
|
+
</span>
|
|
214
|
+
</ShinyButton>
|
|
215
|
+
</motion.div>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Loading KYC status state
|
|
220
|
+
if (isLoadingKycStatus) {
|
|
221
|
+
return (
|
|
222
|
+
<motion.div
|
|
223
|
+
initial={{ opacity: 0 }}
|
|
224
|
+
animate={{ opacity: 1 }}
|
|
225
|
+
transition={{ duration: 0.2, ease: "easeOut" }}
|
|
226
|
+
className={cn("anyspend-kyc-loading flex flex-col items-center gap-3 py-6", classes?.fiatPanel)}
|
|
227
|
+
>
|
|
228
|
+
<Loader2 className="h-5 w-5 animate-spin text-gray-400" />
|
|
229
|
+
<TextShimmer duration={1.5} className="text-sm">
|
|
230
|
+
Checking verification status...
|
|
231
|
+
</TextShimmer>
|
|
232
|
+
</motion.div>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Not required or already approved — render nothing
|
|
237
|
+
if (!kycStatus?.kycRequired || kycStatus.status === "approved") {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Persona flow is open - show loading
|
|
242
|
+
if (personaOpen) {
|
|
243
|
+
return (
|
|
244
|
+
<motion.div
|
|
245
|
+
initial={{ opacity: 0 }}
|
|
246
|
+
animate={{ opacity: 1 }}
|
|
247
|
+
transition={{ duration: 0.2, ease: "easeOut" }}
|
|
248
|
+
className={cn("anyspend-kyc-persona flex flex-col items-center gap-3 py-6", classes?.fiatPanel)}
|
|
249
|
+
>
|
|
250
|
+
<Loader2 className="h-5 w-5 animate-spin text-gray-400" />
|
|
251
|
+
<TextShimmer duration={1.5} className="text-sm">
|
|
252
|
+
Identity verification in progress...
|
|
253
|
+
</TextShimmer>
|
|
254
|
+
<p className="text-xs text-gray-400 dark:text-gray-500">Complete the verification in the popup window</p>
|
|
255
|
+
</motion.div>
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Needs review or completed (submitted, awaiting Persona decision)
|
|
260
|
+
if (kycStatus.status === "needs_review" || kycStatus.status === "completed") {
|
|
261
|
+
return (
|
|
262
|
+
<motion.div
|
|
263
|
+
initial={{ opacity: 0, y: 8 }}
|
|
264
|
+
animate={{ opacity: 1, y: 0 }}
|
|
265
|
+
transition={{ duration: 0.25, ease: "easeOut" }}
|
|
266
|
+
className={cn("anyspend-kyc-review flex flex-col items-center gap-3 py-2", classes?.fiatPanel)}
|
|
267
|
+
>
|
|
268
|
+
<Clock className="h-8 w-8 text-amber-500" />
|
|
269
|
+
<p className="text-center text-sm font-medium text-amber-700 dark:text-amber-300">
|
|
270
|
+
Your verification is under review
|
|
271
|
+
</p>
|
|
272
|
+
<p className="text-center text-xs text-amber-600 dark:text-amber-400">
|
|
273
|
+
This usually takes a few minutes. Please check back shortly.
|
|
274
|
+
</p>
|
|
275
|
+
<button
|
|
276
|
+
onClick={() => refetchKycStatus()}
|
|
277
|
+
className="mt-1 text-sm font-medium text-amber-700 underline hover:text-amber-800 dark:text-amber-300"
|
|
278
|
+
>
|
|
279
|
+
Check status
|
|
280
|
+
</button>
|
|
281
|
+
</motion.div>
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Pending (started before) - offer resume
|
|
286
|
+
if (kycStatus.status === "pending" && kycStatus.inquiry) {
|
|
287
|
+
return (
|
|
288
|
+
<motion.div
|
|
289
|
+
initial={{ opacity: 0, y: 8 }}
|
|
290
|
+
animate={{ opacity: 1, y: 0 }}
|
|
291
|
+
transition={{ duration: 0.25, ease: "easeOut" }}
|
|
292
|
+
className={cn("anyspend-kyc-resume flex flex-col items-center gap-4 py-2", classes?.fiatPanel)}
|
|
293
|
+
>
|
|
294
|
+
<ShieldCheck className="h-8 w-8 text-blue-500" />
|
|
295
|
+
<div className="text-center">
|
|
296
|
+
<p className="text-sm font-medium text-gray-900 dark:text-gray-100">Continue verification</p>
|
|
297
|
+
<p className="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
|
298
|
+
You have an incomplete verification. Resume to continue.
|
|
299
|
+
</p>
|
|
300
|
+
</div>
|
|
301
|
+
<ShinyButton
|
|
302
|
+
accentColor={themeColor || "hsl(var(--as-brand))"}
|
|
303
|
+
className="w-full"
|
|
304
|
+
textClassName="text-white"
|
|
305
|
+
onClick={handleResumeVerification}
|
|
306
|
+
disabled={isCreatingInquiry}
|
|
307
|
+
>
|
|
308
|
+
<span className="flex items-center justify-center gap-2">
|
|
309
|
+
{isCreatingInquiry ? <Loader2 className="h-4 w-4 animate-spin" /> : <ShieldCheck className="h-4 w-4" />}
|
|
310
|
+
Resume Verification
|
|
311
|
+
</span>
|
|
312
|
+
</ShinyButton>
|
|
313
|
+
</motion.div>
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Not verified / declined / expired - show verification prompt
|
|
318
|
+
return (
|
|
319
|
+
<motion.div
|
|
320
|
+
initial={{ opacity: 0, y: 8 }}
|
|
321
|
+
animate={{ opacity: 1, y: 0 }}
|
|
322
|
+
transition={{ duration: 0.25, ease: "easeOut" }}
|
|
323
|
+
className={cn("anyspend-kyc-prompt flex flex-col items-center gap-4 py-2", classes?.fiatPanel)}
|
|
324
|
+
>
|
|
325
|
+
<ShieldCheck className="h-8 w-8 text-blue-500" />
|
|
326
|
+
<div className="text-center">
|
|
327
|
+
<p className="text-sm font-medium text-gray-900 dark:text-gray-100">Identity verification required</p>
|
|
328
|
+
<p className="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
|
329
|
+
Card payments require a one-time identity check. This takes about 2 minutes.
|
|
330
|
+
</p>
|
|
331
|
+
</div>
|
|
332
|
+
|
|
333
|
+
<AnimatePresence initial={false}>
|
|
334
|
+
{personaError && (
|
|
335
|
+
<motion.div
|
|
336
|
+
key="kyc-error"
|
|
337
|
+
initial={{ opacity: 0, height: 0 }}
|
|
338
|
+
animate={{ opacity: 1, height: "auto" }}
|
|
339
|
+
exit={{ opacity: 0, height: 0 }}
|
|
340
|
+
transition={{ duration: 0.2, ease: "easeOut" }}
|
|
341
|
+
style={{ overflow: "hidden" }}
|
|
342
|
+
className="w-full rounded-lg border border-red-200 bg-red-50 px-3 py-2 dark:border-red-800 dark:bg-red-900/20"
|
|
343
|
+
>
|
|
344
|
+
<p className="text-center text-sm text-red-600 dark:text-red-400">{personaError}</p>
|
|
345
|
+
</motion.div>
|
|
346
|
+
)}
|
|
347
|
+
{personaCancelled && (
|
|
348
|
+
<motion.div
|
|
349
|
+
key="kyc-cancelled"
|
|
350
|
+
initial={{ opacity: 0, height: 0 }}
|
|
351
|
+
animate={{ opacity: 1, height: "auto" }}
|
|
352
|
+
exit={{ opacity: 0, height: 0 }}
|
|
353
|
+
transition={{ duration: 0.2, ease: "easeOut" }}
|
|
354
|
+
style={{ overflow: "hidden" }}
|
|
355
|
+
className="w-full rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-800 dark:bg-amber-900/20"
|
|
356
|
+
>
|
|
357
|
+
<p className="text-center text-sm text-amber-600 dark:text-amber-400">
|
|
358
|
+
Verification cancelled. Click below to try again.
|
|
359
|
+
</p>
|
|
360
|
+
</motion.div>
|
|
361
|
+
)}
|
|
362
|
+
</AnimatePresence>
|
|
363
|
+
|
|
364
|
+
{kycStatus.status === "declined" && (
|
|
365
|
+
<div className="flex items-center gap-1.5 rounded-lg border border-red-200 bg-red-50 px-3 py-2 dark:border-red-800 dark:bg-red-900/20">
|
|
366
|
+
<AlertTriangle className="h-3.5 w-3.5 text-red-500" />
|
|
367
|
+
<p className="text-xs text-red-600 dark:text-red-400">
|
|
368
|
+
Previous verification was declined. You may try again.
|
|
369
|
+
</p>
|
|
370
|
+
</div>
|
|
371
|
+
)}
|
|
372
|
+
|
|
373
|
+
<ShinyButton
|
|
374
|
+
accentColor={themeColor || "hsl(var(--as-brand))"}
|
|
375
|
+
className="w-full"
|
|
376
|
+
textClassName="text-white"
|
|
377
|
+
onClick={handleStartVerification}
|
|
378
|
+
disabled={isCreatingInquiry || isVerifying}
|
|
379
|
+
>
|
|
380
|
+
<span className="flex items-center justify-center gap-2">
|
|
381
|
+
{isCreatingInquiry ? <Loader2 className="h-4 w-4 animate-spin" /> : <ShieldCheck className="h-4 w-4" />}
|
|
382
|
+
{isCreatingInquiry ? "Starting..." : "Verify Identity"}
|
|
383
|
+
</span>
|
|
384
|
+
</ShinyButton>
|
|
385
|
+
</motion.div>
|
|
386
|
+
);
|
|
387
|
+
}
|