Exemplo n.º 1
0
        public string SignWithKey(SortedDictionary <string, string> dictionary)
        {
            StringBuilder sb = new StringBuilder();

            foreach (KeyValuePair <string, string> iter in dictionary)
            {
                if (!string.IsNullOrEmpty(iter.Value) && iter.Key != "sign")
                {
                    sb.Append(iter.Key).Append('=').Append(iter.Value).Append("&");
                }
            }
            string signContent = sb.Append("key=").Append(SignSettings.Key).ToString();

            switch (SignSettings.SignType)
            {
            case EnumSignType.MD5:
                return(MD5Hash.HashToHex(signContent).ToUpper());

            case EnumSignType.HMACSHA256:
                return(HMACSHA256Hash.HashToHex(signContent, SignSettings.Key).ToUpper());

            default:
                break;
            }
            return(null);
        }
Exemplo n.º 2
0
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            string ss = HMACSHA256Hash.HashToBase64("https://octodex.github.com/images/codercat.jpg", "secretkey");

            Console.WriteLine(ss);
            Console.ReadKey();



            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            HttpApi.Register <ICCBEBS5Contract>();
            ICCBEBS5Contract ccbPayClient = HttpApi.Resolve <ICCBEBS5Contract>();

            CCBPayOptions options = new CCBPayOptions();


            while (true)
            {
                Func <string>  y = () => { Console.WriteLine("请输入退款订单"); return(Console.ReadLine()); };
                Func <decimal> x = () => { Console.WriteLine("请输入退款金额"); return(decimal.Parse(Console.ReadLine())); };

                CCBRefundRequest refundRequest = new CCBRefundRequest()
                {
                    CUST_ID    = options.MerchantId,
                    USER_ID    = "",
                    PASSWORD   = "",
                    REQUEST_SN = DateTime.Now.ToString("yyMMddHHmmssffff"),
                    TX_INFO    = new CCBRefundRequest.Content
                    {
                        ORDER = y.Invoke(),
                        MONEY = x.Invoke(),
                    }
                };
                CCBRefundResponse result = await ccbPayClient.Refund(ebsHttpEndpoint : "http://192.168.0.205:30001", new CCBEBS5HttpRequest <CCBRefundRequest>(refundRequest));

                Console.ReadKey();
            }
        }