获取内容资料
iOS开发

ios微信支付开发 ios开发教程

摘要:本文将带你了解IOS开发入门实现支付,支付宝支付的开发教程,希望本文对大家学IOS有所帮助。

本文将带你了解IOS开发入门实现支付,支付宝支付的开发教程,希望本文对大家学IOS有所帮助。

然后在appdelegate.m   中

#pragma 支付宝支付

–   (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;

return [WXApi handleOpenURL:url   delegate:self];

// NOTE:   9.0以后使用新API接口

–   (BOOL)application:(UIApplication *)app openURL:(NSURL *)url   options:(NSDictionary   *)options

// safepay 是支付宝, pay   是

if ([url.host isEqualToString:@”safepay”]) {

//跳转支付宝钱包进行支付,处理支付结果

[[AlipaySDK defaultService]   processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic)   {

NSLog(@”result = %@”,resultDic);

return YES;

return [WXApi handleOpenURL:url   delegate:self];

–   (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL   *)url

return [WXApi handleOpenURL:url   delegate:self];

#pragma   WXApiDelegate

-(void)   onReq:(BaseReq*)req{

NSLog(@”-========请求”);

-(void)   onResp:(BaseResp*)resp{

if ([resp isKindOfClass:[PayResp class]]){

PayResp*response=(PayResp*)resp;

switch(response.errCode){

case WXSuccess:

//服务器端查询支付通知或查询API返回的结果再提示成功

NSLog(@”支付成功”);

[self   toHomeVC];

NSLog(@”支付失败,retcode=%d”,resp.errCode);

– (void)toHomeVC{

UIStoryboard *story = [UIStoryboard   storyboardWithName:@”Main” bundle:[NSBundle mainBundle]];

TabBarController *tabVC = [story   instantiateViewControllerWithIdentifier:@”tabVC”];

self.window.rootViewController =   tabVC;

}

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之IOS频道!

Similar Posts

发表评论

邮箱地址不会被公开。 必填项已用*标注