代码如下php
$config = [
// 必要配置
'app_id' => 'xxxxx',
'mch_id' => 'xxxxx',
// 'secret' => 'xxxxxxx',
'key' => 'xxxxxxxx', // API 密钥
'sub_mch_id' => 'xxxxxx',
'sub_appid' => 'xxxxxxx',
'fee_type' => 'HKD',
'version' => '1.0',
];
$app = Factory::payment($config);
$out_trade_no = '434759448394849434111';
$openid = request()->input('openid');
$payInfo = [
'body' => 'test',
'out_trade_no' => $out_trade_no,
'total_fee' => 1 * 100,
'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
'openid' => $openid,
'notify_url' => "https://xxxxx.cc/weber-api/resource/payments/notify/349512521494958080/{$out_trade_no}",
'sub_openid' => $openid,
];
$result = $app->order->unify($payInfo);
签名工具只校验签名的方式是否正确,不校验参数的正确性。检查key是否正确,然后检查参数是否存在计算与请求不一致,参数非法