Ejemplo n.º 1
0
        public async Task <IActionResult> Index(QrCodePayViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError(nameof(model), "invalid form data");
                return(View(model));
            }
            var req = new GetQrCodeRequest
            {
                TotalAmount      = model.totalAmount,
                BillDate         = model.billDate,
                BillDesc         = model.billDesc,
                BillNo           = model.billNo,
                RequestTimestamp = model.requestTimestamp,
                NotifyUrl        = model.notifyUrl,
                ReturnUrl        = model.returnUrl
            };
            var res = await _client.ExecuteAsync(req);

            if (string.IsNullOrWhiteSpace(res.ErrCode) && string.IsNullOrWhiteSpace(res.ErrMsg))
            {
                throw new Exception("请求失败:" + res.Body);
            }
            return(RedirectToAction(nameof(QrCode), new { code = res.BillQrCode }));
        }
Ejemplo n.º 2
0
        public IActionResult Index()
        {
            var req = new QrCodePayViewModel()
            {
                totalAmount      = "1",
                billDate         = DateTime.Now.ToString("yyyy-MM-dd"),
                billNo           = _options.MsgSrcId + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "1234567890",
                billDesc         = "测试",
                requestTimestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                notifyUrl        = _options.NotifyUrl
            };

            return(View(req));
        }