To use Billing API and coomunicate with PC SDK, the game has to re-define the callback functions of StovePCCallback
struct StovePCCallback
{
void(*OnError)(const StovePCError error);
void(*OnInitComplete)();
void(*OnToken)(const StovePCToken token);
void(*OnUser)(const StovePCUser user);
void(*OnOwnership)(int size, StovePCOwnership* ownership);
// Callback called when FetchShopCategories processing is complete
void(*OnFetchShopCategories) OnFetchShopCategories;
// Callback called when FetchProducts processing is complete
void(*OnFetchProducts) OnFetchProducts;
// Callback called when StartPurchase processing is complete
void(*OnStartPurchase) OnStartPurchase;
// Callback called when ConfirmPurchase processing is complete
void(*OnConfirmPurchase) OnConfirmPurchase;
// Callback called when FetchInventory processing is complete
void(*OnFetchInventory) OnFetchInventory;
}
C++
복사
// Create StovePCCallback structure instance
StovePCCallback callback;
// Initialize all function pointers to NULL
memset(&callback, 0, sizeof(StovePCCallback));
// Link implemented function pointers
callback.OnError = OnMyErrorCallback; /* Callback function defined globally */
callback.OnInitComplete = OnMyInitCompleteCallback; /* Callback function defined globally */
callback.OnToken = OnMyTokenCallback; /* Callback function defined globally */
callback.OnUser = OnMyUserInfoCallback; /* Callback function defined globally */
callback.OnOwnership = OnMyOwnershipCallback; /* Callback function defined globally */
// billing service
OnFetchShopCategories = OnMyFetchShopCategories; /* Callback function defined globally */
OnFetchProducts = OnMyFetchProducts; /* Callback function defined globally */
OnStartPurchase = OnMyStartPurchase; /* Callback function defined globally */
OnConfirmPurchase = OnMyConfirmPurchase; /* Callback function defined globally */
OnFetchInventory = OnMyFetchInventory; /* Callback function defined globally */
C++
복사
You are not required to implement the OnFetchShopCategories, OnFetchProducts, OnStartPurchase, OnConfirmPurchase, OnFetchInventory callback at the start of the game - only implement it when needed from the game.
However, for the In-Game purchase to function, all 5 callbacks must be implemented and connected.