51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package wxpay
|
|
|
|
import (
|
|
"crypto/md5"
|
|
"encoding/json"
|
|
"fmt"
|
|
"github.com/codinl/go-logger"
|
|
"mh-server/model"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestGenWxPaySign(t *testing.T) {
|
|
|
|
signStr := "appid=wx806c079463b5b56c&body=创建订单&device_info=WEB&fee_type=CNY&mch_id=1609877389&nonce_str=01to2hxd2Sxbp9w8kR10F6qT1V8gd93B&openid=ohuHh4tpfro8u_fUPMbHEWYx5svQ&out_trade_no=7&profit_sharing=N&sign_type=MD5&spbill_create_ip=119.137.55.15&tify_url=https://switch.deovo.com:8001/api/v1/wxpay/notice&time_start=20210613205030&total_fee=11000&trade_type=JSAPI&key=DeovoMingHuiRengTianTang45675123"
|
|
c := md5.New()
|
|
_, err := c.Write([]byte(signStr))
|
|
if err != nil {
|
|
logger.Error(err)
|
|
}
|
|
|
|
signByte := c.Sum(nil)
|
|
|
|
sign := strings.ToUpper(fmt.Sprintf("%x", signByte))
|
|
|
|
fmt.Println("sign:", sign)
|
|
|
|
//C8FDFC9A5D246C904420A9CE7691C871
|
|
//C8FDFC9A5D246C904420A9CE7691C871
|
|
|
|
}
|
|
|
|
func TestWebPay(t *testing.T) {
|
|
uid := "62389201"
|
|
totalFee := uint32(100)
|
|
user := model.User{WxOpenID: "ohuHh4tpfro8u_fUPMbHEWYx5svQ"}
|
|
webPay, err := WebPay(uid, totalFee, user.WxOpenID, "N", WxPayMember, "")
|
|
if err != nil {
|
|
fmt.Println("err:", err)
|
|
|
|
}
|
|
|
|
webPayJson, _ := json.Marshal(&webPay)
|
|
fmt.Println("webPayJson:", webPayJson)
|
|
}
|
|
|
|
func TestWxPayTransactionOrderClose(t *testing.T) {
|
|
|
|
WxPayTransactionOrderClose("100000", "1609877389")
|
|
}
|