修复支付网关地址空白字符

This commit is contained in:
yml
2026-06-15 00:53:05 +08:00
parent a275a006eb
commit 4a0d615926
4 changed files with 80 additions and 8 deletions
@@ -395,7 +395,7 @@ func notifyParamKeys(params map[string]string) []string {
}
func (c *Client) validate() error {
if c.cfg.GatewayURL == "" || c.cfg.MerchantID == "" || c.cfg.SignKey == "" {
if strings.TrimSpace(c.cfg.GatewayURL) == "" || c.cfg.MerchantID == "" || c.cfg.SignKey == "" {
return ErrConfigIncomplete
}
if c.cfg.SignType != "" && !strings.EqualFold(c.cfg.SignType, "MD5") {
@@ -409,7 +409,7 @@ func (c *Client) post(ctx context.Context, params map[string]string) (map[string
for key, value := range params {
values.Set(key, value)
}
httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, c.cfg.GatewayURL, strings.NewReader(values.Encode()))
httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, strings.TrimSpace(c.cfg.GatewayURL), strings.NewReader(values.Encode()))
if err != nil {
return nil, err
}