ASP.NET Core 2.0 使用支付宝PC网站支付实现代码(3)

/// <summary> /// 订单退款 /// </summary>/// <param>商户订单号</param>/// <param>支付宝交易号</param>/// <param>退款金额</param>/// <param>退款原因</param>/// <param>退款单号</param>/// <returns></returns>[HttpPost]public JsonResult Refund(string tradeno,string alipayTradeNo,string refundAmount,string refundReason,string refundNo){ DefaultAopClient client = new DefaultAopClient(Config.Gatewayurl, Config.AppId, Config.PrivateKey, "json", "2.0", Config.SignType, Config.AlipayPublicKey, Config.CharSet, false); AlipayTradeRefundModel model = new AlipayTradeRefundModel(); model.OutTradeNo = tradeno; model.TradeNo = alipayTradeNo; model.RefundAmount = refundAmount; model.RefundReason = refundReason; model.OutRequestNo = refundNo; AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); request.SetBizModel(model); var response = client.Execute(request); return Json(response.Body);}

退款查询

查询退款信息。

运行:

ASP.NET Core 2.0 使用支付宝PC网站支付实现代码

/// <summary> /// 退款查询 /// </summary> /// <param>商户订单号</param> /// <param>支付宝交易号</param> /// <param>退款单号</param> /// <returns></returns> [HttpPost] 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); var response = client.Execute(request); return Json(response.Body); }

订单关闭

对一定时间以后没有进行付款的订单进行关闭,订单状态需为:待付款,已完成支付的订单无法关闭。

运行:

ASP.NET Core 2.0 使用支付宝PC网站支付实现代码

/// <summary> /// 关闭订单 /// </summary> /// <param>商户订单号</param> /// <param>支付宝交易号</param> /// <returns></returns> [HttpPost] 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); }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdpwzs.html