// 创建支付账户account1 := wxpay.NewAccount("appid", "mchid", "apiKey", false)account2 := wxpay.NewAccount("appid", "mchid", "apiKey", false)// 新建微信支付客户端client := wxpay.NewClient(account1)// 设置证书account.SetCertData("证书地址")// 设置支付账户client.setAccount(account2)// 设置http请求超时时间client.SetHttpConnectTimeoutMs(2000)// 设置http读取信息流超时时间client.SetHttpReadTimeoutMs(1000)// 更改签名类型client.SetSignType(HMACSHA256)
// 统一下单params := make(wxpay.Params)params.SetString("body", "test").SetString("out_trade_no", "436577857").SetInt64("total_fee", 1).SetString("spbill_create_ip", "127.0.0.1").SetString("notify_url", "http://notify.objcoding.com/notify").SetString("trade_type", "APP")p, _ := client.UnifiedOrder(params)// 订单查询params := make(wxpay.Params)params.SetString("out_trade_no", "3568785")p, _ := client.OrderQuery(params)// 退款params := make(wxpay.Params)params.SetString("out_trade_no", "3568785").SetString("out_refund_no", "19374568").SetInt64("total_fee", 1).SetInt64("refund_fee", 1)p, _ := client.Refund(params)// 退款查询params := make(wxpay.Params)params.SetString("out_refund_no", "3568785")p, _ := client.RefundQuery(params)