收藏
回答

使用微信商家转帐号一直报403错误?

调用接口:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/transfer-bills

报错内容:Client error: `POST https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/transfer-bills` resulted in a `403 Forbidden` response

  1. 小程序端支付是能正常使用
  2. 使用wechatpay/wechatpay php版
  3. 商家转帐功能已开通

这是提交的参数

$order = [
  "appid" => "wx****",
  "out_bill_no" => "plasdf12456",
  "transfer_scene_id" => "1005",
  "openid" => "on5S15FTWo9Mv3iu_cK1kGUsQeUE",
  "transfer_amount" => 100,
  "transfer_remark" => "测试转帐",
  "notify_url" => "https://xxxx.cn/wechat/transfer",
  "transfer_scene_report_infos" => array [
    0 => array [
      "info_type" => "岗位类型",
      "info_content" => "外卖员"
    ],
    1 => array [
      "info_type" => "报酬说明",
      "info_content" => "推广佣金提现"
    ]
];


$instance = Builder::factory([
    'mchid'      => $config["mch_id"], // 商户号
    'serial'     => $config["mch_serial"], //「商户API证书」的「证书序列号」
    'privateKey' => Rsa::from($config["ssl_key"], Rsa::KEY_TYPE_PRIVATE), // 商户API私钥
    'certs'      => [
        $config["pub_key_id"] => Rsa::from($config["public_key"], Rsa::KEY_TYPE_PUBLIC), // 微信公钥
    ],
]);

$resp = $instance->chain(“/v3/fund-app/mch-transfer/transfer-bills”)->post([
    'json' => $order,
    'headers'=>[
        'Wechatpay-Serial'=>$config["pub_key_id"]
    ]
]);


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

3 个回答

  • 支付社区运营
    支付社区运营
    10-31

    $response->getBody(); // 返回响应体对象

    $response->getBody()->getContents(); // 返回响应体的内容作为字符串

    你好 辛苦打印下具体报错信息

    10-31
    有用
    回复 1
    • webjs - 超哥
      webjs - 超哥
      10-31
      获取不到getBody方法的内容,直接抛异常:
      10-31
      回复
  • 北望沣渭
    北望沣渭
    发表于移动端
    11-01
    程序运行进入到了异常分路,同步模式代码需要用try catch语句捕获异常,然后在catch到的异常中取response再取getBody,不建议用getContents方法取响应文本,最佳实践是__toString方法取 sdk readme 有异常捕获参考代码
    11-01
    有用
    回复
  • Memory (私信不回复)
    Memory (私信不回复)
    10-31

    403 权限异常,打印一下报错返回的 body就知道问题了

    10-31
    有用
    回复
登录 后发表内容