Пример #1
0
        public static void PaymentPost(HttpContext c, string paymentUrl, string merchantId, string returnUrl, string paymentTypeObjId, string amtStr, string merTransId)
        {
            string        xmlKey     = File.ReadAllText("D:\\" + merchantId + ".xml");
            RSAParameters PrvKeyInfo = RSAUtility.GetPrvKeyFromXmlString(xmlKey);
            RSACng        rsa        = new RSACng();

            rsa.ImportParameters(PrvKeyInfo);
            string        orgString     = merchantId + merTransId + paymentTypeObjId + amtStr + returnUrl;
            ASCIIEncoding byteConverter = new ASCIIEncoding();

            byte[] orgData      = byteConverter.GetBytes(orgString);
            byte[] signedData   = rsa.SignData(orgData, HashAlgorithmName.MD5, RSASignaturePadding.Pkcs1);
            string signedString = Convert.ToBase64String(signedData);

            RemotePost myremotepost = new RemotePost(c);

            myremotepost.Url = paymentUrl;
            myremotepost.Inputs.Add(new string[] { "MerId", merchantId });
            myremotepost.Inputs.Add(new string[] { "Amt", amtStr });
            myremotepost.Inputs.Add(new string[] { "PaymentTypeObjId", paymentTypeObjId });
            myremotepost.Inputs.Add(new string[] { "MerTransId", merTransId });
            myremotepost.Inputs.Add(new string[] { "ReturnUrl", returnUrl });
            myremotepost.Inputs.Add(new string[] { "CheckValue", signedString });
            myremotepost.Post();
        }
Пример #2
0
        public static bool PaymentVerify(HttpRequest curRequest, out string merId, out string amt, out string merTransId, out string transId, out string transTime)
        {
            merId      = curRequest.Form["merId"].ToString();
            amt        = curRequest.Form["amt"].ToString();
            merTransId = curRequest.Form["merTransId"].ToString();
            transId    = curRequest.Form["transId"].ToString();
            transTime  = curRequest.Form["transTime"].ToString();
            string        checkValue       = curRequest.Form["checkValue"].ToString();
            string        PaymentPublicKey = File.ReadAllText("d:\\PaymentPublicKey.txt");
            RSAParameters PubKeyInfo       = RSAUtility.GetPubKeyFromXmlString(PaymentPublicKey);
            string        orgString        = merId + merTransId + amt + transId + transTime;
            ASCIIEncoding byteConverter    = new ASCIIEncoding();

            byte[] orgData               = byteConverter.GetBytes(orgString);
            byte[] signedData            = Convert.FromBase64String(checkValue);
            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

            rsa.ImportParameters(PubKeyInfo);
            return(rsa.VerifyData(orgData, signedData, HashAlgorithmName.MD5, RSASignaturePadding.Pkcs1));
        }