コード例 #1
0
ファイル: AliPaymentService.cs プロジェクト: skehya/cms
        public ServiceResult <bool> CloseOrder(Order order)
        {
            AlipayTradeCloseModel model = new AlipayTradeCloseModel();

            model.OutTradeNo = order.ID;
            model.TradeNo    = order.PaymentID;

            AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();

            request.SetBizModel(model);

            var response      = _alipayService.Execute(request);
            var responseEntry = JObject.Parse(response.Body).GetValue("alipay_trade_close_response").ToObject <AliPaymentResponse>();
            var status        = responseEntry.msg.Equals("Success", StringComparison.OrdinalIgnoreCase);
            var result        = new ServiceResult <bool>
            {
                Result = status
            };

            if (!status)
            {
                result.RuleViolations.Add(new RuleViolation("Error", responseEntry.msg + (responseEntry.sub_msg ?? "")));
            }
            return(result);
        }
コード例 #2
0
        protected void BtnAlipay_Click(object sender, EventArgs e)
        {
            DefaultAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", config.sign_type, config.alipay_public_key, config.charset, false);

            // 商户订单号,和交易号不能同时为空
            string out_trade_no = WIDout_trade_no.Text.Trim();

            // 支付宝交易号,和商户订单号不能同时为空
            string trade_no = WIDtrade_no.Text.Trim();

            AlipayTradeCloseModel model = new AlipayTradeCloseModel();

            model.OutTradeNo = out_trade_no;
            model.TradeNo    = trade_no;

            AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();

            request.SetBizModel(model);

            AlipayTradeCloseResponse response = null;

            try
            {
                response       = client.Execute(request);
                WIDresule.Text = response.Body;
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
コード例 #3
0
        public async Task Test6()
        {
            var config = new AlipayConfig
            {
                NotifyUrl    = "",
                AppId        = "",
                PrivateKey   = "",
                AliPublicKey = "",
                QuitUrl      = ""
            };
            var request = new AlipayTradeCloseModel
            {
                OutTradeNo = "202007297777"
            };
            var response = await AlipayClient.CloseOrderAsync(request, config);

            if (string.IsNullOrEmpty(response.Body))
            {
                Assert.Fail();
            }
            else
            {
                Assert.Pass();
            }
        }
コード例 #4
0
        public JsonResult OrderCloseInfo(string tradeno, string alipayTradeNo)
        {
            DefaultAopClient client = new DefaultAopClient(Config.gatewayUrl, Config.app_id, Config.private_key, "json", "1.0", Config.sign_type, Config.alipay_public_key, Config.charset, false);

            AlipayTradeCloseModel model = new AlipayTradeCloseModel();

            // 商户订单号,和交易号不能同时为空
            model.OutTradeNo = tradeno;
            // 支付宝交易号,和商户订单号不能同时为空
            model.TradeNo = alipayTradeNo;

            AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();

            request.SetBizModel(model);

            AlipayTradeCloseResponse response = null;

            try
            {
                response = client.Execute(request);
                return(Json(response.Body));
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
コード例 #5
0
        public IActionResult Close(string WIDout_trade_no, string WIDtrade_no)
        {
            DefaultAopClient client = new DefaultAopClient(_settings.Value.gateway_url, _settings.Value.app_id, _settings.Value.private_key, _settings.Value.format, _settings.Value.version, _settings.Value.sign_type, _settings.Value.alipay_public_key, _settings.Value.charset, false);

            // 商户订单号,和交易号不能同时为空
            string out_trade_no = WIDout_trade_no;

            // 支付宝交易号,和商户订单号不能同时为空
            string trade_no = WIDtrade_no;

            AlipayTradeCloseModel model = new AlipayTradeCloseModel();

            model.OutTradeNo = out_trade_no;
            model.TradeNo    = trade_no;

            AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();

            request.SetBizModel(model);

            AlipayTradeCloseResponse response = null;

            try
            {
                response = client.Execute(request);
            }
            catch (Exception exp)
            {
                throw exp;
            }
            return(Content(response.Body));
        }
コード例 #6
0
        public AlipayTradeCloseResponse CleanWaitOrder(EAliPayApplication app, EOrderInfo order, EStoreInfo store = null)
        {
            IAopClient aliyapClient = new DefaultAopClient("https://openapi.alipay.com/gateway.do", app.AppId,
                                                           app.Merchant_Private_Key, "json", "1.0", "RSA2", app.Merchant_Public_key, "GBK", false);

            AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();
            AlipayTradeCloseModel   model   = new AlipayTradeCloseModel();

            model.OutTradeNo = order.OrderNo;
            request.SetBizModel(model);
            AlipayTradeCloseResponse response = null;

            if (store != null)
            {
                response = aliyapClient.Execute(request, null, store.AliPayAuthToke);
            }
            else
            {
                response = aliyapClient.Execute(request);
            }



            return(response);
        }
コード例 #7
0
        /// <summary>
        /// 关闭订单
        /// </summary>
        /// <param name="tradeno">商户订单号</param>
        /// <param name="alipayTradeNo">支付宝交易号</param>
        /// <returns></returns>
        public async Task <AlipayTradeCloseResponse> OrderClose(string tradeno, string alipayTradeNo)
        {
            var model = new AlipayTradeCloseModel()
            {
                OutTradeNo = tradeno,
                TradeNo    = alipayTradeNo,
            };

            return(await this.OrderClose(model));
        }
コード例 #8
0
        /// <summary>
        /// 关闭订单
        /// </summary>
        /// <param name="input">关闭订单数据</param>
        /// <returns></returns>
        public async Task <AlipayTradeCloseResponse> OrderClose(AlipayTradeCloseModel input)
        {
            var request = new AlipayTradeCloseRequest();

            request.SetBizModel(input);

            var response = await _alipayService.ExecuteAsync(request);

            return(response);
        }
コード例 #9
0
        /// <summary>
        /// 关闭订单
        /// </summary>
        /// <param name="request">提交给关闭订单API的参数</param>
        /// <param name="config"></param>
        /// <param name="accessToken">用户授权token</param>
        /// <param name="timeOut">接口超时时间</param>
        /// <returns>成功时返回,其他抛异常</returns>
        public static async Task <AlipayTradeCloseResponse> CloseOrderAsync(AlipayTradeCloseModel request, AlipayConfig config, string accessToken = null, 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 AlipayTradeCloseRequest();

            requestData.SetBizModel(request);

            var result = await client.ExecuteAsync(requestData, accessToken);

            if (result.Code != AlipayConstants.SuccessCode)
            {
                throw new Exception(result.SubMsg);
            }
            return(result);
        }
コード例 #10
0
        public async Task <IActionResult> Close(string out_trade_no, string trade_no)
        {
            var model = new AlipayTradeCloseModel()
            {
                OutTradeNo = out_trade_no,
                TradeNo    = trade_no,
            };

            var req = new AlipayTradeCloseRequest();

            req.SetBizModel(model);

            var response = await _client.ExecuteAsync(req);

            return(Ok(response.Body));
        }
コード例 #11
0
        public JsonResult OrderClose(string tradeno, string alipayTradeNo)
        {
            DefaultAopClient client = new DefaultAopClient(Config.Gatewayurl, Config.AppId, Config.PrivateKey, "json", "2.0",
                                                           Config.SignType, Config.AlipayPublicKey, Config.CharSet, false);

            AlipayTradeCloseModel model = new AlipayTradeCloseModel();

            model.OutTradeNo = tradeno;
            model.TradeNo    = alipayTradeNo;

            AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();

            request.SetBizModel(model);

            var response = client.Execute(request);

            return(Json(response.Body));
        }
コード例 #12
0
ファイル: AlipayController.cs プロジェクト: z65877424/paylink
        public async Task <IActionResult> Close(AlipayTradeCloseViewModel viewMode)
        {
            var model = new AlipayTradeCloseModel
            {
                OutTradeNo = viewMode.OutTradeNo,
                TradeNo    = viewMode.TradeNo,
            };

            var req = new AlipayTradeCloseRequest();

            req.SetBizModel(model);
            req.SetNotifyUrl(viewMode.NotifyUrl);

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

            ViewData["response"] = response.Body;
            return(View());
        }
コード例 #13
0
        public JsonResult OrderClose(string tradeno, string alipayTradeNo)
        {
            IAopClient client = new DefaultAopClient(URL, APPID, APP_PRIVATE_KEY, FORMAT, "1.0", "RSA2", ALIPAY_PUBLIC_KEY, CHARSET, false);

            AlipayTradeCloseModel model = new AlipayTradeCloseModel
            {
                OutTradeNo = tradeno,
                TradeNo    = alipayTradeNo
            };

            AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();

            request.SetBizModel(model);

            var response = client.Execute(request);

            return(Json(response.Body));
        }