// // IAPDelegate.h // libcocos2d Mac // // Created by ZhengSong on 2021/5/6. // #ifndef IAPDelegate_h #define IAPDelegate_h #include #include #include namespace iap { enum IAPErrorCode { UserCancel = 1, // 用户取消了购买流程 BillingError = 2, // 支付失败 Pending = 3, // 付款未完成(挂起,安卓慢速卡) NotReady = 4, // 内购环境未准备好 FlowStartError = 5, // 购买流程启动失败 ProductNotExist = 6, // 要购买的产品不存在 Unknown = 999, // 未知错误" }; class IAPDelegate { public: virtual ~IAPDelegate() {}; // 商品信息同步完成,可以获取商品的价格等信息了 virtual void onProductInfoSyncFinished() {}; // 购买完成, 可以发放商品了 virtual void onProductPurchaseSuccess(const std::string &productId) = 0; // 购买失败 virtual void onProductPurchaseFail(const std::string &productId, int errorCode, const std::string &errorMsg) {}; // 历史购买记录商品同步(少数项目用消耗来购买非消耗,需要同步一下数据) virtual void syncPurchasedProducts(const std::vector& productIds) {}; }; }; // end of namespace iap #endif /* IAPDelegate_h */