{"id":21802877,"url":"https://github.com/coderzhuxh/xhpaykit","last_synced_at":"2025-04-05T08:09:09.089Z","repository":{"id":44729296,"uuid":"120894944","full_name":"CoderZhuXH/XHPayKit","owner":"CoderZhuXH","description":"🔥不用官方SDK实现微信支付、支付宝支付","archived":false,"fork":false,"pushed_at":"2019-11-08T03:58:30.000Z","size":703,"stargazers_count":568,"open_issues_count":18,"forks_count":107,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-29T07:09:24.762Z","etag":null,"topics":["ios","objective-c","pod"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CoderZhuXH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-09T10:56:36.000Z","updated_at":"2024-12-24T10:57:44.000Z","dependencies_parsed_at":"2022-08-12T11:21:44.614Z","dependency_job_id":null,"html_url":"https://github.com/CoderZhuXH/XHPayKit","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderZhuXH%2FXHPayKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderZhuXH%2FXHPayKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderZhuXH%2FXHPayKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderZhuXH%2FXHPayKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CoderZhuXH","download_url":"https://codeload.github.com/CoderZhuXH/XHPayKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305935,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","objective-c","pod"],"created_at":"2024-11-27T11:33:59.896Z","updated_at":"2025-04-05T08:09:09.048Z","avatar_url":"https://github.com/CoderZhuXH.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"#\tXHPayKit \n##\t不用官方SDK,实现微信支付、支付宝支付\n\n[![AppVeyor](https://img.shields.io/appveyor/ci/gruntjs/grunt.svg?maxAge=2592000)](https://github.com/CoderZhuXH/XHPayKit)\n[![Version Status](https://img.shields.io/cocoapods/v/XHPayKit.svg?style=flat)](http://cocoadocs.org/docsets/XHPayKit)\n[![Support](https://img.shields.io/badge/support-iOS7%2B-brightgreen.svg)](https://github.com/CoderZhuXH/XHPayKit)\n[![Pod Platform](https://img.shields.io/cocoapods/p/XHPayKit.svg?style=flat)](http://cocoadocs.org/docsets/XHPayKit/)\n[![Pod License](https://img.shields.io/cocoapods/l/XHPayKit.svg?style=flat)](https://github.com/CoderZhuXH/XHPayKit/blob/master/LICENSE)\n\n![](PNG/weixin_alipay.png)\n\n### 技术交流群(群号:537476189)\n![](PNG/qqgroup.png)\n\n\n### 2019.11.08:⚠️警告此库审核时会被检测出来,不要直接使用.解决方案:[请看这里\u003e\u003e\u003e](https://github.com/CoderZhuXH/XHPayKit/blob/master/info/README_Add.md)\n\n\n##  温馨提示\n1.使用XHPayKit走不通支付流程的,基本都是所传支付参数有问题,建议你先使用官方SDK调通支付流程后,再删除官方SDK使用XHPaykit.\u003cbr\u003e\n2.XHPaykit和官方SDK有类似接口,可以实现快速替换.\n\n##\t写在最前\n\n1.此库拥有和官方SDK相似的接口,可以直接替换官方SDK支付接口,如果你使用过官方SDK,那么转换为本库你只需花费极短时间\u003cbr\u003e\n2.此库只有10kb大小,不用导入任何依赖库,便可实现微信支付、支付宝支付,如果你想为项目瘦身或由于某种原因,不想使用官方SDK实现支付功能,此库将是一个不错的选择.\u003cbr\u003e\n3.本库使用时,不需要配置微信等平台appid等信息,服务端配置就可以了,支付不同于登录分享,参数均由后台生成,后台签名订单时会返回appid等信息给客户端.\n\n## 如果你不想让审核人员扫描到APP里面的支付功能[请看这里\u003e\u003e\u003e](https://github.com/CoderZhuXH/XHPayKit/blob/master/审核防检测到支付功能版本/README.md)\n\n###\t注意:\n1.先在微信、支付宝开放平台注册你的应用,并获得支付能力\u003cbr\u003e\n2.导入此库,并请将 weixin 、 alipay 字段添加到info.plist白名单\u003cbr\u003e\n3.并添加两个URL Schemes 如图:\u003cbr\u003e\n![](PNG/URLSchemes.png)\n4.XHPayKit在未安装支付宝/微信情况下,不会拉起网页支付\u003cbr\u003e\n\n\n### 运行Demo注意事项:\n由于demo拉起支付时,未传递真实支付参数,所以并不能真正进行支付,请替换为真实订单参数即可(这些参数由后台进行订单签名时生成并返回给客户端).\n\n##\t代码示例\n\n###\t1.微信支付\n\n//以下参数详细介绍见微信官方文档:\u003chttps://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_12\u0026index=2\u003e\n\n```objc\n\n//微信支付参数,下面7个参数,由后台签名订单后生成,并返回给客服端(与官方SDK一致)\n//注意:请将下面参数设置为你自己真实订单签名后服务器返回参数,便可进行实际支付\n\nXHPayWxReq *req = [[XHPayWxReq alloc] init];\nreq.openID = @\"\";//微信开放平台审核通过的应用APPID\nreq.partnerId = @\"\";//商户号\nreq.prepayId = @\"\";//交易会话ID\nreq.nonceStr = @\"\";//随机串，防重发\nreq.timeStamp = 1518156229;//时间戳，防重发\nreq.package = @\"\";// 扩展字段,暂填写固定值Sign=WXPay\nreq.sign = @\"\";//签名\n        \n//传入订单模型,拉起微信支付\n[[XHPayKit defaultManager] wxpayOrder:req completed:^(NSDictionary *resultDict) {\n      NSLog(@\"支付结果:\\n%@\",resultDict);\n      NSInteger code = [resultDict[@\"errCode\"] integerValue];\n      if(code == 0){//支付成功\n                \n      }\n}];\n\n        \n```\n\n###\t2.支付宝支付\n```objc\n\n//支付宝订单签名,此签名由后台签名订单后生成,并返回给客户端(与官方SDK一致)\n//注意:请将下面值设置为你自己真实订单签名,便可进行实际支付\nNSString *orderSign = @\"很长的一串支付宝订单签名\";\n        \n//传入支付宝订单签名 和 自己App URL Scheme,拉起支付宝支付\n[[XHPayKit defaultManager] alipayOrder:orderSign fromScheme:@\"XHPayKitExample\" completed:^(NSDictionary *resultDict) {\n    NSLog(@\"支付结果:\\n%@\",resultDict);\n    NSInteger status = [resultDict[@\"resultStatus\"] integerValue];\n    if(status == 9000){//支付成功\n                \n    }\n}];\n\n```\n\n###\t 3.在Appdelegate中添加以下代码 - 处理第三方支付跳回商户app携带的支付结果Url\n\n```objc\n#if __IPHONE_OS_VERSION_MAX_ALLOWED \u003e= __IPHONE_9_0\n/** iOS9及以后 */\n- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary\u003cUIApplicationOpenURLOptionsKey, id\u003e *)options\n{\n    BOOL result = [[XHPayKit defaultManager] handleOpenURL:url];\n    if (!result) {//这里处理其他SDK(例如QQ登录,微博登录等)\n        \n    }\n    return result;\n}\n#endif\n/** iOS9以下 */\n- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation\n{\n    BOOL result = [[XHPayKit defaultManager] handleOpenURL:url];\n    if (!result) {//这里处理其他SDK(例如QQ登录,微博登录等)\n        \n    }\n    return result;\n}\n\n```\n\n##\t其它接口\n```objc\n/**\n 是否安装微信\n\n @return 已安装YES,未安装NO\n */\n+(BOOL)isWxAppInstalled;\n\n/**\n 是否安装支付宝\n\n @return 已安装YES,未安装NO\n */\n+(BOOL)isAliAppInstalled;\n\n```\n\n## 支付结果resultDict释义\n\n### 微信\n\n```objc\n{\n    \"errCode\":0,\n    \"errStr\":\"成功\"\n}\n\n//以下状态码含义与官方SDK一致\nerrCode = 0,成功\u003cbr\u003e\nerrCode = -1,普通错误类型\u003cbr\u003e\nerrCode = -2,用户点击取消并返回\u003cbr\u003e\nerrCode = -3,发送失败\u003cbr\u003e\nerrCode = -4,授权失败 \u003cbr\u003e\nerrCode = -5,微信不支持\u003cbr\u003e\n```\n\n### 支付宝\n\n```objc\n{\n    \"result\":\"\",\n    \"resultStatus\":\"9000\",\n    \"memo\":\"支付成功\"\n}\n\n//以下状态码含义与官方SDK一致\nresultStatus = 9000,支付成功\u003cbr\u003e\nresultStatus = 8000,正在处理中，支付结果未知（有可能已经支付成功）,请查询商户订单列表中订单的支付状态\u003cbr\u003e\nresultStatus = 4000,支付失败\u003cbr\u003e\nresultStatus = 5000,重复请求\u003cbr\u003e\nresultStatus = 6001,用户中途取消\u003cbr\u003e\nresultStatus = 6002,网络连接出错\u003cbr\u003e\nresultStatus = 6004,支付结果未知（有可能已经支付成功），请查询商户订单列表中订单的支付状态\u003cbr\u003e\n\n```\n\n\n##  安装\n### 1.手动添加:\u003cbr\u003e\n*   1.将 XHPayKit 文件夹添加到工程目录中\u003cbr\u003e\n*   2.导入 XHPayKit.h\n\n### 2.CocoaPods:\u003cbr\u003e\n*   1.在 Podfile 中添加 pod 'XHPayKit'\u003cbr\u003e\n*   2.执行 pod install 或 pod update\u003cbr\u003e\n*   3.导入 XHPayKit.h\n\n###\t3.Tips\n*   1.如果你pod search XHPayKit 后提示:[!] Unable to find a pod with name, author, summary, or description matching `XHPayKit`,请在终端上执行 rm ~/Library/Caches/CocoaPods/search_index.json , 后重新pod search XHPayKit\n*   2.如果发现pod search XHPayKit 搜索出来的不是最新版本，需要在终端执行cd ~/desktop退回到desktop，然后执行pod setup命令更新本地spec缓存（需要几分钟），然后再搜索就可以了\n*   3.如果你发现你执行pod install后,导入的不是最新版本,请删除Podfile.lock文件,在执行一次 pod install\n*   4.如果在使用过程中遇到BUG，希望你能Issues我，谢谢（或者尝试下载最新的代码看看BUG修复没有）\n\n##  系统要求\n*   该项目最低支持 iOS 7.0 和 Xcode 8.0\n\n##  许可证\nXHPayKit 使用 MIT 许可证，详情见 LICENSE 文件","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderzhuxh%2Fxhpaykit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderzhuxh%2Fxhpaykit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderzhuxh%2Fxhpaykit/lists"}