wechatpay-node-v3-ts
wechatpay-node-v3-ts copied to clipboard
Create T3 App项目中调用方法报错
TypeError: hexoid is not a function
at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected]/node_modules/formidable/src/Formidable.js:15:18)
at (rsc)/./node_modules/.pnpm/[email protected]/node_modules/formidable/src/Formidable.js (...\t3-next\.next\server\vendor-chunks\[email protected]:20:1)
at __webpack_require__ (...\t3-next\.next\server\webpack-runtime.js:33:43)
at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected]/node_modules/formidable/src/index.js:5:20)
at (rsc)/./node_modules/.pnpm/[email protected]/node_modules/formidable/src/index.js (...\t3-next\.next\server\vendor-chunks\[email protected]:63:1)
at __webpack_require__ (...\t3-next\.next\server\webpack-runtime.js:33:43)
at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected]/node_modules/superagent/lib/node/index.js:29:20)
at (rsc)/./node_modules/.pnpm/[email protected]/node_modules/superagent/lib/node/index.js (...\t3-next\.next\server\vendor-chunks\[email protected]:50:1)
at __webpack_require__
这个是我的调用方法
import fs from "node:fs";
import WxPay from "wechatpay-node-v3";
const pay = new WxPay({
appid: "***",
mchid: "***",
publicKey: fs.readFileSync("./cert/apiclient_cert.pem"), // 公钥
privateKey: fs.readFileSync("./cert/apiclient_key.pem"), // 秘钥
});
export const payNative = async () => {
try {
const params = {
description: "测试",
out_trade_no: "***",
notify_url: "https://www.weixin.qq.com/wxpay/pay.php",
amount: {
total: 1,
},
scene_info: {
payer_client_ip: "ip",
},
};
const result = await pay.transactions_native(params);
console.log(result);
} catch (error) {
console.error(error);
}
// # { status: 200, code_url: 'weixin://wxpay/bizpayurl?pr=9xFPmlUzz' }
};