package main import ( "encoding/json" "flag" "fmt" "github.com/gin-gonic/gin" "gold-shop/global" "gold-shop/initialize" "gold-shop/request" "gold-shop/route" "gold-shop/utils" "gold-shop/utils/tlpay" "gold-shop/utils/tlpay/notify" "net/url" ) func main() { initial() //testVerify() //runServer() runServerInWindows() } func initial() { var configFilePath string flag.StringVar(&configFilePath, "config", "./config.yaml", "配置文件") flag.Parse() global.Config = initialize.InitConfig(configFilePath) global.DB = initialize.InitDB(global.Config) global.Redis = initialize.InitRedis(global.Config) } /*func runServer() { r := gin.Default() s := &http.Server{ Addr: ":8080", Handler: r, ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, MaxHeaderBytes: 1 << 20, } route.Initial(r) err := endless.ListenAndServe(":"+global.Config.Server.Port, s.Handler) if err != nil { panic(err) } }*/ func runServerInWindows() { r := gin.Default() route.Initial(r) r.Run(":9090") } func payOrder1() { params := url.Values{} params.Set("service", "pay.order") params.Set("apikey", "00014005") params.Set("money", "0.01") params.Set("nonce_str", "slfksldfs22dfsf") //params.Set("sign", "") params.Set("auth_token", "555555") //params.Set("mch_orderid", "") //params.Set("mid", "") //params.Set("guid", "") params.Set("remarks", "tst") sign := utils.Sign(params, "punr8ucu") params.Set("sign", sign) fmt.Println(params.Encode()) utils.Post("http://api2uat.lfwin.com/payapi/cash/pay_order", params) } func payOrderCommon() { params := url.Values{} params.Set("service", "comm.js.pay") params.Set("apikey", "00014005") params.Set("money", "0.01") params.Set("sub_appid", "wxb1bec7d809e7cf40") params.Set("sub_openid", "ohyVV0v4UBc63GL8D8nlEL0UO5vE") params.Set("nonce_str", "slfksldfs22dfsf") //params.Set("sign", "") params.Set("mch_orderid", "444444444") //params.Set("mch_orderid", "") //params.Set("notify_url", "") //params.Set("guid", "") params.Set("remarks", "tst") sign := utils.Sign(params, "punr8ucu") params.Set("sign", sign) fmt.Println(params.Encode()) utils.Post("http://api2.lfwin.com/payapi/mini/wxpay", params) } func payOrder2() { params := url.Values{} params.Set("grant_type", "client_credentials") utils.Post1("https://api.paypal.com/v1/oauth2/token", params) } func payOrder3() { amount := request.Amount{ CurrencyCode: "USD", Value: "0.01", } purchaseUnit := request.PurchaseUnit{ Amount: amount, Description: "test", CustomId: 1, } r := request.CheckOutOrderRequest{ Intent: "CAPTURE", PurchaseUnits: []request.PurchaseUnit{ purchaseUnit, }, ApplicationContext: request.ApplicationContext{ CancelUrl: "https://www.baidu.com", ReturnUrl: "https://www.baidu.com", }, } body, err := json.Marshal(r) if err != nil { panic(err) } token := "A21AAPb6qISsbMc4lPtdW4imLL13_m0zH1n8CQ_zL-PQgwvaj1g6tM86GqBBAy1NL55KKDTbbuyMDplzDsk8-rCWzNKPxB2-w" fmt.Println(string(body)) utils.Post2("https://api.paypal.com/v2/checkout/orders", string(body), token) } func testVerify() { str := "{\"cusid\":\"6603910521126XB\",\"appid\":\"00307595\",\"outTrxid\":\"2024051323201201\",\"trxcode\":\"VSP301\",\"trxid\":\"240513117804146702\",\"initamt\":\"10\",\"trxamt\":\"10\",\"trxdate\":\"20240513\",\"paytime\":\"20240513232054\",\"chnltrxid\":\"\",\"trxstatus\":\"0000\",\"termno\":\"\",\"termbatchid\":\"\",\"termtraceno\":\"0\",\"termauthno\":\"0513030178146702\",\"termrefnum\":\"2405132301010100017804146702\",\"trxreserved\":\"充值\",\"srctrxid\":\"\",\"cusorderid\":\"2024051323201201\",\"acct\":\"6226631705801444\",\"fee\":\"0\",\"cmid\":\"\",\"chnlid\":\"\",\"chnldata\":\"\",\"accttype\":\"00\",\"bankcode\":\"03030000\",\"logonid\":\"\",\"signtype\":\"RSA\",\"sign\":\"bQlu7ErUyYhmk5Atv7RWcqAnD1B7Ls0UwAaSJSXn7vJkTsl2C0NZ8pXYPpXeVxrZY7D+YWoUkHTSmtZH5V4qRtzlWDZSdOE8T3eeEs54tibr5ZUg6UuhbunUrznyTLRKsof+BvLjDp+4bYCG1+q/mesAXDOqA1fHXkc1jDvvGdQ=\"}" req := notify.PayAgreeNotify{} err := json.Unmarshal([]byte(str), &req) fmt.Println("err1", err) params, err := utils.StructToURLValues(req) fmt.Println("err2", err) err = tlpay.TLPay.Verify(params) fmt.Println("err3", err) }