- 总是遇见这种沙雕问题,prepay_id=up_wx21201855730335ac86f8c43d
下单返回prepay_id=wx21201855730335ac86f8c43d 调起支付prepay_id=up_wx21201855730335ac86f8c43d 为啥调起支付要多个up_
2024-11-30 - 微信支付请求用的User-Agent的值是怎么来的,怎么设置的
提示:{\"code\":\"INVALID_REQUEST\",\"message\":\"Http头缺少Accept或User-Agent\"}
2024-11-29 - 签名相关问题-如何在程序中加载私钥-提示系统找不到指定文件
使用这段代码加载私钥,提示系统找不到指定文件是为何? 我的代码 protected string sign(string message) 2{ 3 // 需去除私钥文件中的-----BEGIN/END PRIVATE KEY----- 4 string privateKey = "MIIEvgIBADANBgkqhkiG...30HBe+GD1tntZgf6I1Y0ZpHZ"; 5 byte[] keyData = Convert.FromBase64String(privateKey); 6 using (CngKey cngKey = CngKey.Import(keyData, CngKeyBlobFormat.Pkcs8PrivateBlob)) 7 using (RSACng rsa = new RSACng(cngKey)) 8 { 9 byte[] data = System.Text.Encoding.UTF8.GetBytes(message); 10 return Convert.ToBase64String(rsa.SignData(data, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1)); 11 } 12}
2024-11-29 - 微信公众号jsapi下单支付通过私钥加密遇见Internal Server: 系统找不到指定的文件。
代码: protected string Sign(string message) { // NOTE: 私钥不包括私钥文件起始的-----BEGIN PRIVATE KEY----- // 亦不包括结尾的-----END PRIVATE KEY----- string keyFilePath = AppDomain.CurrentDomain.BaseDirectory + "apiclient_key.pem"; string privateKey = System.IO.File.ReadAllText(keyFilePath); byte[] keyData = Convert.FromBase64String(privateKey.Replace("-----BEGIN PRIVATE KEY-----", "") .Replace("-----END PRIVATE KEY-----", "") .Replace("\n", "") .Replace("\r", "")); //byte[] keyData = Convert.FromBase64String(privateKey); var rsa = RSA.Create(); rsa.ImportPkcs8PrivateKey(keyData, out _); byte[] data = System.Text.Encoding.UTF8.GetBytes(message); return Convert.ToBase64String(rsa.SignData(data, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1)); } 遇到的问题: Internal Server: 系统找不到指定的文件。 User data verification failed. Please input it correctly. Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: 系统找不到指定的文件。 at System.Security.Cryptography.CngKeyLite.ImportKeyBlob(String blobType, ReadOnlySpan`1 keyBlob, Boolean encrypted, ReadOnlySpan`1 password) at System.Security.Cryptography.CngPkcs8.ImportPkcs8(ReadOnlySpan`1 keyBlob) at System.Security.Cryptography.CngPkcs8.ImportPkcs8PrivateKey(ReadOnlySpan`1 source, Int32& bytesRead) at System.Security.Cryptography.RSAImplementation.RSACng.ImportPkcs8PrivateKey(ReadOnlySpan`1 source, Int32& bytesRead) at MRPrintWeChatAppointment.Web.Entry.Controllers.HttpHandler.Sign(String message) at MRPrintWeChatAppointment.Web.Entry.Controllers.HttpHandler.BuildAuthAsync(HttpRequestMessage request) at MRPrintWeChatAppointment.Web.Entry.Controllers.HttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at MRPrintWeChatAppointment.Web.Entry.Controllers.WxPayController.PaymentOrder(String openId, String orderId, Decimal totalFee) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) json HTTP ERROR 500
2024-11-28 - 微信支付jsapi接口下单接口提示输入源“/appid”映射到字段“公众号ID”必填性规则校验失败?
{ "mchid":"1699804678", "out_trade_no":"123", "appid":"wxcf81a39ba80de894", "description":"测试测试", "notify_url":"http://test.xunmi.org.cn/", "amount":{ "total":2, "currency":"CNY" }, "payer":{ "openid":"222222222" } } 明明都提供了不知为何还报这个错误
2024-11-27