Skip to content

[SDK] Add enableCard prop to control fiat payment visibility #7465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dull-breads-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Adds enableCard prop to BuyWidget, CheckoutWidget, and TransactionWidget
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@
* Quick buy amounts
*/
presetOptions: [number, number, number] | undefined;

/**
* Whether to enable the "Buy with card" (fiat payment) option
*/
enableCard?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we do an array instead of litterals

Crypt, card (later we'll have more like ACH, exchange)

}

export function BridgeOrchestrator({
Expand All @@ -127,6 +132,7 @@
purchaseData,
paymentLinkId,
presetOptions,
enableCard,

Check warning on line 135 in packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L135 was not covered by tests
}: BridgeOrchestratorProps) {
// Initialize adapters
const adapters = useMemo(
Expand Down Expand Up @@ -271,6 +277,7 @@
onError={handleError}
onPaymentMethodSelected={handlePaymentMethodSelected}
receiverAddress={state.context.receiverAddress}
enableCard={enableCard}

Check warning on line 280 in packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L280 was not covered by tests
/>
)}

Expand Down
7 changes: 7 additions & 0 deletions packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@
* @hidden
*/
paymentLinkId?: string;

/**
* Whether to enable the "Buy with card" (fiat payment) option.
* @default true
*/
enableCard?: boolean;
};

// Enhanced UIOptions to handle unsupported token state
Expand Down Expand Up @@ -382,6 +388,7 @@
purchaseData={props.purchaseData}
receiverAddress={undefined}
uiOptions={bridgeDataQuery.data.data}
enableCard={props.enableCard}

Check warning on line 391 in packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L391 was not covered by tests
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@
* @hidden
*/
paymentLinkId?: string;

/**
* Whether to enable the "Buy with card" (fiat payment) option.
* @default true
*/
enableCard?: boolean;
};

// Enhanced UIOptions to handle unsupported token state
Expand Down Expand Up @@ -345,6 +351,7 @@
purchaseData={props.purchaseData}
receiverAddress={props.seller}
uiOptions={bridgeDataQuery.data.data}
enableCard={props.enableCard}

Check warning on line 354 in packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L354 was not covered by tests
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@
* @hidden
*/
paymentLinkId?: string;

/**
* Whether to enable the "Buy with card" (fiat payment) option.
* @default true
*/
enableCard?: boolean;
};

// Enhanced UIOptions to handle unsupported token state
Expand Down Expand Up @@ -404,6 +410,7 @@
purchaseData={props.purchaseData}
receiverAddress={undefined}
uiOptions={bridgeDataQuery.data.data}
enableCard={props.enableCard}

Check warning on line 413 in packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L413 was not covered by tests
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
* Whether to include the destination token in the payment methods
*/
includeDestinationToken?: boolean;

/**
* Whether to enable the "Buy with card" (fiat payment) option
*/
enableCard?: boolean;
}

type Step =
Expand All @@ -90,6 +95,7 @@
connectOptions,
connectLocale,
includeDestinationToken,
enableCard,

Check warning on line 98 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L98 was not covered by tests
}: PaymentSelectionProps) {
const connectedWallets = useConnectedWallets();
const activeWallet = useActiveWallet();
Expand Down Expand Up @@ -248,6 +254,7 @@
onConnectWallet={handleConnectWallet}
onFiatSelected={handleFiatSelected}
onWalletSelected={handleWalletSelected}
enableCard={enableCard}

Check warning on line 257 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L257 was not covered by tests
/>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
onWalletSelected: (wallet: Wallet) => void;
onFiatSelected: () => void;
onConnectWallet: () => void;
enableCard?: boolean;
}

