Commit 47c60b63da8760c95f372732c0a08b1c7a0e29e3

Authored by 张旭
1 parent 7154e144

忽必烈送礼方法

CNLivePayCostModule/Classes/Core/CNLivePayCostModule.h
... ... @@ -37,6 +37,14 @@ NS_ASSUME_NONNULL_BEGIN
37 37 +(void)showApplePayViwWithParamDict:(NSDictionary *)paramDict
38 38 FromVC:(UIViewController *)formVC
39 39 ResultBlock:(void(^)(CNLivePayCostTypeResult resultType))resultBlock;
  40 +/// 拉起苹果支付功能(忽必烈送礼)
  41 +/// @param paramDict 参数
  42 +/// @param formVC 支付界面控制器
  43 +/// @param resultBlock 支付结果
  44 ++(void)showApplePayViwWithHBLGiftParamDict:(NSDictionary *)paramDict
  45 + FromVC:(UIViewController *)formVC
  46 + ResultBlock:(void(^)(CNLivePayCostTypeResult resultType))resultBlock;
  47 ++ (NSString *)payCost_getHBLGiftRandomOrderId;
40 48  
41 49 /// 拉起电商支付功能
42 50 /// @param paramDict 参数
... ...
CNLivePayCostModule/Classes/Core/CNLivePayCostModule.m
... ... @@ -220,6 +220,63 @@
220 220 }];
221 221 }
222 222  
  223 +/// 苹果支付生成订单(忽必烈送礼)
  224 ++ (NSString *)payCost_getHBLGiftRandomOrderId{
  225 + return [CNLivePayCostModel payCost_getRandomOrderId];
  226 +}
  227 +/// 拉起苹果支付功能(忽必烈送礼)
  228 +/// @param paramDict 参数
  229 +/// @param formVC 支付界面控制器
  230 +/// @param resultBlock 支付结果
  231 ++(void)showApplePayViwWithHBLGiftParamDict:(NSDictionary *)paramDict
  232 + FromVC:(UIViewController *)formVC
  233 + ResultBlock:(void(^)(CNLivePayCostTypeResult resultType))resultBlock
  234 +{
  235 + [CNLivePayCostModel sharePayCostModel].protocol = [NSClassFromString(@"CNLivePayCostProtocolImpl") new];
  236 +
  237 + NSString * notify_url = [paramDict stringValueForKey:@"notify_url" default:@""];
  238 + NSString * total_fee = [paramDict stringValueForKey:@"total_fee" default:@""];
  239 + NSString * body = [paramDict stringValueForKey:@"body" default:@""];
  240 + NSString * productId = [paramDict stringValueForKey:@"prdId" default:@""];
  241 + NSString * orderId = [paramDict stringValueForKey:@"orderId" default:@""];
  242 +
  243 + int moneyInt = [total_fee intValue];
  244 + if (((int)moneyInt/100)<=0) {
  245 + [QMUITips showWithText:@"付款金额不正确" inView:formVC.view hideAfterDelay:1.5f];
  246 + return;
  247 + }
  248 + NSString *appleProductId = [NSString stringWithFormat:@"%@%d",CNLiveWjjApplePayAVProductIdBase,(int)moneyInt/100];
  249 + if (((int)moneyInt/100) == 1 || ((int)moneyInt/100) == 3 || ((int)moneyInt/100) == 78){
  250 + appleProductId = [NSString stringWithFormat:@"%@new.%d",CNLiveWjjApplePayAVProductIdBase,(int)moneyInt/100];
  251 + }
  252 +
  253 + CNLivePayArg *arg = [[CNLivePayArg alloc] init];
  254 + arg.account = @"";
  255 + arg.type = CNLivePayTypeInAppPurchase;
  256 + arg.out_trade_no = orderId;//[CNLivePayCostModel payCost_getRandomOrderId];//
  257 + arg.total_fee = moneyInt;
  258 + arg.notify_url = notify_url;
  259 + arg.user_id = CNUserShareModel.uid?CNUserShareModel.uid:@"";
  260 + arg.attach = @{
  261 + @"sid":CNUserShareModel.uid?CNUserShareModel.uid:@"",
  262 + @"plat":@"i",
  263 + @"prdId":productId?productId:@""
  264 + };
  265 + arg.body = [body isNotBlank]?body:[NSString stringWithFormat:@"您购买了付费服务"];
  266 + [QMUITips showLoadingInView:formVC.view];
  267 + NSLog(@"%@,%@,%d,%@,%@,%@,%@,%@",arg.account,arg.out_trade_no,arg.total_fee,arg.notify_url,arg.user_id,arg.attach,arg.body,appleProductId);
  268 + [[CNLivePaySDK sharedCNLivePayManager] pay:arg isDebug:false productId:appleProductId completion:^(CNLivePayResult *cnlivePayResult) {
  269 + dispatch_async(dispatch_get_main_queue(), ^{
  270 + [QMUITips hideAllTipsInView:formVC.view];
  271 + if ([cnlivePayResult.channelBackCode isEqualToString:@"0"]) {
  272 + if (resultBlock) resultBlock(CNLivePayCostTypeResultSucc);
  273 + } else {
  274 + [QMUITips showWithText:cnlivePayResult.backDescription inView:formVC.view hideAfterDelay:1.5f];
  275 + }
  276 + });
  277 + }];
  278 +}
  279 +
223 280 /// 拉起电商支付功能
224 281 /// @param paramDict 参数
225 282 /// @param payType 支付界面控制器
... ...
README.md
1 1 # CNLivePayCostModule
2 2  
  3 +
  4 +本地验证
  5 +pod lib lint --allow-warnings --no-clean --use-libraries --skip-import-validation --sources=http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git,https://github.com/CocoaPods/Specs.git,http://bj.gitlab.cnlive.com/DSIOSTeam/DSSpecRepos.git --verbose
  6 +本地+远程验证
  7 +pod spec lint --allow-warnings --no-clean --use-libraries --skip-import-validation --sources=http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git,https://github.com/CocoaPods/Specs.git,http://bj.gitlab.cnlive.com/DSIOSTeam/DSSpecRepos.git --verbose
  8 +推送
  9 +pod repo push CNLiveRepos CNLivePayCostModule.podspec --allow-warnings --use-libraries --skip-import-validation --sources=http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git,https://github.com/CocoaPods/Specs.git,http://bj.gitlab.cnlive.com/DSIOSTeam/DSSpecRepos.git --verbose
  10 +
  11 +
  12 +
  13 +
3 14 [![CI Status](https://img.shields.io/travis/woshiliushiyu/CNLivePayCostModule.svg?style=flat)](https://travis-ci.org/woshiliushiyu/CNLivePayCostModule)
4 15 [![Version](https://img.shields.io/cocoapods/v/CNLivePayCostModule.svg?style=flat)](https://cocoapods.org/pods/CNLivePayCostModule)
5 16 [![License](https://img.shields.io/cocoapods/l/CNLivePayCostModule.svg?style=flat)](https://cocoapods.org/pods/CNLivePayCostModule)
... ...