突然发现微信支付V3版jsapi支付,当支付金额为1.10元时,无法唤起微信支付,其他金额如1.00,2.10能正常唤起支付。错误如下:
[2025-05-10T21:08:22+08:00][error] [400]Client error: `POST https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi` resulted in a `400 Bad Request` response:
{"code":"PARAM_ERROR","detail":{"location":"body","value":110.00000000000001},"message":"无法将 JSON 输入源“/bod (truncated...)
前端代码如下:
$order = [
'appid' => config("ydy.appid"), // 小程序或公众号AppID
'mchid' => $merchantId, // 商户号
'description' => $res['SFXM'], // 商品描述
'out_trade_no' => $out_trade_no, // 商户订单号
'notify_url' => $notify_url, // 支付结果通知地址
'amount' => [
'total' => $res['JE'] * 100, // 金额,单位:分
'currency' => 'CNY', // 货币类型
],
'payer' => [
'openid' => $openid, // 用户的OpenID
],
];
try {
$resp = $instance->chain('v3/pay/transactions/jsapi')->post(['json' => $order]);
} catch (\Exception $e) {
return 'error';
}
请问如何解决?是否还有其他金额也会出现这样的问题?
你金额精度有问题
Array
(
[appid] => wx2********e4
[mchid] => 171***054
[description] => 舞蹈
[out_trade_no] => 20250510202403-681f456324778
[notify_url] => https://****.com/wxpay/xsxx/notify
[amount] => Array
(
[total] => 110
[currency] => CNY
)
[payer] => Array
(
[openid] => o6iK66EH-JWsQ********yY7GAE
)
)