You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
7.0 KiB
95 lines
7.0 KiB
1 month ago
|
using LitJson;
|
||
|
using Org.BouncyCastle.Crypto.Engines;
|
||
|
using Org.BouncyCastle.Crypto.Modes;
|
||
|
using Org.BouncyCastle.Crypto.Parameters;
|
||
|
using Sog;
|
||
|
using Sog.IO;
|
||
|
using System;
|
||
|
using System.Text;
|
||
|
|
||
|
namespace HttpProxyPay
|
||
|
{
|
||
|
public class GmCmdSvc : BaseReloadableService
|
||
|
{
|
||
|
public override int GetServiceType()
|
||
|
{
|
||
|
return HttpProxyPayServiceType.GmCmdSvc;
|
||
|
}
|
||
|
|
||
|
//销毁的时候清空指令注册
|
||
|
public override void Dispose()
|
||
|
{
|
||
|
GmCommandMgr.Instance.ClearAll();
|
||
|
}
|
||
|
|
||
|
//构造的时候注册所有指令
|
||
|
public GmCmdSvc()
|
||
|
{
|
||
|
RegisterAllGmCmd();
|
||
|
}
|
||
|
|
||
|
private void RegisterAllGmCmd()
|
||
|
{
|
||
|
GmCommandMgr.Instance.Register("TestPay", "TestPay", this.TestPay);
|
||
|
}
|
||
|
|
||
|
public int TestPay(long userid, string[] cmdParams)
|
||
|
{
|
||
|
|
||
|
//if (cmdParams.Length < 1)
|
||
|
//{
|
||
|
// return -1;
|
||
|
//}
|
||
|
//HttpProxyPayMsgHandler.PayWsjsapiReq(1,null);
|
||
|
//TraceLog.Trace("verify " +HttpProxyPayMsgHandler.VerifyWithSHA256RSA(
|
||
|
// "1722850421\nd824f2e086d3c1df967785d13fcd22ef\n{\"code_url\":\"weixin://wxpay/bizpayurl?pr=JyC91EIz1\"}\n",
|
||
|
// //"1554209980\\nc5ac7061fccab6bf3e254dcf98995b8c\\n{\"data\":[{\"serial_no\":\"5157F09EFDC096DE15EBE81A47057A7232F1B8E1\",\"effective_time\":\"2018-03-26T11:39:50+08:00\",\"expire_time\":\"2023-03-25T11:39:50+08:00\",\"encrypt_certificate\":{\"algorithm\":\"AEAD_AES_256_GCM\",\"nonce\":\"d215b0511e9c\",\"associated_data\":\"certificate\",\"ciphertext\":\"...\"}}]}\\n",
|
||
|
// "-----BEGIN PUBLIC KEY-----\r\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4zej1cqugGQtVSY2Ah8RMCKcr2UpZ8Npo+5Ja9xpFPYkWHaF1Gjrn3d5kcwAFuHHcfdc3yxDYx6+9grvJnCA2zQzWjzVRa3BJ5LTMj6yqvhEmtvjO9D1xbFTA2m3kyjxlaIar/RYHZSslT4VmjIatW9KJCDKkwpM6x/RIWL8wwfFwgz2q3Zcrff1y72nB8p8P12ndH7GSLoY6d2Tv0OB2+We2Kyy2+QzfGXOmLp7UK/pFQjJjzhSf9jxaWJXYKIBxpGlddbRZj9PqvFPTiep8rvfKGNZF9Q6QaMYTpTp/uKQ3YvpDlyeQlYe4rRFauH3mOE6j56QlYQWivknDX9VrwIDAQAB\r\n-----END PUBLIC KEY-----",
|
||
|
// "mfI1CPqvBrgcXfgXMFjdNIhBf27ACE2YyeWsWV9ZI7T7RU0vHvbQpu9Z32ogzc+k8ZC5n3kz7h70eWKjgqNdKQF0eRp8mVKlmfzMLBVHbssB9jEZEDXThOX1XFqX7s7ymia1hoHQxQagPGzkdWxtlZPZ4ZPvr1RiqkgAu6Is8MZgXXrRoBKqjmSdrP1N7uxzJ/cjfSiis9FiLjuADoqmQ1P7p2N876YPAol7Rn0+GswwAwxldbdLrmVSjfytfSBJFqTMHn4itojgxSWWN1byuckQt8hSTEv/Lg97QoeGniYP17T80pJeQyL3b+295FPHSO2AtvCgyIbKMZ0BALilAA=="));
|
||
|
string data1 = "123";
|
||
|
string sign1 = SHARSASign.SignWithSHA256RSA(data1, HttpProxyPayServerUtils.GetServerConfig().wxPayPem);
|
||
|
var verify = SHARSASign.VerifyWithSHA256RSA(data1, HttpProxyPayServerUtils.GetServerConfig().wxPayPem, sign1);
|
||
|
TraceLog.Trace("sign " + sign1);
|
||
|
TraceLog.Trace("verify " + verify);
|
||
|
//string jstiket = "O3SMpm8bG7kJnF36aXbe88X9GXql1hLfITZlvqm1o8Ma_D95tdRSDr86YjMaQ2CIFXE-fcPEvvwGeAooZtfyQA";
|
||
|
//string nonceStr = "611586";
|
||
|
//string timestamp = "1733993172";
|
||
|
//string url = "http://10.0.22.35/wx_pay.html?uid=100073&orderId=100073-29954772-1-0-1-0-0--8";
|
||
|
//string text =
|
||
|
// "jsapi_ticket=" + jstiket + "&noncestr=" + nonceStr
|
||
|
// + "×tamp=" + timestamp + "&url=" + url + "";
|
||
|
//var sign = HashHelper.SHA1String(text);
|
||
|
//TraceLog.Trace("text " + text);
|
||
|
//TraceLog.Trace("sign " + sign);
|
||
|
|
||
|
|
||
|
|
||
|
string data = "1734004731\n8Xygcej5IecfeLpoLGUgi7pmK7xmw4DH\n{\"id\":\"bfde5a76-ffaa-5c56-9960-6553229eacc2\",\"create_time\":\"2024-12-12T19:58:34+08:00\",\"resource_type\":\"encrypt-resource\",\"event_type\":\"TRANSACTION.SUCCESS\",\"summary\":\"支付成功\",\"resource\":{\"original_type\":\"transaction\",\"algorithm\":\"AEAD_AES_256_GCM\",\"ciphertext\":\"cweRT4ERqC4BX4L6ndVefP2GFArKL7MR5IlADcsJnfYcupIJr4D6ogsNKSYVPxmYMCZZ9N4dxqt10LLE+mJhK6Ek/RVehNpHThDL2Sim2jw7BXlbutrNc4Ek5oLAdB+6f5WkyHDsAdEciLZDCpqOcioA53GJXwPRitBICcCGlrhK12R8+99ebSCPK86c5zLaG5vzk+vBrH5lXeDFmyIyMEr9e+mfkCOmKuFc1gxWYaa3jXfEXQT01qrSoi2VM82cUdh1mYMBbXTuMNDGndIXE9BI6jKFJFN5o2nuZ660jocRnVO39bUmqUUCvdGxOg7t4pwaHDLL3JRUCT/RHZm/GNEdRQOhYgSP+lOoJyFV/7kfca50acNqZ4lvu4LqvQDmjHIRdaocaiHpjRmpwmH5F6/TAgmp+RZjAq47FunL7i5IeSBtH+KXGCfJ8mfEdbG1tLmfkS/iHLTMOZNpNorl7huqi3QDZ8JL5+dcb91MhUFqU5jswCUXNKqvVYQXoidirHACXz5WdDm2NhsmZOpegCxKDu08M4XssLgO3ge6cIskO49tb8OkvYs7M/BSEe9/Fq2SsbyxMNfviV8=\",\"associated_data\":\"transaction\",\"nonce\":\"CHyBhjKCnehU\"}}\n";
|
||
|
string sign = "sugkKbfi7ecS2vbfnuEuVFa6uIZjyaLobetp1kavXLFjKvIqBmpCxfBu134HpIoe5zQWp2bLpMk3cyMS45ohG3jfiAy69uI+QT4Z0TWq7JCQyqU+OB+Vmkv5puAS43eFMUvchg7a9FtpYhcof0+5PRqDrzVkhGw/msQIxdL/qz+uPvJLoU1ayd0+jrLjnIpDXJOSbW54mSdax505E8BTUmLJbpycIw3xWtJcF8KQRP9OceX7sA6BaCjPU0rmrbO6IzcBmHw4uamd3T9H7dqaugtpvpZtiiQTI/MSPbFEjgQmC2/l9QWVkcn3H7Oj9p/DrwdddtlND258NSqHJHeYiw==";
|
||
|
|
||
|
var verify1 = SHARSASign.VerifyWithSHA256RSA(data, HttpProxyPayServerUtils.GetServerConfig().wxPayPubPem, sign);
|
||
|
TraceLog.Trace("verify " + verify1);
|
||
|
|
||
|
string c = "{\"id\":\"f04276ca-e488-567d-b275-4b91983f5008\",\"create_time\":\"2024-12-12T21:37:16+08:00\",\"resource_type\":\"encrypt-resource\",\"event_type\":\"TRANSACTION.SUCCESS\",\"summary\":\"支付成功\",\"resource\":{\"original_type\":\"transaction\",\"algorithm\":\"AEAD_AES_256_GCM\",\"ciphertext\":\"55F5h6Y799hRjgQXemO4a9eUHqYtGxnaS60pGXmVQVgWICuAWgwNxyxrxWTg9r1Bhu/Lp492Th5gEGSWSmStboY5h6v22UattRvjfwrm8WkUZ39TYs2eS6w591WJtQwfofGg5wdLzJV7G06fKuvrwtXy8ewOzauwRJamS/nBcjNyxEPqnHhDxs2nKMig6djFDyWh+ZRjBIcHei7zX+aZMGliSLCLpN16x99zFBW4cjfD9d6GRRHKZBDwbBuoCPZWe8BNeFMrJaJDg271aKSSE6m5v6dM/N7q6viDotxANIAIvEQ5G3GM0oiEDY055e20IRqoQnhec3VBOSxZLQi2DQ2CrVYaWRct54bBvHo7H9HQlabUlaMbgAndJeHRbaJuAcB5o0BvmNgqgn0SLGel5imneNJ/45gxff/nsGsRGHd3mlUi7JYwVFfbLHzrSR1l3ChoYMzKUzKzRGIdYCQYFx/i0dKcIvhdn0xp1vlY6rjWd1+qd4kDyKfjME7ILit6J6jPTI5WfdopoDmB2S1XnIzGRKkOql5zkWRGQMeEpkXrXJjoT0QJ5WlSfYhxmepfscJ4UbSnzjkWEzwmn/G5\",\"associated_data\":\"transaction\",\"nonce\":\"WmoAgF1yJ3eP\"}}";
|
||
|
JsonData jsonData = JsonMapper.ToObject(c);
|
||
|
|
||
|
JsonData resource = jsonData["resource"];
|
||
|
string ciphertext = resource["ciphertext"].ToString();
|
||
|
string associated_data = resource["associated_data"].ToString();
|
||
|
string nonce = resource["nonce"].ToString();
|
||
|
|
||
|
string sMsg = SHARSASign.AesGcmDecrypt(HttpProxyPayServerUtils.GetServerConfig().wxV3Key, associated_data, nonce, ciphertext);
|
||
|
TraceLog.Trace("HeroPayHttpHandler.HomeMiniJSAPICallBack sMsg {0}", sMsg);
|
||
|
jsonData = JsonMapper.ToObject(sMsg);
|
||
|
DateTimeOffset dateTimeOffset = DateTimeOffset.Parse(jsonData["success_time"].ToString());
|
||
|
|
||
|
// 如果你想将其转换为 UTC 时间,可以调用 .UtcDateTime 属性
|
||
|
DateTime utcTime = dateTimeOffset.DateTime;
|
||
|
var CreateTime = AppTime.ConvertDateTimeToUnixTime(utcTime);
|
||
|
TraceLog.Trace("HeroPayHttpHandler.HomeMiniJSAPICallBack CreateTime {0}", CreateTime);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|