Muniraj Sunderavel wrote:
Thanks for the reply.
Soomla is very detailed and I dont want a detailed store like soomla.
Simple in-app purchase is required.
I tried both your games (ios and android) and need similar in-app purchases.
It will be very helpful of you.
Thank you
This is what i use in my gamesettingssingleton, the code is for setting up the billing (check for outstanding purchases etc)
`static void loadSKUItemsHandler(int error)
{
if (error == GoogleBilling::LOADSKUITEMS_ITEMS_YES)
{
CCLog(“Billing: Inventory loaded”);
GameSettingsSingleton::_billing = true;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
CCLog(“Billing: Check if full version is purchased”);
if (GoogleBilling::Billing::isPurchased(“asteroidinvaders_full_version”))
{
CCLog(“Billing: full version!”);
GoogleBilling::Google::disableAds();
GameSettingsSingleton::isFullGame = true;
}
else
{
CCLog(“Billing: Adsupported version”);
GoogleBilling::Google::enableAds();
GameSettingsSingleton::isFullGame = false;
}
// Check if there are outstanding purchases for extra time
CCLog("Billing: Check if 60 seconds of time was purchased");
if (GoogleBilling::Billing::isPurchased("60seconds"))
{
CCLog("Billing: consume the extra time item!");
GameSettingsSingleton::extraTimePurchased = 60;
}
else
{
CCLog("Billing: no outstanding purchases of extra time");
}
#endif
}
else if (error == GoogleBilling::LOADSKUITEMS_ITEMS_NO)
{
GameSettingsSingleton::_billing = false;
CCLog(“No items, Billing Unavailable”);
}
if (GameSettingsSingleton::isFullGame)
{
GoogleBilling::Google::disableAds();
}
}
static void BillingInitHandler(int error)
{
if (error == GoogleBilling::INIT_BILLING_YES)
{
CCLog(“Billing initialised”);
GoogleBilling::Billing::loadSKUItems(loadSKUItemsHandler);
}
else if (error == GoogleBilling::INIT_BILLING_NO)
{
CCLog(“Billing not availalble!”);
}
}
void GameSettingsSingleton::initBilling()
{
CCLog(“BillingInit”);
_billing = false;
GoogleBilling::Billing::init(BillingInitHandler);
}
`
For buying things i use:
`static void fullversionPurchased(int result)
{
Shop::me->hideMessage();
if (result == GoogleBilling::PURCHASE_ALREADY_PURCHASED)
{
Shop::me->textLayer->fireFloatingMessage(“Already purchased!”, 2.0f, 0.5f, GameSettingsSingleton::relPos(50, 50), ccLIGHTGREY);
CCLog(“Shop:Item already purchased!”);
GameSettingsSingleton::isFullGame = true;
GoogleBilling::Google::disableAds();
GameSettingsSingleton::GetInstance()->saveSettings();
}
else if (result == GoogleBilling::PURCHASE_FAIL)
{
Shop::me->textLayer->fireFloatingMessage(“Failed/Canceled”, 2.0f, 0.5f, GameSettingsSingleton::relPos(50, 50), ccLIGHTGREY);
CCLog(“Shop:Purchase failed or canceled!”);
GameSettingsSingleton::isFullGame = false;
GoogleBilling::Google::enableAds();
GameSettingsSingleton::GetInstance()->saveSettings();
}
else if (result == GoogleBilling::PURCHASE_SUCCESS)
{
Shop::me->textLayer->fireFloatingMessage(“Thank You!”, 2.0f, 0.5f, GameSettingsSingleton::relPos(50, 50), ccLIGHTGREY);
CCLog(“Shop: Purchasing done”);
GameSettingsSingleton::isFullGame = true;
GoogleBilling::Google::disableAds();
GameSettingsSingleton::GetInstance()->saveSettings();
}
}
static void extraTimePurchased(int result)
{
Shop::me->hideMessage();
if (result == GoogleBilling::PURCHASE_ALREADY_PURCHASED)
{
Shop::me->textLayer->fireFloatingMessage(“Already purchased!”, 2.0f, 0.5f, GameSettingsSingleton::relPos(50, 50), ccLIGHTGREY);
CCLog(“Shop:Item already purchased!”);
GameSettingsSingleton::extraTimePurchased = GameSettingsSingleton::extraTimePurchased + 60;
GameSettingsSingleton::GetInstance()->saveSettings();
}
else if (result == GoogleBilling::PURCHASE_FAIL)
{
Shop::me->textLayer->fireFloatingMessage(“Failed/Canceled!”, 2.0f, 0.5f, GameSettingsSingleton::relPos(50, 50), ccLIGHTGREY);
CCLog(“Shop:Purchase failed or canceled!”);
GameSettingsSingleton::extraTimePurchased = 0;
GameSettingsSingleton::GetInstance()->saveSettings();
}
else if (result == GoogleBilling::PURCHASE_SUCCESS)
{
Shop::me->textLayer->fireFloatingMessage(“Thank You!”, 2.0f, 0.5f, GameSettingsSingleton::relPos(50, 50), ccLIGHTGREY);
CCLog(“Shop: Purchasing done”);
GameSettingsSingleton::extraTimePurchased = GameSettingsSingleton::extraTimePurchased + 60;
GameSettingsSingleton::GetInstance()->saveSettings();
}
}
void Shop::buyRemoveAdsCallback(cocos2d::CCObject *pSender)
{
if (GameSettingsSingleton::_billing)
{
CCLog(“LevelTwo: Purchasing full version”);
GoogleBilling::Billing::purchase(“asteroidinvaders_full_version”, 10001,fullversionPurchased);
//GoogleBilling::Billing::purchase(“android.test.purchased”, 10001,fullversionPurchased);
message = textLayer->fireFloatingMessage(“Please wait…”, -1, 0.5f, GameSettingsSingleton::relPos(50, 50), ccLIGHTGREY);
}
else
{
CCLog(“LevelTwo: Billing unavailable”);
message = textLayer->fireFloatingMessage(“Not available…”, 2.0f, 0.5f, GameSettingsSingleton::relPos(50, 50), ccLIGHTGREY);
}
}
void Shop::buy60secondsCallback(cocos2d::CCObject *pSender)
{
Shop::me->hideMessage();
if (GameSettingsSingleton::_billing)
{
CCLog(“LevelTwo: Purchasing 60 seconds”);
GoogleBilling::Billing::purchase(“60seconds”, 10001,extraTimePurchased);
//GoogleBilling::Billing::purchase(“android.test.purchased”, 10001,fullversionPurchased);
message = textLayer->fireFloatingMessage(“Please wait…”, -1, 0.5f, GameSettingsSingleton::relPos(50, 50), ccLIGHTGREY);
}
else
{
CCLog(“LevelTwo: Billing unavailable”);
message = textLayer->fireFloatingMessage(“Not available…”, 2.0f, 0.5f, GameSettingsSingleton::relPos(50, 50), ccLIGHTGREY);
}
}
void Shop::restorePurchasesCallback(cocos2d::CCObject *pSender)
{
if (GameSettingsSingleton::_billing)
{
message = textLayer->fireFloatingMessage("Please wait..", 3.0f, 0.5f, GameSettingsSingleton::relPos(50, 50), ccLIGHTGREY);
CCLog("LevelTwo: restoring in-app purchases");
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
GoogleBilling::Billing::purchase("RESTORE", 1, fullversionPurchased);
#endif
}
else
{
message = textLayer->fireFloatingMessage("Not available!", 2.0, 0.5f, GameSettingsSingleton::relPos(50, 50), ccLIGHTGREY);
CCLog("LevelTwo: Billing unavailable");
}
}`
I hope this helps?