HTXPayManager
第一步 ---- 生成订单
//用来生成订单的接口 + 保存好订单号
-(void)requestPayCurriId:(NSString *)curriId useCoupon:(NSString *)useCoupon isGuarantee:(NSString *)isGuarantee myself:(NSString *)myself personName:(NSString *)personName placeDesc:(NSString *)placeDesc sumFee:(NSString *)sumFee paidAmount:(NSString *)paidAmount prodName:(NSString *)prodName lessonTime:(NSString *)lessonTime completion:(HTXPayManagerCreateOrderCompletionBlock)completion;
第二步 ---- 支付
//用来支付的接口 - 生产signOrderUrl调用支付宝支付 + 微信支付 PayReq 字典模型传入
-(void)getPayRequestPayType:(PayType)payType WithOrderType:(NSString *)orderType paidAmount:(NSString *)paidAmount prodName:(NSString *)prodName completion:(HTXPayManagerCompletionBlock)completion;
第三步 ---- 支付回调
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([url.host isEqualToString:@"safepay"]) {
//跳转支付宝钱包进行支付,处理支付结果
[[HTXPayManager sharedManager] alipayResultWithUrl:url];
return YES;
}else{
return [WXApi handleOpenURL:url delegate:[HTXThirdLoginManager sharedManager]];
}
}
微信:
- (void)onResp:(BaseResp*)resp
if([resp isKindOfClass:[PayResp class]]){
NSString *payResoult = [NSString stringWithFormat: @"errcode:%d", resp.errCode];
NSString *payerrStr= [NSString stringWithFormat: @"errStr:%@", resp.errStr];
NSLog(@" --- onResp ----- payResoult : %@ payerrStr : %@ ",payResoult,payerrStr);
//支付返回结果,实际支付结果需要去微信服务器端查询
switch (resp.errCode) {
case 0:
{
payResoult = @"支付结果:成功!";
[[NSNotificationCenter defaultCenter] postNotificationName:@"WX_PaySuccess" object:nil];
}
break;
case -1:
payResoult = @"支付结果:失败!";
break;
case -2:
payResoult = @"用户已经退出支付!";
break;
default:
payResoult = [NSString stringWithFormat:@"支付结果:失败!retcode = %d, retstr = %@", resp.errCode,resp.errStr];
break;
}
}
-(void)queryWxPayBillWithUrl:(NSString *)url;
支付宝:
-(void)alipayResultWithUrl:(NSURL *)url{
[[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
NSLog(@" standbyCallback result = %@",resultDic);
if ([resultDic[@"resultStatus"] isEqualToString:@"9000"]) {
DSLog(@"standbyCallback:支付成功");
NSString * resultDicStr = [CommonTools convertToJSONData:resultDic];
[self alipayFinishRequestWithSynPayResult:resultDicStr];//支付宝支付成功才去后台查询失败不需要
if (self.payHandler) {
NSString * returnCode = @"000000";
NSString * trade_state = @"SUCCESS";
self.payHandler(returnCode,trade_state);
}
}else if ([resultDic[@"resultStatus"] isEqualToString:@"8000"]){
UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"支付结果确认中..." message:nil delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alter show];
}else{
if (self.payHandler) {
NSString * returnCode = @"100000";
NSString * trade_state = @"Fail";
self.payHandler(returnCode,trade_state);
}
}
}];
}
-(void)alipayFinishRequestWithSynPayResult:(NSString *)synPayResult;