{"id":20675043,"url":"https://github.com/zwczou/goweixin","last_synced_at":"2026-06-04T19:31:26.195Z","repository":{"id":99440573,"uuid":"150919570","full_name":"zwczou/goweixin","owner":"zwczou","description":"微信支付","archived":false,"fork":false,"pushed_at":"2018-09-30T02:06:16.000Z","size":12,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-10T18:38:44.277Z","etag":null,"topics":["go","pay","weixin"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zwczou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-30T01:56:55.000Z","updated_at":"2019-11-25T06:14:57.000Z","dependencies_parsed_at":"2023-04-05T15:16:56.031Z","dependency_job_id":null,"html_url":"https://github.com/zwczou/goweixin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zwczou/goweixin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zwczou%2Fgoweixin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zwczou%2Fgoweixin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zwczou%2Fgoweixin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zwczou%2Fgoweixin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zwczou","download_url":"https://codeload.github.com/zwczou/goweixin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zwczou%2Fgoweixin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33917183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-04T02:00:06.755Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["go","pay","weixin"],"created_at":"2024-11-16T21:08:22.974Z","updated_at":"2026-06-04T19:31:26.180Z","avatar_url":"https://github.com/zwczou.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"微信\n=====\n\n[![GoDoc](https://godoc.org/github.com/zwczou/goweixin?status.svg)](https://godoc.org/github.com/zwczou/goweixin)\n\n### 微信支付\n\n```go\npay := goweixin.NewWeixinPay(\"appid\", \"mch_id\", \"mch_key\", \"http://example.com/weixin/notify\")\n// 开启沙箱模式\npay.Sanbox()\n// 也可以 pay = pay.Sanbox()\n\n// 强制使用双向认证\n//pay = pay.Cert(\"证书内容...\")\n\n// 开启debug模式\npay = pay.Debug()\n\n// 统一下单\nreq := \u0026goweixin.UnifiedOrderRequest{\n    TradeType:      \"JSAPI\",\n    Body:           \"测试标题\",\n    OutTradeNo:     pay.NonceStr(),\n    TotalFee:       101,\n    SpbillCreateIP: \"127.0.0.1\",\n    OpenId:         \"openid\",\n}\nresp, err := pay.UnifiedOrder(req)\nif err != nil {\n    log.Fatal(err)\n}\nfmt.Printf(\"%+v\\n\", resp)\n\n// JSAPI\nreq.OutTradeNo = pay.NonceStr()\nresp2, err := pay.Jsapi(req)\nif err != nil {\n    log.Fatal(err)\n}\nfmt.Printf(\"%+v\\n\", resp2)\n\n// 校验通知内容\n// 伪代码\n// body 请求body\nvar notify goweixin.WeixinPayNotify\nxml.Unmarshal(body, \u0026notify)\nok, err := pay.Check(notify, nil)\nif ok {\n    ctx.String(200, pay.Reply(true, \"OK\"))\n}\nctx.String(200, pay.Reply(true, \"reason\"))\n```\n\n### 工具函数\n\n```go\n// 转换map[string]string为xml\npay.ToXML(map[string]string{\"result\": \"abc\"}) // \u003cxml\u003e\u003cresult\u003eabc\u003c/result\u003e\u003c/xml\u003e\n\n// 校验签名是否正确\n// nil使用MD5\nok, err := pay.Check(val, nil)\n\n// 生成随机字符串\nRandString(10)\n\n// 生成通知回复消息\npay.Reply(true, \"OK\")\n// 如果需要自己格式化, 比如使用`echo`框架\nctx.XML(200, goweixin.ReplyResponse{Code: goweixin.Success, Message: \"ok\"})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzwczou%2Fgoweixin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzwczou%2Fgoweixin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzwczou%2Fgoweixin/lists"}