收藏
回答

B2b申请退款有没有SDK?提示参数为空或非法 detail:[支付签名[pay_sig]校验失败

请求地址:https://api.weixin.qq.com/retail/B2b/refund?access_token=84_qGSu4zasllSKLHHITY9QHhxPJhIMj3xG3ooutS8IQ4ZSgesDP1V5nO4oxQa9hMDJfRFclzN5hBOlJc0FUFepZ7i6whawkA0kEzLeYS2DUVtZY2-BRtjyF-5TogQSMBfADALFU&pay_sig=b28d627e8464832b27f9955c76b093969e1c7a9f389d5bd97682aafe271f6ca7

请求数据:{"mchid":"1686022399","out_trade_no":"20240923142431232065","order_id":"o202409231551411832182491","out_refund_no":"r2024092611365718323558","refund_amount":100,"refund_from":1}

响应结果:{"errcode":9403200,"errmsg":"参数为空或非法 detail:[支付签名[pay_sig]校验失败] rid: 66f4d6da-72a6c1db-136fbf81"}

$signData = [
    "mchid" => "1686022399",
    "out_trade_no" => "20240923142431232065",
    "order_id" => "o202409231551411832182491",
    "out_refund_no" => "r2024092611365718323558",
    "refund_amount" => 100,
    "refund_from" => 1
];
$signData = json_encode($signData, JSON_UNESCAPED_UNICODE);
$appKey = "1OQZtyTWw94IUxhhZYPeqxcDuw8voUTN";
$pay_sig = hash_hmac('sha256', 'requestCommonPayment&' . $signData, $appKey);
最后一次编辑于  09-26
回答关注问题邀请回答
收藏

2 个回答

  • 很复杂😏
    很复杂😏
    12-09
    就是这么写的 还是报错9403200
    
    $postdata = [];
                $postdata['mchid'] = $paylog['mch_id'];
                $postdata['out_trade_no'] = $ordernum;
                $postdata['order_id'] = $paylog['transaction_id'];
                $postdata['out_refund_no'] = date('YmdHis').rand(1000,9999);
                $postdata['refund_amount'] = intval(bcmul($refundmoney, 100, 0));
                $postdata['refund_from'] = 1;//退款来源,枚举值 1:人工客服退款 2:用户自己退款 3:其他
    //            $postdata['refund_reason'] = 0;//退款原因,枚举值 0:暂无描述 1:产品问题 2:售后问题 3:意愿问题 4:价格问题 5:其他原因
                $appkey = $appinfo['wxpay_b2b_appkey'];
                $pay_sig = self::b2b_pay_sig('/retail/B2b/refund',jsonEncode($postdata), $appkey);
                $rs = curl_post($url.'&pay_sig='.$pay_sig, jsonEncode($postdata));
    
    
    private function b2b_pay_sig($uri, $post_body, $appkey) {
        $need_sign_msg = $uri . '&' . $post_body;
        return hash_hmac('sha256', $need_sign_msg, $appkey);
    }
    
    12-09
    有用
    回复 1
    • 很复杂😏
      很复杂😏
      12-09
      已解决,服务端只能用现网appkey,前端用哪个都行
      12-09
      回复
  • 选择
    选择
    09-26

    已处理,uri使用错误导致,感谢各位大佬的关注。

    09-26
    有用
    回复 2
    • 对方正在输入...
      对方正在输入...
      10-11
      你好怎么解决的,看了你的代码,我按照你的写的也不行
      10-11
      回复
    • 选择
      选择
      11-27回复对方正在输入...
      hash_hmac('sha256', '/retail/B2b/refund&' . json_encode($signData), $appKey)
      11-27
      回复
登录 后发表内容