{"id":13847963,"url":"https://github.com/ihaolin/wepay","last_synced_at":"2025-04-14T14:28:23.240Z","repository":{"id":57736574,"uuid":"47344126","full_name":"ihaolin/wepay","owner":"ihaolin","description":"轻量的微信支付组件(A Lightweight Wechat Pay Component)","archived":false,"fork":false,"pushed_at":"2018-08-08T07:53:50.000Z","size":587,"stargazers_count":327,"open_issues_count":4,"forks_count":134,"subscribers_count":42,"default_branch":"master","last_synced_at":"2024-11-21T23:31:14.665Z","etag":null,"topics":["wechat","wechat-sdk","wepay"],"latest_commit_sha":null,"homepage":"","language":"Java","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/ihaolin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-03T16:19:34.000Z","updated_at":"2024-06-19T17:06:53.000Z","dependencies_parsed_at":"2022-08-24T02:50:45.723Z","dependency_job_id":null,"html_url":"https://github.com/ihaolin/wepay","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihaolin%2Fwepay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihaolin%2Fwepay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihaolin%2Fwepay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihaolin%2Fwepay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ihaolin","download_url":"https://codeload.github.com/ihaolin/wepay/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248896429,"owners_count":21179429,"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":["wechat","wechat-sdk","wepay"],"created_at":"2024-08-04T19:00:37.708Z","updated_at":"2025-04-14T14:28:23.210Z","avatar_url":"https://github.com/ihaolin.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"# Wepay[![Build Status](https://travis-ci.org/ihaolin/wepay.svg?branch=master)](https://travis-ci.org/ihaolin/wepay)\n\n轻量的微信支付组件(A Lightweight Wechat Pay Component)\n---\n\n+ 包引入:\n\t\n\t```xml\n\t\u003cdependency\u003e\n        \u003cgroupId\u003eme.hao0\u003c/groupId\u003e\n        \u003cartifactId\u003ewepay-core\u003c/artifactId\u003e\n        \u003cversion\u003e1.3.2\u003c/version\u003e\n    \u003c/dependency\u003e\n\t```\n\t\n+ 依赖包，注意引入项目时是否需要**exclude**:\n\n\t```xml\n\t\u003cdependency\u003e\n        \u003cgroupId\u003eme.hao0\u003c/groupId\u003e\n        \u003cartifactId\u003ecommon\u003c/artifactId\u003e\n        \u003cversion\u003e1.1.2\u003c/version\u003e\n    \u003c/dependency\u003e\n\t\n\t```\n\t\n+ 基本用法:\n\t\n\t```java\n\tWepay wepay = WepayBuilder\n                    .newBuilder(appId, appKey, mchId)\n                    .config1(...)\t// 其他可选配置\n                    ...\n                    .build();\n    \n    wepay.module().api();\n\t```\n\n+ 已实现的组件:\n\n\t+ 支付``pay()``;\n\t+ 退款``refund()``;\n\t+ 订单``order()``;\n\t+ 通知``notify()``;\n\t+ 账单``bill()``。\n\t\t\n+ API文档[这里](API.md)。\n\n+ **关于测试**: \n\t\n\t+ [测试用例中](wepay-core/src/test/java/me/hao0/wepay/WepayTest.java)是一些基本测试，需作一些配置：\n\n\t\t```java\n\t\t// 在test/reources目录中配置dev.properties\n\t\t// 包括appId(APP ID), appKey(支付密钥), mchId(商户号)\n\t\tProperties props = new Properties();\n        InputStream in = Object.class.getResourceAsStream(\"/dev.properties\");\n        props.load(in);\n        in.close();\n\t\t \n\t\t // 配置证书，退款需要证书，不配置可测试除退款的接口 \n        Path path = Paths.get(\"/path/to/your_cert.p12\");\n        byte[] data = Files.readAllBytes(path);\n\n        wepay = WepayBuilder.newBuilder(\n                props.getProperty(\"appId\"),\n                props.getProperty(\"appKey\"),\n                props.getProperty(\"mchId\"))\n                .certPasswd(props.getProperty(\"mchId\"))\n                .certs(data)\n                .build();\n\t\t```\n\t\n\t+ [wepay-demo](wepay-demo)项目是一个可运行web项目，方便测试，可按如下步骤进行测试，复制[wepay-demo](wepay-demo)中的``app-example.properties``为``app.properties``，并作相应配置:\n\n\t\t```ruby\n\t\t# 微信app id\n\t\tappId=\n\t\t# 微信支付key\n\t\tappKey=\n\t\t# 商户号\n\t\tmchId=\n\t\t# 支付通知url\n\t\tpayNotifyUrl=${your_domain}/notifies/paid\n\t\t```\n\t\n\t+ **注意**：**``payNotifyUrl ``**应该配置为微信服务器可以外网调用的地址，本地测试建议使用[ngrok](https://ngrok.com/)工具来作本地外网映射。\n\n\t+ 到[wepay-demo](wepay-demo)根目录运行以下命令即可:\n\n\t\t```bash\n\t\tmvn clean jetty:run -Dmaven.test.skip -Djetty.port={自定义端口号}\n\t\t```\n\t\n\t+ 动态二维码支付可访问(**请求正常后，会出现由联图生成的二维码图片，用微信扫描支付成功后，后台会得到对应通知``Notifies``**):\n\t\t\n\t\t```bash\n\t\thttp://localhost:{port}/pays/qrpay?orderNumber={自定义订单号}\n\t\t```\t\n\t\n\t+ 退款可访问(**提交成功后，微信会有消息通知**):\n\n\t\t```bash\n\t\thttp://localhost:{port}/refunds/apply?orderNumber={商户订单号}\t\t```\n\t\t\n+ 相关文档:\n\t\n\t+ [微信支付文档](https://pay.weixin.qq.com/wiki/doc/api/index.html)。\n\n+ 历史版本:\n\n\t+ 1.0.0:\n\t\t\n\t\t+ 基本功能实现。\n\t\n\t+ 1.1.0:\n\n\t\t+ 增加账单查询。\n\n\t+ 1.1.1:\n\n\t\t+ 修复prepayId。\n\n\t+ 1.1.2:\n\n\t\t+ 修复JS/APP支付签名问题。\n\n\t+ 1.2.2:\n\t\t\n\t\t+ 增加退款查询字段: 退款状态, 退款金额, 退款入账方。\n\t\n\t+ 1.2.3:\n\t\t\t\n        + fix isNullOrEmpty。\n    \n    + 1.2.4:\n    \t\t\t\n        + 升级common至1.1.2, 可配置解析微信XML的编码类型, 默认为UTF-8, 防止与本地默认编码不一致。\n    \n    + 1.2.5:\n    \n        + 二维码支付结果更新为[QrPayResponse](wepay-core/src/main/java/me/hao0/wepay/model/pay/QrPayResponse.java)，并增加**prepay_id**字段。\n    \n    + 1.3.0:\n    \n        + 获取微信响应内容，签名校验失败时，抛出异常[SignException](wepay-core/src/main/java/me/hao0/wepay/exception/SignException.java)。\n     \n    + 1.3.1:\n    \n        + 修复`goods_tag`字段名。\n        \n    + 1.3.2:\n        \n        + 修复`clientIp`字段为`clientIp`。\n\n+ 相关组件:\n\n\t+ \u003ca href=\"https://github.com/ihaolin/alipay\" target=\"_blank\"\u003e支付宝支付组件\u003c/a\u003e；\n\t+ \u003ca href=\"https://github.com/ihaolin/wechat\" target=\"_blank\"\u003e微信公众号组件\u003c/a\u003e。\n\n## 有事请烧钱\n\n+ 支付宝:\n\t\t\n\t\u003cimg src=\"alipay.png\" width=\"200\"\u003e\n\t\n+ 微信:\n\n\t\u003cimg src=\"wechat.png\" width=\"200\"\u003e\n        ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fihaolin%2Fwepay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fihaolin%2Fwepay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fihaolin%2Fwepay/lists"}