@b3dotfun/sdk 0.0.80 → 0.0.81-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/react/components/AnySpend.js +23 -10
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +22 -6
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.d.ts +4 -0
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +14 -7
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +7 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +23 -10
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +23 -7
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.d.ts +4 -0
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +13 -6
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +8 -2
- package/dist/types/anyspend/react/components/common/FiatPaymentMethod.d.ts +4 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +24 -10
- package/src/anyspend/react/components/AnySpendCustom.tsx +42 -33
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +14 -6
- package/src/anyspend/react/components/common/PanelOnramp.tsx +23 -27
|
@@ -362,18 +362,18 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
362
362
|
isBalanceLoading,
|
|
363
363
|
});
|
|
364
364
|
// Get geo-based onramp options for fiat payments
|
|
365
|
-
const { geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support } = (0, react_1.useGeoOnrampOptions)(srcAmountOnRamp);
|
|
365
|
+
const { geoData, coinbaseAvailablePaymentMethods, stripeOnrampSupport, stripeWeb2Support } = (0, react_1.useGeoOnrampOptions)(srcAmountOnRamp);
|
|
366
366
|
// Helper function to map payment method to onramp vendor
|
|
367
367
|
const getOnrampVendor = (paymentMethod) => {
|
|
368
368
|
switch (paymentMethod) {
|
|
369
369
|
case FiatPaymentMethod_1.FiatPaymentMethod.COINBASE_PAY:
|
|
370
370
|
return "coinbase";
|
|
371
371
|
case FiatPaymentMethod_1.FiatPaymentMethod.STRIPE:
|
|
372
|
-
//
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
return undefined;
|
|
372
|
+
// Stripe redirect flow (one-click URL)
|
|
373
|
+
return stripeOnrampSupport ? "stripe" : undefined;
|
|
374
|
+
case FiatPaymentMethod_1.FiatPaymentMethod.STRIPE_WEB2:
|
|
375
|
+
// Stripe embedded payment form
|
|
376
|
+
return stripeWeb2Support?.isSupport ? "stripe-web2" : undefined;
|
|
377
377
|
default:
|
|
378
378
|
return undefined;
|
|
379
379
|
}
|
|
@@ -518,7 +518,9 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
518
518
|
}, [activeTab, selectedSrcChainId, selectedDstChainId, selectedSrcToken.address, selectedDstToken.address]);
|
|
519
519
|
// Determine button state and text
|
|
520
520
|
const btnInfo = (0, react_4.useMemo)(() => {
|
|
521
|
-
|
|
521
|
+
// For fiat tab, check srcAmountOnRamp; for crypto tab, check activeInputAmountInWei
|
|
522
|
+
const hasAmount = activeTab === "fiat" ? srcAmountOnRamp && parseFloat(srcAmountOnRamp) > 0 : activeInputAmountInWei !== "0";
|
|
523
|
+
if (!hasAmount)
|
|
522
524
|
return { text: "Enter an amount", disable: true, error: false, loading: false };
|
|
523
525
|
if (isSameChainSameToken)
|
|
524
526
|
return { text: "Select a different token or chain", disable: true, error: false, loading: false };
|
|
@@ -569,6 +571,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
569
571
|
activeTab,
|
|
570
572
|
effectiveCryptoPaymentMethod,
|
|
571
573
|
selectedFiatPaymentMethod,
|
|
574
|
+
srcAmountOnRamp,
|
|
572
575
|
]);
|
|
573
576
|
// Handle main button click
|
|
574
577
|
const onMainButtonClick = async () => {
|
|
@@ -683,11 +686,21 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
683
686
|
paymentMethodString = coinbaseAvailablePaymentMethods[0]?.id || ""; // Use first available payment method ID
|
|
684
687
|
}
|
|
685
688
|
else if (paymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.STRIPE) {
|
|
686
|
-
|
|
687
|
-
|
|
689
|
+
// Stripe redirect flow (one-click URL)
|
|
690
|
+
if (!stripeOnrampSupport) {
|
|
691
|
+
react_2.toast.error("Credit/Debit Card not available");
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
vendor = "stripe";
|
|
695
|
+
paymentMethodString = "";
|
|
696
|
+
}
|
|
697
|
+
else if (paymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.STRIPE_WEB2) {
|
|
698
|
+
// Stripe embedded payment form
|
|
699
|
+
if (!stripeWeb2Support.isSupport) {
|
|
700
|
+
react_2.toast.error("Pay with Card not available");
|
|
688
701
|
return;
|
|
689
702
|
}
|
|
690
|
-
vendor =
|
|
703
|
+
vendor = "stripe-web2";
|
|
691
704
|
paymentMethodString = "";
|
|
692
705
|
}
|
|
693
706
|
else {
|
|
@@ -236,7 +236,11 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
236
236
|
contractType: orderType === "mint_nft" ? metadata?.nftContract?.type : undefined,
|
|
237
237
|
encodedData: encodedData,
|
|
238
238
|
spenderAddress: spenderAddress,
|
|
239
|
-
onrampVendor: selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.STRIPE
|
|
239
|
+
onrampVendor: selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.STRIPE
|
|
240
|
+
? "stripe"
|
|
241
|
+
: selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.STRIPE_WEB2
|
|
242
|
+
? "stripe-web2"
|
|
243
|
+
: undefined,
|
|
240
244
|
});
|
|
241
245
|
}, [
|
|
242
246
|
activeTab,
|
|
@@ -578,7 +582,13 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
578
582
|
opacity: hasMounted ? 1 : 0,
|
|
579
583
|
y: hasMounted ? 0 : 20,
|
|
580
584
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
581
|
-
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay with" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.FIAT_PAYMENT_METHOD), children:
|
|
585
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay with" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.FIAT_PAYMENT_METHOD), children: (() => {
|
|
586
|
+
const config = FiatPaymentMethod_1.FIAT_PAYMENT_METHOD_DISPLAY[selectedFiatPaymentMethod];
|
|
587
|
+
if (config) {
|
|
588
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 whitespace-nowrap", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-blue-600", children: (0, jsx_runtime_1.jsx)("span", { className: "text-xs font-bold text-white", children: config.icon }) }), config.label] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4 shrink-0" })] }));
|
|
589
|
+
}
|
|
590
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "whitespace-nowrap", children: "Select payment method" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4 shrink-0" })] }));
|
|
591
|
+
})() })] }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), recipientSection, (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsxs)(react_4.motion.div, { initial: false, animate: {
|
|
582
592
|
opacity: hasMounted ? 1 : 0,
|
|
583
593
|
y: hasMounted ? 0 : 20,
|
|
584
594
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -618,11 +628,17 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
618
628
|
setSelectedCryptoPaymentMethod(method);
|
|
619
629
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
620
630
|
} }) }));
|
|
631
|
+
// Stable callback for fiat payment method selection
|
|
632
|
+
const handleFiatPaymentMethodSelect = (0, react_5.useCallback)((method) => {
|
|
633
|
+
setSelectedFiatPaymentMethod(method);
|
|
634
|
+
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
635
|
+
}, []);
|
|
636
|
+
// Stable callback for navigating back to confirm order
|
|
637
|
+
const handleBackToConfirmOrder = (0, react_5.useCallback)(() => {
|
|
638
|
+
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
639
|
+
}, []);
|
|
621
640
|
// Fiat payment method view
|
|
622
|
-
const fiatPaymentMethodView = ((0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4"), children: (0, jsx_runtime_1.jsx)(FiatPaymentMethod_1.FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack:
|
|
623
|
-
setSelectedFiatPaymentMethod(method);
|
|
624
|
-
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
625
|
-
}, srcAmountOnRamp: srcFiatAmount }) }));
|
|
641
|
+
const fiatPaymentMethodView = ((0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4"), children: (0, jsx_runtime_1.jsx)(FiatPaymentMethod_1.FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack: handleBackToConfirmOrder, onSelectPaymentMethod: handleFiatPaymentMethodSelect, srcAmountOnRamp: srcFiatAmount }) }));
|
|
626
642
|
// Points detail view
|
|
627
643
|
const pointsDetailView = ((0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4"), children: (0, jsx_runtime_1.jsx)(PointsDetailPanel_1.PointsDetailPanel, { pointsAmount: anyspendQuote?.data?.pointsAmount || 0, onBack: () => setActivePanel(PanelView.CONFIRM_ORDER) }) }));
|
|
628
644
|
// Return the TransitionPanel with all views
|
|
@@ -4,6 +4,10 @@ export declare enum FiatPaymentMethod {
|
|
|
4
4
|
STRIPE = "stripe",// Stripe redirect (one-click buy URL)
|
|
5
5
|
STRIPE_WEB2 = "stripe_web2"
|
|
6
6
|
}
|
|
7
|
+
export declare const FIAT_PAYMENT_METHOD_DISPLAY: Record<FiatPaymentMethod, {
|
|
8
|
+
icon: string;
|
|
9
|
+
label: string;
|
|
10
|
+
} | null>;
|
|
7
11
|
interface FiatPaymentMethodProps {
|
|
8
12
|
selectedPaymentMethod: FiatPaymentMethod;
|
|
9
13
|
setSelectedPaymentMethod: (method: FiatPaymentMethod) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.FiatPaymentMethod = void 0;
|
|
4
|
+
exports.FIAT_PAYMENT_METHOD_DISPLAY = exports.FiatPaymentMethod = void 0;
|
|
5
5
|
exports.FiatPaymentMethodComponent = FiatPaymentMethodComponent;
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const react_1 = require("../../../../anyspend/react");
|
|
@@ -14,6 +14,13 @@ var FiatPaymentMethod;
|
|
|
14
14
|
FiatPaymentMethod["STRIPE"] = "stripe";
|
|
15
15
|
FiatPaymentMethod["STRIPE_WEB2"] = "stripe_web2";
|
|
16
16
|
})(FiatPaymentMethod || (exports.FiatPaymentMethod = FiatPaymentMethod = {}));
|
|
17
|
+
// Shared display config for fiat payment methods
|
|
18
|
+
exports.FIAT_PAYMENT_METHOD_DISPLAY = {
|
|
19
|
+
[FiatPaymentMethod.COINBASE_PAY]: { icon: "C", label: "Coinbase Pay" },
|
|
20
|
+
[FiatPaymentMethod.STRIPE]: { icon: "S", label: "Pay via Stripe" },
|
|
21
|
+
[FiatPaymentMethod.STRIPE_WEB2]: { icon: "S", label: "Pay with Card" },
|
|
22
|
+
[FiatPaymentMethod.NONE]: null,
|
|
23
|
+
};
|
|
17
24
|
function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedPaymentMethod, onBack, onSelectPaymentMethod, srcAmountOnRamp, }) {
|
|
18
25
|
// Load geo-based onramp options like in PanelOnramp
|
|
19
26
|
const { coinbaseAvailablePaymentMethods, stripeOnrampSupport, stripeWeb2Support, isLoading: isLoadingGeoOnramp, } = (0, react_1.useGeoOnrampOptions)(srcAmountOnRamp);
|
|
@@ -50,25 +57,25 @@ function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedPaymentM
|
|
|
50
57
|
available: true,
|
|
51
58
|
});
|
|
52
59
|
}
|
|
53
|
-
// Add Stripe redirect (one-click) if available -
|
|
60
|
+
// Add Stripe redirect (one-click) if available - redirects to Stripe checkout
|
|
54
61
|
if (stripeOnrampSupport) {
|
|
55
62
|
const stripeFee = getFeeFromApi(FiatPaymentMethod.STRIPE_WEB2); // Use same fee estimate
|
|
56
63
|
availablePaymentMethods.push({
|
|
57
64
|
id: FiatPaymentMethod.STRIPE,
|
|
58
|
-
name: "
|
|
59
|
-
description: "
|
|
65
|
+
name: "Pay via Stripe",
|
|
66
|
+
description: "Redirects to Stripe checkout",
|
|
60
67
|
badge: stripeFee ? `$${Number(stripeFee).toFixed(2)} fee` : undefined,
|
|
61
68
|
badgeColor: "bg-gray-100 text-gray-800",
|
|
62
69
|
available: true,
|
|
63
70
|
});
|
|
64
71
|
}
|
|
65
|
-
// Add Stripe Web2 (embedded) if available -
|
|
72
|
+
// Add Stripe Web2 (embedded) if available - embedded card form
|
|
66
73
|
if (stripeWeb2Support && stripeWeb2Support.isSupport) {
|
|
67
74
|
const stripeFee = getFeeFromApi(FiatPaymentMethod.STRIPE_WEB2);
|
|
68
75
|
availablePaymentMethods.push({
|
|
69
76
|
id: FiatPaymentMethod.STRIPE_WEB2,
|
|
70
|
-
name: "
|
|
71
|
-
description: "
|
|
77
|
+
name: "Pay with Card",
|
|
78
|
+
description: "Fast checkout",
|
|
72
79
|
badge: stripeFee ? `$${Number(stripeFee).toFixed(2)} fee` : undefined,
|
|
73
80
|
badgeColor: "bg-gray-100 text-gray-800",
|
|
74
81
|
available: true,
|
|
@@ -78,7 +78,13 @@ function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, selectedPaymentMetho
|
|
|
78
78
|
const handleQuickAmount = (value) => {
|
|
79
79
|
setSrcAmountOnRamp(value);
|
|
80
80
|
};
|
|
81
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "panel-onramp bg-as-surface-primary flex w-full flex-col", children: [(0, jsx_runtime_1.jsxs)("div", { className: "border-as-border-secondary bg-as-surface-secondary relative flex w-full flex-col rounded-2xl border p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex h-7 w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry flex items-center text-sm font-bold", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm", onClick: () => setActivePanel(fiatPaymentMethodIndex), children:
|
|
81
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "panel-onramp bg-as-surface-primary flex w-full flex-col", children: [(0, jsx_runtime_1.jsxs)("div", { className: "border-as-border-secondary bg-as-surface-secondary relative flex w-full flex-col rounded-2xl border p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex h-7 w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry flex items-center text-sm font-bold", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm", onClick: () => setActivePanel(fiatPaymentMethodIndex), children: (() => {
|
|
82
|
+
const config = selectedPaymentMethod ? FiatPaymentMethod_1.FIAT_PAYMENT_METHOD_DISPLAY[selectedPaymentMethod] : null;
|
|
83
|
+
if (config) {
|
|
84
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-blue-600", children: (0, jsx_runtime_1.jsx)("span", { className: "text-xs font-bold text-white", children: config.icon }) }), config.label] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] }));
|
|
85
|
+
}
|
|
86
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Select payment method", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] }));
|
|
87
|
+
})() })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-center pb-2 pt-8", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-1", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry text-2xl font-bold", children: "$" }), (0, jsx_runtime_1.jsx)(react_2.Input, { ref: amountInputRef, type: "text", value: srcAmountOnRamp, onChange: handleAmountChange, placeholder: "5", className: "text-as-primary placeholder:text-as-primary/50 h-auto border-0 bg-transparent p-0 px-1 pt-1 text-4xl font-bold focus-visible:ring-0 focus-visible:ring-offset-0", style: {
|
|
82
88
|
width: `${Math.max(ONE_CHAR_WIDTH, srcAmountOnRamp.length * ONE_CHAR_WIDTH)}px`,
|
|
83
89
|
} })] }) }), (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("mx-auto mb-6 flex justify-center gap-2", hideDstToken && "mb-0"), children: customUsdInputValues
|
|
84
90
|
.filter(v => !isNaN(Number(v)))
|
|
@@ -355,18 +355,18 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
355
355
|
isBalanceLoading,
|
|
356
356
|
});
|
|
357
357
|
// Get geo-based onramp options for fiat payments
|
|
358
|
-
const { geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support } = useGeoOnrampOptions(srcAmountOnRamp);
|
|
358
|
+
const { geoData, coinbaseAvailablePaymentMethods, stripeOnrampSupport, stripeWeb2Support } = useGeoOnrampOptions(srcAmountOnRamp);
|
|
359
359
|
// Helper function to map payment method to onramp vendor
|
|
360
360
|
const getOnrampVendor = (paymentMethod) => {
|
|
361
361
|
switch (paymentMethod) {
|
|
362
362
|
case FiatPaymentMethod.COINBASE_PAY:
|
|
363
363
|
return "coinbase";
|
|
364
364
|
case FiatPaymentMethod.STRIPE:
|
|
365
|
-
//
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
return undefined;
|
|
365
|
+
// Stripe redirect flow (one-click URL)
|
|
366
|
+
return stripeOnrampSupport ? "stripe" : undefined;
|
|
367
|
+
case FiatPaymentMethod.STRIPE_WEB2:
|
|
368
|
+
// Stripe embedded payment form
|
|
369
|
+
return stripeWeb2Support?.isSupport ? "stripe-web2" : undefined;
|
|
370
370
|
default:
|
|
371
371
|
return undefined;
|
|
372
372
|
}
|
|
@@ -511,7 +511,9 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
511
511
|
}, [activeTab, selectedSrcChainId, selectedDstChainId, selectedSrcToken.address, selectedDstToken.address]);
|
|
512
512
|
// Determine button state and text
|
|
513
513
|
const btnInfo = useMemo(() => {
|
|
514
|
-
|
|
514
|
+
// For fiat tab, check srcAmountOnRamp; for crypto tab, check activeInputAmountInWei
|
|
515
|
+
const hasAmount = activeTab === "fiat" ? srcAmountOnRamp && parseFloat(srcAmountOnRamp) > 0 : activeInputAmountInWei !== "0";
|
|
516
|
+
if (!hasAmount)
|
|
515
517
|
return { text: "Enter an amount", disable: true, error: false, loading: false };
|
|
516
518
|
if (isSameChainSameToken)
|
|
517
519
|
return { text: "Select a different token or chain", disable: true, error: false, loading: false };
|
|
@@ -562,6 +564,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
562
564
|
activeTab,
|
|
563
565
|
effectiveCryptoPaymentMethod,
|
|
564
566
|
selectedFiatPaymentMethod,
|
|
567
|
+
srcAmountOnRamp,
|
|
565
568
|
]);
|
|
566
569
|
// Handle main button click
|
|
567
570
|
const onMainButtonClick = async () => {
|
|
@@ -676,11 +679,21 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
676
679
|
paymentMethodString = coinbaseAvailablePaymentMethods[0]?.id || ""; // Use first available payment method ID
|
|
677
680
|
}
|
|
678
681
|
else if (paymentMethod === FiatPaymentMethod.STRIPE) {
|
|
679
|
-
|
|
680
|
-
|
|
682
|
+
// Stripe redirect flow (one-click URL)
|
|
683
|
+
if (!stripeOnrampSupport) {
|
|
684
|
+
toast.error("Credit/Debit Card not available");
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
vendor = "stripe";
|
|
688
|
+
paymentMethodString = "";
|
|
689
|
+
}
|
|
690
|
+
else if (paymentMethod === FiatPaymentMethod.STRIPE_WEB2) {
|
|
691
|
+
// Stripe embedded payment form
|
|
692
|
+
if (!stripeWeb2Support.isSupport) {
|
|
693
|
+
toast.error("Pay with Card not available");
|
|
681
694
|
return;
|
|
682
695
|
}
|
|
683
|
-
vendor =
|
|
696
|
+
vendor = "stripe-web2";
|
|
684
697
|
paymentMethodString = "";
|
|
685
698
|
}
|
|
686
699
|
else {
|
|
@@ -19,7 +19,7 @@ import { useRecipientAddressState } from "../hooks/useRecipientAddressState.js";
|
|
|
19
19
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper.js";
|
|
20
20
|
import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod.js";
|
|
21
21
|
import { FeeBreakDown } from "./common/FeeBreakDown.js";
|
|
22
|
-
import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod.js";
|
|
22
|
+
import { FIAT_PAYMENT_METHOD_DISPLAY, FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod.js";
|
|
23
23
|
import { OrderDetails } from "./common/OrderDetails.js";
|
|
24
24
|
import { OrderHistory } from "./common/OrderHistory.js";
|
|
25
25
|
import { OrderToken } from "./common/OrderToken.js";
|
|
@@ -197,7 +197,11 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
197
197
|
contractType: orderType === "mint_nft" ? metadata?.nftContract?.type : undefined,
|
|
198
198
|
encodedData: encodedData,
|
|
199
199
|
spenderAddress: spenderAddress,
|
|
200
|
-
onrampVendor: selectedFiatPaymentMethod === FiatPaymentMethod.STRIPE
|
|
200
|
+
onrampVendor: selectedFiatPaymentMethod === FiatPaymentMethod.STRIPE
|
|
201
|
+
? "stripe"
|
|
202
|
+
: selectedFiatPaymentMethod === FiatPaymentMethod.STRIPE_WEB2
|
|
203
|
+
? "stripe-web2"
|
|
204
|
+
: undefined,
|
|
201
205
|
});
|
|
202
206
|
}, [
|
|
203
207
|
activeTab,
|
|
@@ -539,7 +543,13 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
539
543
|
opacity: hasMounted ? 1 : 0,
|
|
540
544
|
y: hasMounted ? 0 : 20,
|
|
541
545
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
542
|
-
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay with" }), _jsx("button", { className: "text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.FIAT_PAYMENT_METHOD), children:
|
|
546
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay with" }), _jsx("button", { className: "text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.FIAT_PAYMENT_METHOD), children: (() => {
|
|
547
|
+
const config = FIAT_PAYMENT_METHOD_DISPLAY[selectedFiatPaymentMethod];
|
|
548
|
+
if (config) {
|
|
549
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2 whitespace-nowrap", children: [_jsx("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-blue-600", children: _jsx("span", { className: "text-xs font-bold text-white", children: config.icon }) }), config.label] }), _jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })] }));
|
|
550
|
+
}
|
|
551
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { className: "whitespace-nowrap", children: "Select payment method" }), _jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })] }));
|
|
552
|
+
})() })] }), _jsx("div", { className: "divider w-full" }), recipientSection, _jsx("div", { className: "divider w-full" }), _jsxs(motion.div, { initial: false, animate: {
|
|
543
553
|
opacity: hasMounted ? 1 : 0,
|
|
544
554
|
y: hasMounted ? 0 : 20,
|
|
545
555
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -579,11 +589,17 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
579
589
|
setSelectedCryptoPaymentMethod(method);
|
|
580
590
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
581
591
|
} }) }));
|
|
592
|
+
// Stable callback for fiat payment method selection
|
|
593
|
+
const handleFiatPaymentMethodSelect = useCallback((method) => {
|
|
594
|
+
setSelectedFiatPaymentMethod(method);
|
|
595
|
+
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
596
|
+
}, []);
|
|
597
|
+
// Stable callback for navigating back to confirm order
|
|
598
|
+
const handleBackToConfirmOrder = useCallback(() => {
|
|
599
|
+
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
600
|
+
}, []);
|
|
582
601
|
// Fiat payment method view
|
|
583
|
-
const fiatPaymentMethodView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4"), children: _jsx(FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack:
|
|
584
|
-
setSelectedFiatPaymentMethod(method);
|
|
585
|
-
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
586
|
-
}, srcAmountOnRamp: srcFiatAmount }) }));
|
|
602
|
+
const fiatPaymentMethodView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4"), children: _jsx(FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack: handleBackToConfirmOrder, onSelectPaymentMethod: handleFiatPaymentMethodSelect, srcAmountOnRamp: srcFiatAmount }) }));
|
|
587
603
|
// Points detail view
|
|
588
604
|
const pointsDetailView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4"), children: _jsx(PointsDetailPanel, { pointsAmount: anyspendQuote?.data?.pointsAmount || 0, onBack: () => setActivePanel(PanelView.CONFIRM_ORDER) }) }));
|
|
589
605
|
// Return the TransitionPanel with all views
|
|
@@ -4,6 +4,10 @@ export declare enum FiatPaymentMethod {
|
|
|
4
4
|
STRIPE = "stripe",// Stripe redirect (one-click buy URL)
|
|
5
5
|
STRIPE_WEB2 = "stripe_web2"
|
|
6
6
|
}
|
|
7
|
+
export declare const FIAT_PAYMENT_METHOD_DISPLAY: Record<FiatPaymentMethod, {
|
|
8
|
+
icon: string;
|
|
9
|
+
label: string;
|
|
10
|
+
} | null>;
|
|
7
11
|
interface FiatPaymentMethodProps {
|
|
8
12
|
selectedPaymentMethod: FiatPaymentMethod;
|
|
9
13
|
setSelectedPaymentMethod: (method: FiatPaymentMethod) => void;
|
|
@@ -10,6 +10,13 @@ export var FiatPaymentMethod;
|
|
|
10
10
|
FiatPaymentMethod["STRIPE"] = "stripe";
|
|
11
11
|
FiatPaymentMethod["STRIPE_WEB2"] = "stripe_web2";
|
|
12
12
|
})(FiatPaymentMethod || (FiatPaymentMethod = {}));
|
|
13
|
+
// Shared display config for fiat payment methods
|
|
14
|
+
export const FIAT_PAYMENT_METHOD_DISPLAY = {
|
|
15
|
+
[FiatPaymentMethod.COINBASE_PAY]: { icon: "C", label: "Coinbase Pay" },
|
|
16
|
+
[FiatPaymentMethod.STRIPE]: { icon: "S", label: "Pay via Stripe" },
|
|
17
|
+
[FiatPaymentMethod.STRIPE_WEB2]: { icon: "S", label: "Pay with Card" },
|
|
18
|
+
[FiatPaymentMethod.NONE]: null,
|
|
19
|
+
};
|
|
13
20
|
export function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedPaymentMethod, onBack, onSelectPaymentMethod, srcAmountOnRamp, }) {
|
|
14
21
|
// Load geo-based onramp options like in PanelOnramp
|
|
15
22
|
const { coinbaseAvailablePaymentMethods, stripeOnrampSupport, stripeWeb2Support, isLoading: isLoadingGeoOnramp, } = useGeoOnrampOptions(srcAmountOnRamp);
|
|
@@ -46,25 +53,25 @@ export function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedP
|
|
|
46
53
|
available: true,
|
|
47
54
|
});
|
|
48
55
|
}
|
|
49
|
-
// Add Stripe redirect (one-click) if available -
|
|
56
|
+
// Add Stripe redirect (one-click) if available - redirects to Stripe checkout
|
|
50
57
|
if (stripeOnrampSupport) {
|
|
51
58
|
const stripeFee = getFeeFromApi(FiatPaymentMethod.STRIPE_WEB2); // Use same fee estimate
|
|
52
59
|
availablePaymentMethods.push({
|
|
53
60
|
id: FiatPaymentMethod.STRIPE,
|
|
54
|
-
name: "
|
|
55
|
-
description: "
|
|
61
|
+
name: "Pay via Stripe",
|
|
62
|
+
description: "Redirects to Stripe checkout",
|
|
56
63
|
badge: stripeFee ? `$${Number(stripeFee).toFixed(2)} fee` : undefined,
|
|
57
64
|
badgeColor: "bg-gray-100 text-gray-800",
|
|
58
65
|
available: true,
|
|
59
66
|
});
|
|
60
67
|
}
|
|
61
|
-
// Add Stripe Web2 (embedded) if available -
|
|
68
|
+
// Add Stripe Web2 (embedded) if available - embedded card form
|
|
62
69
|
if (stripeWeb2Support && stripeWeb2Support.isSupport) {
|
|
63
70
|
const stripeFee = getFeeFromApi(FiatPaymentMethod.STRIPE_WEB2);
|
|
64
71
|
availablePaymentMethods.push({
|
|
65
72
|
id: FiatPaymentMethod.STRIPE_WEB2,
|
|
66
|
-
name: "
|
|
67
|
-
description: "
|
|
73
|
+
name: "Pay with Card",
|
|
74
|
+
description: "Fast checkout",
|
|
68
75
|
badge: stripeFee ? `$${Number(stripeFee).toFixed(2)} fee` : undefined,
|
|
69
76
|
badgeColor: "bg-gray-100 text-gray-800",
|
|
70
77
|
available: true,
|
|
@@ -6,7 +6,7 @@ import { cn, formatUsername } from "../../../../shared/utils/index.js";
|
|
|
6
6
|
import { formatAddress } from "../../../../shared/utils/formatAddress.js";
|
|
7
7
|
import { ChevronRight, Info, Wallet } from "lucide-react";
|
|
8
8
|
import { useRef } from "react";
|
|
9
|
-
import { FiatPaymentMethod } from "./FiatPaymentMethod.js";
|
|
9
|
+
import { FIAT_PAYMENT_METHOD_DISPLAY, FiatPaymentMethod } from "./FiatPaymentMethod.js";
|
|
10
10
|
import { OrderTokenAmountFiat } from "./OrderTokenAmountFiat.js";
|
|
11
11
|
import { PointsBadge } from "./PointsBadge.js";
|
|
12
12
|
const ONE_CHAR_WIDTH = 30;
|
|
@@ -75,7 +75,13 @@ export function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, selectedPayme
|
|
|
75
75
|
const handleQuickAmount = (value) => {
|
|
76
76
|
setSrcAmountOnRamp(value);
|
|
77
77
|
};
|
|
78
|
-
return (_jsxs("div", { className: "panel-onramp bg-as-surface-primary flex w-full flex-col", children: [_jsxs("div", { className: "border-as-border-secondary bg-as-surface-secondary relative flex w-full flex-col rounded-2xl border p-4", children: [_jsxs("div", { className: "flex h-7 w-full items-center justify-between", children: [_jsx("span", { className: "text-as-tertiarry flex items-center text-sm font-bold", children: "Pay" }), _jsx("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm", onClick: () => setActivePanel(fiatPaymentMethodIndex), children:
|
|
78
|
+
return (_jsxs("div", { className: "panel-onramp bg-as-surface-primary flex w-full flex-col", children: [_jsxs("div", { className: "border-as-border-secondary bg-as-surface-secondary relative flex w-full flex-col rounded-2xl border p-4", children: [_jsxs("div", { className: "flex h-7 w-full items-center justify-between", children: [_jsx("span", { className: "text-as-tertiarry flex items-center text-sm font-bold", children: "Pay" }), _jsx("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm", onClick: () => setActivePanel(fiatPaymentMethodIndex), children: (() => {
|
|
79
|
+
const config = selectedPaymentMethod ? FIAT_PAYMENT_METHOD_DISPLAY[selectedPaymentMethod] : null;
|
|
80
|
+
if (config) {
|
|
81
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-blue-600", children: _jsx("span", { className: "text-xs font-bold text-white", children: config.icon }) }), config.label] }), _jsx(ChevronRight, { className: "h-4 w-4" })] }));
|
|
82
|
+
}
|
|
83
|
+
return (_jsxs(_Fragment, { children: ["Select payment method", _jsx(ChevronRight, { className: "h-4 w-4" })] }));
|
|
84
|
+
})() })] }), _jsx("div", { className: "flex items-center justify-center pb-2 pt-8", children: _jsxs("div", { className: "flex gap-1", children: [_jsx("span", { className: "text-as-tertiarry text-2xl font-bold", children: "$" }), _jsx(Input, { ref: amountInputRef, type: "text", value: srcAmountOnRamp, onChange: handleAmountChange, placeholder: "5", className: "text-as-primary placeholder:text-as-primary/50 h-auto border-0 bg-transparent p-0 px-1 pt-1 text-4xl font-bold focus-visible:ring-0 focus-visible:ring-offset-0", style: {
|
|
79
85
|
width: `${Math.max(ONE_CHAR_WIDTH, srcAmountOnRamp.length * ONE_CHAR_WIDTH)}px`,
|
|
80
86
|
} })] }) }), _jsx("div", { className: cn("mx-auto mb-6 flex justify-center gap-2", hideDstToken && "mb-0"), children: customUsdInputValues
|
|
81
87
|
.filter(v => !isNaN(Number(v)))
|
|
@@ -4,6 +4,10 @@ export declare enum FiatPaymentMethod {
|
|
|
4
4
|
STRIPE = "stripe",// Stripe redirect (one-click buy URL)
|
|
5
5
|
STRIPE_WEB2 = "stripe_web2"
|
|
6
6
|
}
|
|
7
|
+
export declare const FIAT_PAYMENT_METHOD_DISPLAY: Record<FiatPaymentMethod, {
|
|
8
|
+
icon: string;
|
|
9
|
+
label: string;
|
|
10
|
+
} | null>;
|
|
7
11
|
interface FiatPaymentMethodProps {
|
|
8
12
|
selectedPaymentMethod: FiatPaymentMethod;
|
|
9
13
|
setSelectedPaymentMethod: (method: FiatPaymentMethod) => void;
|
package/package.json
CHANGED
|
@@ -510,7 +510,8 @@ function AnySpendInner({
|
|
|
510
510
|
});
|
|
511
511
|
|
|
512
512
|
// Get geo-based onramp options for fiat payments
|
|
513
|
-
const { geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support } =
|
|
513
|
+
const { geoData, coinbaseAvailablePaymentMethods, stripeOnrampSupport, stripeWeb2Support } =
|
|
514
|
+
useGeoOnrampOptions(srcAmountOnRamp);
|
|
514
515
|
|
|
515
516
|
// Helper function to map payment method to onramp vendor
|
|
516
517
|
const getOnrampVendor = (paymentMethod: FiatPaymentMethod): "coinbase" | "stripe" | "stripe-web2" | undefined => {
|
|
@@ -518,11 +519,11 @@ function AnySpendInner({
|
|
|
518
519
|
case FiatPaymentMethod.COINBASE_PAY:
|
|
519
520
|
return "coinbase";
|
|
520
521
|
case FiatPaymentMethod.STRIPE:
|
|
521
|
-
//
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
return undefined;
|
|
522
|
+
// Stripe redirect flow (one-click URL)
|
|
523
|
+
return stripeOnrampSupport ? "stripe" : undefined;
|
|
524
|
+
case FiatPaymentMethod.STRIPE_WEB2:
|
|
525
|
+
// Stripe embedded payment form
|
|
526
|
+
return stripeWeb2Support?.isSupport ? "stripe-web2" : undefined;
|
|
526
527
|
default:
|
|
527
528
|
return undefined;
|
|
528
529
|
}
|
|
@@ -683,7 +684,10 @@ function AnySpendInner({
|
|
|
683
684
|
|
|
684
685
|
// Determine button state and text
|
|
685
686
|
const btnInfo: { text: string; disable: boolean; error: boolean; loading: boolean } = useMemo(() => {
|
|
686
|
-
|
|
687
|
+
// For fiat tab, check srcAmountOnRamp; for crypto tab, check activeInputAmountInWei
|
|
688
|
+
const hasAmount =
|
|
689
|
+
activeTab === "fiat" ? srcAmountOnRamp && parseFloat(srcAmountOnRamp) > 0 : activeInputAmountInWei !== "0";
|
|
690
|
+
if (!hasAmount) return { text: "Enter an amount", disable: true, error: false, loading: false };
|
|
687
691
|
if (isSameChainSameToken)
|
|
688
692
|
return { text: "Select a different token or chain", disable: true, error: false, loading: false };
|
|
689
693
|
if (isLoadingAnyspendQuote) return { text: "Loading quote...", disable: true, error: false, loading: true };
|
|
@@ -739,6 +743,7 @@ function AnySpendInner({
|
|
|
739
743
|
activeTab,
|
|
740
744
|
effectiveCryptoPaymentMethod,
|
|
741
745
|
selectedFiatPaymentMethod,
|
|
746
|
+
srcAmountOnRamp,
|
|
742
747
|
]);
|
|
743
748
|
|
|
744
749
|
// Handle main button click
|
|
@@ -870,11 +875,20 @@ function AnySpendInner({
|
|
|
870
875
|
vendor = "coinbase";
|
|
871
876
|
paymentMethodString = coinbaseAvailablePaymentMethods[0]?.id || ""; // Use first available payment method ID
|
|
872
877
|
} else if (paymentMethod === FiatPaymentMethod.STRIPE) {
|
|
873
|
-
|
|
874
|
-
|
|
878
|
+
// Stripe redirect flow (one-click URL)
|
|
879
|
+
if (!stripeOnrampSupport) {
|
|
880
|
+
toast.error("Credit/Debit Card not available");
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
vendor = "stripe";
|
|
884
|
+
paymentMethodString = "";
|
|
885
|
+
} else if (paymentMethod === FiatPaymentMethod.STRIPE_WEB2) {
|
|
886
|
+
// Stripe embedded payment form
|
|
887
|
+
if (!stripeWeb2Support.isSupport) {
|
|
888
|
+
toast.error("Pay with Card not available");
|
|
875
889
|
return;
|
|
876
890
|
}
|
|
877
|
-
vendor =
|
|
891
|
+
vendor = "stripe-web2";
|
|
878
892
|
paymentMethodString = "";
|
|
879
893
|
} else {
|
|
880
894
|
toast.error("Please select a payment method");
|
|
@@ -50,7 +50,7 @@ import { useRecipientAddressState } from "../hooks/useRecipientAddressState";
|
|
|
50
50
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper";
|
|
51
51
|
import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod";
|
|
52
52
|
import { FeeBreakDown } from "./common/FeeBreakDown";
|
|
53
|
-
import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod";
|
|
53
|
+
import { FIAT_PAYMENT_METHOD_DISPLAY, FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod";
|
|
54
54
|
import { OrderDetails } from "./common/OrderDetails";
|
|
55
55
|
import { OrderHistory } from "./common/OrderHistory";
|
|
56
56
|
import { OrderToken } from "./common/OrderToken";
|
|
@@ -355,7 +355,12 @@ function AnySpendCustomInner({
|
|
|
355
355
|
contractType: orderType === "mint_nft" ? metadata?.nftContract?.type : undefined,
|
|
356
356
|
encodedData: encodedData,
|
|
357
357
|
spenderAddress: spenderAddress,
|
|
358
|
-
onrampVendor:
|
|
358
|
+
onrampVendor:
|
|
359
|
+
selectedFiatPaymentMethod === FiatPaymentMethod.STRIPE
|
|
360
|
+
? "stripe"
|
|
361
|
+
: selectedFiatPaymentMethod === FiatPaymentMethod.STRIPE_WEB2
|
|
362
|
+
? "stripe-web2"
|
|
363
|
+
: undefined,
|
|
359
364
|
});
|
|
360
365
|
}, [
|
|
361
366
|
activeTab,
|
|
@@ -1127,32 +1132,28 @@ function AnySpendCustomInner({
|
|
|
1127
1132
|
className="text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700"
|
|
1128
1133
|
onClick={() => setActivePanel(PanelView.FIAT_PAYMENT_METHOD)}
|
|
1129
1134
|
>
|
|
1130
|
-
{
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
<span className="whitespace-nowrap">Select payment method</span>
|
|
1153
|
-
<ChevronRight className="h-4 w-4 shrink-0" />
|
|
1154
|
-
</>
|
|
1155
|
-
)}
|
|
1135
|
+
{(() => {
|
|
1136
|
+
const config = FIAT_PAYMENT_METHOD_DISPLAY[selectedFiatPaymentMethod];
|
|
1137
|
+
if (config) {
|
|
1138
|
+
return (
|
|
1139
|
+
<>
|
|
1140
|
+
<div className="flex items-center gap-2 whitespace-nowrap">
|
|
1141
|
+
<div className="flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-blue-600">
|
|
1142
|
+
<span className="text-xs font-bold text-white">{config.icon}</span>
|
|
1143
|
+
</div>
|
|
1144
|
+
{config.label}
|
|
1145
|
+
</div>
|
|
1146
|
+
<ChevronRight className="h-4 w-4 shrink-0" />
|
|
1147
|
+
</>
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1150
|
+
return (
|
|
1151
|
+
<>
|
|
1152
|
+
<span className="whitespace-nowrap">Select payment method</span>
|
|
1153
|
+
<ChevronRight className="h-4 w-4 shrink-0" />
|
|
1154
|
+
</>
|
|
1155
|
+
);
|
|
1156
|
+
})()}
|
|
1156
1157
|
</button>
|
|
1157
1158
|
</motion.div>
|
|
1158
1159
|
|
|
@@ -1318,17 +1319,25 @@ function AnySpendCustomInner({
|
|
|
1318
1319
|
</div>
|
|
1319
1320
|
);
|
|
1320
1321
|
|
|
1322
|
+
// Stable callback for fiat payment method selection
|
|
1323
|
+
const handleFiatPaymentMethodSelect = useCallback((method: FiatPaymentMethod) => {
|
|
1324
|
+
setSelectedFiatPaymentMethod(method);
|
|
1325
|
+
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
1326
|
+
}, []);
|
|
1327
|
+
|
|
1328
|
+
// Stable callback for navigating back to confirm order
|
|
1329
|
+
const handleBackToConfirmOrder = useCallback(() => {
|
|
1330
|
+
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
1331
|
+
}, []);
|
|
1332
|
+
|
|
1321
1333
|
// Fiat payment method view
|
|
1322
1334
|
const fiatPaymentMethodView = (
|
|
1323
1335
|
<div className={cn("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4")}>
|
|
1324
1336
|
<FiatPaymentMethodComponent
|
|
1325
1337
|
selectedPaymentMethod={selectedFiatPaymentMethod}
|
|
1326
1338
|
setSelectedPaymentMethod={setSelectedFiatPaymentMethod}
|
|
1327
|
-
onBack={
|
|
1328
|
-
onSelectPaymentMethod={
|
|
1329
|
-
setSelectedFiatPaymentMethod(method);
|
|
1330
|
-
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
1331
|
-
}}
|
|
1339
|
+
onBack={handleBackToConfirmOrder}
|
|
1340
|
+
onSelectPaymentMethod={handleFiatPaymentMethodSelect}
|
|
1332
1341
|
srcAmountOnRamp={srcFiatAmount}
|
|
1333
1342
|
/>
|
|
1334
1343
|
</div>
|
|
@@ -11,6 +11,14 @@ export enum FiatPaymentMethod {
|
|
|
11
11
|
STRIPE_WEB2 = "stripe_web2", // Stripe embedded payment
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
// Shared display config for fiat payment methods
|
|
15
|
+
export const FIAT_PAYMENT_METHOD_DISPLAY: Record<FiatPaymentMethod, { icon: string; label: string } | null> = {
|
|
16
|
+
[FiatPaymentMethod.COINBASE_PAY]: { icon: "C", label: "Coinbase Pay" },
|
|
17
|
+
[FiatPaymentMethod.STRIPE]: { icon: "S", label: "Pay via Stripe" },
|
|
18
|
+
[FiatPaymentMethod.STRIPE_WEB2]: { icon: "S", label: "Pay with Card" },
|
|
19
|
+
[FiatPaymentMethod.NONE]: null,
|
|
20
|
+
};
|
|
21
|
+
|
|
14
22
|
interface FiatPaymentMethodProps {
|
|
15
23
|
selectedPaymentMethod: FiatPaymentMethod;
|
|
16
24
|
setSelectedPaymentMethod: (method: FiatPaymentMethod) => void;
|
|
@@ -70,26 +78,26 @@ export function FiatPaymentMethodComponent({
|
|
|
70
78
|
});
|
|
71
79
|
}
|
|
72
80
|
|
|
73
|
-
// Add Stripe redirect (one-click) if available -
|
|
81
|
+
// Add Stripe redirect (one-click) if available - redirects to Stripe checkout
|
|
74
82
|
if (stripeOnrampSupport) {
|
|
75
83
|
const stripeFee = getFeeFromApi(FiatPaymentMethod.STRIPE_WEB2); // Use same fee estimate
|
|
76
84
|
availablePaymentMethods.push({
|
|
77
85
|
id: FiatPaymentMethod.STRIPE,
|
|
78
|
-
name: "
|
|
79
|
-
description: "
|
|
86
|
+
name: "Pay via Stripe",
|
|
87
|
+
description: "Redirects to Stripe checkout",
|
|
80
88
|
badge: stripeFee ? `$${Number(stripeFee).toFixed(2)} fee` : undefined,
|
|
81
89
|
badgeColor: "bg-gray-100 text-gray-800",
|
|
82
90
|
available: true,
|
|
83
91
|
});
|
|
84
92
|
}
|
|
85
93
|
|
|
86
|
-
// Add Stripe Web2 (embedded) if available -
|
|
94
|
+
// Add Stripe Web2 (embedded) if available - embedded card form
|
|
87
95
|
if (stripeWeb2Support && stripeWeb2Support.isSupport) {
|
|
88
96
|
const stripeFee = getFeeFromApi(FiatPaymentMethod.STRIPE_WEB2);
|
|
89
97
|
availablePaymentMethods.push({
|
|
90
98
|
id: FiatPaymentMethod.STRIPE_WEB2,
|
|
91
|
-
name: "
|
|
92
|
-
description: "
|
|
99
|
+
name: "Pay with Card",
|
|
100
|
+
description: "Fast checkout",
|
|
93
101
|
badge: stripeFee ? `$${Number(stripeFee).toFixed(2)} fee` : undefined,
|
|
94
102
|
badgeColor: "bg-gray-100 text-gray-800",
|
|
95
103
|
available: true,
|
|
@@ -8,7 +8,7 @@ import { formatAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
|
|
|
8
8
|
import { ChevronRight, Info, Wallet } from "lucide-react";
|
|
9
9
|
import { useRef } from "react";
|
|
10
10
|
|
|
11
|
-
import { FiatPaymentMethod } from "./FiatPaymentMethod";
|
|
11
|
+
import { FIAT_PAYMENT_METHOD_DISPLAY, FiatPaymentMethod } from "./FiatPaymentMethod";
|
|
12
12
|
import { OrderTokenAmountFiat } from "./OrderTokenAmountFiat";
|
|
13
13
|
import { PointsBadge } from "./PointsBadge";
|
|
14
14
|
|
|
@@ -141,32 +141,28 @@ export function PanelOnramp({
|
|
|
141
141
|
className="text-as-tertiarry flex h-7 items-center gap-1 text-sm"
|
|
142
142
|
onClick={() => setActivePanel(fiatPaymentMethodIndex)} // PanelView.FIAT_PAYMENT_METHOD
|
|
143
143
|
>
|
|
144
|
-
{
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
Select payment method
|
|
167
|
-
<ChevronRight className="h-4 w-4" />
|
|
168
|
-
</>
|
|
169
|
-
)}
|
|
144
|
+
{(() => {
|
|
145
|
+
const config = selectedPaymentMethod ? FIAT_PAYMENT_METHOD_DISPLAY[selectedPaymentMethod] : null;
|
|
146
|
+
if (config) {
|
|
147
|
+
return (
|
|
148
|
+
<>
|
|
149
|
+
<div className="flex items-center gap-2">
|
|
150
|
+
<div className="flex h-5 w-5 items-center justify-center rounded-full bg-blue-600">
|
|
151
|
+
<span className="text-xs font-bold text-white">{config.icon}</span>
|
|
152
|
+
</div>
|
|
153
|
+
{config.label}
|
|
154
|
+
</div>
|
|
155
|
+
<ChevronRight className="h-4 w-4" />
|
|
156
|
+
</>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
return (
|
|
160
|
+
<>
|
|
161
|
+
Select payment method
|
|
162
|
+
<ChevronRight className="h-4 w-4" />
|
|
163
|
+
</>
|
|
164
|
+
);
|
|
165
|
+
})()}
|
|
170
166
|
</button>
|
|
171
167
|
</div>
|
|
172
168
|
|