Skip to main content

Task 1: WordPress site

💡Primary Sales Widget Enablement
The Primary Sales Widget is currently in its closed Beta release phase and we anticipate making it available publicly soon.

To gain access to the Primary Sales Widget, please complete the following form and our team will be in contact.

Create a WordPress site in Pressable or another WordPress hosting provider. After having WordPress up and running, it’s time to install a few plugins and do some basic configuration.

Task 2: Plugins to install

In Wordpress, head to Plugins -> Add New Plugin and use the search field to install the following:

  • WooCommerce
  • WPGraphQL
  • Advanced Custom Fields (ACF)
  • WPGraphQL Smart Cache

Some plugins need to be uploaded as zip files by clicking Upload Plugin:

Task 3: WordPress configuration

  • Enable stock management under WooCommerce > Settings > Products > Inventory (tab) > Enable Stock Management
  • Stores need an active banner so sales can happen. It can be created from Primary Sales -> Banner -> Add New
  • Under Primary Sales -> Settings you can configure the plugin, here is the list of the params and usage:
ParameterDescription
Storefront URLThe URL where the store will be hosted.
Discount groups enabledIf the store will enabled discounts for groups of Wallet addresses, you define the groups under Primary Sales -> Group discount.
Allowlist enabled?If the store will only accept certain wallet addresses to sale products to.
Addresses in allowlistThis is the currency used to define the price of the items.
Currency used for product pricingThis is the currency used to define the price of the items.
Number of decimalsThe number of decimals used in the pricing calculations, this is specially important for items priced in Ether (ETH) or BTC because will usually have many decimals.
Allowed currenciesThis are the currencies accepted as payment (settlment currencies) and if they need to be shown in the storefront (returned by graphQL API).
Immutable API environmentThe environment where WooCommerce will point the API towards.
Primary Sales API Env IDThe environment id created in Immutable Hub and assigned to this project.
Token ID service URLOur plugin needs the token ID's that will be minted, this is a process we call Token reservation. Our plugin will ask the game backend to generate token ids and these token ids should have metadata created/available

Request Example
{
 "products":[
   {"product_id":"game-pack-001","quantity":2}
  ]
}

Response Example
{
 "result":[
  {"product_id":"game-pack-001","token_id":"2074963979115788455251527639386254350"},
  {"product_id":"game-pack-001","token_id":"2074963979115788455251527639386254351"}
 ]
}
Token ID service AuthThe API Key of the API defined as Token ID service URL, we use Authorization as the header.
Order confirmation WebhookIf your game backend needs to be notified when purchases are completed to perform certain action, you can configure your API endpoint in this section. Otherwise you can leave it blank.
Order confirmation Auth KeyThe API Key of the API defined as Order confirmation Webhook, we use Authorization as the header.
Maintenance mode enabled?If the store is in maintenance.
Maintenance mode pageThe page to show in case of maintenance.

Task 4: API Authentication

The plugin’s endpoints are protected using the basic WordPress REST API application passwords. That can be configured under the Users tab, by generating an application key for an admin user.

Clicking on Add New Application Password will show you the generated password. Copy that, then base64 encode your username and password to get the authentication headers that will be used by the Primary Sale API’s config.

Quick example of how to get the authentication header using node on the CLI:

node -e 'console.log("Authorization: Basic " + Buffer.from("USERNAME:PASSWORD").toString("base64"))'

Task 5: Copy the API URLs

Your WooCommerce site can now be configured in the Primary Sales Widget. Because you installed the IMX Primary Sales plugin, automatically the following API endpoints become available:

  • Sale authorization: https://<my_store_url>/wp-json/wc/v3/primary-sales/order/authorise
  • Quotes: https://<my_store_url>/wp-json/wc/v3/primary-sales/order/quote
  • Transaction confirmation: https://<my_store_url>/wp-json/wc/v3/primary-sales/order/confirm
  • Expired orders: https://<my_store_url>/wp-json/wc/v3/primary-sales/order/expire

IMX Whitepaper IMX Tokenomics Block Explorer Careers Contact Us