> For the complete documentation index, see [llms.txt](https://docs.paytweed.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.paytweed.com/getting-started/token-checkout-or-payments/legacy-token-checkout/features/payment-links.md).

# Payment links

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.

{% hint style="info" %}
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.
{% endhint %}

#### 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.

{% hint style="warning" %}
**isTopWindow**  ensures widget Redirects is top-level window.
{% endhint %}

<details>

<summary><code>redirectUriOnSuccess</code> <mark style="color:purple;background-color:yellow;"><code>string</code></mark></summary>

**Description:** When the widget is closed after a succeeded transaction the widget will redirect to the supplied URL<br>

**Called with the transaction hash in the `txHash` URL param**

</details>

<details>

<summary>redirectUriOnFail <mark style="color:purple;background-color:yellow;"><code>string</code></mark></summary>

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

</details>

### Example

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