// 实现接口 func (d *DefaultAlipayClient) ExecuteWithToken(r request.AlipayRequest, token string) (response.AlipayResponse, error) { // 请求 msg, rp, err := d.post(r, token) if err != nil { return nil, err } log.Debugf("alipay return : %s", msg) // body resp := r.GetResponse() resp.SetBody(msg) // replace k := xstrings.ToSnakeCase(resp.ToStr()) if strings.Contains(msg, k) { msg = strings.Replace(msg, k, "response", 1) } else { msg = strings.Replace(msg, "error_response", "response", 1) } // convert var t = &struct { Response response.AlipayResponse `json:"response"` Sign string `json:"sign"` }{ resp, "", } err = json.Unmarshal([]byte(msg), t) if err != nil { log.Error(err) } // 当发生安全机制接入错误时 // 详细见https://fuwu.alipay.com/platform/doc.htm#c09 if !resp.IsSuccess() { logger.SecureError(rp, resp) } return resp, nil }
func (p *parser) addPos(f reflect.Value, sf reflect.StructField) error { p.posArgs = append(p.posArgs, newArg(f, sf, strings.ToUpper(xstrings.ToSnakeCase(sf.Name)))) return nil }