Git下载地址
微信支付可支付的demo
NOTICE
该SDK包含了 微信分享 微信登录等
已经做成组件在cocoapods里
可以搜索
-> WeChatPaySDK (0.0.2)
A short description of WeChatPaySDK.
pod 'WeChatPaySDK', '~> 0.0.2'
- Homepage: https://github.com/7General
- Source: https://github.com/7General/WeChatPaySDK.git
- Versions: 0.0.2, 0.0.1 [master repo]
1:下载微信支付demo,把以前几个文件摘出来
WechatAuthSDK.h(auth相关)
WXApi.h(业务相关)
WXApiObject.h(各种对象)
libWeChatSDK.a (这个不能少)
2:设置info.plist
- 允许http访问
App Transport Security Settings
Allow Arbitrary Loads :YES -
设置URL Types
设置微信支付URL Types
3:接入微信支付appdelegate
//注册微信支付
[WXApi registerApp:MXWechatAPPID withDescription:@"微信支付"];
4:支付回调
#pragma mark - 微信支付回调
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
return [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];
}
// NOTE: 9.0以后使用新API接口
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options
{
return [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];
}
5:唤起微信支付
+ (void)WakeupWeChatPay:(MSSendPayRequest *)payRequest {
PayReq *request = [[PayReq alloc] init];
request.openID = payRequest.openID;
request.partnerId = payRequest.partnerId;
request.prepayId= payRequest.prepayId;
request.package = payRequest.package;
request.nonceStr= payRequest.nonceStr;
request.timeStamp = payRequest.timeStamp;
request.sign= payRequest.sign;
// 调用微信
[WXApi sendReq:request];
}
有些地方说的不到位,还请各位看官指正。。。
- 如有问题可添加QQ群:234812704
- 欢迎各位一块学习,提高逼格!
- 也可以添加洲洲哥的微信公众号
可以来微信公众号(洲洲哥)后台给我们留言。 快来扫码关注我们吧!
公众号二维码
网友评论