Example #1
0
void CCSoomlaStore::buyMarketItem(const std::string& productId,
                                  const std::string& payload, CCError** error) {
    CCPurchasableVirtualItem* item =
        CCStoreInfo::sharedStoreInfo()->getPurchasableItemWithProductId(
            productId.c_str(), error);
    if (item == nullptr) {
        return;
    }

    // simulate onMarketPurchaseStarted event
    CCStoreEventDispatcher::getInstance()->onMarketPurchaseStarted(item);

    // in the editor we just give the item... no real market.
    // simulate onMarketPurchase event
    CCStoreEventDispatcher::getInstance()->onMarketPurchase(
        item, payload, ValueMapNull);

    item->give(1);

    // complete purchasing routine
    CCStoreEventDispatcher::getInstance()->onItemPurchased(
        item, payload);
}