@b3dotfun/sdk 0.0.84-alpha.1 → 0.0.84-alpha.2
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/constants/index.d.ts +6 -0
- package/dist/cjs/anyspend/constants/index.js +13 -0
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +2 -2
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +2 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +5 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +4 -3
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +1 -0
- package/dist/cjs/shared/utils/payment.utils.d.ts +5 -1
- package/dist/cjs/shared/utils/payment.utils.js +13 -5
- package/dist/esm/anyspend/constants/index.d.ts +6 -0
- package/dist/esm/anyspend/constants/index.js +12 -0
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +2 -2
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.d.ts +2 -0
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +2 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +5 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +4 -3
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +1 -0
- package/dist/esm/shared/utils/payment.utils.d.ts +5 -1
- package/dist/esm/shared/utils/payment.utils.js +14 -6
- package/dist/types/anyspend/constants/index.d.ts +6 -0
- package/dist/types/anyspend/react/components/webview/WebviewOnrampPayment.d.ts +2 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +5 -2
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +1 -0
- package/dist/types/shared/utils/payment.utils.d.ts +5 -1
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +13 -0
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +2 -2
- package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +4 -1
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +7 -0
- package/src/global-account/react/components/B3Provider/types.ts +1 -0
- package/src/shared/utils/payment.utils.ts +16 -6
|
@@ -25,6 +25,12 @@ export declare const DEFAULT_NFT_CONTRACT: {
|
|
|
25
25
|
export declare const STRIPE_CONFIG: {
|
|
26
26
|
readonly publishableKey: "pk_live_51QkrBwJnoDg53PsPq7QYOxSLfnXvtCVeD9UuyZ6c136i42XtYC2Z2bl1W5xbDg6AaoGyq63ErCc0yv3C2KBX29CG002AE862CP";
|
|
27
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Get the appropriate Stripe publishable key.
|
|
30
|
+
* If a custom key is provided (via B3Provider stripePublishableKey prop), use it.
|
|
31
|
+
* Otherwise, fall back to the default B3 Stripe account.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getStripePublishableKey(customKey?: string | null): string;
|
|
28
34
|
export declare const PAYMENT_METHOD_ICONS: {
|
|
29
35
|
readonly visa: "https://github.com/marcovoliveira/react-svg-credit-card-payment-icons/raw/main/src/icons/flat-rounded/visa.svg";
|
|
30
36
|
readonly mastercard: "https://github.com/marcovoliveira/react-svg-credit-card-payment-icons/raw/main/src/icons/flat-rounded/mastercard.svg";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VENDOR_DISPLAY_NAMES = exports.PAYMENT_METHOD_ICONS = exports.STRIPE_CONFIG = exports.DEFAULT_NFT_CONTRACT = exports.NFT_CONTRACTS = exports.ETH_BASE = exports.USDC_BASE = exports.ANYSPEND_TOKEN = exports.B3_TOKEN = exports.SOLANA_TOKEN_2022_PROGRAM_ID = exports.SOLANA_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = exports.RELAY_SOLANA_MAINNET_CHAIN_ID = exports.RELAY_SOL_ADDRESS = exports.ZERO_ADDRESS = exports.ANYSPEND_MAINNET_BASE_URL = void 0;
|
|
4
|
+
exports.getStripePublishableKey = getStripePublishableKey;
|
|
4
5
|
const chains_1 = require("viem/chains");
|
|
5
6
|
exports.ANYSPEND_MAINNET_BASE_URL = process.env.NEXT_PUBLIC_ANYSPEND_BASE_URL || "https://mainnet.anyspend.com";
|
|
6
7
|
exports.ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
@@ -75,9 +76,21 @@ exports.NFT_CONTRACTS = [
|
|
|
75
76
|
},
|
|
76
77
|
];
|
|
77
78
|
exports.DEFAULT_NFT_CONTRACT = exports.NFT_CONTRACTS[1];
|
|
79
|
+
// Default B3 Stripe publishable key
|
|
78
80
|
exports.STRIPE_CONFIG = {
|
|
79
81
|
publishableKey: "pk_live_51QkrBwJnoDg53PsPq7QYOxSLfnXvtCVeD9UuyZ6c136i42XtYC2Z2bl1W5xbDg6AaoGyq63ErCc0yv3C2KBX29CG002AE862CP",
|
|
80
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* Get the appropriate Stripe publishable key.
|
|
85
|
+
* If a custom key is provided (via B3Provider stripePublishableKey prop), use it.
|
|
86
|
+
* Otherwise, fall back to the default B3 Stripe account.
|
|
87
|
+
*/
|
|
88
|
+
function getStripePublishableKey(customKey) {
|
|
89
|
+
if (customKey) {
|
|
90
|
+
return customKey;
|
|
91
|
+
}
|
|
92
|
+
return exports.STRIPE_CONFIG.publishableKey;
|
|
93
|
+
}
|
|
81
94
|
exports.PAYMENT_METHOD_ICONS = {
|
|
82
95
|
visa: "https://github.com/marcovoliveira/react-svg-credit-card-payment-icons/raw/main/src/icons/flat-rounded/visa.svg",
|
|
83
96
|
mastercard: "https://github.com/marcovoliveira/react-svg-credit-card-payment-icons/raw/main/src/icons/flat-rounded/mastercard.svg",
|
|
@@ -17,7 +17,7 @@ const AnySpendFingerprintWrapper_1 = require("../AnySpendFingerprintWrapper");
|
|
|
17
17
|
const HowItWorks_1 = __importDefault(require("./HowItWorks"));
|
|
18
18
|
const PaymentMethodIcons_1 = __importDefault(require("./PaymentMethodIcons"));
|
|
19
19
|
function PaymentStripeWeb2({ order, stripePaymentIntentId, onPaymentSuccess }) {
|
|
20
|
-
const { theme } = (0, react_2.useB3)();
|
|
20
|
+
const { theme, stripePublishableKey } = (0, react_2.useB3)();
|
|
21
21
|
const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
|
|
22
22
|
const { clientSecret, isLoadingStripeClientSecret, stripeClientSecretError } = (0, react_1.useStripeClientSecret)(stripePaymentIntentId);
|
|
23
23
|
if (isLoadingStripeClientSecret) {
|
|
@@ -26,7 +26,7 @@ function PaymentStripeWeb2({ order, stripePaymentIntentId, onPaymentSuccess }) {
|
|
|
26
26
|
if (stripeClientSecretError) {
|
|
27
27
|
return (0, jsx_runtime_1.jsx)(StripeErrorState, { error: stripeClientSecretError.message });
|
|
28
28
|
}
|
|
29
|
-
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(react_stripe_js_1.Elements, { stripe: (0, payment_utils_1.getStripePromise)(), options: {
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(react_stripe_js_1.Elements, { stripe: (0, payment_utils_1.getStripePromise)(stripePublishableKey), options: {
|
|
30
30
|
clientSecret: clientSecret || undefined,
|
|
31
31
|
appearance: { theme: theme === "light" ? "stripe" : "night" },
|
|
32
32
|
}, children: (0, jsx_runtime_1.jsx)(StripePaymentForm, { order: order, clientSecret: clientSecret, onPaymentSuccess: onPaymentSuccess }) }) }));
|
|
@@ -5,6 +5,8 @@ interface WebviewOnrampPaymentProps {
|
|
|
5
5
|
recipientAddress?: string;
|
|
6
6
|
destinationToken: components["schemas"]["Token"];
|
|
7
7
|
partnerId?: string;
|
|
8
|
+
/** Partner-specific Stripe publishable key. If not provided, uses default B3 Stripe account. */
|
|
9
|
+
stripePublishableKey?: string;
|
|
8
10
|
anyspendQuote: GetQuoteResponse | undefined;
|
|
9
11
|
onPaymentSuccess: (orderId: string) => void;
|
|
10
12
|
userId?: string;
|
|
@@ -89,7 +89,7 @@ function StripePaymentForm({ order, onPaymentSuccess, }) {
|
|
|
89
89
|
},
|
|
90
90
|
} }) })), error && ((0, jsx_runtime_1.jsx)("div", { className: "mt-4 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error })), (0, jsx_runtime_1.jsx)("button", { type: "submit", disabled: !stripe || isProcessing, className: "mt-6 w-full rounded-xl bg-blue-600 px-4 py-3 font-medium text-white hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50", children: isProcessing ? ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-center gap-2", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-5 w-5 animate-spin" }), (0, jsx_runtime_1.jsx)("span", { children: "Processing..." })] })) : ((0, jsx_runtime_1.jsx)("span", { children: "Complete Payment" })) })] }) }) }));
|
|
91
91
|
}
|
|
92
|
-
function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId, }) {
|
|
92
|
+
function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, stripePublishableKey, anyspendQuote, onPaymentSuccess, userId, }) {
|
|
93
93
|
const [createdOrder, setCreatedOrder] = (0, react_4.useState)(null);
|
|
94
94
|
const orderCreationAttempted = (0, react_4.useRef)(false);
|
|
95
95
|
const { geoData, stripeWeb2Support, isLoading: isLoadingGeoOnramp } = (0, react_1.useGeoOnrampOptions)(srcAmountOnRamp);
|
|
@@ -168,7 +168,7 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
|
|
|
168
168
|
if (createdOrder && clientSecret) {
|
|
169
169
|
return ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto flex w-full max-w-[460px] flex-col gap-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "overflow-hidden rounded-xl bg-white", children: (0, jsx_runtime_1.jsxs)("div", { className: "px-6 py-4", children: [(0, jsx_runtime_1.jsx)("h2", { className: "mb-4 text-lg font-semibold", children: "Order summary" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col divide-y", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between py-3", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-gray-600", children: "Receiving" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [destinationToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("img", { src: destinationToken.metadata.logoURI, alt: destinationToken.symbol, className: "h-5 w-5 rounded-full" })), (0, jsx_runtime_1.jsxs)("span", { className: "font-medium", children: [anyspendQuote?.data?.currencyOut?.amount
|
|
170
170
|
? Number((0, viem_1.formatUnits)(BigInt(anyspendQuote.data.currencyOut.amount), destinationToken.decimals)).toFixed(4)
|
|
171
|
-
: "0", " ", destinationToken.symbol] })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between py-3", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-gray-600", children: "Network" }), (0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: (0, anyspend_1.getChainName)(destinationToken.chainId) })] }), recipientAddress && ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between py-3", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-gray-600", children: "Recipient" }), (0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: (0, centerTruncate_1.default)(recipientAddress) })] })), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between py-3", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-gray-600", children: "You Pay" }), (0, jsx_runtime_1.jsxs)("span", { className: "text-lg font-semibold", children: ["$", parseFloat(srcAmountOnRamp).toFixed(2)] })] })] })] }) }), (0, jsx_runtime_1.jsx)(react_stripe_js_1.Elements, { stripe: (0, payment_utils_1.getStripePromise)(), options: {
|
|
171
|
+
: "0", " ", destinationToken.symbol] })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between py-3", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-gray-600", children: "Network" }), (0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: (0, anyspend_1.getChainName)(destinationToken.chainId) })] }), recipientAddress && ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between py-3", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-gray-600", children: "Recipient" }), (0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: (0, centerTruncate_1.default)(recipientAddress) })] })), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between py-3", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-gray-600", children: "You Pay" }), (0, jsx_runtime_1.jsxs)("span", { className: "text-lg font-semibold", children: ["$", parseFloat(srcAmountOnRamp).toFixed(2)] })] })] })] }) }), (0, jsx_runtime_1.jsx)(react_stripe_js_1.Elements, { stripe: (0, payment_utils_1.getStripePromise)(stripePublishableKey), options: {
|
|
172
172
|
clientSecret,
|
|
173
173
|
appearance: {
|
|
174
174
|
theme: "flat",
|
|
@@ -9,7 +9,7 @@ import { B3ContextType } from "./types";
|
|
|
9
9
|
/**
|
|
10
10
|
* Main B3Provider component
|
|
11
11
|
*/
|
|
12
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, }: {
|
|
12
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, }: {
|
|
13
13
|
theme: "light" | "dark";
|
|
14
14
|
children: React.ReactNode;
|
|
15
15
|
accountOverride?: Account;
|
|
@@ -23,6 +23,8 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
23
23
|
clientType?: ClientType;
|
|
24
24
|
rpcUrls?: Record<number, string>;
|
|
25
25
|
partnerId: string;
|
|
26
|
+
/** Partner-specific Stripe publishable key. If not provided, uses default B3 Stripe account. */
|
|
27
|
+
stripePublishableKey?: string;
|
|
26
28
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
27
29
|
connectors?: CreateConnectorFn[];
|
|
28
30
|
overrideDefaultConnectors?: boolean;
|
|
@@ -32,7 +34,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
32
34
|
/**
|
|
33
35
|
* Inner provider component that provides the actual B3Context
|
|
34
36
|
*/
|
|
35
|
-
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, createClientReferenceId, enableTurnkey, }: {
|
|
37
|
+
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }: {
|
|
36
38
|
children: React.ReactNode;
|
|
37
39
|
accountOverride?: Account;
|
|
38
40
|
environment: B3ContextType["environment"];
|
|
@@ -41,6 +43,7 @@ export declare function InnerProvider({ children, accountOverride, environment,
|
|
|
41
43
|
theme: "light" | "dark";
|
|
42
44
|
clientType?: ClientType;
|
|
43
45
|
partnerId: string;
|
|
46
|
+
stripePublishableKey?: string;
|
|
44
47
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
45
48
|
enableTurnkey?: boolean;
|
|
46
49
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -34,7 +34,7 @@ const queryClient = new react_query_1.QueryClient();
|
|
|
34
34
|
*/
|
|
35
35
|
function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey,
|
|
36
36
|
// deprecated since v0.0.87
|
|
37
|
-
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, }) {
|
|
37
|
+
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, }) {
|
|
38
38
|
// Initialize Google Analytics on mount
|
|
39
39
|
(0, react_2.useEffect)(() => {
|
|
40
40
|
(0, analytics_1.loadGA4Script)();
|
|
@@ -44,12 +44,12 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connector
|
|
|
44
44
|
(0, client_manager_1.setClientType)(clientType);
|
|
45
45
|
}, [clientType]);
|
|
46
46
|
const wagmiConfig = (0, react_2.useMemo)(() => (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
47
|
-
return ((0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(index_1.ToastProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, children: (0, jsx_runtime_1.jsxs)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, createClientReferenceId: createClientReferenceId, enableTurnkey: enableTurnkey, children: [(0, jsx_runtime_1.jsx)(ToastContextConnector, {}), (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" })] })] }) }) }) }) }) }) }));
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(index_1.ToastProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, children: (0, jsx_runtime_1.jsxs)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, enableTurnkey: enableTurnkey, children: [(0, jsx_runtime_1.jsx)(ToastContextConnector, {}), (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" })] })] }) }) }) }) }) }) }));
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Inner provider component that provides the actual B3Context
|
|
51
51
|
*/
|
|
52
|
-
function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", partnerId, createClientReferenceId, enableTurnkey, }) {
|
|
52
|
+
function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }) {
|
|
53
53
|
const activeAccount = (0, react_3.useActiveAccount)();
|
|
54
54
|
const [manuallySelectedWallet, setManuallySelectedWallet] = (0, react_2.useState)(undefined);
|
|
55
55
|
const wallets = (0, react_3.useConnectedWallets)();
|
|
@@ -105,6 +105,7 @@ function InnerProvider({ children, accountOverride, environment, defaultPermissi
|
|
|
105
105
|
theme,
|
|
106
106
|
clientType,
|
|
107
107
|
partnerId: partnerId,
|
|
108
|
+
stripePublishableKey,
|
|
108
109
|
createClientReferenceId,
|
|
109
110
|
enableTurnkey,
|
|
110
111
|
}, children: (0, jsx_runtime_1.jsx)(InnerProvider2, { children: children }) }));
|
|
@@ -22,6 +22,7 @@ export interface B3ContextType {
|
|
|
22
22
|
theme: "light" | "dark";
|
|
23
23
|
clientType: ClientType;
|
|
24
24
|
partnerId: string;
|
|
25
|
+
stripePublishableKey?: string;
|
|
25
26
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
26
27
|
enableTurnkey?: boolean;
|
|
27
28
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { components } from "../../anyspend/types/api";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Get or create a Stripe promise for the given publishable key.
|
|
4
|
+
* @param stripePublishableKey - Partner-specific Stripe publishable key from B3Provider
|
|
5
|
+
*/
|
|
6
|
+
export declare function getStripePromise(stripePublishableKey?: string | null): Promise<import("@stripe/stripe-js").Stripe | null>;
|
|
3
7
|
export declare function getVendorDisplayName(vendor?: components["schemas"]["OnrampMetadata"]["vendor"]): string;
|
|
4
8
|
export declare function getPaymentMethodDescription(vendor?: components["schemas"]["OnrampMetadata"]["vendor"]): string;
|
|
5
9
|
export declare function formatStripeAmount(amount: number): string;
|
|
@@ -7,12 +7,20 @@ exports.formatStripeAmount = formatStripeAmount;
|
|
|
7
7
|
exports.generateReturnUrl = generateReturnUrl;
|
|
8
8
|
const constants_1 = require("../../anyspend/constants");
|
|
9
9
|
const stripe_js_1 = require("@stripe/stripe-js");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
// Cache Stripe promises per publishable key (supports multiple partners)
|
|
11
|
+
const stripePromiseCache = new Map();
|
|
12
|
+
/**
|
|
13
|
+
* Get or create a Stripe promise for the given publishable key.
|
|
14
|
+
* @param stripePublishableKey - Partner-specific Stripe publishable key from B3Provider
|
|
15
|
+
*/
|
|
16
|
+
function getStripePromise(stripePublishableKey) {
|
|
17
|
+
const publishableKey = (0, constants_1.getStripePublishableKey)(stripePublishableKey);
|
|
18
|
+
let cached = stripePromiseCache.get(publishableKey);
|
|
19
|
+
if (!cached) {
|
|
20
|
+
cached = (0, stripe_js_1.loadStripe)(publishableKey);
|
|
21
|
+
stripePromiseCache.set(publishableKey, cached);
|
|
14
22
|
}
|
|
15
|
-
return
|
|
23
|
+
return cached;
|
|
16
24
|
}
|
|
17
25
|
function getVendorDisplayName(vendor) {
|
|
18
26
|
switch (vendor) {
|
|
@@ -25,6 +25,12 @@ export declare const DEFAULT_NFT_CONTRACT: {
|
|
|
25
25
|
export declare const STRIPE_CONFIG: {
|
|
26
26
|
readonly publishableKey: "pk_live_51QkrBwJnoDg53PsPq7QYOxSLfnXvtCVeD9UuyZ6c136i42XtYC2Z2bl1W5xbDg6AaoGyq63ErCc0yv3C2KBX29CG002AE862CP";
|
|
27
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Get the appropriate Stripe publishable key.
|
|
30
|
+
* If a custom key is provided (via B3Provider stripePublishableKey prop), use it.
|
|
31
|
+
* Otherwise, fall back to the default B3 Stripe account.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getStripePublishableKey(customKey?: string | null): string;
|
|
28
34
|
export declare const PAYMENT_METHOD_ICONS: {
|
|
29
35
|
readonly visa: "https://github.com/marcovoliveira/react-svg-credit-card-payment-icons/raw/main/src/icons/flat-rounded/visa.svg";
|
|
30
36
|
readonly mastercard: "https://github.com/marcovoliveira/react-svg-credit-card-payment-icons/raw/main/src/icons/flat-rounded/mastercard.svg";
|
|
@@ -72,9 +72,21 @@ export const NFT_CONTRACTS = [
|
|
|
72
72
|
},
|
|
73
73
|
];
|
|
74
74
|
export const DEFAULT_NFT_CONTRACT = NFT_CONTRACTS[1];
|
|
75
|
+
// Default B3 Stripe publishable key
|
|
75
76
|
export const STRIPE_CONFIG = {
|
|
76
77
|
publishableKey: "pk_live_51QkrBwJnoDg53PsPq7QYOxSLfnXvtCVeD9UuyZ6c136i42XtYC2Z2bl1W5xbDg6AaoGyq63ErCc0yv3C2KBX29CG002AE862CP",
|
|
77
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* Get the appropriate Stripe publishable key.
|
|
81
|
+
* If a custom key is provided (via B3Provider stripePublishableKey prop), use it.
|
|
82
|
+
* Otherwise, fall back to the default B3 Stripe account.
|
|
83
|
+
*/
|
|
84
|
+
export function getStripePublishableKey(customKey) {
|
|
85
|
+
if (customKey) {
|
|
86
|
+
return customKey;
|
|
87
|
+
}
|
|
88
|
+
return STRIPE_CONFIG.publishableKey;
|
|
89
|
+
}
|
|
78
90
|
export const PAYMENT_METHOD_ICONS = {
|
|
79
91
|
visa: "https://github.com/marcovoliveira/react-svg-credit-card-payment-icons/raw/main/src/icons/flat-rounded/visa.svg",
|
|
80
92
|
mastercard: "https://github.com/marcovoliveira/react-svg-credit-card-payment-icons/raw/main/src/icons/flat-rounded/mastercard.svg",
|
|
@@ -11,7 +11,7 @@ import { AnySpendFingerprintWrapper, getFingerprintConfig } from "../AnySpendFin
|
|
|
11
11
|
import HowItWorks from "./HowItWorks.js";
|
|
12
12
|
import PaymentMethodIcons from "./PaymentMethodIcons.js";
|
|
13
13
|
export default function PaymentStripeWeb2({ order, stripePaymentIntentId, onPaymentSuccess }) {
|
|
14
|
-
const { theme } = useB3();
|
|
14
|
+
const { theme, stripePublishableKey } = useB3();
|
|
15
15
|
const fingerprintConfig = getFingerprintConfig();
|
|
16
16
|
const { clientSecret, isLoadingStripeClientSecret, stripeClientSecretError } = useStripeClientSecret(stripePaymentIntentId);
|
|
17
17
|
if (isLoadingStripeClientSecret) {
|
|
@@ -20,7 +20,7 @@ export default function PaymentStripeWeb2({ order, stripePaymentIntentId, onPaym
|
|
|
20
20
|
if (stripeClientSecretError) {
|
|
21
21
|
return _jsx(StripeErrorState, { error: stripeClientSecretError.message });
|
|
22
22
|
}
|
|
23
|
-
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(Elements, { stripe: getStripePromise(), options: {
|
|
23
|
+
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(Elements, { stripe: getStripePromise(stripePublishableKey), options: {
|
|
24
24
|
clientSecret: clientSecret || undefined,
|
|
25
25
|
appearance: { theme: theme === "light" ? "stripe" : "night" },
|
|
26
26
|
}, children: _jsx(StripePaymentForm, { order: order, clientSecret: clientSecret, onPaymentSuccess: onPaymentSuccess }) }) }));
|
|
@@ -5,6 +5,8 @@ interface WebviewOnrampPaymentProps {
|
|
|
5
5
|
recipientAddress?: string;
|
|
6
6
|
destinationToken: components["schemas"]["Token"];
|
|
7
7
|
partnerId?: string;
|
|
8
|
+
/** Partner-specific Stripe publishable key. If not provided, uses default B3 Stripe account. */
|
|
9
|
+
stripePublishableKey?: string;
|
|
8
10
|
anyspendQuote: GetQuoteResponse | undefined;
|
|
9
11
|
onPaymentSuccess: (orderId: string) => void;
|
|
10
12
|
userId?: string;
|
|
@@ -83,7 +83,7 @@ function StripePaymentForm({ order, onPaymentSuccess, }) {
|
|
|
83
83
|
},
|
|
84
84
|
} }) })), error && (_jsx("div", { className: "mt-4 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error })), _jsx("button", { type: "submit", disabled: !stripe || isProcessing, className: "mt-6 w-full rounded-xl bg-blue-600 px-4 py-3 font-medium text-white hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50", children: isProcessing ? (_jsxs("div", { className: "flex items-center justify-center gap-2", children: [_jsx(Loader2, { className: "h-5 w-5 animate-spin" }), _jsx("span", { children: "Processing..." })] })) : (_jsx("span", { children: "Complete Payment" })) })] }) }) }));
|
|
85
85
|
}
|
|
86
|
-
function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId, }) {
|
|
86
|
+
function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, stripePublishableKey, anyspendQuote, onPaymentSuccess, userId, }) {
|
|
87
87
|
const [createdOrder, setCreatedOrder] = useState(null);
|
|
88
88
|
const orderCreationAttempted = useRef(false);
|
|
89
89
|
const { geoData, stripeWeb2Support, isLoading: isLoadingGeoOnramp } = useGeoOnrampOptions(srcAmountOnRamp);
|
|
@@ -162,7 +162,7 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
|
|
|
162
162
|
if (createdOrder && clientSecret) {
|
|
163
163
|
return (_jsxs("div", { className: "mx-auto flex w-full max-w-[460px] flex-col gap-6", children: [_jsx("div", { className: "overflow-hidden rounded-xl bg-white", children: _jsxs("div", { className: "px-6 py-4", children: [_jsx("h2", { className: "mb-4 text-lg font-semibold", children: "Order summary" }), _jsxs("div", { className: "flex flex-col divide-y", children: [_jsxs("div", { className: "flex items-center justify-between py-3", children: [_jsx("span", { className: "text-gray-600", children: "Receiving" }), _jsxs("div", { className: "flex items-center gap-2", children: [destinationToken.metadata?.logoURI && (_jsx("img", { src: destinationToken.metadata.logoURI, alt: destinationToken.symbol, className: "h-5 w-5 rounded-full" })), _jsxs("span", { className: "font-medium", children: [anyspendQuote?.data?.currencyOut?.amount
|
|
164
164
|
? Number(formatUnits(BigInt(anyspendQuote.data.currencyOut.amount), destinationToken.decimals)).toFixed(4)
|
|
165
|
-
: "0", " ", destinationToken.symbol] })] })] }), _jsxs("div", { className: "flex items-center justify-between py-3", children: [_jsx("span", { className: "text-gray-600", children: "Network" }), _jsx("span", { className: "font-medium", children: getChainName(destinationToken.chainId) })] }), recipientAddress && (_jsxs("div", { className: "flex items-center justify-between py-3", children: [_jsx("span", { className: "text-gray-600", children: "Recipient" }), _jsx("span", { className: "font-medium", children: centerTruncate(recipientAddress) })] })), _jsxs("div", { className: "flex items-center justify-between py-3", children: [_jsx("span", { className: "text-gray-600", children: "You Pay" }), _jsxs("span", { className: "text-lg font-semibold", children: ["$", parseFloat(srcAmountOnRamp).toFixed(2)] })] })] })] }) }), _jsx(Elements, { stripe: getStripePromise(), options: {
|
|
165
|
+
: "0", " ", destinationToken.symbol] })] })] }), _jsxs("div", { className: "flex items-center justify-between py-3", children: [_jsx("span", { className: "text-gray-600", children: "Network" }), _jsx("span", { className: "font-medium", children: getChainName(destinationToken.chainId) })] }), recipientAddress && (_jsxs("div", { className: "flex items-center justify-between py-3", children: [_jsx("span", { className: "text-gray-600", children: "Recipient" }), _jsx("span", { className: "font-medium", children: centerTruncate(recipientAddress) })] })), _jsxs("div", { className: "flex items-center justify-between py-3", children: [_jsx("span", { className: "text-gray-600", children: "You Pay" }), _jsxs("span", { className: "text-lg font-semibold", children: ["$", parseFloat(srcAmountOnRamp).toFixed(2)] })] })] })] }) }), _jsx(Elements, { stripe: getStripePromise(stripePublishableKey), options: {
|
|
166
166
|
clientSecret,
|
|
167
167
|
appearance: {
|
|
168
168
|
theme: "flat",
|
|
@@ -9,7 +9,7 @@ import { B3ContextType } from "./types";
|
|
|
9
9
|
/**
|
|
10
10
|
* Main B3Provider component
|
|
11
11
|
*/
|
|
12
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, }: {
|
|
12
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, }: {
|
|
13
13
|
theme: "light" | "dark";
|
|
14
14
|
children: React.ReactNode;
|
|
15
15
|
accountOverride?: Account;
|
|
@@ -23,6 +23,8 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
23
23
|
clientType?: ClientType;
|
|
24
24
|
rpcUrls?: Record<number, string>;
|
|
25
25
|
partnerId: string;
|
|
26
|
+
/** Partner-specific Stripe publishable key. If not provided, uses default B3 Stripe account. */
|
|
27
|
+
stripePublishableKey?: string;
|
|
26
28
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
27
29
|
connectors?: CreateConnectorFn[];
|
|
28
30
|
overrideDefaultConnectors?: boolean;
|
|
@@ -32,7 +34,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
32
34
|
/**
|
|
33
35
|
* Inner provider component that provides the actual B3Context
|
|
34
36
|
*/
|
|
35
|
-
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, createClientReferenceId, enableTurnkey, }: {
|
|
37
|
+
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }: {
|
|
36
38
|
children: React.ReactNode;
|
|
37
39
|
accountOverride?: Account;
|
|
38
40
|
environment: B3ContextType["environment"];
|
|
@@ -41,6 +43,7 @@ export declare function InnerProvider({ children, accountOverride, environment,
|
|
|
41
43
|
theme: "light" | "dark";
|
|
42
44
|
clientType?: ClientType;
|
|
43
45
|
partnerId: string;
|
|
46
|
+
stripePublishableKey?: string;
|
|
44
47
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
45
48
|
enableTurnkey?: boolean;
|
|
46
49
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -30,7 +30,7 @@ const queryClient = new QueryClient();
|
|
|
30
30
|
*/
|
|
31
31
|
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey,
|
|
32
32
|
// deprecated since v0.0.87
|
|
33
|
-
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, }) {
|
|
33
|
+
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, }) {
|
|
34
34
|
// Initialize Google Analytics on mount
|
|
35
35
|
useEffect(() => {
|
|
36
36
|
loadGA4Script();
|
|
@@ -40,12 +40,12 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connector
|
|
|
40
40
|
setClientType(clientType);
|
|
41
41
|
}, [clientType]);
|
|
42
42
|
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
43
|
-
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, children: _jsxs(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, createClientReferenceId: createClientReferenceId, enableTurnkey: enableTurnkey, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" })] })] }) }) }) }) }) }) }));
|
|
43
|
+
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, children: _jsxs(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, enableTurnkey: enableTurnkey, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" })] })] }) }) }) }) }) }) }));
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Inner provider component that provides the actual B3Context
|
|
47
47
|
*/
|
|
48
|
-
export function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", partnerId, createClientReferenceId, enableTurnkey, }) {
|
|
48
|
+
export function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }) {
|
|
49
49
|
const activeAccount = useActiveAccount();
|
|
50
50
|
const [manuallySelectedWallet, setManuallySelectedWallet] = useState(undefined);
|
|
51
51
|
const wallets = useConnectedWallets();
|
|
@@ -101,6 +101,7 @@ export function InnerProvider({ children, accountOverride, environment, defaultP
|
|
|
101
101
|
theme,
|
|
102
102
|
clientType,
|
|
103
103
|
partnerId: partnerId,
|
|
104
|
+
stripePublishableKey,
|
|
104
105
|
createClientReferenceId,
|
|
105
106
|
enableTurnkey,
|
|
106
107
|
}, children: _jsx(InnerProvider2, { children: children }) }));
|
|
@@ -22,6 +22,7 @@ export interface B3ContextType {
|
|
|
22
22
|
theme: "light" | "dark";
|
|
23
23
|
clientType: ClientType;
|
|
24
24
|
partnerId: string;
|
|
25
|
+
stripePublishableKey?: string;
|
|
25
26
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
26
27
|
enableTurnkey?: boolean;
|
|
27
28
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { components } from "../../anyspend/types/api";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Get or create a Stripe promise for the given publishable key.
|
|
4
|
+
* @param stripePublishableKey - Partner-specific Stripe publishable key from B3Provider
|
|
5
|
+
*/
|
|
6
|
+
export declare function getStripePromise(stripePublishableKey?: string | null): Promise<import("@stripe/stripe-js").Stripe | null>;
|
|
3
7
|
export declare function getVendorDisplayName(vendor?: components["schemas"]["OnrampMetadata"]["vendor"]): string;
|
|
4
8
|
export declare function getPaymentMethodDescription(vendor?: components["schemas"]["OnrampMetadata"]["vendor"]): string;
|
|
5
9
|
export declare function formatStripeAmount(amount: number): string;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getStripePublishableKey, VENDOR_DISPLAY_NAMES } from "../../anyspend/constants/index.js";
|
|
2
2
|
import { loadStripe } from "@stripe/stripe-js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
// Cache Stripe promises per publishable key (supports multiple partners)
|
|
4
|
+
const stripePromiseCache = new Map();
|
|
5
|
+
/**
|
|
6
|
+
* Get or create a Stripe promise for the given publishable key.
|
|
7
|
+
* @param stripePublishableKey - Partner-specific Stripe publishable key from B3Provider
|
|
8
|
+
*/
|
|
9
|
+
export function getStripePromise(stripePublishableKey) {
|
|
10
|
+
const publishableKey = getStripePublishableKey(stripePublishableKey);
|
|
11
|
+
let cached = stripePromiseCache.get(publishableKey);
|
|
12
|
+
if (!cached) {
|
|
13
|
+
cached = loadStripe(publishableKey);
|
|
14
|
+
stripePromiseCache.set(publishableKey, cached);
|
|
7
15
|
}
|
|
8
|
-
return
|
|
16
|
+
return cached;
|
|
9
17
|
}
|
|
10
18
|
export function getVendorDisplayName(vendor) {
|
|
11
19
|
switch (vendor) {
|
|
@@ -25,6 +25,12 @@ export declare const DEFAULT_NFT_CONTRACT: {
|
|
|
25
25
|
export declare const STRIPE_CONFIG: {
|
|
26
26
|
readonly publishableKey: "pk_live_51QkrBwJnoDg53PsPq7QYOxSLfnXvtCVeD9UuyZ6c136i42XtYC2Z2bl1W5xbDg6AaoGyq63ErCc0yv3C2KBX29CG002AE862CP";
|
|
27
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Get the appropriate Stripe publishable key.
|
|
30
|
+
* If a custom key is provided (via B3Provider stripePublishableKey prop), use it.
|
|
31
|
+
* Otherwise, fall back to the default B3 Stripe account.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getStripePublishableKey(customKey?: string | null): string;
|
|
28
34
|
export declare const PAYMENT_METHOD_ICONS: {
|
|
29
35
|
readonly visa: "https://github.com/marcovoliveira/react-svg-credit-card-payment-icons/raw/main/src/icons/flat-rounded/visa.svg";
|
|
30
36
|
readonly mastercard: "https://github.com/marcovoliveira/react-svg-credit-card-payment-icons/raw/main/src/icons/flat-rounded/mastercard.svg";
|
|
@@ -5,6 +5,8 @@ interface WebviewOnrampPaymentProps {
|
|
|
5
5
|
recipientAddress?: string;
|
|
6
6
|
destinationToken: components["schemas"]["Token"];
|
|
7
7
|
partnerId?: string;
|
|
8
|
+
/** Partner-specific Stripe publishable key. If not provided, uses default B3 Stripe account. */
|
|
9
|
+
stripePublishableKey?: string;
|
|
8
10
|
anyspendQuote: GetQuoteResponse | undefined;
|
|
9
11
|
onPaymentSuccess: (orderId: string) => void;
|
|
10
12
|
userId?: string;
|
|
@@ -9,7 +9,7 @@ import { B3ContextType } from "./types";
|
|
|
9
9
|
/**
|
|
10
10
|
* Main B3Provider component
|
|
11
11
|
*/
|
|
12
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, }: {
|
|
12
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, }: {
|
|
13
13
|
theme: "light" | "dark";
|
|
14
14
|
children: React.ReactNode;
|
|
15
15
|
accountOverride?: Account;
|
|
@@ -23,6 +23,8 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
23
23
|
clientType?: ClientType;
|
|
24
24
|
rpcUrls?: Record<number, string>;
|
|
25
25
|
partnerId: string;
|
|
26
|
+
/** Partner-specific Stripe publishable key. If not provided, uses default B3 Stripe account. */
|
|
27
|
+
stripePublishableKey?: string;
|
|
26
28
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
27
29
|
connectors?: CreateConnectorFn[];
|
|
28
30
|
overrideDefaultConnectors?: boolean;
|
|
@@ -32,7 +34,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
32
34
|
/**
|
|
33
35
|
* Inner provider component that provides the actual B3Context
|
|
34
36
|
*/
|
|
35
|
-
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, createClientReferenceId, enableTurnkey, }: {
|
|
37
|
+
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }: {
|
|
36
38
|
children: React.ReactNode;
|
|
37
39
|
accountOverride?: Account;
|
|
38
40
|
environment: B3ContextType["environment"];
|
|
@@ -41,6 +43,7 @@ export declare function InnerProvider({ children, accountOverride, environment,
|
|
|
41
43
|
theme: "light" | "dark";
|
|
42
44
|
clientType?: ClientType;
|
|
43
45
|
partnerId: string;
|
|
46
|
+
stripePublishableKey?: string;
|
|
44
47
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
45
48
|
enableTurnkey?: boolean;
|
|
46
49
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -22,6 +22,7 @@ export interface B3ContextType {
|
|
|
22
22
|
theme: "light" | "dark";
|
|
23
23
|
clientType: ClientType;
|
|
24
24
|
partnerId: string;
|
|
25
|
+
stripePublishableKey?: string;
|
|
25
26
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
26
27
|
enableTurnkey?: boolean;
|
|
27
28
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Get or create a Stripe promise for the given publishable key.
|
|
4
|
+
* @param stripePublishableKey - Partner-specific Stripe publishable key from B3Provider
|
|
5
|
+
*/
|
|
6
|
+
export declare function getStripePromise(stripePublishableKey?: string | null): Promise<import("@stripe/stripe-js").Stripe | null>;
|
|
3
7
|
export declare function getVendorDisplayName(vendor?: components["schemas"]["OnrampMetadata"]["vendor"]): string;
|
|
4
8
|
export declare function getPaymentMethodDescription(vendor?: components["schemas"]["OnrampMetadata"]["vendor"]): string;
|
|
5
9
|
export declare function formatStripeAmount(amount: number): string;
|
package/package.json
CHANGED
|
@@ -86,11 +86,24 @@ export const NFT_CONTRACTS: components["schemas"]["NftContract"][] = [
|
|
|
86
86
|
|
|
87
87
|
export const DEFAULT_NFT_CONTRACT = NFT_CONTRACTS[1];
|
|
88
88
|
|
|
89
|
+
// Default B3 Stripe publishable key
|
|
89
90
|
export const STRIPE_CONFIG = {
|
|
90
91
|
publishableKey:
|
|
91
92
|
"pk_live_51QkrBwJnoDg53PsPq7QYOxSLfnXvtCVeD9UuyZ6c136i42XtYC2Z2bl1W5xbDg6AaoGyq63ErCc0yv3C2KBX29CG002AE862CP",
|
|
92
93
|
} as const;
|
|
93
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Get the appropriate Stripe publishable key.
|
|
97
|
+
* If a custom key is provided (via B3Provider stripePublishableKey prop), use it.
|
|
98
|
+
* Otherwise, fall back to the default B3 Stripe account.
|
|
99
|
+
*/
|
|
100
|
+
export function getStripePublishableKey(customKey?: string | null): string {
|
|
101
|
+
if (customKey) {
|
|
102
|
+
return customKey;
|
|
103
|
+
}
|
|
104
|
+
return STRIPE_CONFIG.publishableKey;
|
|
105
|
+
}
|
|
106
|
+
|
|
94
107
|
export const PAYMENT_METHOD_ICONS = {
|
|
95
108
|
visa: "https://github.com/marcovoliveira/react-svg-credit-card-payment-icons/raw/main/src/icons/flat-rounded/visa.svg",
|
|
96
109
|
mastercard:
|
|
@@ -19,7 +19,7 @@ interface PaymentStripeWeb2Props {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export default function PaymentStripeWeb2({ order, stripePaymentIntentId, onPaymentSuccess }: PaymentStripeWeb2Props) {
|
|
22
|
-
const { theme } = useB3();
|
|
22
|
+
const { theme, stripePublishableKey } = useB3();
|
|
23
23
|
const fingerprintConfig = getFingerprintConfig();
|
|
24
24
|
|
|
25
25
|
const { clientSecret, isLoadingStripeClientSecret, stripeClientSecretError } =
|
|
@@ -36,7 +36,7 @@ export default function PaymentStripeWeb2({ order, stripePaymentIntentId, onPaym
|
|
|
36
36
|
return (
|
|
37
37
|
<AnySpendFingerprintWrapper fingerprint={fingerprintConfig}>
|
|
38
38
|
<Elements
|
|
39
|
-
stripe={getStripePromise()}
|
|
39
|
+
stripe={getStripePromise(stripePublishableKey)}
|
|
40
40
|
options={{
|
|
41
41
|
clientSecret: clientSecret || undefined,
|
|
42
42
|
appearance: { theme: theme === "light" ? "stripe" : "night" },
|
|
@@ -18,6 +18,8 @@ interface WebviewOnrampPaymentProps {
|
|
|
18
18
|
recipientAddress?: string;
|
|
19
19
|
destinationToken: components["schemas"]["Token"];
|
|
20
20
|
partnerId?: string;
|
|
21
|
+
/** Partner-specific Stripe publishable key. If not provided, uses default B3 Stripe account. */
|
|
22
|
+
stripePublishableKey?: string;
|
|
21
23
|
anyspendQuote: GetQuoteResponse | undefined;
|
|
22
24
|
onPaymentSuccess: (orderId: string) => void;
|
|
23
25
|
userId?: string;
|
|
@@ -153,6 +155,7 @@ function WebviewOnrampPaymentInner({
|
|
|
153
155
|
srcAmountOnRamp,
|
|
154
156
|
recipientAddress,
|
|
155
157
|
destinationToken,
|
|
158
|
+
stripePublishableKey,
|
|
156
159
|
anyspendQuote,
|
|
157
160
|
onPaymentSuccess,
|
|
158
161
|
userId,
|
|
@@ -307,7 +310,7 @@ function WebviewOnrampPaymentInner({
|
|
|
307
310
|
|
|
308
311
|
{/* Stripe Elements */}
|
|
309
312
|
<Elements
|
|
310
|
-
stripe={getStripePromise()}
|
|
313
|
+
stripe={getStripePromise(stripePublishableKey)}
|
|
311
314
|
options={{
|
|
312
315
|
clientSecret,
|
|
313
316
|
appearance: {
|
|
@@ -58,6 +58,7 @@ export function B3Provider({
|
|
|
58
58
|
clientType = "rest",
|
|
59
59
|
rpcUrls,
|
|
60
60
|
partnerId,
|
|
61
|
+
stripePublishableKey,
|
|
61
62
|
onConnect,
|
|
62
63
|
connectors,
|
|
63
64
|
overrideDefaultConnectors = false,
|
|
@@ -77,6 +78,8 @@ export function B3Provider({
|
|
|
77
78
|
clientType?: ClientType;
|
|
78
79
|
rpcUrls?: Record<number, string>;
|
|
79
80
|
partnerId: string;
|
|
81
|
+
/** Partner-specific Stripe publishable key. If not provided, uses default B3 Stripe account. */
|
|
82
|
+
stripePublishableKey?: string;
|
|
80
83
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
81
84
|
connectors?: CreateConnectorFn[];
|
|
82
85
|
overrideDefaultConnectors?: boolean;
|
|
@@ -112,6 +115,7 @@ export function B3Provider({
|
|
|
112
115
|
automaticallySetFirstEoa={!!automaticallySetFirstEoa}
|
|
113
116
|
clientType={clientType}
|
|
114
117
|
partnerId={partnerId}
|
|
118
|
+
stripePublishableKey={stripePublishableKey}
|
|
115
119
|
createClientReferenceId={createClientReferenceId}
|
|
116
120
|
enableTurnkey={enableTurnkey}
|
|
117
121
|
>
|
|
@@ -143,6 +147,7 @@ export function InnerProvider({
|
|
|
143
147
|
theme = "light",
|
|
144
148
|
clientType = "socket",
|
|
145
149
|
partnerId,
|
|
150
|
+
stripePublishableKey,
|
|
146
151
|
createClientReferenceId,
|
|
147
152
|
enableTurnkey,
|
|
148
153
|
}: {
|
|
@@ -154,6 +159,7 @@ export function InnerProvider({
|
|
|
154
159
|
theme: "light" | "dark";
|
|
155
160
|
clientType?: ClientType;
|
|
156
161
|
partnerId: string;
|
|
162
|
+
stripePublishableKey?: string;
|
|
157
163
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
158
164
|
enableTurnkey?: boolean;
|
|
159
165
|
}) {
|
|
@@ -226,6 +232,7 @@ export function InnerProvider({
|
|
|
226
232
|
theme,
|
|
227
233
|
clientType,
|
|
228
234
|
partnerId: partnerId,
|
|
235
|
+
stripePublishableKey,
|
|
229
236
|
createClientReferenceId,
|
|
230
237
|
enableTurnkey,
|
|
231
238
|
}}
|
|
@@ -24,6 +24,7 @@ export interface B3ContextType {
|
|
|
24
24
|
theme: "light" | "dark";
|
|
25
25
|
clientType: ClientType;
|
|
26
26
|
partnerId: string;
|
|
27
|
+
stripePublishableKey?: string;
|
|
27
28
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
28
29
|
enableTurnkey?: boolean;
|
|
29
30
|
}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getStripePublishableKey, VENDOR_DISPLAY_NAMES } from "@b3dotfun/sdk/anyspend/constants";
|
|
2
2
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
3
3
|
import { loadStripe } from "@stripe/stripe-js";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
// Cache Stripe promises per publishable key (supports multiple partners)
|
|
6
|
+
const stripePromiseCache: Map<string, ReturnType<typeof loadStripe>> = new Map();
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get or create a Stripe promise for the given publishable key.
|
|
10
|
+
* @param stripePublishableKey - Partner-specific Stripe publishable key from B3Provider
|
|
11
|
+
*/
|
|
12
|
+
export function getStripePromise(stripePublishableKey?: string | null) {
|
|
13
|
+
const publishableKey = getStripePublishableKey(stripePublishableKey);
|
|
14
|
+
|
|
15
|
+
let cached = stripePromiseCache.get(publishableKey);
|
|
16
|
+
if (!cached) {
|
|
17
|
+
cached = loadStripe(publishableKey);
|
|
18
|
+
stripePromiseCache.set(publishableKey, cached);
|
|
9
19
|
}
|
|
10
|
-
return
|
|
20
|
+
return cached;
|
|
11
21
|
}
|
|
12
22
|
|
|
13
23
|
export function getVendorDisplayName(vendor?: components["schemas"]["OnrampMetadata"]["vendor"]): string {
|