-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
70 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package wechat | ||
|
||
import ( | ||
"fmt" | ||
"github.com/lucky-lee/gutil/gStr" | ||
"time" | ||
) | ||
|
||
//二次签名支付配置 | ||
type TwoSignApp struct { | ||
AppId string `json:"app_id" xml:"appid"` | ||
NonceStr string `json:"nonce_str" xml:"noncestr"` | ||
packAge string `json:"package" xml:"package"` | ||
PartnerId string `json:"partner_id" xml:"partnerid"` | ||
PrepayId string `json:"prepay_id" xml:"prepayid"` | ||
Timestamp string `json:"timestamp" xml:"timestamp"` | ||
Sign string `json:"sign" xml:"-"` | ||
PackageVal string `json:"package_val" xml:"-"` | ||
OrderId string `json:"order_id"` //订单id | ||
} | ||
|
||
//生成-二次签名-配置 | ||
func newTwoSignApp(orderId, prepayId string) (res TwoSignApp) { | ||
pVal := "Sign=WXPay" | ||
|
||
res.AppId = AppId() | ||
res.PartnerId = MchId() | ||
res.PrepayId = prepayId | ||
res.NonceStr = gStr.RandStr(32) | ||
res.Timestamp = fmt.Sprintf("%d", time.Now().Unix()) | ||
res.packAge = pVal | ||
res.PackageVal = pVal | ||
res.Sign = toSign(res) | ||
res.OrderId = orderId | ||
|
||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package wechat | ||
|
||
import ( | ||
"fmt" | ||
"github.com/lucky-lee/gutil/gStr" | ||
"time" | ||
) | ||
|
||
type TwoSignApplet struct { | ||
AppId string `json:"app_id" xml:"appId"` //应用id | ||
NonceStr string `json:"nonce_str" xml:"nonceStr"` //随机字符串 不长于32位 | ||
Package string `json:"package" xml:"package"` //数据包 | ||
SignType string `json:"sign_type" xml:"signType"` //签名方式 | ||
Timestamp string `json:"timestamp" xml:"timeStamp"` //时间戳 | ||
|
||
PaySign string `json:"pay_sign" xml:"-"` // | ||
OrderId string `json:"order_id"` //订单id | ||
} | ||
|
||
//生成 二次签名 配置 | ||
func newTwoSignApplet(orderId, prepayId string) (res TwoSignApplet) { | ||
res.AppId = AppId() | ||
res.Timestamp = fmt.Sprintf("%d", time.Now().Unix()) | ||
res.NonceStr = gStr.RandStr(32) | ||
res.Package = fmt.Sprintf("prepay_id=%s", prepayId) | ||
res.SignType = "MD5" | ||
res.PaySign = toSign(res) | ||
res.OrderId = orderId | ||
|
||
return | ||
} |