# Backend SDK (Payments)

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

***

{% hint style="info" %}
**Note:** We show here an example for NFT checkout,\
but its the same process for Token checkout as well,\
the only difference being the name of the function and the `id` parameter.
{% endhint %}

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

In this function you are expected to define the transaction parameters, and define your desired settlement type.\
(For more info about settlement types see: [Flow of Funds](/getting-started/token-checkout-or-payments/legacy-token-checkout/features/flow-of-funds.md))

For each settlement type you will have to adjust your `getNftPurchaseData` parameters accordingly:

```typescript
// Common parameters for all settlement types
const nftCheckoutCommon = {
  title: 'Tweed Demo NFT',
  fiatCurrencyId: 'USD',
  contractAddress: DEMO_NFT_CONTRACT_ADDRESS,
  chain: 'polygonAmoy',
  description: "Non-fungible token for demonstration of Tweed's capabilities",
  tokenUri: 'https://paytweed-assets.s3.amazonaws.com/pinky.png' // A simple PNG for the NFT on Tweed's widget
}

const nftCheckoutVariants: Record<string, NftPurchaseBackendPayload> = {
  'demo-freemint': {
    ...nftCheckoutCommon,
    nftId: 'demo-freemint',
    priceInCrypto: '0', // For free mint
    tokenContractAddress: undefined, // For free mint
    abi: DEMO_NFT_CONTRACT_ABI_FREE,
  },
  'demo-paidmint-native': {
    ...nftCheckoutCommon,
    nftId: 'demo-paidmint-native',
    priceInCrypto: String(1e16), // For native settlement -- set price to 0.01 MATIC
    abi: DEMO_NFT_CONTRACT_ABI_PAID_NATIVE,
  },
  'demo-paidmint-erc20': {
    ...nftCheckoutCommon,
    nftId: 'demo-paidmint-erc20',
    priceInCrypto: String(100e18), // For ERC20 settlement -- 100 fake USDC token
    tokenContractAddress: FAKE_USDC_CONTRACT_ADDRESS, // For ERC20 settlement -- fake USDC token address
    abi: DEMO_NFT_CONTRACT_ABI_PAID_ERC20,
  },
}
```

{% hint style="info" %}
*See source repository for full example:* [*https://github.com/paytweed/demo-v2-next/blob/main/services/tweed.service.ts*](https://github.com/paytweed/demo-v2-next/blob/main/services/tweed.service.ts)
{% endhint %}

Note how we provide different parameters based on the type of the settlement.

The `nftId` should correlate to the `nftId` passed from the frontend in the `buyWithFiat` function call.

#### Correctly specifiying your ABI:

The `abi` parameter should contain the name of the function and its arguments declerations,\
similar to the following example: \
`safeMint(sendTo address, tokenId uint256, tokenUri string)`. \
\
The arguments needs to get populated into the`customMintParams` object like so:

```javascript
customMintParams : {
    sendTo: <THE_WALLET_ADDRESS_VAR>,
    tokenId: <YOUR_TOKEN_ID_VAR>,
    tokenUri: <YOUR_TOKEN_URI_VAR>
}
```


---

# Agent Instructions: 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:

```
GET https://docs.paytweed.com/developer-tools/tweed-sdks/payments-sdks-v1/backend-sdk-payments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
