Payment links

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.

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.

redirectUriOnSuccess string

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

  const buyNftPayload: 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>"
      }
  }
  
  // optional
  const widgetRedirectUris: BackendWidgetRedirectUri = {
    redirectUriOnSuccess: 'https://www.redirectUriOnSuccess.com',
    redirectUriOnFail: 'https://www.redirectUriOnFail.com/',
  }

  const widgetUrl = await backendSDK.nft.buyWithFiat(buyNftPayload, widgetRedirectUris)
  console.log({ widgetUrl })

Last updated