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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.paytweed.com/getting-started/token-checkout-or-payments/legacy-token-checkout/features/payment-links.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
