You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
2.8 KiB
Go

11 months ago
package main
import (
8 months ago
"encoding/json"
11 months ago
"fmt"
8 months ago
"github.com/fvbock/endless"
11 months ago
"github.com/gin-gonic/gin"
8 months ago
"gold-shop/global"
"gold-shop/initialize"
"gold-shop/request"
"gold-shop/route"
"gold-shop/utils"
"net/http"
"net/url"
"time"
11 months ago
)
func main() {
8 months ago
RunServer()
8 months ago
}
func RunServer() {
11 months ago
global.Config = initialize.InitConfig()
global.DB = initialize.InitDB(global.Config)
8 months ago
global.Redis = initialize.InitRedis(global.Config)
11 months ago
r := gin.Default()
8 months ago
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 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)
11 months ago
}