How to get started with setting up your UI
This guide will walk you through the basic steps of implementing a user interface integrated with the Headless Checkout. The first step in the process will be to create an Order via API call.
You can create an order on load and add the recipient later, or wait to create the order when you have the recipient info ready. Creating the order immediately helps obtain the price quote for display. Let’s proceed with that approach in mind.
There are four key components you’ll need to represent in the UI for your users.
It is common to create an order upon initial render for your user, and then update the details of that order as the adjustments are made by the user. You’ll need to create a function in your application that can call the create-order API and save the response.
After you create the order
you’ll get back metadata related to the collectionId
you pass in the create-order call. You can use this metadata to build the preview highlighted in the screenshot below.
After you create the order
you’ll get back metadata related to the collectionId
you pass in the create-order call. You can use this metadata to build the preview highlighted in the screenshot below.
To enable the cross-chain payments feature, you’ll need to provide an easy way for users to connect their wallet. This guide will not go into detail about how to add any specific tools, since there are a variety available and the implementation of each is unique to the tool.
However, you will want to set up your app to listen for changes to the primary connected wallet and selected network so that the order is updated automatically.
Once the user has connected their wallet they might still change the primary connected account or network. You need to listen for these changes and update the order.
Once the user has connected their wallet they might still change the primary connected account or network. You need to listen for these changes and update the order.
Note the dependency array at the end of this useEffect
watches primaryWallet
and selectedNetwork
. If any of these change your app needs to refresh the order with the new values.
How to get started with setting up your UI
This guide will walk you through the basic steps of implementing a user interface integrated with the Headless Checkout. The first step in the process will be to create an Order via API call.
You can create an order on load and add the recipient later, or wait to create the order when you have the recipient info ready. Creating the order immediately helps obtain the price quote for display. Let’s proceed with that approach in mind.
There are four key components you’ll need to represent in the UI for your users.
It is common to create an order upon initial render for your user, and then update the details of that order as the adjustments are made by the user. You’ll need to create a function in your application that can call the create-order API and save the response.
After you create the order
you’ll get back metadata related to the collectionId
you pass in the create-order call. You can use this metadata to build the preview highlighted in the screenshot below.
After you create the order
you’ll get back metadata related to the collectionId
you pass in the create-order call. You can use this metadata to build the preview highlighted in the screenshot below.
To enable the cross-chain payments feature, you’ll need to provide an easy way for users to connect their wallet. This guide will not go into detail about how to add any specific tools, since there are a variety available and the implementation of each is unique to the tool.
However, you will want to set up your app to listen for changes to the primary connected wallet and selected network so that the order is updated automatically.
Once the user has connected their wallet they might still change the primary connected account or network. You need to listen for these changes and update the order.
Once the user has connected their wallet they might still change the primary connected account or network. You need to listen for these changes and update the order.
Note the dependency array at the end of this useEffect
watches primaryWallet
and selectedNetwork
. If any of these change your app needs to refresh the order with the new values.