-
Notifications
You must be signed in to change notification settings - Fork 630
[MNY-345] Portal: Add Checkout widget iframe docs #8581
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
+566
−23
Merged
Changes from all commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
apps/portal/src/app/bridge/checkout-widget/iframe/iframe-code-preview.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,34 @@ | ||
| import { CodeBlock, Tabs, TabsContent, TabsList, TabsTrigger } from "@doc"; | ||
|
|
||
| export function IframeCodePreview(props: { src: string }) { | ||
| return ( | ||
| <Tabs defaultValue="code"> | ||
| <TabsList> | ||
| <TabsTrigger value="code">Code</TabsTrigger> | ||
| <TabsTrigger value="preview">Preview</TabsTrigger> | ||
| </TabsList> | ||
| <TabsContent value="code"> | ||
| <CodeBlock | ||
| code={`\ | ||
| <iframe | ||
| src="${props.src}" | ||
| height="700px" | ||
| width="100%" | ||
| style="border: 0;" | ||
| />`} | ||
| lang="html" | ||
| /> | ||
| </TabsContent> | ||
| <TabsContent value="preview"> | ||
| <iframe | ||
| title="Checkout widget iframe" | ||
| src={props.src} | ||
| height="700px" | ||
MananTank marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| className="rounded-xl" | ||
| width="100%" | ||
| style={{ border: 0 }} | ||
| /> | ||
| </TabsContent> | ||
| </Tabs> | ||
| ); | ||
| } | ||
162 changes: 162 additions & 0 deletions
162
apps/portal/src/app/bridge/checkout-widget/iframe/page.mdx
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,162 @@ | ||
| import { | ||
| ArticleIconCard, | ||
| Details, | ||
| createMetadata, | ||
| DocImage, | ||
| } from "@doc"; | ||
| import { IframeCodePreview } from "./iframe-code-preview"; | ||
| import { PlayIcon } from "lucide-react"; | ||
| import checkoutWidgetDark from "../checkout-widget-dark.jpg"; | ||
| import checkoutWidgetLight from "../checkout-widget.jpg"; | ||
|
|
||
| export const metadata = createMetadata({ | ||
| image: { | ||
| title: "Checkout widget iframe", | ||
| icon: "payments", | ||
| }, | ||
| title: "Checkout widget iframe", | ||
| description: "Add a widget to accept crypto and fiat payments in your app using an iframe", | ||
| }); | ||
|
|
||
| # Checkout widget iframe | ||
|
|
||
| The Checkout widget iframe makes it easy to accept crypto and fiat payments in your app. Just add an iframe to your HTML and get a fully customizable checkout widget - no build setup required. | ||
|
|
||
| <div className='dark-only'> | ||
| <DocImage src={checkoutWidgetDark} /> | ||
| </div> | ||
| <div className='light-only'> | ||
| <DocImage src={checkoutWidgetLight} /> | ||
| </div> | ||
|
|
||
| ## Features | ||
|
|
||
| - Accept payments in crypto or fiat (credit/debit cards) | ||
| - Cross-chain payment support across 85+ blockchains | ||
| - Display product information (name, description, image) | ||
| - Dark and light mode support | ||
| - Display fiat values in multiple currencies | ||
|
|
||
| ## Iframe Integration | ||
|
|
||
| The checkout widget requires below minimum parameters to be set: | ||
|
|
||
| - `chain` - The chain ID where you want to receive payment (e.g., 8453 for Base) | ||
| - `tokenAddress` (optional) - The token address to accept as payment. If this parameter is not set, payment will be accepted in the native token of the specified chain. | ||
| - `amount` - The amount to charge (as a decimal string, e.g., "0.01") | ||
| - `seller` - The wallet address that will receive the payment | ||
|
|
||
| ### Example | ||
|
|
||
| Accept 0.1 USDC on Base as payment to seller (`0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024`) | ||
|
|
||
| <IframeCodePreview src="https://thirdweb.com/bridge/checkout-widget?chain=8453&tokenAddress=0x833589fcd6edb6e08f4c7c32d4f71b54bda02913&amount=0.1&seller=0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024" /> | ||
|
|
||
| ## Try it out | ||
|
|
||
| <ArticleIconCard | ||
| title="Checkout Widget Playground" | ||
| description="Try out the Checkout Widget in our live playground" | ||
| icon={PlayIcon} | ||
| href="https://playground.thirdweb.com/bridge/checkout-widget?tab=iframe" | ||
| /> | ||
|
|
||
| ## Options | ||
|
|
||
| You can customize the checkout widget using query parameters as mentioned below. | ||
|
|
||
|
|
||
| ### Theme | ||
|
|
||
| By default the widget uses the "dark" theme. You can set the light theme by passing the `theme=light` query parameter. | ||
|
|
||
| <IframeCodePreview src="https://thirdweb.com/bridge/checkout-widget?chain=8453&amount=0.01&seller=0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024&theme=light" /> | ||
|
|
||
|
|
||
| ### Product Information | ||
|
|
||
| You can display product information by passing `title`, `description`, and `image` query parameters. Each of these parameters are optional. | ||
|
|
||
| Make sure to URI encode the parameters if they contain special characters | ||
|
|
||
| <Details summary="Example"> | ||
|
|
||
| * title: `"Something"` | ||
| * description: `"Description of something goes here"` | ||
| * image: `"https://picsum.photos/600/300"` | ||
| * price: 0.01 ETH on Base | ||
|
|
||
| <IframeCodePreview src="https://thirdweb.com/bridge/checkout-widget?chain=8453&amount=0.01&seller=0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024&title=Something&description=Description%20of%20something%20goes%20here&image=https%3A%2F%2Fpicsum.photos%2F600%2F300" /> | ||
|
|
||
| </Details> | ||
|
|
||
|
|
||
| ### Currency | ||
|
|
||
| By default the fiat value of the token amounts is displayed in USD. You can change the currency by setting the `currency` query parameter. | ||
|
|
||
| <Details summary="Supported Currencies"> | ||
|
|
||
| - `USD` - US Dollar (default) | ||
| - `EUR` - Euro | ||
| - `GBP` - British Pound | ||
| - `JPY` - Japanese Yen | ||
| - `KRW` - Korean Won | ||
| - `CNY` - Chinese Yuan | ||
| - `INR` - Indian Rupee | ||
| - `NOK` - Norwegian Krone | ||
| - `SEK` - Swedish Krona | ||
| - `CHF` - Swiss Franc | ||
| - `AUD` - Australian Dollar | ||
| - `CAD` - Canadian Dollar | ||
| - `NZD` - New Zealand Dollar | ||
| - `MXN` - Mexican Peso | ||
| - `BRL` - Brazilian Real | ||
| - `CLP` - Chilean Peso | ||
| - `CZK` - Czech Koruna | ||
| - `DKK` - Danish Krone | ||
| - `HKD` - Hong Kong Dollar | ||
| - `HUF` - Hungarian Forint | ||
| - `IDR` - Indonesian Rupiah | ||
| - `ILS` - Israeli New Sheqel | ||
| - `ISK` - Icelandic Krona | ||
|
|
||
| </Details> | ||
|
|
||
| #### Example | ||
|
|
||
| Show fiat values in Euro (EUR) in the widget. | ||
|
|
||
| <IframeCodePreview src="https://thirdweb.com/bridge/checkout-widget?chain=8453&amount=0.01&seller=0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024¤cy=EUR" /> | ||
|
|
||
| ### thirdweb branding | ||
|
|
||
| By default, the widget displays thirdweb branding at the bottom. You can hide this by setting the `showThirdwebBranding` query parameter to `false`. | ||
|
|
||
| <IframeCodePreview src="https://thirdweb.com/bridge/checkout-widget?chain=8453&amount=0.01&seller=0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024&showThirdwebBranding=false" /> | ||
|
|
||
| ## Listening for Events | ||
|
|
||
| The checkout widget iframe sends events to the parent window using `postMessage` when a purchase succeeds or fails. | ||
|
|
||
| You can listen for these events to handle the purchase result in your application. | ||
|
|
||
| ```js | ||
| window.addEventListener("message", (event) => { | ||
|
|
||
| // verify that message is from thirdweb checkout widget iframe | ||
| if ( | ||
| event.origin === "https://thirdweb.com" && event.data.source === "checkout-widget" | ||
| ) { | ||
|
|
||
| if (event.data.type === "success") { | ||
| console.log("Purchase successful!"); | ||
| } | ||
|
|
||
| if (event.data.type === "error") { | ||
| console.error("Purchase failed with error:", event.data.message); | ||
| } | ||
| } | ||
|
|
||
| }); | ||
| ``` |
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,71 @@ | ||
| import { | ||
| Details, | ||
| createMetadata, | ||
| DocImage, | ||
| } from "@doc"; | ||
| import { ArticleIconCard } from "@doc"; | ||
| import { FrameIcon, PlayIcon } from "lucide-react"; | ||
| import { ReactIcon } from "@/icons"; | ||
| import checkoutWidgetDark from "./checkout-widget-dark.jpg"; | ||
| import checkoutWidgetLight from "./checkout-widget.jpg"; | ||
|
|
||
| export const metadata = createMetadata({ | ||
| image: { | ||
| title: "Checkout widget", | ||
| icon: "payments", | ||
| }, | ||
| title: "Checkout widget", | ||
| description: "Add a widget to accept crypto and fiat payments in your app", | ||
| }); | ||
|
|
||
| # Checkout widget | ||
|
|
||
| The Checkout widget makes it easy to accept crypto and fiat payments directly to your wallet. It supports cross-chain payments, fiat onramp via credit/debit cards, and provides a seamless checkout experience for your users. | ||
|
|
||
| <div className='dark-only'> | ||
| <DocImage src={checkoutWidgetDark} /> | ||
| </div> | ||
| <div className='light-only'> | ||
| <DocImage src={checkoutWidgetLight} /> | ||
| </div> | ||
|
|
||
| ## Features | ||
|
|
||
| - Accept payments in crypto or fiat (credit/debit cards) | ||
| - Cross-chain payment support across 85+ blockchains | ||
| - Display product information (name, description, image) | ||
| - Customizable UI with dark and light mode support | ||
| - Display fiat values in multiple currencies | ||
| - Event callbacks to track purchase status (success, error, cancel) | ||
|
|
||
| ## Get Started | ||
|
|
||
| You can integrate the checkout widget into your website using an iframe or a React component. | ||
|
|
||
| <div className="space-y-4"> | ||
|
|
||
| <ArticleIconCard | ||
| title="Iframe" | ||
| icon={FrameIcon} | ||
| description="Integrate checkout widget into your website using an iframe" | ||
| href="/bridge/checkout-widget/iframe" | ||
| /> | ||
|
|
||
| <ArticleIconCard | ||
| title="React Component" | ||
| icon={ReactIcon} | ||
| description="Integrate checkout widget into your app using a React component" | ||
| href="/bridge/checkout-widget/react" | ||
| /> | ||
|
|
||
| </div> | ||
|
|
||
| ## Try it out | ||
|
|
||
| <ArticleIconCard | ||
| title="Checkout Widget Playground" | ||
| description="Try out the Checkout Widget in our live playground" | ||
| icon={PlayIcon} | ||
| href="https://playground.thirdweb.com/bridge/checkout-widget" | ||
| /> | ||
|
|
Oops, something went wrong.
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.