XYPayAPIManager.m 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // XYPayAPIManager.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2019/12/23.
  6. // Copyright © 2019 翟玉磊. All rights reserved.
  7. //
  8. #import "XYPayAPIManager.h"
  9. /// 获取金币充值项目
  10. static NSString * const RECHARGE_GET_COIN_RECHARGE_ITEMS = @"api-app/v1/recharge/getCoinRechargeItems";
  11. /// 创建金币充值订单
  12. static NSString * const RECHARGE_ADD_COIN_RECHARGE_ORDER = @"api-app/v1/recharge/addCoinRechargeOrder";
  13. /// 创建支付订单
  14. static NSString * const PAY_ADD_PAY_ORDER = @"api-app/v1/pay/addPayOrder";
  15. /// 创建苹果支付订单
  16. static NSString * const PAY_ADD_APPLE_PAY_ORDER = @"api-app/v1/pay/addApplePayOrder";
  17. /// 获取支付状态
  18. static NSString * const PAY_GET_PAY_STATUS = @"api-app/v1/pay/getPayStatus";
  19. /// 加入主播粉丝团
  20. static NSString * const PAY_FOR_JOIN_FANSTEAM = @"api-app/v1/pay/forJoinFansTeam";
  21. @implementation XYPayAPIManager
  22. /// 获取金币充值项目
  23. /// @param successHandler 请求成功
  24. /// @param failureHandler 请求失败
  25. - (NSNumber *)getCoinRechargeItemsSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  26. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  27. config.urlPath = [RECHARGE_GET_COIN_RECHARGE_ITEMS copy];
  28. config.instructions = @"获取金币充值项目";
  29. config.requestType = ZYLNetworkRequestTypeGet;
  30. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  31. }
  32. /// 创建金币充值订单
  33. /// @param itemId 要充值的项目Id
  34. /// @param successHandler 请求成功
  35. /// @param failureHandler 请求失败
  36. - (NSNumber *)addCoinRechargeOrderItemId:(NSString *)itemId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  37. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  38. config.urlPath = [RECHARGE_ADD_COIN_RECHARGE_ORDER copy];
  39. config.instructions = @"创建金币充值订单";
  40. config.requestParameters = @{@"itemId":itemId};
  41. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  42. }
  43. /// 创建支付订单
  44. /// @param orderId 订单id
  45. /// @param successHandler 请求成功
  46. /// @param failureHandler 请求失败
  47. - (NSNumber *)addPayOrderWithOrderId:(NSString *)orderId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  48. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  49. config.urlPath = [PAY_ADD_PAY_ORDER copy];
  50. config.instructions = @"创建支付订单";
  51. config.requestParameters = @{@"orderId":orderId};
  52. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  53. }
  54. /// 效验苹果支付订单
  55. /// @param orderId 订单id
  56. /// @param successHandler 请求成功
  57. /// @param failureHandler 请求失败
  58. - (NSNumber *)addPayOrderWithOrderId:(NSString *)orderId transactionId:(NSString *)transactionId receiptData:(NSString *)receiptData successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  59. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  60. config.urlPath = [PAY_ADD_APPLE_PAY_ORDER copy];
  61. config.instructions = @"创建苹果支付订单";
  62. config.requestParameters = @{@"orderId":orderId, @"transactionId":transactionId, @"receiptData":receiptData};
  63. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  64. }
  65. /// 获取支付状态
  66. /// @param orderId 获取订单状态
  67. /// @param successHandler 请求成功
  68. /// @param failureHandler 请求失败
  69. - (NSNumber *)getPayStatusWithOrderId:(NSString *)orderId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  70. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  71. config.urlPath = [PAY_GET_PAY_STATUS copy];
  72. config.instructions = @"获取支付状态";
  73. config.requestType = ZYLNetworkRequestTypeGet;
  74. config.requestParameters = @{@"orderId":orderId};
  75. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  76. }
  77. /// 加入主播粉丝团
  78. /// @param anchorUserId 主播id
  79. /// @param successHandler 请求成功
  80. /// @param failureHandler 请求失败
  81. - (NSNumber *)forJoinFansTeamWithAnchorUserId:(NSString *)anchorUserId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  82. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  83. config.urlPath = [PAY_FOR_JOIN_FANSTEAM copy];
  84. config.instructions = @"加入主播粉丝团";
  85. config.requestParameters = @{@"anchorUserId":anchorUserId};
  86. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  87. }
  88. @end