github.com/gorocks/apikit@v0.0.0-20170808011444-396ab031afbd/pay/doc.go (about) 1 /* 2 Package pay provides several pay services API access. 3 4 Example: 5 s := wechat.New(&http.Client{}) 6 r := wechat.OrderReq{} 7 r.AppID = "" 8 r.MchID = "" 9 rand.Seed(time.Now().UnixNano()) 10 r.NonceStr = strconv.FormatInt(rand.Int63n(99999999999999), 10) 11 r.Body = "Test" 12 r.OutTradeNo = strconv.FormatInt(time.Now().UnixNano(), 10) 13 r.TotalFee = 1 14 r.SpbillCreateIP = "127.0.0.1" 15 r.NotifyURL = "http://www.baidu.com" 16 r.TradeType = "APP" 17 r.Sign = s.Sign(r, "") 18 resp, err := s.Order(&r) 19 fmt.Printf("%#v %s\n", resp, err) 20 21 s := ali.New(&http.Client{}) 22 r := ali.OrderReq{} 23 r.Service = "create_direct_pay_by_user" 24 r.Partner = "" 25 r.InputCharset = "utf-8" 26 r.SignType = "MD5" 27 r.NotifyURL = "http://127.0.0.1" 28 r.OutTradeNo = strconv.FormatInt(time.Now().UnixNano(), 10) 29 r.Subject = "Test" 30 r.PaymentType = "1" 31 r.TotalFee = "0.01" 32 r.SellerEmail = "" 33 r.Sign = string(s.Sign(r, []byte(``))) 34 fmt.Println(s.PayURL(r)) 35 36 r := union.DefaultOrderReq() 37 r.CertID = "" // openssl pkcs12 -in acp_prod_sign.pfx -clcerts -nokeys -out key.cert 38 r.BackURL = "http://127.0.0.1" 39 r.MerID = "" 40 r.OrderID = strconv.FormatInt(time.Now().UnixNano(), 10) 41 r.FrontURL = "http://127.0.0.1" 42 r.OrderDesc = "desc" 43 secret := `` // openssl pkcs12 -in acp_prod_sign.pfx -nocerts -nodes -out key.pem 44 s := union.Sign(req, []byte(secret)) 45 r.Signature = s 46 resp := union.AppConsume(r) 47 public := `` // acp_prod_verify_sign.cer 48 fmt.Println(union.Verify(resp, []byte(public), []byte(resp.Signature))) 49 */ 50 package pay