WBPayManager
支付宝和 WXPay 管理提示:支付宝需要先在 URL Scheme infoplist 中添加 LSApplicationQueriesSchemes wechat weixin alipay alipayshare
- 在 appdelegate 中引入头文件 #import "<WBPayManager.h>"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[WBPayManager shared] confingAppScheme:@"AppScheme"]; [[WBPayManager shared] configWXPayIdWithWXid:@"wxKey"]; return YES; }
- 在 appdelegate 中添加
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary
*)options{ return [[WBPayManager shared] handleOpenURL:url]; }
4. 调用
[[WBPayManager shared] aliPayWithPayParam:@"" success:^(PayCode code) {
} failure:^(PayCode code, NSString * _Nonnull errorText) {
}];
PayReq* req = [[PayReq alloc] init];
req.partnerId = @"partnerId";
req.prepayId = @"prepayid";
req.nonceStr = @"noncestr";
req.timeStamp = @"timestamp".intValue;
req.package = @"Sign=WXPay";
req.sign = @"sign";
[[WBPayManager shared] wxPayWithPayReq:req success:^(PayCode code) {
} failure:^(PayCode code, NSString * _Nonnull errorText) {
}];