收藏
回答

JSAPI v3 小程序支付功能 ,获取预支付id失败,notify_url 这个参数没有具体说明

产品:JSAPI v3 小程序支付功能 

接口:JSAPI下单  

参考官方文档:https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_1.shtml

请求URL:https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi 

---------------------------------------------------------------------------------------------------------------------------------------------------------

问题:直接在postman上调用时报错:Http头Authorization值格式错误,请参考《微信支付商户REST API签名规则》

帮忙看看请求参数或方法哪里调用错了?notify_url 这个参数要满足哪些要求(文档中并没有描述清楚),是不是这个参数有问题呢

最后一次编辑于  06-14
回答关注问题邀请回答
收藏

2 个回答

  • 石峰狂
    石峰狂
    06-17

    dynamic param = new {

     "mchid": "1900006XXX",

     "out_trade_no": "1217752501201407033233368318",

     "appid": "wxdace645e0bc2cXXX",

     "description": "Image形象店-深圳腾大-QQ公仔",

     "notify_url": "https://www.weixin.qq.com/wxpay/pay.php",

     "amount": {

      "total": 1,

      "currency": "CNY"

     },

     "payer": {

      "openid": "o4GgauInH_RCEdvrrNGrntXDuXXX"

     }

    };


    string method = "POST", uri = "/v3/pay/transactions/jsapi", _timeStamp = getTimeStamp(),_nonce_str = get_nonce_str(),body = JsonHelper.SerializeObject(param);

    string message = $"{method}\n{uri}\n{_timeStamp}\n{_nonce_str}\n{body}\n";

    // 使用RSA进行签名

    string  _signature = ComputeSha256Hash(message, _mch_private_key);

    string authrizationValue = $"mchid=\"{_mch_id}\",nonce_str=\"{_nonce_str}\",timestamp=\"{_timeStamp}\",serial_no=\"{_serial_no}\",signature=\"{_signature}\"";


    HttpRequestMessage httpRequest = new HttpRequestMessage(HttpMethod.Post, jsapi_v3_Url);

                    httpRequest.Content = new StringContent(body, Encoding.UTF8, "application/json");

                    httpRequest.Headers.Add("Accept", "application/json");

                    httpRequest.Headers.Add("ContentType", "application/json");

                    httpRequest.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("WECHATPAY2-SHA256-RSA2048", authrizationValue);


    using (HttpClient httpClient = new HttpClient())

    {

          HttpResponseMessage response = await httpClient.SendAsync(httpRequest);  //这里就一直没反应,也不报错 $$_$$!

                string responseString = await response.Content.ReadAsStringAsync();

    }

    06-17
    有用
    回复
  • momo
    momo
    06-14

    阁下名字起的真不错,很疯狂

    06-14
    有用
    回复 2
    • 石峰狂
      石峰狂
      06-17
      挽尊
      06-17
      回复
    • YY
      YY
      11-26
      不说还没发现,笑死
      11-26
      回复
登录 后发表内容