Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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);
        }