@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { eqci, getChainName, getDefaultToken, getExplorerTxUrl, getHyperliquidUSDCToken, HYPERLIQUID_CHAIN_ID, HYPERLIQUID_USDC_ADDRESS, USDC_BASE, ZERO_ADDRESS, } from "../../../anyspend/index.js";
|
|
4
4
|
import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useGasPrice, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
|
|
5
|
-
import { Button, ShinyButton, StyleRoot, TabsPrimitive, toast, TransitionPanel, useAccountWallet, useB3Config, useModalStore, useProfile, useRouter, useSearchParamsSSR, useTokenBalanceDirect, useTokenData, useTokenFromUrl, } from "../../../global-account/react/index.js";
|
|
5
|
+
import { Button, ShinyButton, StyleRoot, TabsPrimitive, toast, TransitionPanel, useAccountWallet, useAuth, useAuthStore, useB3Config, useModalStore, useProfile, useRouter, useSearchParamsSSR, useTokenBalanceDirect, useTokenData, useTokenFromUrl, } from "../../../global-account/react/index.js";
|
|
6
6
|
import BottomNavigation from "../../../global-account/react/components/ManageAccount/BottomNavigation.js";
|
|
7
7
|
import { useAccountWalletImage } from "../../../global-account/react/hooks/useAccountWallet.js";
|
|
8
8
|
import { getThirdwebChain } from "../../../shared/constants/chains/supported.js";
|
|
@@ -30,6 +30,8 @@ import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaym
|
|
|
30
30
|
import { GasIndicator } from "./common/GasIndicator.js";
|
|
31
31
|
import { OrderDetails, OrderDetailsLoadingView } from "./common/OrderDetails.js";
|
|
32
32
|
import { OrderHistory } from "./common/OrderHistory.js";
|
|
33
|
+
import { KycGate } from "./checkout/KycGate.js";
|
|
34
|
+
import { LoginStep } from "../../../global-account/react/components/SignInWithB3/steps/LoginStep.js";
|
|
33
35
|
import { PanelOnramp } from "./common/PanelOnramp.js";
|
|
34
36
|
import { PanelOnrampPayment } from "./common/PanelOnrampPayment.js";
|
|
35
37
|
import { PointsDetailPanel } from "./common/PointsDetailPanel.js";
|
|
@@ -50,19 +52,28 @@ export var PanelView;
|
|
|
50
52
|
PanelView[PanelView["POINTS_DETAIL"] = 8] = "POINTS_DETAIL";
|
|
51
53
|
PanelView[PanelView["FEE_DETAIL"] = 9] = "FEE_DETAIL";
|
|
52
54
|
PanelView[PanelView["DIRECT_TRANSFER_SUCCESS"] = 10] = "DIRECT_TRANSFER_SUCCESS";
|
|
55
|
+
PanelView[PanelView["FIAT_KYC"] = 11] = "FIAT_KYC";
|
|
56
|
+
PanelView[PanelView["FIAT_AUTH"] = 12] = "FIAT_AUTH";
|
|
53
57
|
})(PanelView || (PanelView = {}));
|
|
54
58
|
const ANYSPEND_RECIPIENTS_KEY = "anyspend_recipients";
|
|
55
59
|
export function AnySpend(props) {
|
|
56
60
|
const fingerprintConfig = getFingerprintConfig();
|
|
57
61
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendCustomizationProvider, { slots: props.slots, content: props.content, theme: props.theme, children: _jsx(AnySpendInner, { ...props }) }) }));
|
|
58
62
|
}
|
|
59
|
-
function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, onTokenSelect, onSuccess, customUsdInputValues, hideHeader, hideBottomNavigation = false, disableUrlParamManagement = false, returnToHomeUrl, customRecipientLabel, returnHomeLabel, classes, allowDirectTransfer = false, destinationTokenAmount, callbackMetadata, senderAddress, }) {
|
|
63
|
+
function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, onTokenSelect, onSuccess, customUsdInputValues, hideHeader, hideBottomNavigation = false, disableUrlParamManagement = false, returnToHomeUrl, customRecipientLabel, returnHomeLabel, classes, allowDirectTransfer = false, destinationTokenAmount, callbackMetadata, senderAddress, kycEnabled = false, }) {
|
|
60
64
|
const { slots, content } = useAnySpendCustomization();
|
|
61
65
|
const searchParams = useSearchParamsSSR();
|
|
62
66
|
const router = useRouter();
|
|
63
67
|
const { partnerId } = useB3Config();
|
|
64
68
|
const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
|
|
65
69
|
const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
|
|
70
|
+
const { isAuthenticated } = useAuth();
|
|
71
|
+
// KYC approval is tracked per-session so we only prompt the wallet
|
|
72
|
+
// signature when the user actually clicks Buy, not on panel mount.
|
|
73
|
+
// useRef so handleFiatOrder can read the updated value synchronously
|
|
74
|
+
// in the same frame that onStatusResolved sets it (setState is async).
|
|
75
|
+
// When kycEnabled is false (default), pre-approve so the KYC gate is skipped.
|
|
76
|
+
const kycApprovedRef = useRef(!kycEnabled);
|
|
66
77
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
67
78
|
const isBuyMode = !!(destinationTokenAddress && destinationTokenChainId);
|
|
68
79
|
// Add refs to track URL state
|
|
@@ -72,7 +83,17 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
72
83
|
const animationDirection = useRef(null);
|
|
73
84
|
// Track previous panel for proper back navigation
|
|
74
85
|
const previousPanel = useRef(PanelView.MAIN);
|
|
75
|
-
const [activeTab, setActiveTab] = useState(
|
|
86
|
+
const [activeTab, setActiveTab] = useState(() => {
|
|
87
|
+
if (typeof window !== "undefined") {
|
|
88
|
+
const stored = sessionStorage.getItem("anyspend_active_tab");
|
|
89
|
+
if (stored === "crypto" || stored === "fiat")
|
|
90
|
+
return stored;
|
|
91
|
+
}
|
|
92
|
+
return defaultActiveTab;
|
|
93
|
+
});
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
sessionStorage.setItem("anyspend_active_tab", activeTab);
|
|
96
|
+
}, [activeTab]);
|
|
76
97
|
const [orderId, setOrderId] = useState(loadOrder);
|
|
77
98
|
const [directTransferTxHash, setDirectTransferTxHash] = useState();
|
|
78
99
|
const { orderAndTransactions: oat, getOrderAndTransactionsError } = useAnyspendOrderAndTransactions(orderId);
|
|
@@ -93,9 +114,19 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
93
114
|
const [customRecipients, setCustomRecipients] = useState([]);
|
|
94
115
|
// Payment method state with dual-state system (auto + explicit user selection)
|
|
95
116
|
const { cryptoPaymentMethod, setCryptoPaymentMethod, selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod, effectiveCryptoPaymentMethod, resetPaymentMethods, } = useCryptoPaymentMethodState();
|
|
96
|
-
const [selectedFiatPaymentMethod, setSelectedFiatPaymentMethod] = useState(
|
|
117
|
+
const [selectedFiatPaymentMethod, setSelectedFiatPaymentMethod] = useState(() => {
|
|
118
|
+
if (typeof window !== "undefined") {
|
|
119
|
+
const stored = sessionStorage.getItem("anyspend_fiat_method");
|
|
120
|
+
if (stored && Object.values(FiatPaymentMethod).includes(stored))
|
|
121
|
+
return stored;
|
|
122
|
+
}
|
|
123
|
+
return FiatPaymentMethod.NONE;
|
|
124
|
+
});
|
|
97
125
|
// const [newRecipientAddress, setNewRecipientAddress] = useState("");
|
|
98
126
|
// const recipientInputRef = useRef<HTMLInputElement>(null);
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
sessionStorage.setItem("anyspend_fiat_method", selectedFiatPaymentMethod);
|
|
129
|
+
}, [selectedFiatPaymentMethod]);
|
|
99
130
|
// Get initial chain IDs from URL or defaults
|
|
100
131
|
const initialSrcChainId = sourceChainId || parseInt(searchParams.get("fromChainId") || "0") || mainnet.id;
|
|
101
132
|
const initialDstChainId = parseInt(searchParams.get("toChainId") || "0") || (isBuyMode ? destinationTokenChainId : base.id);
|
|
@@ -112,10 +143,27 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
112
143
|
const [selectedSrcToken, setSelectedSrcToken] = useState(effectiveSrcToken);
|
|
113
144
|
const { data: srcTokenMetadata } = useTokenData(selectedSrcToken?.chainId, selectedSrcToken?.address);
|
|
114
145
|
const [srcAmount, setSrcAmount] = useState(searchParams.get("fromAmount") || "0");
|
|
115
|
-
// State for onramp amount
|
|
116
|
-
const [srcAmountOnRamp, setSrcAmountOnRamp] = useState(
|
|
117
|
-
|
|
118
|
-
|
|
146
|
+
// State for onramp amount — persisted in sessionStorage so it survives Persona KYC roundtrip
|
|
147
|
+
const [srcAmountOnRamp, setSrcAmountOnRamp] = useState(() => {
|
|
148
|
+
if (typeof window !== "undefined") {
|
|
149
|
+
const stored = sessionStorage.getItem("anyspend_fiat_amount");
|
|
150
|
+
if (stored)
|
|
151
|
+
return stored;
|
|
152
|
+
}
|
|
153
|
+
return searchParams.get("fromAmount") || "5";
|
|
154
|
+
});
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
sessionStorage.setItem("anyspend_fiat_amount", srcAmountOnRamp);
|
|
157
|
+
}, [srcAmountOnRamp]);
|
|
158
|
+
// State for destination chain/token selection (sync effects come after state declarations below) — persisted in sessionStorage for Persona KYC roundtrip
|
|
159
|
+
const [selectedDstChainId, setSelectedDstChainId] = useState(() => {
|
|
160
|
+
if (!isBuyMode && typeof window !== "undefined") {
|
|
161
|
+
const stored = sessionStorage.getItem("anyspend_dst_chain_id");
|
|
162
|
+
if (stored)
|
|
163
|
+
return parseInt(stored, 10);
|
|
164
|
+
}
|
|
165
|
+
return initialDstChainId;
|
|
166
|
+
});
|
|
119
167
|
// Helper to check if address is Hyperliquid USDC (supports both 34-char and 42-char formats)
|
|
120
168
|
const isHyperliquidUSDCAddress = (address) => eqci(address, HYPERLIQUID_USDC_ADDRESS) || eqci(address, ZERO_ADDRESS);
|
|
121
169
|
const defaultDstToken = isBuyMode
|
|
@@ -135,9 +183,29 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
135
183
|
defaultToken: defaultDstToken,
|
|
136
184
|
prefix: "to",
|
|
137
185
|
});
|
|
138
|
-
const [selectedDstToken, setSelectedDstToken] = useState(
|
|
186
|
+
const [selectedDstToken, setSelectedDstToken] = useState(() => {
|
|
187
|
+
if (!isBuyMode && typeof window !== "undefined") {
|
|
188
|
+
const stored = sessionStorage.getItem("anyspend_dst_token");
|
|
189
|
+
if (stored) {
|
|
190
|
+
try {
|
|
191
|
+
return JSON.parse(stored);
|
|
192
|
+
}
|
|
193
|
+
catch { }
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return isBuyMode ? defaultDstToken : dstTokenFromUrl;
|
|
197
|
+
});
|
|
139
198
|
const { data: dstTokenMetadata } = useTokenData(selectedDstToken?.chainId, selectedDstToken?.address);
|
|
140
199
|
const [dstAmount, setDstAmount] = useState(searchParams.get("toAmount") || "");
|
|
200
|
+
// Sync dst chain/token to sessionStorage so they survive Persona KYC roundtrip
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
if (!isBuyMode)
|
|
203
|
+
sessionStorage.setItem("anyspend_dst_chain_id", selectedDstChainId.toString());
|
|
204
|
+
}, [selectedDstChainId, isBuyMode]);
|
|
205
|
+
useEffect(() => {
|
|
206
|
+
if (!isBuyMode)
|
|
207
|
+
sessionStorage.setItem("anyspend_dst_token", JSON.stringify(selectedDstToken));
|
|
208
|
+
}, [selectedDstToken, isBuyMode]);
|
|
141
209
|
const [isSrcInputDirty, setIsSrcInputDirty] = useState(true);
|
|
142
210
|
// Add refs to track if we've applied metadata
|
|
143
211
|
const appliedSrcMetadataRef = useRef(false);
|
|
@@ -490,6 +558,16 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
490
558
|
}, [anyspendQuote, isSrcInputDirty, destinationTokenAmount]);
|
|
491
559
|
// Call onSuccess when order is executed
|
|
492
560
|
useOnOrderSuccess({ orderData: oat, orderId, onSuccess });
|
|
561
|
+
// Clear all persisted selection state once an order is submitted — next open starts fresh
|
|
562
|
+
useEffect(() => {
|
|
563
|
+
if (orderId) {
|
|
564
|
+
sessionStorage.removeItem("anyspend_fiat_amount");
|
|
565
|
+
sessionStorage.removeItem("anyspend_active_tab");
|
|
566
|
+
sessionStorage.removeItem("anyspend_fiat_method");
|
|
567
|
+
sessionStorage.removeItem("anyspend_dst_chain_id");
|
|
568
|
+
sessionStorage.removeItem("anyspend_dst_token");
|
|
569
|
+
}
|
|
570
|
+
}, [orderId]);
|
|
493
571
|
const { createOrder, isCreatingOrder } = useAnyspendCreateOrder({
|
|
494
572
|
onSuccess: data => {
|
|
495
573
|
const orderId = data.data.id;
|
|
@@ -570,8 +648,8 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
570
648
|
if (selectedFiatPaymentMethod === FiatPaymentMethod.NONE) {
|
|
571
649
|
return { text: "Select payment method", disable: false, error: false, loading: false };
|
|
572
650
|
}
|
|
573
|
-
// If payment method is selected, show "
|
|
574
|
-
return { text: "
|
|
651
|
+
// If payment method is selected, show "Continue"
|
|
652
|
+
return { text: "Continue", disable: false, error: false, loading: false };
|
|
575
653
|
}
|
|
576
654
|
if (activeTab === "crypto") {
|
|
577
655
|
// For crypto: check payment method first, then recipient
|
|
@@ -592,7 +670,7 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
592
670
|
return { text: "Continue to payment", disable: false, error: false, loading: false };
|
|
593
671
|
}
|
|
594
672
|
}
|
|
595
|
-
return { text: "
|
|
673
|
+
return { text: "Continue", disable: false, error: false, loading: false };
|
|
596
674
|
}, [
|
|
597
675
|
activeInputAmountInWei,
|
|
598
676
|
isSameChainSameToken,
|
|
@@ -754,7 +832,20 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
754
832
|
paymentMethodString = "";
|
|
755
833
|
}
|
|
756
834
|
else if (paymentMethod === FiatPaymentMethod.STRIPE_WEB2) {
|
|
757
|
-
// Stripe embedded payment form
|
|
835
|
+
// Stripe embedded payment form requires authentication + KYC
|
|
836
|
+
// Read from store directly to avoid stale closure when called from onLoginSuccess callback
|
|
837
|
+
const currentlyAuthenticated = useAuthStore.getState().isAuthenticated;
|
|
838
|
+
if (!currentlyAuthenticated) {
|
|
839
|
+
navigateToPanel(PanelView.FIAT_AUTH, "forward");
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
if (!kycApprovedRef.current) {
|
|
843
|
+
// Navigate to KYC gate. KycGate shows an explicit "Continue to Verify"
|
|
844
|
+
// CTA and pre-signs from that user-gesture context before enabling
|
|
845
|
+
// the useKycStatus query — so no surprise signature popup here.
|
|
846
|
+
navigateToPanel(PanelView.FIAT_KYC, "forward");
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
758
849
|
if (!stripeWeb2Support.isSupport) {
|
|
759
850
|
toast.error("Pay with Card not available");
|
|
760
851
|
return;
|
|
@@ -863,8 +954,16 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
863
954
|
window.removeEventListener("popstate", handlePopState);
|
|
864
955
|
};
|
|
865
956
|
}, [activePanel, navigateBack]);
|
|
866
|
-
|
|
867
|
-
|
|
957
|
+
// When auth completes while on the FIAT_AUTH panel, navigate back and retry the order
|
|
958
|
+
useEffect(() => {
|
|
959
|
+
if (isAuthenticated && activePanel === PanelView.FIAT_AUTH) {
|
|
960
|
+
navigateBack();
|
|
961
|
+
handleFiatOrder(selectedFiatPaymentMethod);
|
|
962
|
+
}
|
|
963
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
964
|
+
}, [isAuthenticated]);
|
|
965
|
+
const historyView = (_jsx("div", { className: "mx-auto flex w-full max-w-[560px] flex-col items-center", children: _jsx(OrderHistory, { mode: mode, onBack: navigateBack, onSelectOrder: onSelectOrder }) }));
|
|
966
|
+
const orderDetailsView = (_jsx("div", { className: "mx-auto w-full max-w-[460px] p-5", children: _jsx("div", { className: "relative flex flex-col gap-4", children: oat && (_jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTxs: oat.data.relayTxs, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod, onPaymentMethodChange: method => {
|
|
868
967
|
// When user explicitly changes payment method, set it as selected
|
|
869
968
|
setSelectedCryptoPaymentMethod(method);
|
|
870
969
|
}, points: oat.data.points || undefined, onBack: () => {
|
|
@@ -873,7 +972,7 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
873
972
|
// Reset payment methods when going back
|
|
874
973
|
resetPaymentMethods();
|
|
875
974
|
}, returnToHomeUrl: returnToHomeUrl, returnHomeLabel: returnHomeLabel, disableUrlParamManagement: disableUrlParamManagement })) }) }));
|
|
876
|
-
const mainView = (_jsxs("div", { className: classes?.mainContent || "mx-auto flex w-
|
|
975
|
+
const mainView = (_jsxs("div", { className: classes?.mainContent || "mx-auto flex w-full max-w-[460px] flex-col items-center gap-2 pt-5", children: [_jsxs("div", { className: "flex w-full max-w-full flex-col items-center gap-2 px-5", children: [isBuyMode && !hideHeader && (_jsxs("div", { className: classes?.header || "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && (_jsx("div", { className: "relative", children: _jsx("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: classes?.headerLogo || "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), _jsx("div", { children: _jsxs("h1", { className: classes?.headerTitle || "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), _jsx(TabSection, { activeTab: activeTab, setActiveTab: tab => {
|
|
877
976
|
setActiveTab(tab);
|
|
878
977
|
// Reset payment methods when switching tabs
|
|
879
978
|
resetPaymentMethods();
|
|
@@ -990,13 +1089,23 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
990
1089
|
},
|
|
991
1090
|
returnUrl: returnToHomeUrl,
|
|
992
1091
|
returnLabel: resolvedReturnLabel || undefined,
|
|
993
|
-
})) : (_jsxs("div", { className: "mx-auto flex w-
|
|
1092
|
+
})) : (_jsxs("div", { className: "mx-auto flex w-full max-w-[460px] flex-col items-center gap-6 p-5", children: [_jsxs("div", { className: "flex flex-col items-center gap-4", children: [_jsx(AnimatedCheckmark, { className: "h-16 w-16" }), _jsxs("div", { className: "text-center", children: [_jsx("h2", { className: "text-as-primary text-xl font-bold", children: defaultSuccessTitle }), _jsx("p", { className: "text-as-secondary mt-1 text-sm", children: defaultSuccessDesc })] })] }), directTransferTxHash && (_jsx("a", { href: getExplorerTxUrl(selectedSrcChainId, directTransferTxHash), target: "_blank", rel: "noopener noreferrer", className: "text-as-brand hover:text-as-brand/80 text-sm underline", children: "View transaction" })), _jsx("div", { className: "flex w-full flex-col gap-2", children: returnToHomeUrl ? (_jsx(Button, { onClick: () => {
|
|
994
1093
|
window.location.href = returnToHomeUrl;
|
|
995
1094
|
}, className: "bg-as-brand hover:bg-as-brand/90 w-full text-white", children: resolvedReturnLabel || "Return to Home" })) : (_jsx(Button, { onClick: () => {
|
|
996
1095
|
onSuccess?.(directTransferTxHash);
|
|
997
1096
|
setDirectTransferTxHash(undefined);
|
|
998
1097
|
setB3ModalOpen(false);
|
|
999
1098
|
}, className: "bg-as-brand hover:bg-as-brand/90 w-full text-white", children: resolvedReturnLabel || "Done" })) })] }));
|
|
1099
|
+
const kycView = (_jsx("div", { className: "mx-auto flex w-full max-w-[460px] flex-col gap-4 px-5 pt-5", children: _jsx(KycGate, { enabled: activePanel === PanelView.FIAT_KYC, onStatusResolved: approved => {
|
|
1100
|
+
if (approved) {
|
|
1101
|
+
kycApprovedRef.current = true;
|
|
1102
|
+
navigateBack();
|
|
1103
|
+
handleFiatOrder(selectedFiatPaymentMethod);
|
|
1104
|
+
}
|
|
1105
|
+
} }) }));
|
|
1106
|
+
const authView = (_jsx("div", { className: "mx-auto w-full max-w-[460px]", children: _jsx(LoginStep, { chain: baseChain, onSuccess: async () => {
|
|
1107
|
+
// isAuthenticated will be true at this point — the useEffect below handles navigation
|
|
1108
|
+
} }) }));
|
|
1000
1109
|
// Add tabs to the main component when no order is loaded
|
|
1001
1110
|
return (_jsx(StyleRoot, { children: _jsx("div", { className: classes?.container ||
|
|
1002
1111
|
cn("anyspend-container font-inter mx-auto w-full max-w-[460px]", mode === "page" &&
|
|
@@ -1030,5 +1139,7 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
1030
1139
|
_jsx("div", { className: cn(mode === "page" && "p-6"), children: pointsDetailView }, "points-detail-view"),
|
|
1031
1140
|
_jsx("div", { className: cn(mode === "page" && "p-6"), children: feeDetailView }, "fee-detail-view"),
|
|
1032
1141
|
_jsx("div", { className: cn(mode === "page" && "p-6"), children: directTransferSuccessView }, "direct-transfer-success-view"),
|
|
1142
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: kycView }, "fiat-kyc-view"),
|
|
1143
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: authView }, "fiat-auth-view"),
|
|
1033
1144
|
] }) }) }));
|
|
1034
1145
|
}
|
|
@@ -561,13 +561,13 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
561
561
|
}
|
|
562
562
|
}, className: "relative w-full", children: isCreatingOrder ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Creating order..." })] })) : isLoadingAnyspendQuote ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Loading quote..." })] })) : !recipientAddress ? ("Select recipient") : selectedFiatPaymentMethod === FiatPaymentMethod.NONE ? ("Select payment method") : anyspendQuote ? (_jsxs(_Fragment, { children: [_jsx("span", { children: "Buy" }), _jsx(ChevronRightCircle, { className: "absolute right-0 top-1/2 size-6 -translate-y-1/2 opacity-70" })] })) : ("No quote found") }) }) })] }) })] })] }));
|
|
563
563
|
// Recipient selection view
|
|
564
|
-
const recipientSelectionView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-
|
|
564
|
+
const recipientSelectionView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-full max-w-[460px] rounded-xl p-4"), children: _jsx(RecipientSelection, { initialValue: recipientAddress || "", title: "Add recipient address or ENS", description: "Send tokens to another address", onBack: () => setActivePanel(PanelView.CONFIRM_ORDER), onConfirm: address => {
|
|
565
565
|
// User manually selected a recipient
|
|
566
566
|
setSelectedRecipientAddress(address);
|
|
567
567
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
568
568
|
} }) }));
|
|
569
569
|
// Crypto payment method view
|
|
570
|
-
const cryptoPaymentMethodView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-
|
|
570
|
+
const cryptoPaymentMethodView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-full max-w-[460px] rounded-xl p-4"), children: _jsx(CryptoPaymentMethod, { selectedPaymentMethod: effectiveCryptoPaymentMethod, setSelectedPaymentMethod: method => {
|
|
571
571
|
// When user explicitly selects a payment method, save it
|
|
572
572
|
setSelectedCryptoPaymentMethod(method);
|
|
573
573
|
}, isCreatingOrder: isCreatingOrder, onBack: () => setActivePanel(PanelView.CONFIRM_ORDER), onSelectPaymentMethod: (method) => {
|
|
@@ -585,9 +585,9 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
585
585
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
586
586
|
}, []);
|
|
587
587
|
// Fiat payment method view
|
|
588
|
-
const fiatPaymentMethodView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-
|
|
588
|
+
const fiatPaymentMethodView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-full max-w-[460px] rounded-xl p-4"), children: _jsx(FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack: handleBackToConfirmOrder, onSelectPaymentMethod: handleFiatPaymentMethodSelect, srcAmountOnRamp: srcFiatAmount }) }));
|
|
589
589
|
// Points detail view
|
|
590
|
-
const pointsDetailView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-
|
|
590
|
+
const pointsDetailView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-full max-w-[460px] rounded-xl p-4"), children: _jsx(PointsDetailPanel, { pointsAmount: anyspendQuote?.data?.pointsAmount || 0, onBack: () => setActivePanel(PanelView.CONFIRM_ORDER) }) }));
|
|
591
591
|
// Return the TransitionPanel with all views
|
|
592
592
|
return (_jsx(StyleRoot, { children: _jsx(TransitionPanel, { activeIndex: orderId
|
|
593
593
|
? oat
|
|
@@ -226,7 +226,7 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
226
226
|
};
|
|
227
227
|
const headerContent = header ? (header({ anyspendPrice: anyspendQuote, isLoadingAnyspendPrice: isLoadingAnyspendQuote })) : (_jsx("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: _jsxs("div", { children: [_jsx("h1", { className: "text-as-primary text-xl font-bold", children: actionLabel }), _jsx("p", { className: "text-as-secondary text-sm", children: "Pay from any token to execute a custom exact-in transaction." })] }) }));
|
|
228
228
|
const mainView = (_jsxs("div", { className: classes?.container ||
|
|
229
|
-
"anyspend-custom-exact-in-container mx-auto flex w-
|
|
229
|
+
"anyspend-custom-exact-in-container mx-auto flex w-full max-w-[460px] flex-col items-center gap-2", children: [headerContent, _jsx("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [paymentType === "crypto" ? (_jsx(CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, isSrcInputDirty: isSrcInputDirty, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote, onTokenSelect: onTokenSelect })) : (_jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmount, setSrcAmountOnRamp: setSrcAmount, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: selectedRecipientOrDefault, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, dstTokenSymbol: DESTINATION_TOKEN_DETAILS.SYMBOL, hideDstToken: true, destinationAmount: dstAmount, onDestinationTokenChange: () => { }, onDestinationChainChange: () => { }, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL), onShowFeeDetail: () => setActivePanel(PanelView.FEE_DETAIL), customUsdInputValues: customUsdInputValues, customRecipientLabel: customRecipientLabel }) })), _jsx("div", { className: cn("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden"), children: _jsx(Button, { variant: "ghost", className: classes?.swapDirectionButton ||
|
|
230
230
|
"swap-direction-button border-as-stroke bg-as-surface-primary z-10 h-10 w-10 cursor-default rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", children: _jsx("div", { className: "relative flex items-center justify-center transition-opacity", children: _jsx(ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }) }), paymentType === "crypto" && (_jsx(CryptoReceiveSection, { isDepositMode: false, isBuyMode: false, effectiveRecipientAddress: selectedRecipientOrDefault, recipientName: recipientName || undefined, customRecipientLabel: customRecipientLabel, onSelectRecipient: () => setActivePanel(PanelView.RECIPIENT_SELECTION), dstAmount: isSrcInputDirty && !destinationTokenAmount ? dstAmount : dstAmountInput, dstToken: selectedDstToken, dstTokenSymbol: DESTINATION_TOKEN_DETAILS.SYMBOL, dstTokenLogoURI: DESTINATION_TOKEN_DETAILS.LOGO_URI, selectedDstChainId: selectedDstChainId, setSelectedDstChainId: () => { }, setSelectedDstToken: () => { }, isSrcInputDirty: isSrcInputDirty, onChangeDstAmount: value => {
|
|
231
231
|
setIsSrcInputDirty(false);
|
|
232
232
|
setDstAmountInput(value);
|
|
@@ -393,7 +393,7 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
393
393
|
toast.error("Failed to create order: " + err.message);
|
|
394
394
|
}
|
|
395
395
|
};
|
|
396
|
-
const orderDetailsView = (_jsx("div", { className: "mx-auto w-
|
|
396
|
+
const orderDetailsView = (_jsx("div", { className: "mx-auto w-full max-w-[460px]", children: _jsx("div", { className: "relative flex flex-col gap-4", children: oat && (_jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTxs: oat.data.relayTxs, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, cryptoPaymentMethod: paymentType === "fiat" ? CryptoPaymentMethodType.NONE : effectiveCryptoPaymentMethod, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod, onPaymentMethodChange: setSelectedCryptoPaymentMethod, onBack: () => {
|
|
397
397
|
setOrderId(undefined);
|
|
398
398
|
setActivePanel(PanelView.MAIN);
|
|
399
399
|
}, disableUrlParamManagement: true, points: oat.data.points || undefined, returnToHomeUrl: returnToHomeUrl, returnHomeLabel: returnHomeLabel })) }) }));
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
import {
|
|
3
|
-
export type { AnySpendCheckoutClasses } from "../types/classes";
|
|
2
|
+
import type { AddressData, CheckoutFormComponentProps, CheckoutFormSchema, DiscountResult, ShippingOption } from "../../../types/forms";
|
|
4
3
|
import type { AnySpendCheckoutClasses } from "../types/classes";
|
|
5
4
|
import type { AnySpendContent, AnySpendSlots, AnySpendTheme } from "../types/customization";
|
|
6
|
-
import
|
|
7
|
-
|
|
5
|
+
import { type PaymentMethod } from "./CheckoutPaymentPanel";
|
|
6
|
+
import { type VariablePricingConfig } from "./VariablePricingInput";
|
|
7
|
+
export type { AnySpendCheckoutClasses } from "../types/classes";
|
|
8
|
+
export type { VariablePricingConfig } from "./VariablePricingInput";
|
|
9
|
+
export type { AddressData, CheckoutFormComponentProps, CheckoutFormSchema, DiscountResult, ShippingOption };
|
|
8
10
|
export interface CheckoutItem {
|
|
9
11
|
id?: string;
|
|
10
12
|
name: string;
|
|
@@ -33,7 +35,7 @@ export interface AnySpendCheckoutProps {
|
|
|
33
35
|
destinationTokenAddress: string;
|
|
34
36
|
/** The destination chain ID */
|
|
35
37
|
destinationTokenChainId: number;
|
|
36
|
-
/** Line items */
|
|
38
|
+
/** Line items. When `variablePricing.enabled` is true, pass a single placeholder item (e.g. amount "0") — the user-entered amount overrides the total. */
|
|
37
39
|
items: CheckoutItem[];
|
|
38
40
|
/** Override computed total */
|
|
39
41
|
totalAmount?: string;
|
|
@@ -113,5 +115,11 @@ export interface AnySpendCheckoutProps {
|
|
|
113
115
|
onDiscountApplied?: (result: DiscountResult) => void;
|
|
114
116
|
/** Async function to validate a discount code. Returns DiscountResult. */
|
|
115
117
|
validateDiscount?: (code: string) => Promise<DiscountResult>;
|
|
118
|
+
/** Variable pricing / name your price config. When enabled, user enters amount before payment. */
|
|
119
|
+
variablePricing?: VariablePricingConfig;
|
|
120
|
+
/** When true, fees are added on top of the amount (payer pays more, receiver gets exact amount) */
|
|
121
|
+
feeOnTop?: boolean;
|
|
122
|
+
/** When true, identity verification (KYC) is required before card payment. Defaults to false. */
|
|
123
|
+
kycEnabled?: boolean;
|
|
116
124
|
}
|
|
117
|
-
export declare function AnySpendCheckout({ mode, recipientAddress, destinationTokenAddress, destinationTokenChainId, items, totalAmount: totalAmountOverride, organizationName, organizationLogo, themeColor, buttonText, checkoutSessionId, onSuccess, onError, returnUrl, returnLabel, classes, footer, defaultPaymentMethod, senderAddress, slots, content, theme, showPoints, showOrderId, shipping: shippingProp, tax, discount: discountProp, summaryLines, formSchema, formComponent, onFormSubmit, shippingOptions, collectShippingAddress, onShippingChange: onShippingChangeProp, enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount, }: AnySpendCheckoutProps): import("react/jsx-runtime").JSX.Element;
|
|
125
|
+
export declare function AnySpendCheckout({ mode, recipientAddress, destinationTokenAddress, destinationTokenChainId, items, totalAmount: totalAmountOverride, organizationName, organizationLogo, themeColor, buttonText, checkoutSessionId, onSuccess, onError, returnUrl, returnLabel, classes, footer, defaultPaymentMethod, senderAddress, slots, content, theme, showPoints, showOrderId, shipping: shippingProp, tax, discount: discountProp, summaryLines, formSchema, formComponent, onFormSubmit, shippingOptions, collectShippingAddress, onShippingChange: onShippingChangeProp, enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount, variablePricing, feeOnTop, kycEnabled, }: AnySpendCheckoutProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useTokenData } from "../../../../global-account/react/index.js";
|
|
4
3
|
import { USDC_BASE } from "../../../../anyspend/constants/index.js";
|
|
4
|
+
import { useTokenData } from "../../../../global-account/react/index.js";
|
|
5
5
|
import { formatUnits, safeBigInt } from "../../../../shared/utils/number.js";
|
|
6
6
|
import { useCallback, useMemo, useState } from "react";
|
|
7
7
|
import { useAnyspendQuote } from "../../hooks/useAnyspendQuote.js";
|
|
8
8
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "../AnySpendFingerprintWrapper.js";
|
|
9
|
+
import { AnySpendCustomizationProvider } from "../context/AnySpendCustomizationContext.js";
|
|
9
10
|
import { CheckoutCartPanel } from "./CheckoutCartPanel.js";
|
|
10
11
|
import { CheckoutFormPanel } from "./CheckoutFormPanel.js";
|
|
11
12
|
import { CheckoutLayout } from "./CheckoutLayout.js";
|
|
12
13
|
import { CheckoutPaymentPanel } from "./CheckoutPaymentPanel.js";
|
|
13
|
-
import {
|
|
14
|
+
import { VariablePricingInput } from "./VariablePricingInput.js";
|
|
14
15
|
const emptyAddress = { street: "", city: "", state: "", zip: "", country: "" };
|
|
15
16
|
export function AnySpendCheckout({ mode = "page", recipientAddress, destinationTokenAddress, destinationTokenChainId, items, totalAmount: totalAmountOverride, organizationName, organizationLogo, themeColor, buttonText = "Pay", checkoutSessionId, onSuccess, onError, returnUrl, returnLabel, classes, footer, defaultPaymentMethod, senderAddress, slots, content, theme, showPoints, showOrderId, shipping: shippingProp, tax, discount: discountProp, summaryLines,
|
|
16
17
|
// New form props
|
|
@@ -18,7 +19,13 @@ formSchema, formComponent, onFormSubmit,
|
|
|
18
19
|
// New shipping props
|
|
19
20
|
shippingOptions, collectShippingAddress, onShippingChange: onShippingChangeProp,
|
|
20
21
|
// New discount props
|
|
21
|
-
enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount,
|
|
22
|
+
enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount,
|
|
23
|
+
// Variable pricing
|
|
24
|
+
variablePricing, feeOnTop, kycEnabled = false, }) {
|
|
25
|
+
// ===== Variable pricing state =====
|
|
26
|
+
const [variablePricingAmount, setVariablePricingAmount] = useState("0");
|
|
27
|
+
const isVariablePricingActive = variablePricing?.enabled === true;
|
|
28
|
+
const isVariablePricingValid = isVariablePricingActive ? variablePricingAmount !== "0" : true;
|
|
22
29
|
// ===== Form state =====
|
|
23
30
|
const [formData, setFormData] = useState({});
|
|
24
31
|
const [selectedShipping, setSelectedShipping] = useState(null);
|
|
@@ -63,7 +70,25 @@ enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount,
|
|
|
63
70
|
return undefined;
|
|
64
71
|
}, [appliedDiscount, discountProp]);
|
|
65
72
|
// Compute total from items + adjustments (including dynamic shipping/discount)
|
|
73
|
+
// Variable pricing overrides the total when active
|
|
66
74
|
const computedTotal = useMemo(() => {
|
|
75
|
+
if (isVariablePricingActive && variablePricingAmount !== "0") {
|
|
76
|
+
let total = safeBigInt(variablePricingAmount);
|
|
77
|
+
if (effectiveShipping?.amount)
|
|
78
|
+
total += safeBigInt(effectiveShipping.amount);
|
|
79
|
+
const taxAmt = typeof tax === "string" ? tax : tax?.amount;
|
|
80
|
+
if (taxAmt)
|
|
81
|
+
total += safeBigInt(taxAmt);
|
|
82
|
+
if (effectiveDiscount?.amount)
|
|
83
|
+
total -= safeBigInt(effectiveDiscount.amount);
|
|
84
|
+
if (summaryLines) {
|
|
85
|
+
for (const line of summaryLines)
|
|
86
|
+
total += safeBigInt(line.amount);
|
|
87
|
+
}
|
|
88
|
+
if (total < BigInt(0))
|
|
89
|
+
total = BigInt(0);
|
|
90
|
+
return total.toString();
|
|
91
|
+
}
|
|
67
92
|
if (totalAmountOverride)
|
|
68
93
|
return totalAmountOverride;
|
|
69
94
|
let total = BigInt(0);
|
|
@@ -84,7 +109,16 @@ enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount,
|
|
|
84
109
|
if (total < BigInt(0))
|
|
85
110
|
total = BigInt(0);
|
|
86
111
|
return total.toString();
|
|
87
|
-
}, [
|
|
112
|
+
}, [
|
|
113
|
+
items,
|
|
114
|
+
totalAmountOverride,
|
|
115
|
+
effectiveShipping,
|
|
116
|
+
tax,
|
|
117
|
+
effectiveDiscount,
|
|
118
|
+
summaryLines,
|
|
119
|
+
isVariablePricingActive,
|
|
120
|
+
variablePricingAmount,
|
|
121
|
+
]);
|
|
88
122
|
// Get destination token metadata
|
|
89
123
|
const { data: tokenData } = useTokenData(destinationTokenChainId, destinationTokenAddress);
|
|
90
124
|
const tokenSymbol = tokenData?.symbol || "";
|
|
@@ -136,14 +170,27 @@ enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount,
|
|
|
136
170
|
meta.customerName = formData.name;
|
|
137
171
|
if (checkoutSessionId)
|
|
138
172
|
meta.checkoutSessionId = checkoutSessionId;
|
|
173
|
+
if (isVariablePricingActive && variablePricingAmount !== "0") {
|
|
174
|
+
meta.variablePricingAmount = variablePricingAmount;
|
|
175
|
+
}
|
|
139
176
|
return Object.keys(meta).length > 0 ? meta : undefined;
|
|
140
|
-
}, [
|
|
141
|
-
|
|
177
|
+
}, [
|
|
178
|
+
formData,
|
|
179
|
+
selectedShipping,
|
|
180
|
+
shippingAddress,
|
|
181
|
+
appliedDiscount,
|
|
182
|
+
checkoutSessionId,
|
|
183
|
+
isVariablePricingActive,
|
|
184
|
+
variablePricingAmount,
|
|
185
|
+
]);
|
|
186
|
+
// Check if required form fields are filled and variable pricing is valid
|
|
142
187
|
const isFormValid = useMemo(() => {
|
|
188
|
+
if (!isVariablePricingValid)
|
|
189
|
+
return false;
|
|
143
190
|
if (!formSchema)
|
|
144
191
|
return true;
|
|
145
192
|
return formSchema.fields.filter(f => f.required).every(f => formData[f.id] != null && formData[f.id] !== "");
|
|
146
|
-
}, [formSchema, formData]);
|
|
193
|
+
}, [formSchema, formData, isVariablePricingValid]);
|
|
147
194
|
// Check if we have a form panel to show
|
|
148
195
|
const hasFormContent = (formSchema && formSchema.fields.length > 0) ||
|
|
149
196
|
formComponent ||
|
|
@@ -151,5 +198,5 @@ enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount,
|
|
|
151
198
|
(shippingOptions && shippingOptions.length > 0) ||
|
|
152
199
|
collectShippingAddress ||
|
|
153
200
|
enableDiscountCode;
|
|
154
|
-
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprint, children: _jsx(AnySpendCustomizationProvider, { slots: slots, content: content, theme: theme, children: _jsx(CheckoutLayout, { mode: mode, paymentPanel: _jsxs(_Fragment, { children: [hasFormContent && (_jsxs("div", { className: "mb-6", children: [_jsx(CheckoutFormPanel, { formSchema: formSchema, formComponent: formComponent, shippingOptions: shippingOptions, collectShippingAddress: collectShippingAddress, enableDiscountCode: enableDiscountCode, validateDiscount: validateDiscount, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals, classes: classes, formData: formData, onFormDataChange: handleFormDataChange, selectedShipping: selectedShipping, onShippingChange: handleShippingChange, appliedDiscount: appliedDiscount, onDiscountApplied: handleDiscountApplied, onDiscountRemoved: handleDiscountRemoved, shippingAddress: shippingAddress, onShippingAddressChange: setShippingAddress, checkoutFormSlot: slots?.checkoutForm }), _jsx("div", { className: "mt-6 border-t border-gray-200 dark:border-neutral-700" })] })), _jsx(CheckoutPaymentPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: computedTotal, buttonText: buttonText, themeColor: themeColor, returnUrl: returnUrl, returnLabel: returnLabel, onSuccess: onSuccess, onError: onError, classes: classes, defaultPaymentMethod: defaultPaymentMethod, senderAddress: senderAddress, showPoints: showPoints, showOrderId: showOrderId, callbackMetadata: checkoutFormMetadata, isFormValid: isFormValid })] }), cartPanel: _jsx(CheckoutCartPanel, { items: items, totalAmount: computedTotal, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals, organizationName: organizationName, organizationLogo: organizationLogo, classes: classes, footer: footer, shipping: effectiveShipping, tax: typeof tax === "string" ? { amount: tax } : tax, discount: effectiveDiscount, summaryLines: summaryLines, usdEquivalent: usdEquivalent }), classes: classes }) }) }));
|
|
201
|
+
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprint, children: _jsx(AnySpendCustomizationProvider, { slots: slots, content: content, theme: theme, children: _jsx(CheckoutLayout, { mode: mode, paymentPanel: _jsxs(_Fragment, { children: [isVariablePricingActive && tokenData && variablePricing && (_jsx(VariablePricingInput, { config: variablePricing, tokenDecimals: tokenDecimals, tokenSymbol: tokenSymbol, themeColor: themeColor, onChange: setVariablePricingAmount })), hasFormContent && (_jsxs("div", { className: "mb-6", children: [_jsx(CheckoutFormPanel, { formSchema: formSchema, formComponent: formComponent, shippingOptions: shippingOptions, collectShippingAddress: collectShippingAddress, enableDiscountCode: enableDiscountCode, validateDiscount: validateDiscount, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals, classes: classes, formData: formData, onFormDataChange: handleFormDataChange, selectedShipping: selectedShipping, onShippingChange: handleShippingChange, appliedDiscount: appliedDiscount, onDiscountApplied: handleDiscountApplied, onDiscountRemoved: handleDiscountRemoved, shippingAddress: shippingAddress, onShippingAddressChange: setShippingAddress, checkoutFormSlot: slots?.checkoutForm }), _jsx("div", { className: "mt-6 border-t border-gray-200 dark:border-neutral-700" })] })), _jsx(CheckoutPaymentPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: computedTotal, buttonText: buttonText, themeColor: themeColor, returnUrl: returnUrl, returnLabel: returnLabel, onSuccess: onSuccess, onError: onError, classes: classes, defaultPaymentMethod: defaultPaymentMethod, senderAddress: senderAddress, showPoints: showPoints, showOrderId: showOrderId, callbackMetadata: checkoutFormMetadata, isFormValid: isFormValid, feeOnTop: feeOnTop, kycEnabled: kycEnabled })] }), cartPanel: _jsx(CheckoutCartPanel, { items: items, totalAmount: computedTotal, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals, organizationName: organizationName, organizationLogo: organizationLogo, classes: classes, footer: footer, shipping: effectiveShipping, tax: typeof tax === "string" ? { amount: tax } : tax, discount: effectiveDiscount, summaryLines: summaryLines, usdEquivalent: usdEquivalent }), classes: classes }) }) }));
|
|
155
202
|
}
|
|
@@ -77,5 +77,7 @@ export interface AnySpendCheckoutTriggerProps {
|
|
|
77
77
|
};
|
|
78
78
|
/** Additional summary line items (fees, tips, etc.) */
|
|
79
79
|
summaryLines?: CheckoutSummaryLine[];
|
|
80
|
+
/** When true, identity verification (KYC) is required before card payment. Defaults to false. */
|
|
81
|
+
kycEnabled?: boolean;
|
|
80
82
|
}
|
|
81
|
-
export declare function AnySpendCheckoutTrigger({ recipientAddress, destinationTokenAddress, destinationTokenChainId, items, totalAmount: totalAmountOverride, organizationName, organizationLogo, themeColor, buttonText, workflowId, orgId, callbackMetadata, onSuccess, onError, returnUrl, returnLabel, classes, footer, defaultPaymentMethod, senderAddress, slots, content, theme, shipping, tax, discount, summaryLines, }: AnySpendCheckoutTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
83
|
+
export declare function AnySpendCheckoutTrigger({ recipientAddress, destinationTokenAddress, destinationTokenChainId, items, totalAmount: totalAmountOverride, organizationName, organizationLogo, themeColor, buttonText, workflowId, orgId, callbackMetadata, onSuccess, onError, returnUrl, returnLabel, classes, footer, defaultPaymentMethod, senderAddress, slots, content, theme, shipping, tax, discount, summaryLines, kycEnabled, }: AnySpendCheckoutTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,7 +9,7 @@ import { AnySpendCustomizationProvider } from "../context/AnySpendCustomizationC
|
|
|
9
9
|
import { CheckoutCartPanel } from "./CheckoutCartPanel.js";
|
|
10
10
|
import { CheckoutPaymentPanel } from "./CheckoutPaymentPanel.js";
|
|
11
11
|
import { PoweredByBranding } from "./PoweredByBranding.js";
|
|
12
|
-
export function AnySpendCheckoutTrigger({ recipientAddress, destinationTokenAddress, destinationTokenChainId, items, totalAmount: totalAmountOverride, organizationName, organizationLogo, themeColor, buttonText = "Pay", workflowId, orgId, callbackMetadata, onSuccess, onError, returnUrl, returnLabel, classes, footer, defaultPaymentMethod, senderAddress, slots, content, theme, shipping, tax, discount, summaryLines, }) {
|
|
12
|
+
export function AnySpendCheckoutTrigger({ recipientAddress, destinationTokenAddress, destinationTokenChainId, items, totalAmount: totalAmountOverride, organizationName, organizationLogo, themeColor, buttonText = "Pay", workflowId, orgId, callbackMetadata, onSuccess, onError, returnUrl, returnLabel, classes, footer, defaultPaymentMethod, senderAddress, slots, content, theme, shipping, tax, discount, summaryLines, kycEnabled = false, }) {
|
|
13
13
|
// Merge workflowId + orgId into callbackMetadata
|
|
14
14
|
const mergedMetadata = useMemo(() => {
|
|
15
15
|
if (!workflowId && !orgId && !callbackMetadata)
|
|
@@ -54,5 +54,5 @@ export function AnySpendCheckoutTrigger({ recipientAddress, destinationTokenAddr
|
|
|
54
54
|
const formattedTotal = useMemo(() => formatTokenAmount(BigInt(computedTotal || "0"), tokenDecimals), [computedTotal, tokenDecimals]);
|
|
55
55
|
const hasItems = items && items.length > 0;
|
|
56
56
|
const fingerprint = getFingerprintConfig();
|
|
57
|
-
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprint, children: _jsx(AnySpendCustomizationProvider, { slots: slots, content: content, theme: theme, children: _jsxs("div", { className: "anyspend-checkout-trigger flex flex-col", children: [hasItems && (_jsx("div", { className: "border-b border-gray-200 p-5 dark:border-neutral-700", children: _jsx(CheckoutCartPanel, { items: items, totalAmount: computedTotal, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals, organizationName: organizationName, organizationLogo: organizationLogo, classes: classes, footer: footer, shipping: typeof shipping === "string" ? { amount: shipping } : shipping, tax: typeof tax === "string" ? { amount: tax } : tax, discount: typeof discount === "string" ? { amount: discount } : discount, summaryLines: summaryLines }) })), !hasItems && (_jsx("div", { className: "border-b border-gray-200 p-5 dark:border-neutral-700", children: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: cn("flex items-center justify-between", classes?.cartSummary), children: [_jsx("span", { className: "text-base font-semibold text-gray-900 dark:text-gray-100", children: "Total" }), _jsxs("span", { className: cn("text-base font-semibold text-gray-900 dark:text-gray-100", classes?.cartTotal), children: [formattedTotal, " ", tokenSymbol] })] }), footer === undefined ? (_jsx(PoweredByBranding, { organizationName: organizationName, organizationLogo: organizationLogo, classes: classes })) : (footer)] }) })), _jsx("div", { className: "px-2 py-3", children: _jsx(CheckoutPaymentPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: computedTotal, buttonText: buttonText, themeColor: themeColor, returnUrl: returnUrl, returnLabel: returnLabel, onSuccess: onSuccess, onError: onError, callbackMetadata: mergedMetadata, classes: classes, defaultPaymentMethod: defaultPaymentMethod, senderAddress: senderAddress }) })] }) }) }));
|
|
57
|
+
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprint, children: _jsx(AnySpendCustomizationProvider, { slots: slots, content: content, theme: theme, children: _jsxs("div", { className: "anyspend-checkout-trigger flex flex-col", children: [hasItems && (_jsx("div", { className: "border-b border-gray-200 p-5 dark:border-neutral-700", children: _jsx(CheckoutCartPanel, { items: items, totalAmount: computedTotal, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals, organizationName: organizationName, organizationLogo: organizationLogo, classes: classes, footer: footer, shipping: typeof shipping === "string" ? { amount: shipping } : shipping, tax: typeof tax === "string" ? { amount: tax } : tax, discount: typeof discount === "string" ? { amount: discount } : discount, summaryLines: summaryLines }) })), !hasItems && (_jsx("div", { className: "border-b border-gray-200 p-5 dark:border-neutral-700", children: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: cn("flex items-center justify-between", classes?.cartSummary), children: [_jsx("span", { className: "text-base font-semibold text-gray-900 dark:text-gray-100", children: "Total" }), _jsxs("span", { className: cn("text-base font-semibold text-gray-900 dark:text-gray-100", classes?.cartTotal), children: [formattedTotal, " ", tokenSymbol] })] }), footer === undefined ? (_jsx(PoweredByBranding, { organizationName: organizationName, organizationLogo: organizationLogo, classes: classes })) : (footer)] }) })), _jsx("div", { className: "px-2 py-3", children: _jsx(CheckoutPaymentPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: computedTotal, buttonText: buttonText, themeColor: themeColor, returnUrl: returnUrl, returnLabel: returnLabel, onSuccess: onSuccess, onError: onError, callbackMetadata: mergedMetadata, classes: classes, defaultPaymentMethod: defaultPaymentMethod, senderAddress: senderAddress, kycEnabled: kycEnabled }) })] }) }) }));
|
|
58
58
|
}
|
|
@@ -26,6 +26,10 @@ interface CheckoutPaymentPanelProps {
|
|
|
26
26
|
showOrderId?: boolean;
|
|
27
27
|
/** Whether the checkout form is valid. When false, payment methods are disabled. */
|
|
28
28
|
isFormValid?: boolean;
|
|
29
|
+
/** When true, fees are added on top (payer pays more, receiver gets exact amount) */
|
|
30
|
+
feeOnTop?: boolean;
|
|
31
|
+
/** When true, identity verification (KYC) is required before card payment. Defaults to false. */
|
|
32
|
+
kycEnabled?: boolean;
|
|
29
33
|
}
|
|
30
|
-
export declare function CheckoutPaymentPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, buttonText, themeColor, returnUrl, returnLabel, onSuccess, onError, callbackMetadata, classes, defaultPaymentMethod, senderAddress, showPoints, showOrderId, isFormValid, }: CheckoutPaymentPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export declare function CheckoutPaymentPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, buttonText, themeColor, returnUrl, returnLabel, onSuccess, onError, callbackMetadata, classes, defaultPaymentMethod, senderAddress, showPoints, showOrderId, isFormValid, feeOnTop, kycEnabled, }: CheckoutPaymentPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
31
35
|
export {};
|
|
@@ -26,7 +26,7 @@ function AmexLogo() {
|
|
|
26
26
|
function CoinbaseLogo() {
|
|
27
27
|
return (_jsxs("svg", { viewBox: "0 0 24 24", style: { width: 20, height: 20 }, "aria-label": "Coinbase", children: [_jsx("circle", { cx: "12", cy: "12", r: "12", fill: "#0052FF" }), _jsx("path", { d: "M12 4.5a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15zm-1.8 4.8h3.6c.33 0 .6.27.6.6v4.2c0 .33-.27.6-.6.6h-3.6a.6.6 0 0 1-.6-.6V9.9c0-.33.27-.6.6-.6z", fill: "white" })] }));
|
|
28
28
|
}
|
|
29
|
-
export function CheckoutPaymentPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, buttonText, themeColor, returnUrl, returnLabel, onSuccess, onError, callbackMetadata, classes, defaultPaymentMethod, senderAddress, showPoints, showOrderId, isFormValid = true, }) {
|
|
29
|
+
export function CheckoutPaymentPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, buttonText, themeColor, returnUrl, returnLabel, onSuccess, onError, callbackMetadata, classes, defaultPaymentMethod, senderAddress, showPoints, showOrderId, isFormValid = true, feeOnTop, kycEnabled = false, }) {
|
|
30
30
|
const [paymentMethod, setPaymentMethod] = useState(defaultPaymentMethod ?? null);
|
|
31
31
|
// Restore activeOrderId from sessionStorage (handles page refresh / Coinbase return)
|
|
32
32
|
const [activeOrderId, setActiveOrderId] = useState(() => {
|
|
@@ -57,5 +57,5 @@ export function CheckoutPaymentPanel({ recipientAddress, destinationTokenAddress
|
|
|
57
57
|
? "bg-white dark:bg-neutral-900"
|
|
58
58
|
: "bg-white hover:bg-gray-50 dark:bg-neutral-900 dark:hover:bg-neutral-800", classes?.paymentMethodButton);
|
|
59
59
|
const expandedPanelClass = cn("anyspend-payment-method-panel border-t border-gray-100 bg-white px-4 py-4 dark:border-neutral-800 dark:bg-neutral-900");
|
|
60
|
-
return (_jsxs("div", { className: cn("anyspend-payment-panel flex flex-col gap-5", classes?.paymentPanel), children: [_jsx("h2", { className: cn("anyspend-payment-title text-lg font-semibold text-gray-900 dark:text-gray-100", classes?.paymentTitle), children: "Payment" }), !isFormValid && (_jsx("p", { className: "text-sm text-amber-600 dark:text-amber-400", children: "Please complete the required fields above before proceeding to payment." })), _jsxs("div", { className: cn("anyspend-payment-methods divide-y divide-gray-200 overflow-hidden rounded-xl border border-gray-200 dark:divide-neutral-700 dark:border-neutral-700", !isFormValid && "pointer-events-none opacity-50", classes?.paymentMethodSelector), children: [_jsxs("div", { className: "anyspend-method-crypto", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "crypto" ? null : "crypto"), className: accordionButtonClass(paymentMethod === "crypto"), children: [_jsx(RadioCircle, { selected: paymentMethod === "crypto", themeColor: themeColor }), _jsx(Wallet, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Pay with crypto" })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "crypto" && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: _jsx("div", { className: expandedPanelClass, children: _jsx(CryptoPayPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, buttonText: buttonText, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes, senderAddress: senderAddress }) }) }, "crypto-panel")) })] }), _jsxs("div", { className: "anyspend-method-card", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "card" ? null : "card"), className: accordionButtonClass(paymentMethod === "card"), children: [_jsx(RadioCircle, { selected: paymentMethod === "card", themeColor: themeColor }), _jsx(CreditCard, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Credit or debit card" }), _jsxs("div", { className: "ml-auto flex items-center gap-1", children: [_jsx(VisaLogo, {}), _jsx(MastercardLogo, {}), _jsx(AmexLogo, {})] })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "card" && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: _jsx("div", { className: expandedPanelClass, children: _jsx(FiatCheckoutPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes }) }) }, "card-panel")) })] }), _jsxs("div", { className: "anyspend-method-coinbase", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "coinbase" ? null : "coinbase"), className: accordionButtonClass(paymentMethod === "coinbase"), children: [_jsx(RadioCircle, { selected: paymentMethod === "coinbase", themeColor: themeColor }), _jsx(CoinbaseLogo, {}), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Coinbase Pay" })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "coinbase" && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: _jsx("div", { className: expandedPanelClass, children: _jsx(CoinbaseCheckoutPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes }) }) }, "coinbase-panel")) })] })] })] }));
|
|
60
|
+
return (_jsxs("div", { className: cn("anyspend-payment-panel flex flex-col gap-5", classes?.paymentPanel), children: [_jsx("h2", { className: cn("anyspend-payment-title text-lg font-semibold text-gray-900 dark:text-gray-100", classes?.paymentTitle), children: "Payment" }), !isFormValid && (_jsx("p", { className: "text-sm text-amber-600 dark:text-amber-400", children: "Please complete the required fields above before proceeding to payment." })), _jsxs("div", { className: cn("anyspend-payment-methods divide-y divide-gray-200 overflow-hidden rounded-xl border border-gray-200 dark:divide-neutral-700 dark:border-neutral-700", !isFormValid && "pointer-events-none opacity-50", classes?.paymentMethodSelector), children: [_jsxs("div", { className: "anyspend-method-crypto", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "crypto" ? null : "crypto"), className: accordionButtonClass(paymentMethod === "crypto"), children: [_jsx(RadioCircle, { selected: paymentMethod === "crypto", themeColor: themeColor }), _jsx(Wallet, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Pay with crypto" })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "crypto" && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: _jsx("div", { className: expandedPanelClass, children: _jsx(CryptoPayPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, buttonText: buttonText, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes, senderAddress: senderAddress }) }) }, "crypto-panel")) })] }), _jsxs("div", { className: "anyspend-method-card", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "card" ? null : "card"), className: accordionButtonClass(paymentMethod === "card"), children: [_jsx(RadioCircle, { selected: paymentMethod === "card", themeColor: themeColor }), _jsx(CreditCard, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Credit or debit card" }), _jsxs("div", { className: "ml-auto flex items-center gap-1", children: [_jsx(VisaLogo, {}), _jsx(MastercardLogo, {}), _jsx(AmexLogo, {})] })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "card" && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: _jsx("div", { className: expandedPanelClass, children: _jsx(FiatCheckoutPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes, feeOnTop: feeOnTop, kycEnabled: kycEnabled }) }) }, "card-panel")) })] }), _jsxs("div", { className: "anyspend-method-coinbase", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "coinbase" ? null : "coinbase"), className: accordionButtonClass(paymentMethod === "coinbase"), children: [_jsx(RadioCircle, { selected: paymentMethod === "coinbase", themeColor: themeColor }), _jsx(CoinbaseLogo, {}), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Coinbase Pay" })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "coinbase" && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: _jsx("div", { className: expandedPanelClass, children: _jsx(CoinbaseCheckoutPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes }) }) }, "coinbase-panel")) })] })] })] }));
|
|
61
61
|
}
|