create a payment links or use token checkout without using a frontend
Provides a URL to a widget enabling users to purchase an NFT using traditional payment methods such as payment cards, Google Pay, or Apple Pay. This URL can be utilized to send a purchase link to your user's email, for instance.
The widget remains active indefinitely until it is first opened, after which it remains accessible for 24 hours. Once this period elapses, the widget becomes unusable.
Retrun type
Promise<{ widgetUrl: string; requestId: string }>
Redirect URI
Provides the option to redirect users upon completing the checkout process, whether it is successful or unsuccessful.
isTopWindow ensures widget Redirects is top-level window.
redirectUriOnSuccessstring
Description: When the widget is closed after a succeeded transaction the widget will redirect to the supplied URL
Called with the transaction hash in the txHash URL param
redirectUriOnFail string
Description: When the widget is closed after a failed transaction the widget will redirect to the supplied URL
Called with the reason to the failure in the error URL param
Example
constbuyNftPayload:NftPurchaseBackendPayload= { nftId:"123",//Can be a ramdom generated by the user priceInCents:100,//Optionally 0 for freemint //priceInCrypto: 10000000000000, //If the user wants to get crypto instead of fiat fiatCurrencyId:'USD', tokenUri:'<THUMBNAIL_URI>', contractAddress:'<NFT_ADDRESS>', chain:'ethereumSepolia',//The chainId according to the Tweed docs title:'<NFT_NAME>', description:'<NFT_DESCRIPTION>', abi:'safeMint(toAddress address, tokenUri string)', customMintParams: { toWalletAddress:"<WALLET_ADDRESS>", tokenUri:"<TOKEN_URI>" } }// optionalconstwidgetRedirectUris:BackendWidgetRedirectUri= { redirectUriOnSuccess:'https://www.redirectUriOnSuccess.com', redirectUriOnFail:'https://www.redirectUriOnFail.com/', }constwidgetUrl=awaitbackendSDK.nft.buyWithFiat(buyNftPayload, widgetRedirectUris)console.log({ widgetUrl })