Frontend SDKs (Payments)

This page compliments the Basic Payment Integration guide. Here you will find additional information regarding functions used in the Payments Integration Guide.

Buy with fiat

Depending on whether your use case requires a Token or NFT checkout, The path to the function will be different:

  • For NFT checkout use: frontendSDK.nft.buyWithFiat With the nftId parameter.

  • For Token checkout use: frontendSDK.token.buyWithFiat With the tokenId parameter.

The synopsis for both functions almost identical, with the `tokenId` / `nftId` being the only difference:

type buyWithFiat = (payload: {
    nftId: string;
    data: Record<string, any> | undefined;
    toWalletAddress: string | undefined;
    customMintParams: Record<string, any> | undefined;
    callbacks: WidgetCallbacks<any> | undefined;
    settings: WidgetSettings | undefined;
}): Promise<string>
Field NameDescription

nftID

or tokenID

The ID of the NFT or Token, as defined by your implementation of the Tweed Backend Payment SDK. (Read more about the: Backend side of the Payments integration)

data

Your custom data that will be passed to Tweed, and later will be sent to you in the Webhook(s).

toWalletAddress

The wallet address that the NFT will be send to, If the wallet was created by tweed the wallet address will be populated automatically.

customMintParams

A key-value set of parameters that will be passed into your on-chain smart contract. Needs to match your contract's ABI!

callbacks

You may define handlers for the following widget events: onSuccess, onError, onClose

Example of usage

try {
      sdkv1.nft.buyWithFiat({
        nftId,
        toWalletAddress,
        customMintParams: {},
        data: {},
        callbacks: {
          onSuccess: (data) => {
            console.log('[buyNft] Freemint success!', data)
          },
          onError: (error) => {
            console.error('[buyNft] Freemint error!', error)
          },
          onClose,
        },
        settings: {
          
        }
      })
    } catch (err) {
      console.error(err)
    }

Last updated