uni-app 支付宝配置

363 阅读1分钟

"errMsg":"requestPayment:fail [payment支付宝:62009]未知错误""code":-100

这个报错的原因是因为支付宝的密钥配置错误

privateKey 私钥与 alipayPublicKey公钥不匹配

const unipay = require('@dcloudio/unipay');
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)

	const unipayIns = unipay.initAlipay({
		appId: '', // APPId
		mchId: '',// 商户号
		privateKey: "",// 私钥 对中的私钥
		alipayPublicKey: ""// 支付宝的公钥
	});
	let orderInfo = await unipayIns.getOrderInfo({
		"subject": event.subject,// 支付名称
		"outTradeNo": event.outTradeNo,// 订单编号
		"totalFee": event.totalFee,// 订单金额
		"notifyUrl": "",// 订单完成回调地址
		"spbillCreateIp": context.CLIENTIP,// 客户端IP
		"tradeType": "APP"// 调用支付类型
	})
	//返回数据给客户端
	return orderInfo
};