# How to integrate

Go through the [API documentation](https://nivapay.gitbook.io/product-and-api-documentation/api-documentation/nft-minting) to know about the endpoints to integrate. This page talks about certain request parameters and the values they take.

### Generating a new order

Before performing integration, please ensure that you have at least [registered your testnet smart contract function](https://nivapay.gitbook.io/product-and-api-documentation/products/registering-your-smart-contract) with us. You must have received a smart contract config ID, which you need to pass in the `smartContractFunctionId` param.

One needs to call the [Create Order](https://nivapay.gitbook.io/product-and-api-documentation/api-documentation/nft-minting#create-order) endpoint to generate a new order and redirect the user to the hosted checkout URL to complete the journey. If you are integrating with our [Web SDK](https://nivapay.gitbook.io/product-and-api-documentation/integrations/web-sdk-reactjs), then you don't need to redirect your user. Instead a widget will open on top of your website and the user can engage with it until they complete the journey and close that widget.

#### Parameters required to execute the smart contract

You need to specify appropriate values for `payment.payableCryptoSymbol`, `payment.payableCryptoContractAddress` and `network_params.networkName` within the `contractExecution` object corresponding to the smart contract function you intend to call.  Permissible values of these params are listed below.

<table data-full-width="false"><thead><tr><th width="223">payableCryptoSymbol</th><th width="305">payableCryptoContractAddress</th><th width="199">NetworkName</th></tr></thead><tbody><tr><td>ETH</td><td>-</td><td>Ethereum</td></tr><tr><td>BNB</td><td>-</td><td>Binance Smart Chain</td></tr></tbody></table>

*Currently, we do not support smart contracts which receive ERC20 / BEP20 tokens*

Nivapay does not have semantic understand of what your smart contract function does. So depending on the `function_args`, only you would know how much compute intensive it will be and how much funds does it need for successful execution. Therefore, while generating an order please provide accurate values for `function_args`, `payment.totalValue` and `network_params.customGasLimit` because there will be minimal validation from our end.

If `network_params.customGasLimit` is skipped then we will use the default gas limit provided at the time of smart contract registration.

If the smart contract function does not require any funds to execute (or is not payable) then the entire `payment` object in the request can be skipped.  &#x20;

#### Parameters corresponding to payment to be done by the user

Permissible values for `crypto_symbol`, `crypto_network` and `crypto_contract_address` are listed below.

<table><thead><tr><th width="106">Symbol</th><th width="194">Network</th><th width="167">contract_address</th><th>Description</th></tr></thead><tbody><tr><td>ETH</td><td>Ethereum</td><td>-</td><td>Ether, the native currency of Ethereum mainnet</td></tr><tr><td>BNB</td><td>Binance Smart Chain</td><td>-</td><td>BNB coin, the native currency of BSC mainnet</td></tr></tbody></table>

*Currently, we do not support paying in ERC20 / BEP20 tokens*

Once you specify these params accurately, the [Create Order](https://nivapay.gitbook.io/product-and-api-documentation/api-documentation/nft-minting#create-order) endpoint will do the job of back calculating the crypto amount required to successfully execute the entire order. This amount is shared with you in the endpoint's [response](https://nivapay.gitbook.io/product-and-api-documentation/api-documentation/nft-minting#create-order) and [`order.created`](https://nivapay.gitbook.io/product-and-api-documentation/webhooks/nft-minting#context-structure-for-event-order.created) webhook event. It will also be shown to the user on the order preview (first) page.

If you want to display this fiat amount pre-emptively to the user on your platform, then you can call the [Generate Crypto Quote](https://nivapay.gitbook.io/product-and-api-documentation/api-documentation/nft-minting#generate-crypto-quote) endpoint with the same set of params as discussed above. This endpoint returns the `crypto_amount` and `allowed` param, which tells that whether this amount is permissible to be paid. If `allowed` = FALSE, then `message` contains the detailed reason. This reason can be displayed to your user so that they can take necessary action.

#### User session validity

The hosted checkout URL when accessed by the user, generates a session for that order. The user can interact with the payment gateway screens to complete the journey during that session. However, once that session is closed or interrupted, it cannot be accessed again due to security reasons. A new order is required to be created to reattempt the transaction. In case the user has already made the payment, then they should wait for at least 2 hours and receive the final status update through email.


---

# 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://nivapay.gitbook.io/product-and-api-documentation/products/nft-minting/how-to-integrate.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.
