From be6d856e9f9eb15ea6952945cc5c001aeaebf9a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Thu, 29 Sep 2022 10:41:16 +0800 Subject: [PATCH] - update --- const.go | 52 +++++++++++++--------------------------------------- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 16 insertions(+), 42 deletions(-) diff --git a/const.go b/const.go index ef14cc1..f843308 100644 --- a/const.go +++ b/const.go @@ -1,7 +1,5 @@ package wechatpayopen -import "time" - // 微信支付 API 地址 const ( apiUrl = "https://api.mch.weixin.qq.com" @@ -10,26 +8,8 @@ const ( // SDK 相关信息 const ( - LogTable = "wechatpayopen" - Version = "1.0.24" // SDK 版本 - UserAgentFormat = "WechatPay-Go/%s (%s) GO/%s" // UserAgent中的信息 -) - -// HTTP 请求报文 Header 相关常量 -const ( - Authorization = "Authorization" // Header 中的 Authorization 字段 - Accept = "Accept" // Header 中的 Accept 字段 - ContentType = "Content-Type" // Header 中的 ContentType 字段 - ContentLength = "Content-Length" // Header 中的 ContentLength 字段 - UserAgent = "User-Agent" // Header 中的 UserAgent 字段 -) - -// 常用 ContentType -const ( - ApplicationJSON = "application/json" - ImageJPG = "image/jpg" - ImagePNG = "image/png" - VideoMP4 = "video/mp4" + LogTable = "wechatpayopen" + Version = "1.0.25" // SDK 版本 ) // 请求报文签名相关常量 @@ -39,21 +19,6 @@ const ( HeaderAuthorizationFormat = "%s mchid=\"%s\",nonce_str=\"%s\",timestamp=\"%d\",serial_no=\"%s\",signature=\"%s\"" ) -// HTTP 应答报文 Header 相关常量 -const ( - WechatPayTimestamp = "Wechatpay-Timestamp" // 微信支付回包时间戳 - WechatPayNonce = "Wechatpay-Nonce" // 微信支付回包随机字符串 - WechatPaySignature = "Wechatpay-Signature" // 微信支付回包签名信息 - WechatPaySerial = "Wechatpay-Serial" // 微信支付回包平台序列号 - RequestID = "Request-Id" // 微信支付回包请求ID -) - -// 时间相关常量 -const ( - FiveMinute = 5 * 60 // 回包校验最长时间(秒) - DefaultTimeout = 30 * time.Second // HTTP 请求默认超时时间 -) - func getAuthorizationType() string { return "WECHATPAY2-" + algorithm() } @@ -63,8 +28,17 @@ func algorithm() string { return "SHA256-RSA2048" } -const ( - CodeSuccess = "SUCCESS" +// 接口状态 +const ( + CodeSUCCESS = "SUCCESS" // 支付成功 退款成功 + CodeREFUND = "REFUND" // 转入退款 + CodeNOTPAY = "NOTPAY" // 未支付 + CodeCLOSED = "CLOSED" // 已关闭 退款关闭 + CodeREVOKED = "REVOKED" // 已撤销 + CodeUSERPAYING = "USERPAYING" // 用户支付中 + CodePAYERROR = "PAYERROR" // 支付失败 + CodePROCESSING = "PROCESSING" // 退款处理中 + CodeABNORMAL = "ABNORMAL" // 退款异常 ) type ApiError struct { diff --git a/go.mod b/go.mod index 929694f..752aa0a 100644 --- a/go.mod +++ b/go.mod @@ -85,7 +85,7 @@ require ( golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220927171203-f486391704dc // indirect golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7 // indirect - golang.org/x/sys v0.0.0-20220927170352-d9d178bc13c6 // indirect + golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 771dc1d..c8cc9a1 100644 --- a/go.sum +++ b/go.sum @@ -654,8 +654,8 @@ golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220927170352-d9d178bc13c6 h1:cy1ko5847T/lJ45eyg/7uLprIE/amW5IXxGtEnQdYMI= -golang.org/x/sys v0.0.0-20220927170352-d9d178bc13c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI= +golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=