Commit ea59aec8a718ffe79bdca157aaef06bef5673cde
1 parent
dfc22a0f
0.0.4
Showing
7 changed files
with
44 additions
and
18 deletions
CNLivePayCostModule.podspec
CNLivePayCostModule/Classes/Core/CNLivePayCostHeader.h
| ... | ... | @@ -42,6 +42,8 @@ typedef enum { |
| 42 | 42 | CNLivePayCostThreePayTypeScren = 2, //扫码支付 |
| 43 | 43 | CNLivePayCostThreePayTypeTicke = 4, //门票支付 |
| 44 | 44 | CNLivePayCostThreePayTypeSHSop = 5, //上海电商支付(自定义回调地址属性) |
| 45 | + CNLivePayCostThreePayTypeHTML = 6, //网页支付 | |
| 46 | + CNLivePayCostThreePayTypeShop = 7, //电商支付(传参为全部自定义的) | |
| 45 | 47 | } CNLivePayCostThreePayType; |
| 46 | 48 | |
| 47 | 49 | ... | ... |
CNLivePayCostModule/Classes/Core/CNLivePayCostModule.m
| ... | ... | @@ -220,7 +220,7 @@ |
| 220 | 220 | |
| 221 | 221 | NSString * p = [NSString stringWithFormat:@"%d",(NSInteger)([price floatValue]*100)]; |
| 222 | 222 | |
| 223 | - [CNLivePayCostNetwork requestWithUMSPayForPrePayWithOrderId:orderId Body:body Price:p CouponFee:couponFee BalanceFee:balanceFee NotifyUrl:notifyUrl Type:payType FrmId:@"debug" PassWord:password CompleterBlcok:^(NSInteger statue) { | |
| 223 | + [CNLivePayCostNetwork requestWithUMSPayForPrePayWithOrderId:orderId Body:body Price:p CouponFee:couponFee BalanceFee:balanceFee NotifyUrl:notifyUrl Type:payType ThreePayType:CNLivePayCostThreePayTypeShop FrmId:@"debug" PassWord:password CompleterBlcok:^(NSInteger statue) { | |
| 224 | 224 | if (resultBlock) { |
| 225 | 225 | if (statue == 0) resultBlock(statue == 0?CNLivePayCostTypeResultSucc:CNLivePayCostTypeResultFail); |
| 226 | 226 | } | ... | ... |
CNLivePayCostModule/Classes/Core/CNLivePayCostNetwork.h
| ... | ... | @@ -30,6 +30,7 @@ NS_ASSUME_NONNULL_BEGIN |
| 30 | 30 | /// @param balance_fee 余额金额 |
| 31 | 31 | /// @param notify_url 服务端回调地址 |
| 32 | 32 | /// @param type 支付方式 3:支付宝,4:余额,9:云闪付 |
| 33 | +/// @param threeType 支付类型 | |
| 33 | 34 | /// @param frmId 渠道id |
| 34 | 35 | /// param completerBlock 返回 |
| 35 | 36 | +(void)requestWithUMSPayForPrePayWithOrderId:(NSString *)orderId |
| ... | ... | @@ -39,6 +40,7 @@ NS_ASSUME_NONNULL_BEGIN |
| 39 | 40 | BalanceFee:(NSString *)balance_fee |
| 40 | 41 | NotifyUrl:(NSString *)notify_url |
| 41 | 42 | Type:(CNLivePayCostPayType)type |
| 43 | + ThreePayType:(CNLivePayCostThreePayType)threeType | |
| 42 | 44 | FrmId:(NSString *)frmId |
| 43 | 45 | PassWord:(NSString *)password |
| 44 | 46 | CompleterBlcok:(void(^)(NSInteger statue))completerBlock; |
| ... | ... | @@ -77,6 +79,7 @@ NS_ASSUME_NONNULL_BEGIN |
| 77 | 79 | @param desc 描述 |
| 78 | 80 | @param notifyUrl 回调地址 |
| 79 | 81 | @param password 支付密码 |
| 82 | + @param threeType 三方支付 | |
| 80 | 83 | @param completerBlock 支付结果返回 |
| 81 | 84 | */ |
| 82 | 85 | -(void)requestActiveGroupWjjPayMentWithFromId:(NSString *)fromId |
| ... | ... | @@ -88,6 +91,7 @@ NS_ASSUME_NONNULL_BEGIN |
| 88 | 91 | Desc:(NSString *)desc |
| 89 | 92 | NotifyUrl:(NSString *)notifyUrl |
| 90 | 93 | PassWord:(NSString *)password |
| 94 | + ThreePayType:(CNLivePayCostThreePayType)threeType | |
| 91 | 95 | CompleterBlock:(void (^)(NSInteger))completerBlock; |
| 92 | 96 | |
| 93 | 97 | /// 判断是否有支付密码 | ... | ... |
CNLivePayCostModule/Classes/Core/CNLivePayCostNetwork.m
| ... | ... | @@ -40,6 +40,7 @@ static NSString *const CNLiveWillBecomeActivePaycostForSHShopNotification = @"CN |
| 40 | 40 | /// @param balance_fee 余额金额 |
| 41 | 41 | /// @param notify_url 服务端回调地址 |
| 42 | 42 | /// @param type 支付方式 3:支付宝,4:余额,9:云闪付 |
| 43 | +/// @param threeType 支付类型 | |
| 43 | 44 | /// @param frmId 渠道id |
| 44 | 45 | /// @param completerBlock 返回 |
| 45 | 46 | +(void)requestWithUMSPayForPrePayWithOrderId:(NSString *)orderId |
| ... | ... | @@ -49,6 +50,7 @@ static NSString *const CNLiveWillBecomeActivePaycostForSHShopNotification = @"CN |
| 49 | 50 | BalanceFee:(NSString *)balance_fee |
| 50 | 51 | NotifyUrl:(NSString *)notify_url |
| 51 | 52 | Type:(CNLivePayCostPayType)type |
| 53 | + ThreePayType:(CNLivePayCostThreePayType)threeType | |
| 52 | 54 | FrmId:(NSString *)frmId |
| 53 | 55 | PassWord:(NSString *)password |
| 54 | 56 | CompleterBlcok:(void(^)(NSInteger statue))completerBlock |
| ... | ... | @@ -65,14 +67,22 @@ static NSString *const CNLiveWillBecomeActivePaycostForSHShopNotification = @"CN |
| 65 | 67 | }]; |
| 66 | 68 | }else if (type == CNLivePayCostPayTypeWjjPay) { |
| 67 | 69 | |
| 70 | + NSString * notifyUrls = threeType == CNLivePayCostThreePayTypeTicke ? CNJSFYNotifyUrl: (type == CNLivePayCostPayTypeWeChatPay ? CNWeChatPayUrl : type == CNLivePayCostPayTypeAliPay ? CNAliPayUrl : CNUnionPayUrl); | |
| 71 | + | |
| 72 | + //上海电商需要特殊的回调地址 | |
| 73 | + if (!CNLiveStringIsEmpty(notify_url) | |
| 74 | + && threeType == CNLivePayCostThreePayTypeSHSop) notifyUrls = notify_url; | |
| 75 | + | |
| 76 | + NSString * desc = threeType == CNLivePayCostThreePayTypeScren?@"扫码支付":body; | |
| 77 | + | |
| 68 | 78 | NSDictionary * paramDict = @{ |
| 69 | 79 | @"appId":AppId, |
| 70 | 80 | @"user_id":CNUserShareModel.uid?CNUserShareModel.uid:@"", |
| 71 | 81 | @"out_trade_no":orderId, |
| 72 | - @"body":body, | |
| 82 | + @"body":desc, | |
| 73 | 83 | @"coupon_fee":@"0", |
| 74 | 84 | @"balance_fee":price, |
| 75 | - @"notify_url":notify_url, | |
| 85 | + @"notify_url":notifyUrls, | |
| 76 | 86 | @"page_url":@"", |
| 77 | 87 | @"type":@"4", |
| 78 | 88 | @"password":[NSString md5String:password], |
| ... | ... | @@ -90,7 +100,8 @@ static NSString *const CNLiveWillBecomeActivePaycostForSHShopNotification = @"CN |
| 90 | 100 | [QMUITips showError:[errorMessage isNotBlank]?errorMessage:@"支付失败" inView:AppKeyWindow hideAfterDelay:1.5]; |
| 91 | 101 | if (completerBlock) { |
| 92 | 102 | if (errorCode == 100011) completerBlock(2); |
| 93 | - if (errorCode != 100011) completerBlock(3); | |
| 103 | + if (errorCode == 100010) completerBlock(1); | |
| 104 | + if (errorCode != 100010 && errorCode != 100011) completerBlock(3); | |
| 94 | 105 | } |
| 95 | 106 | } |
| 96 | 107 | }]; |
| ... | ... | @@ -100,15 +111,24 @@ static NSString *const CNLiveWillBecomeActivePaycostForSHShopNotification = @"CN |
| 100 | 111 | if (type == CNLivePayCostPayTypeAliPay) index = @"3"; |
| 101 | 112 | if (type == CNLivePayCostPayTypeUnionPay) index = @"9"; |
| 102 | 113 | if (type == CNLivePayCostPayTypeWjjPay) index = @"4"; |
| 114 | + | |
| 115 | + NSString * notifyUrls = threeType == CNLivePayCostThreePayTypeTicke ? CNJSFYNotifyUrl: (type == CNLivePayCostPayTypeWeChatPay ? CNWeChatPayUrl : type == CNLivePayCostPayTypeAliPay ? CNAliPayUrl : CNUnionPayUrl); | |
| 116 | + | |
| 117 | + //上海电商需要特殊的回调地址 | |
| 118 | + if (!CNLiveStringIsEmpty(notify_url) | |
| 119 | + && threeType == CNLivePayCostThreePayTypeSHSop) notifyUrls = notify_url; | |
| 120 | + | |
| 121 | + NSString * desc = threeType == CNLivePayCostThreePayTypeScren?@"扫码支付":body; | |
| 122 | + | |
| 103 | 123 | NSDictionary * paramDict = @{ |
| 104 | 124 | @"appId":AppId, |
| 105 | 125 | @"user_id":CNUserShareModel.uid?CNUserShareModel.uid:@"", |
| 106 | 126 | @"out_trade_no":orderId, |
| 107 | - @"body":body, | |
| 127 | + @"body":desc, | |
| 108 | 128 | @"total_fee":price, |
| 109 | 129 | @"coupon_fee":coupon_fee, |
| 110 | 130 | @"balance_fee":balance_fee, |
| 111 | - @"notify_url":notify_url, | |
| 131 | + @"notify_url":notifyUrls, | |
| 112 | 132 | @"page_url":@"", |
| 113 | 133 | @"type":index, |
| 114 | 134 | @"frmId":frmId |
| ... | ... | @@ -177,7 +197,7 @@ static NSString *const CNLiveWillBecomeActivePaycostForSHShopNotification = @"CN |
| 177 | 197 | |
| 178 | 198 | NSString * p = [NSString stringWithFormat:@"%d",(NSInteger)([price floatValue]*100)]; |
| 179 | 199 | |
| 180 | - [CNLivePayCostNetwork requestWithUMSPayForPrePayWithOrderId:groupId Body:desc Price:p CouponFee:@"0" BalanceFee:@"0" NotifyUrl:notifyUrl Type:payType FrmId:@"ios" PassWord:@"" CompleterBlcok:^(NSInteger statue) { | |
| 200 | + [CNLivePayCostNetwork requestWithUMSPayForPrePayWithOrderId:groupId Body:desc Price:p CouponFee:@"0" BalanceFee:@"0" NotifyUrl:notifyUrl Type:payType ThreePayType:threeType FrmId:@"ios" PassWord:@"" CompleterBlcok:^(NSInteger statue) { | |
| 181 | 201 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
| 182 | 202 | if (completerBlock) completerBlock(statue); |
| 183 | 203 | }); |
| ... | ... | @@ -245,7 +265,7 @@ static NSString *const CNLiveWillBecomeActivePaycostForSHShopNotification = @"CN |
| 245 | 265 | if (payType == CNLivePayCostPayTypeWjjPay) { |
| 246 | 266 | |
| 247 | 267 | NSString * toid = threeType == CNLivePayCostTypeOrder ? fundsId : groupId; |
| 248 | - [self requestActiveGroupWjjPayMentWithFromId:CNUserShareModel.uid Toid:toid Price:[price floatValue] Expand:expand SourceId:[responseObject objectForKey:@"payId"] PayId:responseObject[@"payId"] Desc:desc NotifyUrl:notifyUrl PassWord:password CompleterBlock:^(NSInteger statue) { | |
| 268 | + [self requestActiveGroupWjjPayMentWithFromId:CNUserShareModel.uid Toid:toid Price:[price floatValue] Expand:expand SourceId:[responseObject objectForKey:@"payId"] PayId:responseObject[@"payId"] Desc:desc NotifyUrl:notifyUrl PassWord:password ThreePayType:threeType CompleterBlock:^(NSInteger statue) { | |
| 249 | 269 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
| 250 | 270 | if (completerBlock) completerBlock(statue); |
| 251 | 271 | }); |
| ... | ... | @@ -301,6 +321,7 @@ static NSString *const CNLiveWillBecomeActivePaycostForSHShopNotification = @"CN |
| 301 | 321 | Desc:(NSString *)desc |
| 302 | 322 | NotifyUrl:(NSString *)notifyUrl |
| 303 | 323 | PassWord:(NSString *)password |
| 324 | + ThreePayType:(CNLivePayCostThreePayType)threeType | |
| 304 | 325 | CompleterBlock:(void (^)(NSInteger))completerBlock |
| 305 | 326 | { |
| 306 | 327 | |
| ... | ... | @@ -308,7 +329,7 @@ static NSString *const CNLiveWillBecomeActivePaycostForSHShopNotification = @"CN |
| 308 | 329 | |
| 309 | 330 | NSString * p = [NSString stringWithFormat:@"%d",(NSInteger)(price*100)]; |
| 310 | 331 | |
| 311 | - [CNLivePayCostNetwork requestWithUMSPayForPrePayWithOrderId:payId Body:desc Price:p CouponFee:@"0" BalanceFee:@"0" NotifyUrl:notifyUrl Type:CNLivePayCostPayTypeWjjPay FrmId:@"ios" PassWord:password CompleterBlcok:^(NSInteger statue) { | |
| 332 | + [CNLivePayCostNetwork requestWithUMSPayForPrePayWithOrderId:payId Body:desc Price:p CouponFee:@"0" BalanceFee:@"0" NotifyUrl:notifyUrl Type:CNLivePayCostPayTypeWjjPay ThreePayType:threeType FrmId:@"ios" PassWord:password CompleterBlcok:^(NSInteger statue) { | |
| 312 | 333 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
| 313 | 334 | if (completerBlock) completerBlock(statue); |
| 314 | 335 | }); | ... | ... |
CNLivePayCostModule/Classes/View/CNLivePayCostContentView.m
| ... | ... | @@ -288,27 +288,27 @@ static NSString *const CNActiveContentPayViewIdentifier = @"CNActiveContentPayVi |
| 288 | 288 | } |
| 289 | 289 | if (self.payModel.payType == CNLivePayCostTypeOrder) { |
| 290 | 290 | |
| 291 | - [[CNLivePayCostNetwork sharePayCostNetWork] requestActiveGroupWjjPayMentWithFromId:CNUserShareModel.uid Toid:self.payModel.userId Price:self.payModel.price Expand:self.payModel.expand SourceId:self.payModel.orderId PayId:self.payModel.orderId Desc:self.payModel.descStr NotifyUrl:self.payModel.notifyUrl PassWord:password CompleterBlock:^(NSInteger statue) { | |
| 291 | + [[CNLivePayCostNetwork sharePayCostNetWork] requestActiveGroupWjjPayMentWithFromId:CNUserShareModel.uid Toid:self.payModel.userId Price:self.payModel.price Expand:self.payModel.expand SourceId:self.payModel.orderId PayId:self.payModel.orderId Desc:self.payModel.descStr NotifyUrl:self.payModel.notifyUrl PassWord:password ThreePayType:CNLivePayCostThreePayTypeOrder CompleterBlock:^(NSInteger statue) { | |
| 292 | 292 | [weakSelf showPayStatue:statue]; |
| 293 | 293 | }]; |
| 294 | 294 | } |
| 295 | 295 | if (self.payModel.payType == CNLivePayCostTypeSweep) { |
| 296 | - [[CNLivePayCostNetwork sharePayCostNetWork] requestActiveGroupWjjPayMentWithFromId:CNUserShareModel.uid Toid:self.payModel.toId Price:self.payModel.price Expand:self.payModel.expand SourceId:self.payModel.orderId PayId:self.payModel.orderId Desc:self.payModel.descStr NotifyUrl:self.payModel.notifyUrl PassWord:password CompleterBlock:^(NSInteger statue) { | |
| 296 | + [[CNLivePayCostNetwork sharePayCostNetWork] requestActiveGroupWjjPayMentWithFromId:CNUserShareModel.uid Toid:self.payModel.toId Price:self.payModel.price Expand:self.payModel.expand SourceId:self.payModel.orderId PayId:self.payModel.orderId Desc:self.payModel.descStr NotifyUrl:self.payModel.notifyUrl PassWord:password ThreePayType:CNLivePayCostThreePayTypeScren CompleterBlock:^(NSInteger statue) { | |
| 297 | 297 | [weakSelf showPayStatue:statue]; |
| 298 | 298 | }]; |
| 299 | 299 | } |
| 300 | 300 | if (self.payModel.payType == CNLivePayCostTypeTicke) { |
| 301 | - [[CNLivePayCostNetwork sharePayCostNetWork] requestActiveGroupWjjPayMentWithFromId:CNUserShareModel.uid Toid:self.payModel.toId Price:self.payModel.price Expand:self.payModel.expand SourceId:self.payModel.orderId PayId:self.payModel.orderId Desc:self.payModel.descStr NotifyUrl:self.payModel.notifyUrl PassWord:password CompleterBlock:^(NSInteger statue) { | |
| 301 | + [[CNLivePayCostNetwork sharePayCostNetWork] requestActiveGroupWjjPayMentWithFromId:CNUserShareModel.uid Toid:self.payModel.toId Price:self.payModel.price Expand:self.payModel.expand SourceId:self.payModel.orderId PayId:self.payModel.orderId Desc:self.payModel.descStr NotifyUrl:self.payModel.notifyUrl PassWord:password ThreePayType:CNLivePayCostThreePayTypeTicke CompleterBlock:^(NSInteger statue) { | |
| 302 | 302 | [weakSelf showPayStatue:statue]; |
| 303 | 303 | }]; |
| 304 | 304 | } |
| 305 | 305 | if (self.payModel.payType == CNLivePayCostTypeSHShop) { |
| 306 | - [[CNLivePayCostNetwork sharePayCostNetWork] requestActiveGroupWjjPayMentWithFromId:CNUserShareModel.uid Toid:self.payModel.toId Price:self.payModel.price Expand:self.payModel.expand SourceId:self.payModel.orderId PayId:self.payModel.orderId Desc:self.payModel.descStr NotifyUrl:self.payModel.notifyUrl PassWord:password CompleterBlock:^(NSInteger statue) { | |
| 306 | + [[CNLivePayCostNetwork sharePayCostNetWork] requestActiveGroupWjjPayMentWithFromId:CNUserShareModel.uid Toid:self.payModel.toId Price:self.payModel.price Expand:self.payModel.expand SourceId:self.payModel.orderId PayId:self.payModel.orderId Desc:self.payModel.descStr NotifyUrl:self.payModel.notifyUrl PassWord:password ThreePayType:CNLivePayCostThreePayTypeSHSop CompleterBlock:^(NSInteger statue) { | |
| 307 | 307 | [weakSelf showPayStatue:statue]; |
| 308 | 308 | }]; |
| 309 | 309 | } |
| 310 | 310 | if (self.payModel.payType == CNLivePayCostTypeHtml) { |
| 311 | - [[CNLivePayCostNetwork sharePayCostNetWork] requestActiveGroupWjjPayMentWithFromId:CNUserShareModel.uid Toid:self.payModel.toId Price:self.payModel.price Expand:self.payModel.expand SourceId:self.payModel.orderId PayId:self.payModel.orderId Desc:self.payModel.descStr NotifyUrl:self.payModel.notifyUrl PassWord:password CompleterBlock:^(NSInteger statue) { | |
| 311 | + [[CNLivePayCostNetwork sharePayCostNetWork] requestActiveGroupWjjPayMentWithFromId:CNUserShareModel.uid Toid:self.payModel.toId Price:self.payModel.price Expand:self.payModel.expand SourceId:self.payModel.orderId PayId:self.payModel.orderId Desc:self.payModel.descStr NotifyUrl:self.payModel.notifyUrl PassWord:password ThreePayType:CNLivePayCostThreePayTypeHTML CompleterBlock:^(NSInteger statue) { | |
| 312 | 312 | [weakSelf showPayStatue:statue]; |
| 313 | 313 | }]; |
| 314 | 314 | } | ... | ... |
Example/CNLivePayCostModule/CNLIVEViewController.m
| ... | ... | @@ -34,8 +34,8 @@ |
| 34 | 34 | UIButton * batchBtn = [UIButton buttonWithType:UIButtonTypeSystem]; |
| 35 | 35 | batchBtn.frame = CGRectMake(0, CGRectGetMaxY(requestBtn.frame)+5, kWidth, 70); |
| 36 | 36 | batchBtn.backgroundColor = [UIColor cyanColor]; |
| 37 | - [batchBtn setTitle:@"支付宝支付" forState: UIControlStateNormal]; | |
| 38 | - [batchBtn setTitle:@"支付宝支付" forState: UIControlStateHighlighted]; | |
| 37 | + [batchBtn setTitle:@"电商支付" forState: UIControlStateNormal]; | |
| 38 | + [batchBtn setTitle:@"电商支付" forState: UIControlStateHighlighted]; | |
| 39 | 39 | [batchBtn addTarget:self action:@selector(batchRequestAction) forControlEvents:UIControlEventTouchUpInside]; |
| 40 | 40 | [self.view addSubview:batchBtn]; |
| 41 | 41 | } |
| ... | ... | @@ -48,7 +48,6 @@ |
| 48 | 48 | @"descStr":@"测试", |
| 49 | 49 | @"price":@0.01, |
| 50 | 50 | @"orderType":@"1", |
| 51 | - @"notifyUrl":@"http://unifypay.cnlive.com/test/notify_url" | |
| 52 | 51 | }; |
| 53 | 52 | [CNLivePayCostModule showDefaultPayViwWithParamDict:paramDict PayCostType:CNLivePayCostTypeOrder FromVC:self ResultBlock:^(CNLivePayCostTypeResult resultType) { |
| 54 | 53 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:resultType == CNLivePayCostTypeResultSucc?@"支付成功":@"支付失败" message:nil delegate:self cancelButtonTitle:@"确认" otherButtonTitles:nil, nil]; | ... | ... |