public ActionResult PublicPay(string out_trade_no, int total_amount, string body) { var request = new PublicPayRequest(); request.AddGatewayData(new PublicPayModel() { Body = body, OutTradeNo = out_trade_no, TotalAmount = total_amount }); var response = _gateway.Execute(request); return(Json(response)); }
public HttpResponseMessage Pay([FromBody] WebPayModel payModel) { if (ModelState.IsValid) { var request = new WebPayRequest(); request.AddGatewayData(payModel); var response = _gateway.Execute(request); var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(response.Html, Encoding.UTF8, "text/html") }; return(result); } return(new HttpResponseMessage(HttpStatusCode.MethodNotAllowed)); }
public ActionResult UnifiedPay(string out_trade_no, int total_amount, string body) { var request = new UnifiedPayRequest(); request.AddGatewayData(new UnifiedPayModel() { PayType = PayType.A01, Body = body, TotalAmount = total_amount, OutTradeNo = out_trade_no }); var response = _gateway.Execute(request); return(Json(response)); }
public BarcodePayResponse BarcodePay(PayRequest payRequest) { _gateway = _gateways.GetByStoreId <WechatpayGateway>(payRequest.GetStoreId()); var queryModel = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(payRequest.BizContent, new { body = "", total_amount = 0, out_trade_no = "", auth_code = "" }); // 记录支付日志 var content = JsonConvert.SerializeObject(payRequest); var payHistory = new PaymentHistory(); payHistory.LogWechatBarcodeRequestPay(queryModel.out_trade_no, queryModel.total_amount.ToString(), "saleorder", content); _db.Insert(payHistory); _db.SaveChange(); var request = new BarcodePayRequest(); request.AddGatewayData(new BarcodePayModel() { Body = queryModel.body, TotalAmount = queryModel.total_amount, OutTradeNo = queryModel.out_trade_no, AuthCode = queryModel.auth_code }); request.PaySucceed += BarcodePay_PaySucceed; request.PayFailed += BarcodePay_PayFaild; var response = _gateway.Execute(request); return(response); }
public RefundResponse Refund(PayRequest payRequest) { _gateway = _gateways.GetByStoreId <AlipayGateway>(payRequest.GetStoreId()); var queryModel = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(payRequest.BizContent, new { out_trade_no = "", trade_no = "", refund_amount = 0, refund_reason = "", out_refund_no = "" }); // 记录支付日志 //var content = JsonConvert.SerializeObject(payRequest); //var payHistory = new PaymentHistory(); //payHistory.LogAlipayBarcodeRequestPay(queryModel.out_trade_no, queryModel.total_amount.ToString(), "saleorder", content); //_db.Insert(payHistory); //_db.SaveChange(); var request = new RefundRequest(); request.AddGatewayData(new RefundModel() { OutTradeNo = queryModel.out_trade_no, TradeNo = queryModel.trade_no, RefundAmount = queryModel.refund_amount, RefundReason = queryModel.refund_reason, OutRefundNo = queryModel.out_refund_no }); var response = _gateway.Execute(request); return(response); }
public IActionResult WebPay(string order_id, int total_amount) { var request = new WebPayRequest(); request.AddGatewayData(new WebPayModel() { TotalAmount = total_amount, OrderId = order_id }); var response = _gateway.Execute(request); return(Content(response.Html, "text/html", Encoding.UTF8)); }
public CancelResponse Cancel(PayRequest payRequest) { _gateway = _gateways.GetByStoreId <WechatpayGateway>(payRequest.GetStoreId()); var queryModel = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(payRequest.BizContent, new { out_trade_no = "" }); var request = new CancelRequest(); request.AddGatewayData(new CancelModel() { OutTradeNo = queryModel.out_trade_no }); var response = _gateway.Execute(request); return(response); }
public async Task <IActionResult> Web(string orderNo, int amount, string bank = "") { var request = new WebPayRequest(new WebPayModel { Amount = amount, OrderId = orderNo, ReturnUrl = "http://www.baidu.com", GateId = bank, GoodsId = "10001", GoodsInfo = "招投标承保系统保费", PayType = "B2B" }); var result = await _gateway.Execute(request); return(Content(result.Html, "text/html", Encoding.UTF8)); }
public QueryResponse Query(PayRequest payRequest) { var queryModel = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(payRequest.BizContent, new { out_trade_no = "", trade_no = "" }); var request = new QueryRequest(); request.AddGatewayData(new QueryModel() { TradeNo = queryModel.trade_no, OutTradeNo = queryModel.out_trade_no }); var response = _gateway.Execute(request); return(response); }
public RefundQueryResponse RefundQuery(PayRequest payRequest) { _gateway = _gateways.GetByStoreId <AlipayGateway>(payRequest.GetStoreId()); var queryModel = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(payRequest.BizContent, new { trade_no = "", out_trade_no = "", out_refund_no = "" }); var request = new RefundQueryRequest(); request.AddGatewayData(new RefundQueryModel() { TradeNo = queryModel.trade_no, OutTradeNo = queryModel.out_trade_no, OutRefundNo = queryModel.out_refund_no }); var response = _gateway.Execute(request); return(response); }
public RefundResponse Refund(PayRequest payRequest) { _gateway = _gateways.GetByStoreId <WechatpayGateway>(payRequest.GetStoreId()); var queryModel = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(payRequest.BizContent, new { trade_no = "", out_trade_no = "", total_amount = 0, refund_amount = 0, refund_reason = "", out_refund_no = "" }); var request = new RefundRequest(); request.AddGatewayData(new RefundModel() { TradeNo = queryModel.trade_no, RefundAmount = queryModel.refund_amount, RefundDesc = queryModel.refund_reason, OutRefundNo = queryModel.out_refund_no, TotalAmount = queryModel.total_amount, OutTradeNo = queryModel.out_trade_no }); var response = _gateway.Execute(request); return(response); }
public IActionResult WebPay(string out_trade_no, string subject, double total_amount, string body) { var request = new WebPayRequest(); request.AddGatewayData(new WebPayModel() { Body = body, TotalAmount = total_amount, Subject = subject, OutTradeNo = out_trade_no }); var response = _gateway.Execute(request); return(Content(response.Html, "text/html", Encoding.UTF8)); }
public IHttpActionResult Pay([FromBody] ScanPayModel payModel) { var request = new ScanPayRequest(); if (payModel.TotalAmount == 0) { payModel.TotalAmount = 500; } request.AddGatewayData(payModel); var response = _gateway.Execute(request); return(Json(response)); }
public ActionResult PublicKey() { var request = new PublicKeyRequest(); var response = _gateway.Execute(request); return(Json(response)); }
public async Task <JsonResult> Create([FromForm] string token, [FromForm] int courseId) { DataResult dr = new DataResult(); try { if (courseId < 10000) { dr.code = "201"; dr.msg = "参数错误"; return(Json(dr)); } UserEntity userEntity = this.GetUserByToken(token); CourseEntity courseEntity = courseOrderBLL.ActionDal.ActionDBAccess.Queryable <CourseEntity>().InSingle(courseId); if (courseEntity == null) { dr.code = "201"; dr.msg = "不存在该课程"; return(Json(dr)); } CourseOrderEntity courseOrderEntity = new CourseOrderEntity() { courseId = courseEntity.courseId, createDate = DateTime.Now, modifyDate = DateTime.Now, orderNo = "WX" + userEntity.userId.ToString() + DateTime.Now.ToString("yyyyMMddHHmmss"), orderTotal = courseEntity.price, payChannel = "", payDate = Helper.ConvertHelper.DEFAULT_DATE, payNo = "", realTotal = 0, state = 1, userId = userEntity.userId }; CourseOrderEntity courseOrder = await courseOrderBLL.ActionDal.ActionDBAccess.Insertable(courseOrderEntity).ExecuteReturnEntityAsync(); if (courseOrder == null) { dr.code = "201"; dr.msg = "创建订单失败"; return(Json(dr)); } CoursePayResult coursePayResult = new CoursePayResult(); coursePayResult.courseOrderEntity = courseOrder; var request = new AppPayRequest(); request.AddGatewayData(new AppPayModel() { Body = "购买课程" + courseEntity.name, TotalAmount = Convert.ToInt32(courseOrder.orderTotal * 100), OutTradeNo = courseOrder.orderNo }); var response = _gateway.Execute(request); coursePayResult.payResult = response.OrderInfo; dr.code = "200"; dr.msg = "成功"; dr.data = coursePayResult; } catch (Exception ex) { dr.code = "999"; dr.msg = ex.Message; } return(Json(dr)); }
public bool Process(Person person) { int returnCode = gateway.Execute(ref person); return(returnCode == 0); }