关于微信支付

一、关于微信支付回调

1.具体支付配置参考文档,强调一下:所有的加密等除了调用SDK的代码外,别的全部应该放到服务器!!

2.关于回调:支付成功之后可能会出现不回调或者无法返回APP的问题。首先应该检查一下自己的URL-Schemes,如果没问题就继续。

3.AppDelegate.m中。前两个9.0之前的,最后一个9.0之后的,为了兼容应该在三个里面都写上同样的代码。支付的回调都是在这里面的。

4.鉴于有时候集成多种支付方式,走的都是同样的代理方法,这时候就要区分一下是哪一个回调了,根据不同的支付方式回调,触发不同的动作。

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url NS_DEPRECATED_IOS(2_0, 9_0, "Please use application:openURL:options:") __TVOS_PROHIBITED;

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(nullable NSString *)sourceApplication annotation:(id)annotation NS_DEPRECATED_IOS(4_2, 9_0, "Please use application:openURL:options:") __TVOS_PROHIBITED;

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary*)options NS_AVAILABLE_IOS(9_0); // no equiv. notification. return NO if the application can't open for some reason

5.区分方法,例如:

//url Schemes回调

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{

return [self applicationOpenURL:url];

}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{

return [self applicationOpenURL:url];

}

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

return [self applicationOpenURL:url];

}


- (BOOL)applicationOpenURL:(NSURL *)url{

if([[url absoluteString] rangeOfString:@"wx000000000000://pay"].location == 0) //你的微信开发者appid

return [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];

else{

//在这里处理别的支付方式或者别的回调

return [UMSocialSnsService handleOpenURL:url wxApiDelegate:[WXApiManager sharedManager]];

}

}

二、参考链接

http://www.2cto.com/kf/201603/492080.html

你可能感兴趣的:(关于微信支付)