-
Notifications
You must be signed in to change notification settings - Fork 540
[SDK] Feature: Allow for supported providers to be passed to PayEmbed #7108
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
joaquim-verges
merged 5 commits into
thirdweb-dev:main
from
RobbyUitbeijerse:feature/payembed-supported-fiat-providers
May 23, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2bc1f09
feat: introduce supportedProviders option for fiat onramping
RobbyUitbeijerse 1a0dde6
chore: add comment with an explainer
RobbyUitbeijerse a3fbc69
chore: rename util
RobbyUitbeijerse 0c5260c
chore: update import path for FiatProvider type
RobbyUitbeijerse 2dab506
chore: adjust preferredProvider passed to the quote to ensure we only…
RobbyUitbeijerse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"thirdweb": patch | ||
--- | ||
|
||
Add support for filtering fiat payment providers in PayEmbed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/PayProviderSelection.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { ChevronDownIcon } from "@radix-ui/react-icons"; | ||
import type { FiatProvider } from "../../../../../../pay/utils/commonTypes.js"; | ||
import { iconSize, spacing } from "../../../../../core/design-system/index.js"; | ||
import { Container } from "../../../components/basic.js"; | ||
import { Button } from "../../../components/buttons.js"; | ||
import { Text } from "../../../components/text.js"; | ||
import { getProviderLabel } from "./utils.js"; | ||
|
||
/** | ||
* Shows the selected payment provider based on the preferred provider OR the quoted provider. | ||
* @internal | ||
*/ | ||
export const PayProviderSelection = (props: { | ||
onShowProviders: () => void; | ||
quotedProvider?: FiatProvider; | ||
preferredProvider?: FiatProvider; | ||
supportedProviders: FiatProvider[]; | ||
}) => { | ||
const ProviderItem = ( | ||
<Container | ||
flex="row" | ||
center="y" | ||
gap="xxs" | ||
color="secondaryText" | ||
style={{ padding: spacing.md }} | ||
> | ||
<Text size="xs"> | ||
{getProviderLabel( | ||
props.preferredProvider ?? props.quotedProvider ?? "", | ||
)} | ||
</Text> | ||
{props.supportedProviders.length > 1 && ( | ||
<ChevronDownIcon width={iconSize.sm} height={iconSize.sm} /> | ||
)} | ||
</Container> | ||
); | ||
|
||
return ( | ||
<Container | ||
bg="tertiaryBg" | ||
flex="row" | ||
borderColor="borderColor" | ||
style={{ | ||
paddingLeft: spacing.md, | ||
justifyContent: "space-between", | ||
alignItems: "center", | ||
borderWidth: "1px", | ||
borderStyle: "solid", | ||
borderBottom: "none", | ||
}} | ||
> | ||
<Text size="xs" color="secondaryText"> | ||
Provider | ||
</Text> | ||
{props.supportedProviders.length > 1 ? ( | ||
<Button | ||
variant="ghost" | ||
onClick={props.onShowProviders} | ||
style={{ padding: 0 }} // Padding is managed within children as the button is conditional | ||
> | ||
{ProviderItem} | ||
</Button> | ||
) : ( | ||
ProviderItem | ||
)} | ||
</Container> | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/utils.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
export function getBuyTokenAmountFontSize(value: string) { | ||
return value.length > 10 ? "26px" : value.length > 6 ? "34px" : "50px"; | ||
} | ||
|
||
/** | ||
* | ||
* @param str accepts any string but expects a fully upppercased string / type FiatProvider | ||
* @returns Fiat provider label to be rendered used within presentation logic | ||
*/ | ||
export function getProviderLabel(str: string) { | ||
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.