使用的.netcore,做了后台API接口服务。用了盛派的SDK,域名还未备案完成。
localhost调试时,在swagger页面调用接口,可以正常生成预付订单。在uni上运行微信开发者工具调试时,报异常(我uni上配置的是域名),请哪位大神能帮我解答下,谢谢!
异常日志如下:
{"prepay_id":null,"ResultCode":{"Success":false,"StateCode":null,"ErrorCode":null,
"ErrorMessage":"\u7CFB\u7EDF\u627E\u4E0D\u5230\u6307\u5B9A\u7684\u6587\u4EF6\u3002",
"Solution":null,"Additional":null},"VerifySignSuccess":null}
生成预支付订单代码如下:
public async Task<ActionResult> GetPrepayid([FromBody] VWxOpenPayPara wxOpenPayPara)
{
try
{
//生成订单10位序列号,此处用时间和随机数生成,商户根据自己调整,保证唯一
var sp_billno = string.Format("{0}{1}{2}", Config.SenparcWeixinSetting.TenPayV3_MchId /*10位*/, SystemTime.Now.ToString("yyyyMMddHHmmss"),
TenPayV3Util.BuildRandomStr(6));
var name = “小程序支付”;
var price = 1;//单位:分
var notifyUrl = Config.SenparcWeixinSetting.TenPayV3_WxOpenTenpayNotify;
var basePayApis = new Senparc.Weixin.TenPayV3.Apis.BasePayApis(Config.SenparcWeixinSetting);
var requestData = new Senparc.Weixin.TenPayV3.Apis.BasePay.TransactionsRequestData(WxOpenAppId, Config.SenparcWeixinSetting.TenPayV3_MchId, name, sp_billno,
new Senparc.Weixin.TenPayV3.Entities.TenpayDateTime(SystemTime.Now.AddMinutes(120).DateTime, false),
HttpContext.UserHostAddress().ToString(), notifyUrl, null, new() { currency = "CNY", total = price },
new(wxOpenPayPara.openId), null, null, null);
var result = await basePayApis.JsApiAsync(requestData);
var packageStr = "prepay_id=" + result.prepay_id;
var jsApiUiPackage = TenPaySignHelper.GetJsApiUiPackage(WxOpenAppId, result.prepay_id);
return Json(new { result = true, data = new {
prepay_id = result.prepay_id,
appId = Config.SenparcWeixinSetting.WxOpenAppId,
timeStamp = jsApiUiPackage.Timestamp,
nonceStr = jsApiUiPackage.NonceStr,
package = packageStr,
signType = "RSA",
paySign = jsApiUiPackage.Signature,
partnerid = Config.SenparcWeixinSetting.TenPayV3_MchId
} });
}
catch (Exception ex)
{
_Logger.LogInformation(ex.Message);
return Json(new
{
result = false,
msg = ex.StackTrace
});
}
}
报错:系统找不到指定的文件。谁知道盛派SDK是个啥东西