// // IAPProcess.hpp // TileManor // // Created by 徐炼新 on 2024/1/18. // #ifndef IAPProcess_hpp #define IAPProcess_hpp #include "cocos2d.h" #include "IAPConf.hpp" #include "IAP/IAPDelegate.h" #include "RUQCoreLayer.h" class IAPProcess : cocos2d::Ref, public iap::IAPDelegate {//}, public MapUIModule { public: static IAPProcess* getInstance(); void doWhileLaunched(); // 用户购买了某个商品 void buy(const GoodsInfo& gi, int placementId, std::function cbIfSuccess, std::function cbIfFail); // 注册一个商品 void registerAProduct(const std::string& id); // IAP virtual void onProductInfoSyncFinished() override; virtual void onProductPurchaseSuccess(const std::string &productId) override; virtual void onProductPurchaseFail(const std::string &productId, int errorCode, const std::string &errorMsg) override; virtual void syncPurchasedProducts(const std::vector& productIds) override; // UIModule virtual bool needDoWhileMapIsReady(bool& bSkippable) const; virtual void doWhileMapIsReady(std::function cb); private: IAPProcess(); virtual ~IAPProcess(); /// 显示购买成功界面 void showIAPSuccess(const GoodsInfo& gi); void init(); private: static IAPProcess* _instance; std::function _cbIfSuccess = nullptr; std::function _cbIfFail = nullptr; redutils::QCoreLayer* _efxLoading = nullptr; int _placementId = 0; bool _bLaunching = false; std::list _productsIDs; }; #endif /* IAPProcess_hpp */