Ejemplo n.º 1
0
        public async Task <IActionResult> Pay(string out_trade_no, string subject, string total_amount, string body, string scene, string auth_code)
        {
            var model = new AlipayTradePayModel
            {
                OutTradeNo  = out_trade_no,
                Subject     = subject,
                Scene       = scene,
                AuthCode    = auth_code,
                TotalAmount = total_amount,
                Body        = body
            };
            var req = new AlipayTradePayRequest();

            req.SetBizModel(model);

            var response = await _client.ExecuteAsync(req);

            ResponseModel responseModel = new ResponseModel()
            {
                code = HTTPResponseCode.PartialContent,
                data = response.Body
            };

            if (response.IsError)
            {
                responseModel.code    = HTTPResponseCode.BadRequest;
                responseModel.message = response.Msg;
            }
            else
            {
                responseModel.code = HTTPResponseCode.Successful;
            }
            return(Json(responseModel));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 条码支付
        /// </summary>
        public void BarCodePay(decimal amount, string orderNo, string authCode, string subject, string storeId, string terminalId)
        {
            bool success = false;

            //组装业务参数
            var model = new AlipayTradePayModel()
            {
                OutTradeNo     = orderNo,
                TotalAmount    = amount.ToString(),
                Scene          = "bar_code",
                AuthCode       = authCode,
                Subject        = subject,
                StoreId        = storeId,
                TerminalId     = terminalId,
                TimeoutExpress = "2m"
            };

            var request = new AlipayTradePayRequest();

            request.SetBizModel(model);

            AlipayTradePayResponse response = aopClient.Execute(request);

            if (response != null && response.Code == "10000")
            {
                success = true;

                //response.TradeNo 支付宝28位交易号
            }

            //记日志response.ToJson();

            //return success;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 统一收单交易支付接口
        /// </summary>
        /// <param name="request">提交给统一下单API的参数</param>
        /// <param name="config"></param>
        /// <param name="timeOut">超时时间</param>
        /// <returns>成功时返回,其他抛异常</returns>
        public static async Task <AlipayTradePayResponse> CreateOrder(AlipayTradePayModel request, AlipayConfig config, int timeOut = 6)
        {
            IAopClient client      = new AopClient(AlipayConstants.GATEWAYURL, config.AppId, config.PrivateKey, config.Format, config.Version, config.SignType, config.AliPublicKey, config.Charset, config.KeyFromFile);
            var        requestData = new AlipayTradePayRequest();

            requestData.SetNotifyUrl(config.NotifyUrl);
            requestData.SetReturnUrl(config.QuitUrl);
            requestData.SetBizModel(request);

            return(await client.ExecuteAsync(requestData));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Pay(AlipayTradePayViewModel viewModel)
        {
            var model = new AlipayTradePayModel
            {
                OutTradeNo  = viewModel.OutTradeNo,
                Subject     = viewModel.Subject,
                Scene       = viewModel.Scene,
                AuthCode    = viewModel.AuthCode,
                TotalAmount = viewModel.TotalAmount,
                Body        = viewModel.Body
            };
            var req = new AlipayTradePayRequest();

            req.SetBizModel(model);

            var response = await _client.CertificateExecuteAsync(req, _optionsAccessor.Value);

            return(Ok(response.Body));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Pay(string out_trade_no, string scene, string auth_code, string subject, string total_amount, string body, string notify_url)
        {
            var model = new AlipayTradePayModel()
            {
                Scene       = scene,
                AuthCode    = auth_code,
                Body        = body,
                Subject     = subject,
                TotalAmount = total_amount,
                OutTradeNo  = out_trade_no,
            };
            var req = new AlipayTradePayRequest();

            req.SetBizModel(model);
            req.SetNotifyUrl(notify_url);

            var response = await _client.ExecuteAsync(req);

            return(Ok(response.Body));
        }
        public async Task <IActionResult> Pay(AlipayTradePayViewModel viewModel)
        {
            var model = new AlipayTradePayModel
            {
                OutTradeNo  = viewModel.OutTradeNo,
                Subject     = viewModel.Subject,
                Scene       = viewModel.Scene,
                AuthCode    = viewModel.AuthCode,
                TotalAmount = viewModel.TotalAmount,
                Body        = viewModel.Body
            };
            var req = new AlipayTradePayRequest();

            req.SetBizModel(model);

            var response = await _client.ExecuteAsync(req);

            ViewData["response"] = response.Body;
            return(View());
        }
Ejemplo n.º 7
0
        // 条码/声波支付
        public async Task <AlipayTradePayResponse> Pay(PayRequest request)
        {
            var order = OrderService.Get(request.Id);
            var model = new AlipayTradePayModel
            {
                OutTradeNo  = order.Order_SN,
                Subject     = order.Name,
                Scene       = "bar_code", //wave_code
                AuthCode    = request.AuthCode,
                TotalAmount = order.Order_Money.ToString("n"),
                Body        = order.Remark,
                ProductCode = request.ProduceCode ?? "FACE_TO_FACE_PAYMENT"
            };

            var req = new AlipayTradePayRequest();

            req.SetBizModel(model);

            return(await client.ExecuteAsync(req, options.Value));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Pay(AlipayTradePayViewModel viewModel)
        {
            if (_Interceptor != null)
            {
                return(Ok("this is _Interceptor"));
            }
            var model = new AlipayTradePayModel
            {
                OutTradeNo  = viewModel.OutTradeNo,
                Subject     = viewModel.Subject,
                Scene       = viewModel.Scene,
                AuthCode    = viewModel.AuthCode,
                TotalAmount = viewModel.TotalAmount,
                Body        = viewModel.Body
            };
            var req = new AlipayTradePayRequest();

            req.SetBizModel(model);

            var response = await _client.CertificateExecuteAsync(req, _optionsAccessor.Value);

            ViewData["response"] = response.Body;
            return(View());
        }