IOS支付宝支付流程

IOS支付宝支付流程,第1张

概述一、集成和配置。       1、签名注册AppKey 我们是由后台完成。       2、我用cocoapods集成             pod ‘AlipaySDK-iOS‘       3、需要在info文件 URL Types中建一个URL Schems 支付宝返回应用用到,和跳转时schemeStr设置一样就行。 二、代码实现       1、AppDelegate 的代码实现   

一、集成和配置。

      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支付宝支付流程所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1067196.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存