# Frontend SDKs (Payments)

This page compliments the [Basic Payment Integration](https://docs.paytweed.com/getting-started/token-checkout-or-payments/legacy-token-checkout/basic-checkout-integration) guide.\
Here you will find additional information regarding functions used in the Payments Integration Guide.

## Buy with fiat[​](https://docs.paytweed.com/frontend-sdk/javascript/on-chain-functions/#buy-with-fiat) <a href="#buy-with-fiat" id="buy-with-fiat"></a>

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>
```

<table><thead><tr><th width="234" align="center">Field Name</th><th>Description</th></tr></thead><tbody><tr><td align="center"><p><code>nftID</code></p><p>or<br><code>tokenID</code></p></td><td>The ID of the <strong>NFT</strong> or <strong>Token</strong>, as defined by your implementation of the Tweed Backend Payment SDK.<br>(Read more about the: <a href="backend-sdk-payments">Backend side of the Payments integration</a>)</td></tr><tr><td align="center">data</td><td>Your custom data that will be passed to Tweed, and later will be sent to you in the Webhook(s).</td></tr><tr><td align="center">toWalletAddress</td><td>The wallet address that the NFT will be send to, If the wallet was created by tweed the wallet address will be populated automatically.</td></tr><tr><td align="center">customMintParams</td><td>A key-value set of parameters that will be passed into your on-chain smart contract. <strong>Needs to match your contract's ABI!</strong></td></tr><tr><td align="center">callbacks</td><td>You may define handlers for the following widget events:<br><code>onSuccess</code>, <code>onError</code>, <code>onClose</code></td></tr></tbody></table>

**Example of usage**[**​**](https://docs.paytweed.com/frontend-sdk/javascript/on-chain-functions/#example-of-usage-8)

```typescript
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)
    }
```
