예제 #1
0
        public Refund BuildRefundQuery(Refund refund)
        {
            IAopClient alipayClient = GetAopClient();
            AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest();
            AlipayTradeFastpayRefundQueryModel   model   = new AlipayTradeFastpayRefundQueryModel();

            model.OutTradeNo = refund.OrderNo;
            if (!string.IsNullOrEmpty(refund.TradeNo))
            {
                model.TradeNo = refund.TradeNo;
            }
            model.OutRequestNo = refund.OutRefundNo;
            request.SetBizModel(model);
            AlipayTradeFastpayRefundQueryResponse response = alipayClient.Execute(request);

            if (response.Code == "10000" && !string.IsNullOrEmpty(response.RefundAmount))
            {
                double refundAmount;
                if (double.TryParse(response.RefundAmount, out refundAmount))
                {
                    if (refundAmount > 0.0)
                    {
                        refund.TradeNo      = response.TradeNo;
                        refund.RefundAmount = refundAmount;
                        refund.RefundStatus = true;
                    }
                }
            }
            return(refund);
        }
        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();

            // 请求退款接口时,传入的退款号,如果在退款时未传入该值,则该值为创建交易时的商户订单号,必填。
            string out_request_no = WIDout_request_no.Text.Trim();

            AlipayTradeFastpayRefundQueryModel model = new AlipayTradeFastpayRefundQueryModel();

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

            AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest();

            request.SetBizModel(model);

            AlipayTradeFastpayRefundQueryResponse response = null;

            try
            {
                response       = client.Execute(request);
                WIDresule.Text = response.Body;
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
예제 #3
0
        public async Task <IActionResult> RefundQuery(string out_trade_no, string trade_no, string out_request_no)
        {
            var model = new AlipayTradeFastpayRefundQueryModel
            {
                OutTradeNo   = out_trade_no,
                TradeNo      = trade_no,
                OutRequestNo = out_request_no
            };

            var req = new AlipayTradeFastpayRefundQueryRequest();

            req.SetBizModel(model);

            var response = await _client.ExecuteAsync(req);

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

            if (response.IsError)
            {
                responseModel.code    = HTTPResponseCode.BadRequest;
                responseModel.message = response.Msg;
            }
            else
            {
                responseModel.code = HTTPResponseCode.Successful;
            }
            return(Json(responseModel));
        }
예제 #4
0
		public Result<AlipayRefundQueryResult> QueryRefund(string originalOrderNo, string refundRequestNo) {
			var model = new AlipayTradeFastpayRefundQueryModel {
				OutTradeNo = originalOrderNo,
				OutRequestNo = refundRequestNo
			};
			var request = new AlipayTradeFastpayRefundQueryRequest();
			request.SetBizModel(model);

			try {
				var response = _alipay.Execute(request);
				var ok = response is { IsError: false, Msg: "Success" };

				if ( !ok ) {
					return new Failure<AlipayRefundQueryResult>(response.SubMsg ?? response.Msg);
				}
				return new Success<AlipayRefundQueryResult> {
					Data = new AlipayRefundQueryResult {
						RefundReason = response.RefundReason,
						RefundAmount = response.RefundAmount.AsDecimal(),
						OriginalResult = response
					}
				};
			}
			catch ( Exception e ) {
				return new Failure<AlipayRefundQueryResult>(e.Message);
			}
		}
예제 #5
0
        /// <summary>
        /// 退款查询
        /// </summary>
        /// <param name="tradeno">商户订单号</param>
        /// <param name="alipayTradeNo">支付宝交易号</param>
        /// <param name="refundNo">退款单号</param>
        /// <returns></returns>
        public ActionResult RefundQueryInfo(string tradeno, string alipayTradeNo, string refundNo)
        {
            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);

            if (string.IsNullOrEmpty(refundNo))
            {
                refundNo = tradeno;
            }
            AlipayTradeFastpayRefundQueryModel model = new AlipayTradeFastpayRefundQueryModel();

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

            AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest();

            request.SetBizModel(model);

            AlipayTradeFastpayRefundQueryResponse response = null;

            try
            {
                response = client.Execute(request);
                return(Json(response.Body));
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
예제 #6
0
        public JsonResult RefundQuery(string tradeno, string alipayTradeNo, string refundNo)
        {
            DefaultAopClient client = new DefaultAopClient(Config.Gatewayurl, Config.AppId, Config.PrivateKey, "json", "2.0",
                                                           Config.SignType, Config.AlipayPublicKey, Config.CharSet, false);

            if (string.IsNullOrEmpty(refundNo))
            {
                refundNo = tradeno;
            }

            AlipayTradeFastpayRefundQueryModel model = new AlipayTradeFastpayRefundQueryModel();

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

            AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest();

            request.SetBizModel(model);

            try
            {
                var response = client.Execute(request);
                return(Json(response.Body));
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
예제 #7
0
        /// <summary>
        /// 查询退款
        /// 提交退款申请后,通过该接口查询退款状态。退款有一定延时
        /// 用零钱支付的退款20分钟内到账,银行卡支付的退款3个工作日后重新查询退款状态。
        /// </summary>
        /// <param name="request">out_refund_no、out_trade_no、transaction_id、refund_id四个参数必填一个</param>
        /// <param name="config"></param>
        /// <param name="accessToken">用户授权token</param>
        /// <param name="timeOut">接口超时时间</param>
        /// <returns>成功时返回,其他抛异常</returns>
        public static async Task <AlipayTradeFastpayRefundQueryResponse> RefundQueryAsync(AlipayTradeFastpayRefundQueryModel 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 AlipayTradeFastpayRefundQueryRequest();

            requestData.SetBizModel(request);

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

            if (result.Code != AlipayConstants.SuccessCode)
            {
                throw new Exception(result.SubMsg);
            }
            return(result);
        }
예제 #8
0
        /// <summary>
        /// 订单退款查询
        /// </summary>
        /// <param name="model">查询信息</param>
        /// <returns></returns>
        public async Task <AlipayTradeFastpayRefundQueryResponse> RefundQuery(AlipayTradeFastpayRefundQueryModel input)
        {
            if (string.IsNullOrEmpty(input.OutRequestNo))
            {
                input.OutRequestNo = input.OutTradeNo;
            }

            var request = new AlipayTradeFastpayRefundQueryRequest();

            request.SetBizModel(input);

            AlipayTradeFastpayRefundQueryResponse response = await _alipayService.ExecuteAsync(request);

            return(response);
        }
예제 #9
0
        public async Task <IActionResult> RefundQuery(string out_trade_no, string trade_no, string out_request_no)
        {
            var model = new AlipayTradeFastpayRefundQueryModel()
            {
                OutTradeNo   = out_trade_no,
                TradeNo      = trade_no,
                OutRequestNo = out_request_no
            };

            var req = new AlipayTradeFastpayRefundQueryRequest();

            req.SetBizModel(model);

            var response = await _client.ExecuteAsync(req);

            return(Ok(response.Body));
        }
예제 #10
0
        public async Task <IActionResult> RefundQuery(AlipayTradeRefundQueryViewModel viewMode)
        {
            var model = new AlipayTradeFastpayRefundQueryModel
            {
                OutTradeNo   = viewMode.OutTradeNo,
                TradeNo      = viewMode.TradeNo,
                OutRequestNo = viewMode.OutRequestNo
            };

            var req = new AlipayTradeFastpayRefundQueryRequest();

            req.SetBizModel(model);

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

            return(Ok(response.Body));
        }
예제 #11
0
        public async Task <IActionResult> RefundQuery(AlipayTradeRefundQueryViewModel viewMode)
        {
            var model = new AlipayTradeFastpayRefundQueryModel()
            {
                OutTradeNo   = viewMode.OutTradeNo,
                TradeNo      = viewMode.TradeNo,
                OutRequestNo = viewMode.OutRequestNo
            };

            var req = new AlipayTradeFastpayRefundQueryRequest();

            req.SetBizModel(model);

            var response = await _client.ExecuteAsync(req);

            ViewData["response"] = response.Body;
            return(View());
        }
예제 #12
0
        public RefundInfo GetRefund(Order order)
        {
            AlipayTradeFastpayRefundQueryModel model = new AlipayTradeFastpayRefundQueryModel();

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

            AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest();

            request.SetBizModel(model);

            var response      = _alipayService.Execute(request);
            var responseEntry = JObject.Parse(response.Body).GetValue("alipay_trade_fastpay_refund_query_response").ToObject <AliPaymentResponse>();

            return(new RefundInfo
            {
                RefundAmount = responseEntry.refund_amount,
                TotalAmount = responseEntry.total_amount
            });
        }
예제 #13
0
        public IActionResult RefundQuery(string WIDout_trade_no, string WIDtrade_no, string WIDout_request_no)
        {
            var 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);

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

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

            // 请求退款接口时,传入的退款号,如果在退款时未传入该值,则该值为创建交易时的商户订单号,必填。
            var out_request_no = WIDout_request_no;

            var model = new AlipayTradeFastpayRefundQueryModel
            {
                OutTradeNo   = out_trade_no,
                TradeNo      = trade_no,
                OutRequestNo = out_request_no
            };

            var request = new AlipayTradeFastpayRefundQueryRequest();

            request.SetBizModel(model);

            AlipayTradeFastpayRefundQueryResponse response = null;

            try
            {
                response = client.Execute(request);
            }
            catch (Exception exp)
            {
                throw exp;
            }

            return(Content(response.Body));
        }
        public async Task <JsonResult> RefundQuery(string tradeno, string alipayTradeNo, string refundNo)
        {
            /*DefaultAopClient client = new DefaultAopClient(Config.Gatewayurl, Config.AppId, Config.PrivateKey, "json", "2.0",
             *      Config.SignType, Config.AlipayPublicKey, Config.CharSet, false);*/

            if (string.IsNullOrEmpty(refundNo))
            {
                refundNo = tradeno;
            }

            AlipayTradeFastpayRefundQueryModel model = new AlipayTradeFastpayRefundQueryModel();

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

            AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest();

            request.SetBizModel(model);

            var response = await _alipayService.ExecuteAsync(request);

            return(Json(response.Body));
        }
예제 #15
0
        public JsonResult RefundQuery(string tradeno, string alipayTradeNo, string refundNo)
        {
            IAopClient client = new DefaultAopClient(URL, APPID, APP_PRIVATE_KEY, FORMAT, "1.0", "RSA2", ALIPAY_PUBLIC_KEY, CHARSET, false);

            if (string.IsNullOrEmpty(refundNo))
            {
                refundNo = tradeno;
            }

            AlipayTradeFastpayRefundQueryModel model = new AlipayTradeFastpayRefundQueryModel
            {
                OutTradeNo   = tradeno,
                TradeNo      = alipayTradeNo,
                OutRequestNo = refundNo
            };

            AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest();

            request.SetBizModel(model);

            var response = client.Execute(request);

            return(Json(response.Body));
        }