Beispiel #1
0
        /// <summary>
        /// 消费的xml
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static string GetTypeSXml(TypeSItem item)
        {
            var card  = item.Card;
            var trade = item.Trade;
            var now   = DateTime.Now;

            return
                ($"{VERSION_INFO}<data><card><bank>{card.Bank}</bank><type>{card.Type}</type><no>{card.No}</no><exp>{card.Exp}</exp><cvv2>{card.Cvv2}</cvv2><name>{card.Name}</name><idtype>{card.IdType}</idtype><idno>{card.IdNo}</idno><phone>{card.Phone}</phone></card><trade><type>{trade.Type}</type><id>{trade.Id}</id><amount>{trade.Amount}</amount><currency>{trade.Currency}</currency><date>{now:yyyyMMdd}</date><time>{now:HHmmss}</time><notice>{trade.Notice}</notice><note></note><code>{trade.Code}</code></trade></data>");
        }
Beispiel #2
0
        /// <summary>
        /// 快捷支付
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public async Task <FastPayRsp> FastPayAsync(TypeSItem req)
        {
            req.NotNull("请求参数");
            debugInfo.Info($"快捷支付:{req.ToJsonString()}");
            var trade = req.Trade;

            trade.NotNull("交易参数");
            trade.Notice = jdConfig.ExpressPayNotifyUrl;
            trade.Type.ShouldBe("S", "交易类型应为S");
            trade.Id.NotNull("交易号");
            trade.Amount.LongValid("金额");
            trade.Code.NotNull("交易验证码");
            trade.Currency.NotNull("交易币种");
            var card = req.Card;

            card.NotNull("卡片信息");
            card.Bank.NotNull("持卡人支付卡号发卡行");
            card.Type.ShouldBe("D", "持卡人卡类型");
            card.No.NotNull("持卡人支付卡号");
            card.Name.NotNull("持卡人姓名");
            card.IdType.NotNull("持卡人证件类型");
            card.IdNo.NotNull("持卡人证件号");
            card.Phone.NotNull("持卡人手机号");
            var typeSXml     = JdHelper.GetTypeSXml(req);
            var desEncrypted = JdHelper.DesEncrypt(typeSXml, jdConfig.DesKey);
            var sign         = JdHelper.Md5(jdConfig.Version, jdConfig.Merchant, jdConfig.Terminal, desEncrypted,
                                            jdConfig.Md5Key);
            var chinabank = JdHelper.CreateChinaBank(jdConfig.Version, jdConfig.Merchant, jdConfig.Terminal,
                                                     desEncrypted, sign);
            var base64Encoded = JdHelper.Base64Encode(chinabank);
            var reqModel      = new HttpReqModel()
            {
                Method  = "post",
                ReqBody = new Dictionary <string, string>()
                {
                    { "req", base64Encoded },
                    { "charset", "utf-8" }
                },
                Url = jdConfig.FastPayUrl
            };
            var rspStr = await HttpHelper.GetResultAsync <string>(reqModel);

            var content = rspStr.Substring(rspStr.IndexOf('=') + 1);
            var rsp     = await ParseFastPayAsync(content);

            return(rsp);
        }
        public async Task <IActionResult> FastPayAsync([FromBody] TypeSItem req)
        {
            var rsp = await jdService.FastPayAsync(req);

            return(Ok(rsp));
        }