예제 #1
0
파일: ZfPay.cs 프로젝트: dmhai/dxpay
        /// <summary>
        /// 智付支付通道苹果调用方式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">商品价格</param>
        /// <param name="TableName">订单表表名</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse PayZfIos(int apptype, string code, string goodsname, decimal price, int orderid, int appid)
        {
            InnerResponse inn = new InnerResponse();
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
            Dictionary <string, string>       DPcfg     = DPConfing.loadCfg(apptype, appid);

            if (!UpdateOrde.OrdeUpdateInfo(orderid, Int32.Parse(DPcfg["pay_id"].ToString())))
            {
                inn = inn.ToResponse(ErrorCode.Code101);
                return(inn);
            }
            //调用示例
            var formField = new FormField(
                DPcfg["partner"].ToString(),                                                                          //商家账号
                code,                                                                                                 //订单编号
                price.ToString("f2"),                                                                                 //交易金额
                ConfigurationManager.AppSettings["ZFTokenUrl"].ToString().Replace("{0}", DPcfg["pay_id"].ToString()), //通知地址
                "RSA-S",                                                                                              //签名方式
                DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),                                                         //订单时间
                goodsname,                                                                                            //商品描述
                new FormProperty("")                                                                                  //表单属性对象
                );
            //商家私钥
            string merchantPrivateKey = DPcfg["dpkey"].ToString();
            //实例化HTML构造器
            var htmlCreator = new HtmlCreator(formField, new PrivateKeySignRsas(merchantPrivateKey));
            //生成表单字符串
            var htmlForm = htmlCreator.CreateHtmlAz();

            inn = inn.ToResponse(ErrorCode.Code100);
            string data = "{" + htmlForm.ToString().Replace("{", "").Replace("}", "") + ",\"PaymentType\":\"3\",\"SubType\":\"1\",\"IsH5\":\"0\"}";

            inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(data, ConfigurationManager.AppSettings["encryption"].ToString());
            return(inn);
        }