Client error: `POST https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi` resulted in a `401 Unauthorized` response: {"code":"SIGN_ERROR","detail":{"detail":{"issue":"sign not match"},"field":"signature","location":"authorization","sign_ (truncated...) 401 Unauthorized {"code":"SIGN_ERROR","detail":{"detail":{"issue":"sign not match"},"field":"signature","location":"authorization","sign_information":{"method":"POST","sign_message_length":386,"truncated_sign_message":"POST\n/v3/pay/transactions/jsapi\n1673516732\nBmDeMJd2KTv6g0XqySrv5HlSt6y7amWk\n{\"mchid\"\n","url":"/v3/pay/transactions/jsapi"}},"message":"签名错误,请检查后再试" #0
{\"mchid\"\n"
从日志提示上看,你初始化Builder::factory([])商户号 可能没取到,另外建议装个dev包,IDE就带提示了
https://github.com/TheNorthMemory/wechatpay-openapi/blob/master/src/V3/Pay/Transactions/Jsapi.php#L17-L58
public function post(array $options = [ 'json' => [ 'appid' => 'wxd678efh567hg6787', 'mchid' => '1230000109', 'description' => 'Image形象店-深圳腾大-QQ公仔', 'attach' => '自定义数据', 'out_trade_no' => '1217752501201407033233368018', 'amount' => [ 'total' => 100, 'currency' => 'CNY', ], 'time_expire' => '2018-06-08T10:34:56+08:00', 'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php', 'goods_tag' => 'WXG', 'limit_pay' => ['string'], 'support_fapiao' => true, 'detail' => [ 'cost_price' => 608800, 'invoice_id' => '微信123', 'goods_detail' => [[ 'merchant_goods_id' => '商品编码', 'wechatpay_goods_id' => '1001', 'goods_name' => 'iPhoneX 256G', 'quantity' => 1, 'unit_price' => 828800, ],], ], 'scene_info' => [ 'payer_client_ip' => '14.23.150.211', 'device_id' => '013467007045764', 'store_info' => [ 'id' => '0001', 'name' => '腾讯大厦分店', 'area_code' => '440305', 'address' => '广东省深圳市南山区科技中一道10000号', ], ], 'payer' => [ 'openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o', ], ], ]): ResponseInterface;