一、集成和配置。
1、签名注册AppKey 我们是由后台完成。
2、我用cocoapods集成
pod ‘AlipaySDK-iOS‘
3、需要在info文件 URL Types中建一个URL Schems 支付宝返回应用用到,和跳转时schemeStr设置一样就行。
二、代码实现
1、AppDelegate 的代码实现
# import <AlipaySDK/AlipaySDK.h>支付宝
- (BOol)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(Nsstring *)sourceApplication annotation:(ID)annotation { if ([url.host isEqualToString:@"safepay"]) { //跳转支付宝钱包进行支付,处理支付结果 [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) { NSLog(@"result = %@",resultDic); }]; } return YES; } // NOTE: 9.0以后使用新API接口 - (BOol)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<Nsstring*,ID> *)options { if ([url.host isEqualToString:@"safepay"]) { //跳转支付宝钱包进行支付,处理支付结果 [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) { NSLog(@"result = %@",resultDic); //发送支付成功通知 [[NSNotificationCenter defaultCenter] postNotificationname:ReturnSucceedPayNotification object:nil]; }]; } if ([url.host isEqualToString:@"platformAPI"]){//支付宝钱包快登授权返回authCode [[AlipaySDK defaultService] processAuthResult:url standbyCallback:^(NSDictionary *resultDic) { //【由于在跳转支付宝客户端支付的过程中,商户app在后台很可能被系统kill了,所以pay接口的callback就会失效,请商户对standbyCallback返回的回调结果进行处理,就是在这个方法里面处理跟callback一样的逻辑】 NSLog(@"platformAPI result = %@",resultDic); //发送支付失败通知 [[NSNotificationCenter defaultCenter] postNotificationname:ReturnSucceedPayNotification object:nil]; } ];}; return YES; }
2、签名和拼接在后台,APP不在进行二次签名,向后台创建单子返回数据为
3、获取返回的sign,跳转支付宝进行支付
Nsstring *appScheme = @"PayAppScheme"; //跟info文件 URL Types中Schems一致。
Nsstring *orderString = [self.payDict objectForKey:@"sign"]; [[AlipaySDK defaultService] payOrder:orderString fromScheme:appScheme callback:^(NSDictionary *resultDic) { NSLog(@"reslut = %@",resultDic); }];
以上是内存溢出为你收集整理的IOS支付宝支付流程全部内容,希望文章能够帮你解决IOS支付宝支付流程所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)