首页 > 学院 > 开发设计 > 正文

关于支付的回调处理

2019-11-09 17:05:08
字体:
来源:转载
供稿:网友

此处拿微信支付来举例,支付宝支付同理 添加WXApiDelegate //不同iOS版本的回调函数不同,但也大同小异,具体不再列举。 - (BOOL)application: (UIApplication * )application openURL: (NSURL * )url sourceApplication: (NSString * )sourceApplication annotation: (id)annotation if ([WXApi handleOpenURL: url delegate:self]) { return [WXApi handleOpenURL: url delegate:self]; } } 只有实现了上述回调才会返回对应的支付结果 -(void) onResp: (BaseResp* )resp { NSString *strMsg = [NSString stringWithFormat: @”errcode: %d”, resp.errCode]; NSString *strTitle;

if([resp isKindOfClass: [SendMessageToWXResp class]]){ strTitle = [NSString stringWithFormat: @"发送媒体消息结果"];}if([resp isKindOfClass: [PayResp class]]){ //支付返回结果,实际支付结果需要去微信服务器端查询 strTitle = [NSString stringWithFormat: @"支付结果"]; switch (resp.errCode) { case WXSuccess: { strMsg = @"支付结果:成功!"; NSLog(@"支付成功-PaySuccess,retcode = %d", resp.errCode); NSNotification *notification = [NSNotification notificationWithName:ORDER_PAY_NOTIFICATION object: @"success"]; [[NSNotificationCenter defaultCenter] postNotification:notification]; break; } default: { strMsg = [NSString stringWithFormat: @"支付结果:失败!retcode = %d, retstr = %@", resp.errCode,resp.errStr]; NSLog(@"错误,retcode = %d, retstr = %@", resp.errCode,resp.errStr); NSNotification *notification = [NSNotification notificationWithName:ORDER_PAY_NOTIFICATION object: @"fail"]; [[NSNotificationCenter defaultCenter] postNotification:notification]; break; } }}

}


上一篇:环信集成错误

下一篇:定时任务组件

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表