Skip to content

Commit a6b3d14

Browse files
gregfromstlclaude
andcommitted
[SDK] Add enableCard prop to control fiat payment visibility
Adds enableCard prop to BuyWidget, CheckoutWidget, and TransactionWidget components to allow hiding the "Buy with card" fiat payment option. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 6d1d344 commit a6b3d14

File tree

9 files changed

+95
-68
lines changed

9 files changed

+95
-68
lines changed

.changeset/dull-breads-start.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Adds enableCard prop to BuyWidget, CheckoutWidget, and TransactionWidget

packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ export interface BridgeOrchestratorProps {
113113
* Quick buy amounts
114114
*/
115115
presetOptions: [number, number, number] | undefined;
116+
117+
/**
118+
* Whether to enable the "Buy with card" (fiat payment) option
119+
*/
120+
enableCard?: boolean;
116121
}
117122

118123
export function BridgeOrchestrator({
@@ -127,6 +132,7 @@ export function BridgeOrchestrator({
127132
purchaseData,
128133
paymentLinkId,
129134
presetOptions,
135+
enableCard,
130136
}: BridgeOrchestratorProps) {
131137
// Initialize adapters
132138
const adapters = useMemo(
@@ -271,6 +277,7 @@ export function BridgeOrchestrator({
271277
onError={handleError}
272278
onPaymentMethodSelected={handlePaymentMethodSelected}
273279
receiverAddress={state.context.receiverAddress}
280+
enableCard={enableCard}
274281
/>
275282
)}
276283

packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ export type BuyWidgetProps = {
160160
* @hidden
161161
*/
162162
paymentLinkId?: string;
163+
164+
/**
165+
* Whether to enable the "Buy with card" (fiat payment) option.
166+
* @default true
167+
*/
168+
enableCard?: boolean;
163169
};
164170

165171
// Enhanced UIOptions to handle unsupported token state
@@ -382,6 +388,7 @@ export function BuyWidget(props: BuyWidgetProps) {
382388
purchaseData={props.purchaseData}
383389
receiverAddress={undefined}
384390
uiOptions={bridgeDataQuery.data.data}
391+
enableCard={props.enableCard}
385392
/>
386393
);
387394
}

packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ export type CheckoutWidgetProps = {
166166
* @hidden
167167
*/
168168
paymentLinkId?: string;
169+
170+
/**
171+
* Whether to enable the "Buy with card" (fiat payment) option.
172+
* @default true
173+
*/
174+
enableCard?: boolean;
169175
};
170176

171177
// Enhanced UIOptions to handle unsupported token state
@@ -345,6 +351,7 @@ export function CheckoutWidget(props: CheckoutWidgetProps) {
345351
purchaseData={props.purchaseData}
346352
receiverAddress={props.seller}
347353
uiOptions={bridgeDataQuery.data.data}
354+
enableCard={props.enableCard}
348355
/>
349356
);
350357
}

packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ export type TransactionWidgetProps = {
169169
* @hidden
170170
*/
171171
paymentLinkId?: string;
172+
173+
/**
174+
* Whether to enable the "Buy with card" (fiat payment) option.
175+
* @default true
176+
*/
177+
enableCard?: boolean;
172178
};
173179

174180
// Enhanced UIOptions to handle unsupported token state
@@ -404,6 +410,7 @@ export function TransactionWidget(props: TransactionWidgetProps) {
404410
purchaseData={props.purchaseData}
405411
receiverAddress={undefined}
406412
uiOptions={bridgeDataQuery.data.data}
413+
enableCard={props.enableCard}
407414
/>
408415
);
409416
}

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ export interface PaymentSelectionProps {
7171
* Whether to include the destination token in the payment methods
7272
*/
7373
includeDestinationToken?: boolean;
74+
75+
/**
76+
* Whether to enable the "Buy with card" (fiat payment) option
77+
*/
78+
enableCard?: boolean;
7479
}
7580

7681
type Step =
@@ -90,6 +95,7 @@ export function PaymentSelection({
9095
connectOptions,
9196
connectLocale,
9297
includeDestinationToken,
98+
enableCard,
9399
}: PaymentSelectionProps) {
94100
const connectedWallets = useConnectedWallets();
95101
const activeWallet = useActiveWallet();
@@ -248,6 +254,7 @@ export function PaymentSelection({
248254
onConnectWallet={handleConnectWallet}
249255
onFiatSelected={handleFiatSelected}
250256
onWalletSelected={handleWalletSelected}
257+
enableCard={enableCard}
251258
/>
252259
)}
253260

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface WalletFiatSelectionProps {
2121
onWalletSelected: (wallet: Wallet) => void;
2222
onFiatSelected: () => void;
2323
onConnectWallet: () => void;
24+
enableCard?: boolean;
2425
}
2526

2627
export function WalletFiatSelection({
@@ -29,6 +30,7 @@ export function WalletFiatSelection({
2930
onWalletSelected,
3031
onFiatSelected,
3132
onConnectWallet,
33+
enableCard = true,
3234
}: WalletFiatSelectionProps) {
3335
const theme = useCustomTheme();
3436

@@ -126,47 +128,50 @@ export function WalletFiatSelection({
126128
</Container>
127129
</Button>
128130

129-
<Spacer y="md" />
131+
{enableCard && (
132+
<>
133+
<Spacer y="md" />
130134

131-
{/* Pay with Debit Card */}
132-
<Text color="primaryText" size="md">
133-
Pay with Fiat
134-
</Text>
135+
<Text color="primaryText" size="md">
136+
Pay with Card
137+
</Text>
135138

136-
<Spacer y="md" />
139+
<Spacer y="md" />
137140

138-
<Button
139-
fullWidth
140-
onClick={onFiatSelected}
141-
style={{
142-
backgroundColor: theme.colors.tertiaryBg,
143-
border: `1px solid ${theme.colors.borderColor}`,
144-
borderRadius: radius.md,
145-
height: "auto",
146-
padding: `${spacing.sm} ${spacing.md}`,
147-
textAlign: "left",
148-
}}
149-
variant="secondary"
150-
>
151-
<Container
152-
flex="row"
153-
gap="md"
154-
style={{ alignItems: "center", width: "100%" }}
155-
>
156-
<CreditCardIcon
157-
color={theme.colors.secondaryIconColor}
158-
size={iconSize.lg}
159-
/>
160-
<Container flex="column" gap="3xs" style={{ flex: 1 }}>
161-
<Text color="primaryText" size="sm" style={{ fontWeight: 600 }}>
162-
Pay with Card
163-
</Text>
164-
<Text color="secondaryText" size="xs">
165-
Buy crypto and bridge in one step
166-
</Text>
167-
</Container>
168-
</Container>
169-
</Button>
141+
<Button
142+
fullWidth
143+
onClick={onFiatSelected}
144+
style={{
145+
backgroundColor: theme.colors.tertiaryBg,
146+
border: `1px solid ${theme.colors.borderColor}`,
147+
borderRadius: radius.md,
148+
height: "auto",
149+
padding: `${spacing.sm} ${spacing.md}`,
150+
textAlign: "left",
151+
}}
152+
variant="secondary"
153+
>
154+
<Container
155+
flex="row"
156+
gap="md"
157+
style={{ alignItems: "center", width: "100%" }}
158+
>
159+
<CreditCardIcon
160+
color={theme.colors.secondaryIconColor}
161+
size={iconSize.lg}
162+
/>
163+
<Container flex="column" gap="3xs" style={{ flex: 1 }}>
164+
<Text color="primaryText" size="sm" style={{ fontWeight: 600 }}>
165+
Pay with Card
166+
</Text>
167+
<Text color="secondaryText" size="xs">
168+
Buy crypto and bridge in one step
169+
</Text>
170+
</Container>
171+
</Container>
172+
</Button>
173+
</>
174+
)}
170175
</>
171176
);
172177
}

packages/thirdweb/src/react/web/ui/PayEmbed.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ export function PayEmbed(props: PayEmbedProps) {
359359
onSuccess={() => props.payOptions?.onPurchaseSuccess?.()}
360360
theme={theme}
361361
title={metadata?.name || "Buy"}
362+
enableCard={props.payOptions?.buyWithFiat === false ? false : true}
362363
tokenAddress={
363364
props.payOptions.prefillBuy.token?.address as Address | undefined
364365
}
@@ -377,6 +378,7 @@ export function PayEmbed(props: PayEmbedProps) {
377378
name={metadata?.name || "Checkout"}
378379
onSuccess={() => props.payOptions?.onPurchaseSuccess?.()}
379380
seller={props.payOptions.paymentInfo.sellerAddress as Address}
381+
enableCard={props.payOptions?.buyWithFiat === false ? false : true}
380382
theme={theme}
381383
tokenAddress={
382384
props.payOptions.paymentInfo.token?.address as Address | undefined
@@ -393,6 +395,7 @@ export function PayEmbed(props: PayEmbedProps) {
393395
image={metadata?.image}
394396
onSuccess={() => props.payOptions?.onPurchaseSuccess?.()}
395397
theme={theme}
398+
enableCard={props.payOptions?.buyWithFiat === false ? false : true}
396399
title={metadata?.name}
397400
transaction={props.payOptions.transaction}
398401
/>
@@ -513,10 +516,10 @@ export type PayEmbedConnectOptions = {
513516
* ```
514517
*/
515518
autoConnect?:
516-
| {
517-
timeout: number;
518-
}
519-
| boolean;
519+
| {
520+
timeout: number;
521+
}
522+
| boolean;
520523

521524
/**
522525
* Metadata of the app that will be passed to connected wallet. Setting this is highly recommended.

pnpm-lock.yaml

Lines changed: 5 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)