收藏
回答

云托管微信支付得到"参数格式校验错误",问题在哪里?

云托管的后端发起支付,得到错误

{"errcode":0,"errmsg":"ok","respdata":{"return_code":"FAIL","return_msg":"参数格式校验错误"}}

后端 php 代码如下(curl部分来自 TCloudBase/wxcloudrun-pay-demo )

public function directPay()

    {

        $url  = 'http://api.weixin.qq.com/_/pay/unifiedOrder';

        $hdr  = Request::header();

        $data = array(

            "out_trade_no"  => time(),

            "body"          => "测试支付",

            "total_fee"     => 50,

            "openid"        => $hdr["x-wx-openid"],

            "env_id"        => $hdr["x-wx-env"],

            "spbill_create_ip" => $hdr["x-original-forwarded-for"],

            "sub_mch_id"    => "151195123",

            "callback_type" => 2,

            "container"     => array(

                "service"   => $hdr["x-wx-service"],

                "path"      => "/api/payback",

            )

        );

        $curl = curl_init();

        curl_setopt_array($curl, array(

            CURLOPT_URL => $url,

            CURLOPT_RETURNTRANSFER => true,

            CURLOPT_ENCODING => '',

            CURLOPT_MAXREDIRS => 10,

            CURLOPT_TIMEOUT => 0,

            CURLOPT_FOLLOWLOCATION => true,

            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

            CURLOPT_CUSTOMREQUEST => 'POST',

            CURLOPT_POSTFIELDS => json_encode($data),

            CURLOPT_HTTPHEADER => array(

                'Content-Type: application/json'

            ),

        ));

        $response = curl_exec($curl);

        curl_close($curl);

        return $response;

    }

很急!


回答关注问题邀请回答
收藏

4 个回答

  • Memory
    Memory
    2023-05-08

    商户号1开9位?

    2023-05-08
    有用 2
    回复 6
    • 宏叔®
      宏叔®
      2023-05-09
      商户号是 1511954081
      2023-05-09
      回复
    • 宏叔®
      宏叔®
      2023-05-09
      完整数据如下 {"out_trade_no":1683341547,"body":"微信支付测试","total_fee":50,"openid":"o1A6u4md1zyf7uqEg3obw3ivDYag","env_id":"prod-4gb2q25m538957ce","appid":"wx43f46dfd311facc3","spbill_create_ip":"116.228.38.138","mch_id":"1511954081","container":{"service":"develop","path":"/api/payback"}}
      2023-05-09
      回复
    • Memory
      Memory
      2023-05-09回复宏叔®
      单纯看内容看不出来,去提个工单吧
      2023-05-09
      回复
    • 宏叔®
      宏叔®
      2023-05-09回复Memory
      能给个提交工单的地址吗?我在云托管里提交了,说不归他们管
      2023-05-09
      回复
    • 宏叔®
      宏叔®
      2023-05-10
      ??
      2023-05-10
      回复
    查看更多(1)
  • 向日葵托管教育史老师
    向日葵托管教育史老师
    01-16

    不要看示例json,对照着请求参数表每个参数不能少,参数类型也必须对

    01-16
    有用
    回复
  • lsq
    lsq
    2023-06-06

    同问

    2023-06-06
    有用
    回复
  • 宏叔®
    宏叔®
    2023-05-06

    补充:环境ID prod-4gb2q25m538957ce 2023-05-06 下午测试过几次

    2023-05-06
    有用
    回复
登录 后发表内容