{"id":22001602,"url":"https://github.com/perzy/co-wechat-payment","last_synced_at":"2026-02-25T10:07:13.913Z","repository":{"id":57201883,"uuid":"62369757","full_name":"perzy/co-wechat-payment","owner":"perzy","description":"Wechat payment lib for node.js koa framework.","archived":false,"fork":false,"pushed_at":"2017-11-17T11:05:39.000Z","size":12,"stargazers_count":21,"open_issues_count":3,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-25T17:13:30.581Z","etag":null,"topics":["koa","nodejs","wechat-payment"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/perzy.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":"2016-07-01T06:31:59.000Z","updated_at":"2023-05-25T09:15:24.000Z","dependencies_parsed_at":"2022-09-17T11:22:53.966Z","dependency_job_id":null,"html_url":"https://github.com/perzy/co-wechat-payment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/perzy/co-wechat-payment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perzy%2Fco-wechat-payment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perzy%2Fco-wechat-payment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perzy%2Fco-wechat-payment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perzy%2Fco-wechat-payment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perzy","download_url":"https://codeload.github.com/perzy/co-wechat-payment/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perzy%2Fco-wechat-payment/sbom","scorecard":{"id":728267,"data":{"date":"2025-08-11","repo":{"name":"github.com/perzy/co-wechat-payment","commit":"a817dc37f5d9bd74bfc415643be31c20498baf7f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":1,"reason":"Found 2/11 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T13:33:58.645Z","repository_id":57201883,"created_at":"2025-08-22T13:33:58.645Z","updated_at":"2025-08-22T13:33:58.645Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29817178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T05:36:42.804Z","status":"ssl_error","status_checked_at":"2026-02-25T05:36:31.934Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["koa","nodejs","wechat-payment"],"created_at":"2024-11-29T23:14:23.736Z","updated_at":"2026-02-25T10:07:13.898Z","avatar_url":"https://github.com/perzy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# co-wechat-payment\n微信支付 for node.js\n\n[![npm version](https://badge.fury.io/js/co-wechat-payment.svg)](http://badge.fury.io/js/co-wechat-payment)\n\n## Installation\n```\nnpm install co-wechat-payment\n```\n\n## Usage\n\n创建统一支付订单\n```js\nvar WXPay = require('co-wechat-payment');\n\nvar wxpay = new WXPay({\n\tappId: 'xxxxxxxx',\n\tmchId: '1234567890',\n\tpartnerKey: 'xxxxxxxxxxxxxxxxx', //微信商户平台API密钥\n\tpfx: fs.readFileSync('./wxpay_cert.p12'), //微信商户平台证书\n});\n\nvar result = yield wxpay.unifiedOrder({\n\tbody: 'js H5支付',\n\tout_trade_no: '20160701'+Math.random().toString().substr(2, 10),\n\ttotal_fee: 1, // 1分钱\n\tspbill_create_ip: '10.10.10.10',\n\tnotify_url: 'http://xx.xx.xx/wxpay/notify/',\n\ttrade_type: 'JSAPI',\n\tproduct_id: '1234567890'\n});\n```\n\n查询订单\nhttps://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2\n```js\n// 通过微信订单号查\nvar result = yield wxpay.queryOrder({ transaction_id:\"xxxxxx\" });\n\n// 通过商户订单号查\nvar result = yield wxpay.queryOrder({ out_trade_no:\"xxxxxx\" });\n```\n\n关闭订单\nhttps://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_3\n```js\nvar result = yield wxpay.closeOrder({ out_trade_no:\"xxxxxx\"});\n```\n退款接口\n```js\nvar params = {\n\tappid: 'xxxxxxxx',\n\tmch_id: '1234567890',\n    op_user_id: '商户号即可',\n    out_refund_no: '20140703'+Math.random().toString().substr(2, 10),\n    total_fee: '1', //原支付金额\n    refund_fee: '1', //退款金额\n    transaction_id: '微信订单号'\n};\n\nvar result = yield wxpay.refund(params);\n```\n\n### 原生支付 (NATIVE)\n\n\n### 公众号支付 (JS API)\n\n生成JS API支付参数，发给页面\n```js\nvar result = yield wxpay.getBrandWCPayRequestParams({\n\topenid: '微信用户 openid',\n\tbody: '公众号支付测试',\n    detail: '公众号支付测试',\n\tout_trade_no: '20150331'+Math.random().toString().substr(2, 10),\n\ttotal_fee: 1,\n\tspbill_create_ip: '192.168.2.210',\n\tnotify_url: 'http://wxpay_notify_url'\n});\n\nyield this.render('/wechat/pay',{payArgs:result});\n```\n\n网页调用参数（以ejs为例）\n```js\nWeixinJSBridge.invoke(\n\t\"getBrandWCPayRequest\", \u003c%-JSON.stringify(payArgs)%\u003e, function(res){\n\t\tif(res.err_msg == \"get_brand_wcpay_request:ok\" ) {\n    \t\t// success\n    \t}\n});\n```\n\n根据之前预创建订单接口返回的prepare_id参数，生成JS API支付参数，发给页面\n```js\nvar result = yield wxpay.getJsPayRequestParams('xxxxx');\n\nyield this.render('/wechat/pay',{payArgs:result});\n```\n\n### 中间件\n\n商户服务端处理微信的回调（koa为例）\n```js\nvar wechatBodyParser = require('co-wechat-body');\napp.use(wechatBodyParser(options));\n\n// 支付结果异步通知\nrouter.post('/wechat/payment/notify', wechatPayment.middleware(), function* (){\n  var message = this.request.body;\n  // 处理你的订单状态更新逻辑. [warn] 注意，分布式并发情况下需要加锁处理.\n  // do something...\n\n  // 向微信返回处理成功信息\n  this.body = 'OK';\n\n  // 如果业务逻辑处理异常, 向微信返回错误信息，微信服务器会继续通知.\n  // this.body =  new Error('server error');\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperzy%2Fco-wechat-payment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperzy%2Fco-wechat-payment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperzy%2Fco-wechat-payment/lists"}