IOS集成支付宝回调的坑

来源:互联网 发布:大数据专业 编辑:程序博客网 时间:2024/06/01 18:51

最近做个项目需要集成支付,当然选用支付宝,但是过程中发现了巨大的坑

支付完成后,在appdelegate中作回调,但是这个是不会执行

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {    NSString *str1 = [url absoluteString];    NSLog(@"url %@",[str1 stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]);    //urle    //跳转支付宝钱包进行支付,处理支付结果    //妈的这是个坑,下面这个函数根本就不会执行        //如果极简 SDK 不可用,会跳转支付宝钱包进行支付,需要将支付宝钱包的支付结果回传给 SDK    if ([url.host isEqualToString:@"safepay"]) {        NSLog(@"url %@",url.host);        [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {            NSLog(@"safepay = %@",resultDic);        }];    }        if ([url.host isEqualToString:@"platformapi"]){//支付宝钱包快登授权返回 authCode        [[AlipaySDK defaultService] processAuthResult:url standbyCallback:^(NSDictionary *resultDic) {            NSLog(@"platformapi = %@",resultDic);        }];    }    return YES;}

回调操作在下面代码中


[[AlipaySDK defaultService] payOrder:orderString fromScheme:appScheme callback:^(NSDictionary *resultDic) {            NSLog(@"reslut 这里回调? = %@",resultDic);            [self aLiPayCallBack:resultDic tradeNO:_product.orderId];        }];


特别注意一点:在appdelegate中的回调是不能删除的,删除后,调用支付宝客户端支付后不能回调。

支付宝Sdk版本:2.2.3



0 0
原创粉丝点击