Store API Integration - GameDistribution/GD-HTML5 GitHub Wiki

🛒 GameDistribution HTML5 SDK – Store API Integration

GameDistribution HTML5 SDK now includes powerful Store API features. This guide explains how to open the store UI, retrieve virtual products and currencies, manage the cart and inventory, and handle user authentication using the gdsdk.executeStoreAction() method.


📘 Table of Contents


🧩 UI Control

// Open the store UI
gdsdk.executeStoreAction({ action: 'ui.open' });

// Close the store UI
gdsdk.executeStoreAction({ action: 'ui.close' });



## 📦 Fetch Store Data

// Get virtual items
const items = await gdsdk.executeStoreAction({ action: 'api.items' });

// Get bundles
const bundles = await gdsdk.executeStoreAction({ action: 'api.bundles' });

// Get virtual currencies
const currencies = await gdsdk.executeStoreAction({ action: 'api.virtualCurrencies' });

// Get currency packages
const currencyPackages = await gdsdk.executeStoreAction({ action: 'api.virtualCurrencyPackages' });




## 🎒 Inventory Management

// Get inventory items
const inventoryItems = await gdsdk.executeStoreAction({ action: 'api.inventoryItems' });

// Get inventory currencies
const inventoryCurrencies = await gdsdk.executeStoreAction({ action: 'api.inventoryCurrencies' });




## 🛍️ Cart Operations

// Add product to cart
await gdsdk.executeStoreAction({
  action: 'api.addToCart',
  payload: { sku: 'your-sku', quantity: 1 }
});

// Remove product from cart
await gdsdk.executeStoreAction({
  action: 'api.removeFromCart',
  payload: { sku: 'your-sku' }
});

// Update item quantity
await gdsdk.executeStoreAction({
  action: 'api.updateCartItem',
  payload: { sku: 'your-sku', quantity: 3 }
});

// Get current cart contents
const cart = await gdsdk.executeStoreAction({ action: 'api.getCurrentCart' });

// Clear cart
await gdsdk.executeStoreAction({ action: 'api.clearCart' });

// Purchase cart
await gdsdk.executeStoreAction({ action: 'api.buyCart' });




## 💸 Product Purchase & Consumption

// Buy a single product
await gdsdk.executeStoreAction({
  action: 'api.buyProduct',
  payload: { sku: 'your-sku', quantity: 1 }
});

// Consume an item from inventory
await gdsdk.executeStoreAction({
  action: 'api.consume',
  payload: { sku: 'your-sku', quantity: 1 }
});




## 🔐 User Authentication

// Get login info
const loginInfo = await gdsdk.executeStoreAction({ action: 'api.loginInfo' });

// Check if user is logged in
const isLoggedIn = await gdsdk.executeStoreAction({ action: 'api.isLoggedIn' });

// Login
await gdsdk.executeStoreAction({ action: 'api.login' });

// Logout
await gdsdk.executeStoreAction({ action: 'api.logout' });