1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- //
- // 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<void()> cbIfSuccess, std::function<void()> 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<std::string>& productIds) override;
-
- // UIModule
- virtual bool needDoWhileMapIsReady(bool& bSkippable) const;
- virtual void doWhileMapIsReady(std::function<void()> cb);
-
- private:
- IAPProcess();
- virtual ~IAPProcess();
- /// 显示购买成功界面
- void showIAPSuccess(const GoodsInfo& gi);
- void init();
-
- private:
- static IAPProcess* _instance;
-
- std::function<void()> _cbIfSuccess = nullptr;
- std::function<void()> _cbIfFail = nullptr;
- redutils::QCoreLayer* _efxLoading = nullptr;
-
- int _placementId = 0;
- bool _bLaunching = false;
- std::list<std::string> _productsIDs;
- };
- #endif /* IAPProcess_hpp */
|