IAPDelegate.h 1.3 KB

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