export function WalletFiatSelection({
Expand All @@ -29,6 +30,7 @@
onWalletSelected,
onFiatSelected,
onConnectWallet,
enableCard = true,

Check warning on line 33 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L33 was not covered by tests
}: WalletFiatSelectionProps) {
const theme = useCustomTheme();

Expand Down Expand Up @@ -126,47 +128,50 @@
</Container>
</Button>

<Spacer y="md" />
{enableCard && (
<>
<Spacer y="md" />

Check warning on line 133 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L131 - L133 were not covered by tests

{/* Pay with Debit Card */}
<Text color="primaryText" size="md">
Pay with Fiat
</Text>
<Text color="primaryText" size="md">

Check warning on line 135 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L135 was not covered by tests
Pay with Card
</Text>

Check warning on line 137 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L137 was not covered by tests

<Spacer y="md" />
<Spacer y="md" />

Check warning on line 139 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L139 was not covered by tests

<Button
fullWidth
onClick={onFiatSelected}
style={{
backgroundColor: theme.colors.tertiaryBg,
border: `1px solid ${theme.colors.borderColor}`,
borderRadius: radius.md,
height: "auto",
padding: `${spacing.sm} ${spacing.md}`,
textAlign: "left",
}}
variant="secondary"
>
<Container
flex="row"
gap="md"
style={{ alignItems: "center", width: "100%" }}
>
<CreditCardIcon
color={theme.colors.secondaryIconColor}
size={iconSize.lg}
/>
<Container flex="column" gap="3xs" style={{ flex: 1 }}>
<Text color="primaryText" size="sm" style={{ fontWeight: 600 }}>
Pay with Card
</Text>
<Text color="secondaryText" size="xs">
Buy crypto and bridge in one step
</Text>
</Container>
</Container>
</Button>
<Button
fullWidth
onClick={onFiatSelected}
style={{
backgroundColor: theme.colors.tertiaryBg,
border: `1px solid ${theme.colors.borderColor}`,
borderRadius: radius.md,
height: "auto",
padding: `${spacing.sm} ${spacing.md}`,
textAlign: "left",
}}
variant="secondary"

Check warning on line 152 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L141 - L152 were not covered by tests
>
<Container
flex="row"
gap="md"
style={{ alignItems: "center", width: "100%" }}

Check warning on line 157 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L154 - L157 were not covered by tests
>
<CreditCardIcon
color={theme.colors.secondaryIconColor}
size={iconSize.lg}
/>
<Container flex="column" gap="3xs" style={{ flex: 1 }}>
<Text color="primaryText" size="sm" style={{ fontWeight: 600 }}>

Check warning on line 164 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L159 - L164 were not covered by tests
Pay with Card
</Text>
<Text color="secondaryText" size="xs">

Check warning on line 167 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L166 - L167 were not covered by tests
Buy crypto and bridge in one step
</Text>
</Container>
</Container>
</Button>
</>

Check warning on line 173 in packages/thirdweb/src/react/web/ui/Bridge/payment-selection/WalletFiatSelection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L169 - L173 were not covered by tests
)}
</>
);
}
11 changes: 7 additions & 4 deletions packages/thirdweb/src/react/web/ui/PayEmbed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
onSuccess={() => props.payOptions?.onPurchaseSuccess?.()}
theme={theme}
title={metadata?.name || "Buy"}
enableCard={props.payOptions?.buyWithFiat === false ? false : true}

Check warning on line 362 in packages/thirdweb/src/react/web/ui/PayEmbed.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L362 was not covered by tests
tokenAddress={
props.payOptions.prefillBuy.token?.address as Address | undefined
}
Expand All @@ -377,6 +378,7 @@
name={metadata?.name || "Checkout"}
onSuccess={() => props.payOptions?.onPurchaseSuccess?.()}
seller={props.payOptions.paymentInfo.sellerAddress as Address}
enableCard={props.payOptions?.buyWithFiat === false ? false : true}

Check warning on line 381 in packages/thirdweb/src/react/web/ui/PayEmbed.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L381 was not covered by tests
theme={theme}
tokenAddress={
props.payOptions.paymentInfo.token?.address as Address | undefined
Expand All @@ -393,6 +395,7 @@
image={metadata?.image}
onSuccess={() => props.payOptions?.onPurchaseSuccess?.()}
theme={theme}
enableCard={props.payOptions?.buyWithFiat === false ? false : true}

Check warning on line 398 in packages/thirdweb/src/react/web/ui/PayEmbed.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L398 was not covered by tests
title={metadata?.name}
transaction={props.payOptions.transaction}
/>
Expand Down Expand Up @@ -513,10 +516,10 @@
* ```
*/
autoConnect?:
| {
timeout: number;
}
| boolean;
| {
timeout: number;
}
| boolean;

/**
* Metadata of the app that will be passed to connected wallet. Setting this is highly recommended.
Expand Down
31 changes: 5 additions & 26 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading