IAPReceiptModel.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. //
  2. // IAPReceiptModel.h
  3. // PDF Reader Pro
  4. //
  5. // Created by User-Tangchao on 2025/1/1.
  6. //
  7. #import <Foundation/Foundation.h>
  8. NS_ASSUME_NONNULL_BEGIN
  9. @interface IAPReceiptInfoModel: NSObject
  10. @property (nonatomic, copy) NSString *product_id;
  11. @property (nonatomic, copy) NSString *purchase_date;
  12. @property (nonatomic, copy) NSString *purchase_date_ms;
  13. @property (nonatomic, copy) NSString *purchase_date_pst;
  14. @property (nonatomic, copy) NSString *expires_date;
  15. @property (nonatomic, copy) NSString *expires_date_ms;
  16. @property (nonatomic, copy) NSString *expires_date_pst;
  17. @property (nonatomic, copy) NSString *original_purchase_date;
  18. @property (nonatomic, copy) NSString *original_purchase_date_ms;
  19. @property (nonatomic, copy) NSString *original_purchase_date_pst;
  20. @property (nonatomic, copy) NSString *original_transaction_id;
  21. @property (nonatomic, copy) NSString *transaction_id;
  22. // 订阅群组标识
  23. @property (nonatomic, copy) NSString *subscription_group_identifier;
  24. // PURCHASED 购买者本人‌
  25. // FAMILY_SHARED‌ 家庭成员受益 [家庭共享订阅]
  26. @property (nonatomic, copy) NSString *in_app_ownership_type;
  27. //  如果收据中之前的订阅期具有is_trial_period或is_in_intro_offer_period键的“true”值,则用户没有资格在该订阅组内获得免费试用或介绍性价格。
  28. // 享受推介优惠期间 true 处于享受推介优惠中
  29. @property (nonatomic, assign) BOOL is_in_intro_offer_period;
  30. // 订阅试用期 true 处于免费试用期
  31. @property (nonatomic, assign) BOOL is_trial_period;
  32. @property (nonatomic, assign) NSInteger quantity;
  33. // 促销优惠的优惠卷ID
  34. @property (nonatomic, copy) NSString *promotional_offer_id;
  35. // 网上订单行项目ID
  36. // 用于识别订阅购买的主密钥。
  37. // 此值是一个唯一ID,用于识别跨设备的购买事件,包括订阅续订购买事件。
  38. @property (nonatomic, copy) NSString *web_order_line_item_id;
  39. - (instancetype)initWithDict:(NSDictionary *)dict;
  40. + (instancetype)modelWithDict:(NSDictionary *)dict;
  41. @end
  42. @interface IAPPendingRenewalInfoModel: NSObject
  43. // 续订的产品 [有切换套餐时 是切换后的产品]
  44. @property (nonatomic, copy) NSString *auto_renew_product_id;
  45. // 订阅自动续订状态 1 订阅将在当前订阅期结束时续订 0 客户已关闭订阅的自动续订
  46. @property (nonatomic, assign) NSInteger auto_renew_status;
  47. // 订阅到期的原因 1 客户取消 2 账单错误 eg 客户的支付信息无效 3 客户不同意自动续订订阅价格增加 导致订阅到期 4 在续订时产品不可购买 5 其他原因
  48. @property (nonatomic, assign) NSInteger expiration_intent;
  49. // 订阅重试标识 1 AppStore 在尝试续订 0 已停止尝试续订
  50. @property (nonatomic, assign) NSInteger is_in_billing_retry_period;
  51. // 切换前的产品 [有切换套餐后 会与 auto_renew_product_id 不一致]
  52. @property (nonatomic, copy) NSString *product_id;
  53. - (instancetype)initWithDict:(NSDictionary *)dict;
  54. + (instancetype)modelWithDict:(NSDictionary *)dict;
  55. @end
  56. @interface IAPInAppReceiptModel: NSObject
  57. // App ID
  58. @property (nonatomic, assign) NSInteger adam_id;
  59. // 应用程序项目ID
  60. // 如果您的服务器支持多个应用程序,您可以使用此值来区分它们。
  61. // Mac应用程序不提供此字段。
  62. @property (nonatomic, assign) NSInteger app_item_id;
  63. @property (nonatomic, copy) NSString *application_version;
  64. @property (nonatomic, copy) NSString *bundle_id;
  65. @property (nonatomic, assign) NSInteger download_id;
  66. @property (nonatomic, assign) NSInteger version_external_identifier;
  67. @property (nonatomic, copy) NSString *original_application_version;
  68. @property (nonatomic, copy) NSString *original_purchase_date;
  69. // 时间戳
  70. @property (nonatomic, copy) NSString *original_purchase_date_ms;
  71. @property (nonatomic, copy) NSString *original_purchase_date_pst;
  72. @property (nonatomic, copy) NSString *receipt_creation_date;
  73. @property (nonatomic, copy) NSString *receipt_creation_date_ms;
  74. @property (nonatomic, copy) NSString *receipt_creation_date_pst;
  75. // 凭证类型 沙盒 ProductionSandbox 正式
  76. @property (nonatomic, copy) NSString *receipt_type;
  77. @property (nonatomic, copy) NSString *request_date;
  78. @property (nonatomic, copy) NSString *request_date_ms;
  79. @property (nonatomic, copy) NSString *request_date_pst;
  80. @property (nonatomic, strong) NSArray *in_app;
  81. - (instancetype)initWithDict:(NSDictionary *)dict;
  82. + (instancetype)modelWithDict:(NSDictionary *)dict;
  83. @property (nonatomic, strong) NSArray <IAPReceiptInfoModel *> *inAppModels;
  84. @end
  85. @interface IAPReceiptModel : NSObject
  86. // Sandbox
  87. @property (nonatomic, copy) NSString *environment;
  88. @property (nonatomic, assign) BOOL is_sandbox;
  89. @property (nonatomic, copy) NSString *latest_receipt;
  90. @property (nonatomic, strong) NSArray *latest_receipt_info;
  91. // 下个续费周期订阅的产品
  92. @property (nonatomic, strong) NSArray *pending_renewal_info;
  93. @property (nonatomic, strong) NSDictionary *receipt;
  94. // 0 检验成果
  95. @property (nonatomic, assign) NSInteger status;
  96. - (instancetype)initWithDict:(NSDictionary *)dict;
  97. + (instancetype)modelWithDict:(NSDictionary *)dict;
  98. @property (nonatomic, strong) IAPInAppReceiptModel *receiptModel;
  99. @property (nonatomic, strong) NSArray <IAPReceiptInfoModel *> *latestReceiptInfoModels;
  100. @property (nonatomic, strong) NSArray <IAPPendingRenewalInfoModel *> *pendingRenewalInfoModels;
  101. @end
  102. @interface IAPReceiptTool: NSObject
  103. // 是否在免费试用中
  104. + (BOOL)isFreeTrailingWithModel:(IAPReceiptModel * _Nullable)model withProductId:(NSString * _Nullable)productId;
  105. // 是否为新用户
  106. + (BOOL)isNewUserWithModel:(IAPReceiptModel * _Nullable)model withGroupIdentifier:(NSString * _Nullable)groupIdentifier;
  107. // 是否有享受过 推介优惠 [免费试用]
  108. + (BOOL)hasFreeTrialWithModel:(IAPReceiptModel * _Nullable)model withGroupIdentifier:(NSString * _Nullable)groupIdentifier;
  109. // 是否有享受过 推介优惠
  110. + (BOOL)hasIntroOfferWithModel:(IAPReceiptModel * _Nullable)model withGroupIdentifier:(NSString * _Nullable)groupIdentifier;
  111. // 获取订阅群组的所有票据
  112. + (NSArray <IAPReceiptInfoModel *> *)fetchReceiptsWithModel:(IAPReceiptModel * _Nullable)model withGroupIdentifier:(NSString * _Nullable)groupIdentifier;
  113. // 获取对应商品的最后的票据
  114. + (IAPReceiptInfoModel * _Nullable)fetchProductLastestReceiptsWithModel:(IAPReceiptModel * _Nullable)model withProductId:(NSString * _Nullable)productId;
  115. // 获取对应商品的所有票据
  116. + (NSArray <IAPReceiptInfoModel *> *)fetchProductReceiptsWithModel:(IAPReceiptModel * _Nullable)model withProductId:(NSString * _Nullable)productId;
  117. // 获取所有的票据
  118. + (NSArray <IAPReceiptInfoModel *> *)fetchReceiptsWithModel:(IAPReceiptModel * _Nullable)model;
  119. @end
  120. /** status
  121. 21000 未使用HTTPPOST请求方式向AppStore发送请求
  122. 21001 此状态代码不再由AppStore发送
  123. 21002 该receipt-data属性中的数据格式错误或丢失
  124. 21003 收据无法认证
  125. 21004 提供的共享密码与账号的文件共享密码不匹配
  126. 21005 收据服务器当前不可用
  127. 21006 该收据有效,但订阅已过期。当次状态代码返回到你的服务器时,收据数据也会被解码并作为响应的一部分返回。仅针对自动续订的iOS6样式的交易收据返回
  128. 21007 该收据来自测试环境 但已发送到生产环境以进行验证
  129. 21008 该收据来自生产环境 但是已发送到测试环境以进行验证
  130. 21009 内部数据访问错误 稍后再试
  131. 21010 找不到或删除了该用户账号
  132. */
  133. NS_ASSUME_NONNULL_END