|
|
@@ -124,6 +124,38 @@ func TradeH5Pay(client *wechat.Client, subject, orderID, amount, notifyUrl strin |
|
|
|
} |
|
|
|
return r, nil |
|
|
|
} |
|
|
|
func TradePcPay(client *wechat.Client, subject, orderID, amount, notifyUrl, productId string) (map[string]string, error) { |
|
|
|
// 初始化 BodyMap |
|
|
|
bm := make(gopay.BodyMap) |
|
|
|
bm.Set("nonce_str", util.GetRandomString(32)). |
|
|
|
Set("body", subject). |
|
|
|
Set("out_trade_no", orderID). |
|
|
|
Set("total_fee", amount). |
|
|
|
Set("spbill_create_ip", "121.196.29.49"). |
|
|
|
Set("notify_url", notifyUrl). |
|
|
|
Set("product_id", productId). |
|
|
|
Set("trade_type", wechat.TradeType_Native). |
|
|
|
Set("sign_type", wechat.SignType_MD5) |
|
|
|
// 预下单 |
|
|
|
wxRsp, err := client.UnifiedOrder(bm) |
|
|
|
if err != nil { |
|
|
|
_ = zhios_pay_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
_, err = wechat.VerifySign(client.ApiKey, wechat.SignType_MD5, wxRsp) |
|
|
|
if err != nil { |
|
|
|
_ = zhios_pay_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
timeStamp := strconv.FormatInt(time.Now().Unix(), 10) |
|
|
|
packages := "prepay_id=" + wxRsp.PrepayId |
|
|
|
paySign := wechat.GetH5PaySign(client.AppId, wxRsp.NonceStr, packages, wechat.SignType_MD5, timeStamp, client.ApiKey) |
|
|
|
fmt.Println("paySign===", paySign) |
|
|
|
r := map[string]string{ |
|
|
|
"redirect_url": wxRsp.MwebUrl, |
|
|
|
} |
|
|
|
return r, nil |
|
|
|
} |
|
|
|
|
|
|
|
// TradeMiniProgPay is 微信小程序支付 ☑️ |
|
|
|
func TradeMiniProgPay(client *wechat.Client, subject, orderID, amount, notifyUrl, openid string) (map[string]string, error) { |
|
|
|