> For the complete documentation index, see [llms.txt](https://nivapay.gitbook.io/product-and-api-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nivapay.gitbook.io/product-and-api-documentation/products/nft-checkout/how-to-integrate.md).

# How to integrate

Go through the [API documentation](/product-and-api-documentation/api-documentation/nft-checkout.md) 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](/product-and-api-documentation/products/registering-your-smart-contract.md) 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](/product-and-api-documentation/api-documentation/nft-checkout.md#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](/product-and-api-documentation/integrations/web-sdk-reactjs.md), 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

You need to know in advance, which fiat currency and payment method is the user going to make payment with. Refer to the [Currency Coverage](/product-and-api-documentation/products/currency-coverage.md) section to know the appropriate values to be passed for `order_fiat_symbol` and `fiat_payment_method` .

Once you specify all these params accurately, the [Create Order](/product-and-api-documentation/api-documentation/nft-checkout.md#create-order) endpoint will do the job of back calculating the fiat amount required to successfully execute the entire order. This amount is shared with you in the endpoint's [response](/product-and-api-documentation/api-documentation/nft-checkout.md#create-order) and [`order.created`](https://nivapay.gitbook.io/product-and-api-documentation/products/nft-checkout/pages/UZ88UueQfNfUuWSNp5UE#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 Fiat Quote](/product-and-api-documentation/api-documentation/nft-checkout.md#generate-fiat-quote) endpoint with the same set of params as discussed above. This endpoint returns the `fiat_amount` and `allowed` param, which tells that whether this amount is permissible under the limits set for the desired fiat currency and payment method. 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.
